-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rfac: abstracts TextField to AppTextField and AppFormField
- Loading branch information
Showing
6 changed files
with
200 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import 'package:appetizer/data/core/theme/dimensional/dimensional.dart'; | ||
import 'package:appetizer/presentation/components/app_textfield.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:google_fonts/google_fonts.dart'; | ||
|
||
class AppFormField extends StatelessWidget { | ||
const AppFormField({ | ||
Key? key, | ||
required this.hintText, | ||
this.controller, | ||
this.onChanged, | ||
this.obscureText, | ||
this.suffix, | ||
this.border, | ||
required this.title, | ||
this.maxLength, | ||
this.maxLines, | ||
this.titleStyle, | ||
}) : assert( | ||
obscureText == null || suffix != null, | ||
'Suffix should be provided if obscureText is provided', | ||
), | ||
assert( | ||
controller != null || onChanged != null, | ||
'Either controller or onChanged should be provided', | ||
), | ||
super(key: key); | ||
|
||
final String hintText; | ||
final TextEditingController? controller; | ||
final Function(String)? onChanged; | ||
final bool? obscureText; | ||
final Widget? suffix; | ||
final InputBorder? border; | ||
final String title; | ||
final int? maxLength; | ||
final int? maxLines; | ||
final TextStyle? titleStyle; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Text( | ||
title, | ||
style: titleStyle ?? | ||
GoogleFonts.notoSans( | ||
fontSize: 18.toAutoScaledFont, | ||
fontWeight: FontWeight.w600, | ||
), | ||
), | ||
SizedBox( | ||
height: title == "Description" ? 0 : 20.toAutoScaledHeight, | ||
), | ||
AppTextField( | ||
controller: controller, | ||
onChanged: onChanged, | ||
obscureText: obscureText, | ||
hintText: hintText, | ||
suffix: suffix, | ||
border: border, | ||
maxLength: maxLength, | ||
maxLines: maxLines, | ||
), | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.