Skip to content

Commit

Permalink
make 'autocorrect' and 'enableSuggestions' FormItem attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
IoanaAlexandru committed Aug 28, 2020
1 parent ab5d09d commit d8b101d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
1 change: 1 addition & 0 deletions lib/authentication/view/login_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class _LoginViewState extends State<LoginView> {
hint: S.of(context).hintEmail,
suffix: emailDomain,
controller: emailController,
autocorrect: false,
check: (email, {BuildContext context}) =>
authProvider.canSignInWithPassword(
email: email + emailDomain, context: context),
Expand Down
1 change: 1 addition & 0 deletions lib/authentication/view/sign_up_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class _SignUpViewState extends State<SignUpView> {
label: S.of(context).labelEmail,
hint: S.of(context).hintEmail,
suffix: emailDomain,
autocorrect: false,
check: (email, {BuildContext context}) => authProvider
.canSignUpWithEmail(email: email + emailDomain, context: context),
),
Expand Down
26 changes: 16 additions & 10 deletions lib/widgets/form/form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,21 @@ class FormItem {
final bool obscureText;
final String suffix;
Future<bool> valid;
final bool autocorrect;
final bool enableSuggestions;

FormItem(
{this.label,
this.additionalHint,
this.hint,
TextEditingController controller,
FocusNode focusNode,
this.check,
this.obscureText = false,
this.suffix})
: this.controller = controller ?? TextEditingController(),
FormItem({
this.label,
this.additionalHint,
this.hint,
TextEditingController controller,
FocusNode focusNode,
this.check,
this.obscureText = false,
this.suffix,
this.autocorrect = true,
this.enableSuggestions = true,
}) : this.controller = controller ?? TextEditingController(),
this.focusNode = focusNode ?? FocusNode(),
this.valid = Future<bool>(() => null);
}
Expand Down Expand Up @@ -70,6 +74,8 @@ class _AppFormState extends State<AppForm> {
obscureText: field.obscureText,
controller: field.controller,
focusNode: field.focusNode,
autocorrect: field.autocorrect,
enableSuggestions: field.enableSuggestions,
onChanged: (text) => setState(() {
if (text == null || text == "") {
field.valid = Future<bool>(() => null);
Expand Down
8 changes: 6 additions & 2 deletions lib/widgets/form/form_text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class FormTextField extends StatefulWidget {
final Function(String) onChanged;
final Function(String) onSubmitted;
final Widget suffixIcon;
final bool autocorrect;
final bool enableSuggestions;

FormTextField({
Key key,
Expand All @@ -25,6 +27,8 @@ class FormTextField extends StatefulWidget {
this.onChanged,
this.onSubmitted,
this.suffixIcon,
this.autocorrect = true,
this.enableSuggestions = true,
}) : super(key: key);

@override
Expand Down Expand Up @@ -60,8 +64,8 @@ class _FormTextFieldState extends State<FormTextField> {
children: <Widget>[
Expanded(
child: TextField(
autocorrect: false,
enableSuggestions: false,
autocorrect: widget.autocorrect,
enableSuggestions: widget.enableSuggestions,
obscureText: widget.obscureText,
controller: widget.controller,
focusNode: widget.focusNode,
Expand Down

0 comments on commit d8b101d

Please sign in to comment.