diff --git a/lib/ui/app/forms/decorated_form_field.dart b/lib/ui/app/forms/decorated_form_field.dart index 1c9992efd..1cf19657d 100644 --- a/lib/ui/app/forms/decorated_form_field.dart +++ b/lib/ui/app/forms/decorated_form_field.dart @@ -15,7 +15,6 @@ class DecoratedFormField extends StatefulWidget { this.controller, this.label, this.onSavePressed, - this.autovalidate = false, this.autocorrect = false, this.obscureText = false, this.onChanged, @@ -48,7 +47,6 @@ class DecoratedFormField extends StatefulWidget { final TextInputType keyboardType; final int maxLines; final int minLines; - final bool autovalidate; final bool enabled; final bool autocorrect; final bool obscureText; @@ -140,13 +138,11 @@ class _DecoratedFormFieldState extends State { autofocus: widget.autofocus, decoration: inputDecoration, validator: widget.validator, + autovalidateMode: AutovalidateMode.onUserInteraction, keyboardType: widget.keyboardType, maxLines: widget.expands ? null : widget.maxLines ?? 1, minLines: widget.expands ? null : widget.minLines, expands: widget.expands, - autovalidateMode: widget.autovalidate - ? AutovalidateMode.onUserInteraction - : AutovalidateMode.disabled, autocorrect: widget.isMoney || widget.isPercent ? false : widget.autocorrect, obscureText: widget.obscureText, diff --git a/lib/ui/app/forms/password_field.dart b/lib/ui/app/forms/password_field.dart index e3e758336..e255ba28a 100644 --- a/lib/ui/app/forms/password_field.dart +++ b/lib/ui/app/forms/password_field.dart @@ -8,7 +8,6 @@ import 'package:invoiceninja_flutter/utils/localization.dart'; class PasswordFormField extends StatefulWidget { const PasswordFormField({ this.controller, - this.autoValidate, this.newPassword = true, this.validate = true, this.onSavePressed, @@ -17,7 +16,6 @@ class PasswordFormField extends StatefulWidget { final TextEditingController controller; final Function(BuildContext) onSavePressed; - final bool autoValidate; final bool newPassword; final bool validate; final String labelText; @@ -44,7 +42,6 @@ class _PasswordFormFieldState extends State { controller: widget.controller, onSavePressed: widget.onSavePressed, autocorrect: false, - autovalidate: widget.autoValidate, decoration: InputDecoration( labelText: widget.labelText ?? localization.password, suffixIcon: IconButton( diff --git a/lib/ui/auth/login_view.dart b/lib/ui/auth/login_view.dart index aac0b03c0..15d55815f 100644 --- a/lib/ui/auth/login_view.dart +++ b/lib/ui/auth/login_view.dart @@ -77,7 +77,6 @@ class _LoginState extends State { bool _createAccount = false; bool _recoverPassword = false; - bool _autoValidate = false; bool _termsChecked = false; bool _privacyChecked = false; @@ -157,7 +156,6 @@ class _LoginState extends State { : kAppProductionUrl; setState(() { - _autoValidate = !isValid ?? false; _loginError = ''; }); @@ -223,7 +221,6 @@ class _LoginState extends State { final viewModel = widget.viewModel; setState(() { - _autoValidate = !isValid ?? false; _loginError = ''; }); @@ -428,7 +425,6 @@ class _LoginState extends State { controller: _emailController, label: localization.email, keyboardType: TextInputType.emailAddress, - autovalidate: _autoValidate, validator: (val) => val.isEmpty || val.trim().isEmpty ? localization.pleaseEnterYourEmail @@ -441,7 +437,6 @@ class _LoginState extends State { !_recoverPassword) PasswordFormField( controller: _passwordController, - autoValidate: false, newPassword: _createAccount, onSavePressed: (_) => _submitForm(), ), @@ -470,7 +465,6 @@ class _LoginState extends State { labelText: '${localization.secret} (${localization.optional})', controller: _secretController, - autoValidate: _autoValidate, validate: false, onSavePressed: (_) => _submitForm(), ), diff --git a/lib/ui/bank_account/edit/bank_account_edit.dart b/lib/ui/bank_account/edit/bank_account_edit.dart index 5570fafde..3e96096f1 100644 --- a/lib/ui/bank_account/edit/bank_account_edit.dart +++ b/lib/ui/bank_account/edit/bank_account_edit.dart @@ -27,7 +27,6 @@ class _BankAccountEditState extends State { static final GlobalKey _formKey = GlobalKey(debugLabel: '_bankAccountEdit'); final FocusScopeNode _focusNode = FocusScopeNode(); - bool _autoValidate = false; final _nameController = TextEditingController(); @@ -88,10 +87,6 @@ class _BankAccountEditState extends State { onSavePressed: (context) { final bool isValid = _formKey.currentState.validate(); - setState(() { - _autoValidate = !isValid; - }); - if (!isValid) { return; } @@ -115,7 +110,6 @@ class _BankAccountEditState extends State { validator: (val) => val.isEmpty || val.trim().isEmpty ? localization.pleaseEnterAName : null, - autovalidate: _autoValidate, onSavePressed: viewModel.onSavePressed, keyboardType: TextInputType.text, ), diff --git a/lib/ui/design/edit/design_edit.dart b/lib/ui/design/edit/design_edit.dart index a691af158..f6182e4aa 100644 --- a/lib/ui/design/edit/design_edit.dart +++ b/lib/ui/design/edit/design_edit.dart @@ -251,12 +251,6 @@ class _DesignEditState extends State : (context) { final bool isValid = _formKey.currentState.validate(); - /* - setState(() { - _autoValidate = !isValid; - }); - */ - if (!isValid) { return; } @@ -458,6 +452,8 @@ class _DesignSettingsState extends State { label: localization.name, controller: widget.nameController, keyboardType: TextInputType.text, + validator: (value) => + value.isEmpty ? localization.pleaseEnterAName : null, ), DesignPicker( label: localization.design, diff --git a/lib/ui/expense_category/edit/expense_category_edit.dart b/lib/ui/expense_category/edit/expense_category_edit.dart index 259bc4195..5a05c38f2 100644 --- a/lib/ui/expense_category/edit/expense_category_edit.dart +++ b/lib/ui/expense_category/edit/expense_category_edit.dart @@ -27,7 +27,6 @@ class _ExpenseCategoryEditState extends State { static final GlobalKey _formKey = GlobalKey(debugLabel: '_expenseCategoryEdit'); final _debouncer = Debouncer(); - bool _autoValidate = false; // STARTER: controllers - do not remove comment final _nameController = TextEditingController(); @@ -86,10 +85,6 @@ class _ExpenseCategoryEditState extends State { onSavePressed: (context) { final bool isValid = _formKey.currentState.validate(); - setState(() { - _autoValidate = !isValid; - }); - if (!isValid) { return; } @@ -107,7 +102,6 @@ class _ExpenseCategoryEditState extends State { DecoratedFormField( autofocus: true, controller: _nameController, - autovalidate: _autoValidate, label: localization.name, onSavePressed: viewModel.onSavePressed, keyboardType: TextInputType.text, diff --git a/lib/ui/group/edit/group_edit.dart b/lib/ui/group/edit/group_edit.dart index 814aaf59e..fc0311e50 100644 --- a/lib/ui/group/edit/group_edit.dart +++ b/lib/ui/group/edit/group_edit.dart @@ -32,7 +32,6 @@ class _GroupEditState extends State { List _controllers = []; final _debouncer = Debouncer(); - bool autoValidate = false; @override void didChangeDependencies() { @@ -85,10 +84,6 @@ class _GroupEditState extends State { onSavePressed: (context) { final bool isValid = _formKey.currentState.validate(); - setState(() { - autoValidate = !isValid ?? false; - }); - if (!isValid) { return; } @@ -111,8 +106,7 @@ class _GroupEditState extends State { onSavePressed: viewModel.onSavePressed, validator: (val) => val.isEmpty || val.trim().isEmpty ? localization.pleaseEnterAValue - : null, - autovalidate: autoValidate, + : null, ), ], ), diff --git a/lib/ui/product/edit/product_edit.dart b/lib/ui/product/edit/product_edit.dart index 13d818503..4e953a8ac 100644 --- a/lib/ui/product/edit/product_edit.dart +++ b/lib/ui/product/edit/product_edit.dart @@ -32,7 +32,6 @@ class _ProductEditState extends State { static final GlobalKey _formKey = GlobalKey(debugLabel: '_productEdit'); final FocusScopeNode _focusNode = FocusScopeNode(); - bool _autoValidate = false; final _productKeyController = TextEditingController(); final _notesController = TextEditingController(); @@ -149,10 +148,6 @@ class _ProductEditState extends State { onSavePressed: (context) { final bool isValid = _formKey.currentState.validate(); - setState(() { - _autoValidate = !isValid; - }); - if (!isValid) { return; } @@ -175,7 +170,6 @@ class _ProductEditState extends State { validator: (val) => val.isEmpty || val.trim().isEmpty ? localization.pleaseEnterAProductKey : null, - autovalidate: _autoValidate, onSavePressed: viewModel.onSavePressed, keyboardType: TextInputType.text, ), diff --git a/lib/ui/project/edit/project_edit.dart b/lib/ui/project/edit/project_edit.dart index 9cb96d26a..f63c93dee 100644 --- a/lib/ui/project/edit/project_edit.dart +++ b/lib/ui/project/edit/project_edit.dart @@ -35,8 +35,6 @@ class _ProjectEditState extends State { GlobalKey(debugLabel: '_projectEdit'); final _debouncer = Debouncer(); - bool _autoValidate = false; - final _numberController = TextEditingController(); final _nameController = TextEditingController(); final _dueDateController = TextEditingController(); @@ -132,10 +130,6 @@ class _ProjectEditState extends State { onSavePressed: (context) { final bool isValid = _formKey.currentState.validate(); - setState(() { - _autoValidate = !isValid; - }); - if (!isValid) { return; } @@ -156,7 +150,6 @@ class _ProjectEditState extends State { validator: (String val) => val.trim().isEmpty ? localization.pleaseEnterAName : null, - autovalidate: _autoValidate, keyboardType: TextInputType.text, autofocus: true, label: localization.projectName, @@ -175,7 +168,6 @@ class _ProjectEditState extends State { validator: (String val) => val.trim().isEmpty ? localization.pleaseSelectAClient : null, - autoValidate: _autoValidate, onSelected: (client) { viewModel.onChanged(project.rebuild( (b) => b..clientId = client?.id ?? '')); diff --git a/lib/ui/settings/client_portal.dart b/lib/ui/settings/client_portal.dart index 58c396f98..a1d0b62fc 100644 --- a/lib/ui/settings/client_portal.dart +++ b/lib/ui/settings/client_portal.dart @@ -53,7 +53,6 @@ class _ClientPortalState extends State TabController _controller; final _webClient = WebClient(); - bool _autoValidate = false; bool _isSubdomainUnique = true; bool _isCheckingSubdomain = false; @@ -218,10 +217,6 @@ class _ClientPortalState extends State void _onSavePressed(BuildContext context) { final bool isValid = _formKey.currentState.validate(); - setState(() { - _autoValidate = !isValid; - }); - if (!isValid || _isCheckingSubdomain) { return; } @@ -304,7 +299,6 @@ class _ClientPortalState extends State company.portalMode == kClientPortalModeSubdomain) ...[ DecoratedFormField( label: localization.subdomain, - autovalidate: _autoValidate, controller: _subdomainController, keyboardType: TextInputType.text, hint: localization.subdomainHelp, diff --git a/lib/ui/settings/company_details.dart b/lib/ui/settings/company_details.dart index fd95a237c..59b88e9c8 100644 --- a/lib/ui/settings/company_details.dart +++ b/lib/ui/settings/company_details.dart @@ -53,7 +53,6 @@ class _CompanyDetailsState extends State final FocusScopeNode _focusNode = FocusScopeNode(); TabController _controller; - bool autoValidate = false; final _debouncer = Debouncer(sendFirstAction: true); final _nameController = TextEditingController(); @@ -272,7 +271,6 @@ class _CompanyDetailsState extends State validator: (val) => val.isEmpty || val.trim().isEmpty ? localization.pleaseEnterAName : null, - autovalidate: autoValidate, onSavePressed: viewModel.onSavePressed, keyboardType: TextInputType.text, ), diff --git a/lib/ui/settings/settings_wizard.dart b/lib/ui/settings/settings_wizard.dart index ed0800357..72fbaf773 100644 --- a/lib/ui/settings/settings_wizard.dart +++ b/lib/ui/settings/settings_wizard.dart @@ -48,7 +48,6 @@ class _SettingsWizardState extends State { final FocusScopeNode _focusNode = FocusScopeNode(); final _debouncer = Debouncer(milliseconds: kMillisecondsToDebounceSave); - bool _autoValidate = false; bool _isSaving = false; bool _isSubdomainUnique = false; bool _isCheckingSubdomain = false; @@ -127,10 +126,6 @@ class _SettingsWizardState extends State { void _onSavePressed() { final bool isValid = _formKey.currentState.validate(); - setState(() { - _autoValidate = !isValid; - }); - if (!isValid || _isCheckingSubdomain) { return; } @@ -196,7 +191,6 @@ class _SettingsWizardState extends State { final companyName = DecoratedFormField( autofocus: true, label: localization.companyName, - autovalidate: _autoValidate, controller: _nameController, validator: (value) => value.isEmpty ? localization.pleaseEnterAValue : null, @@ -205,7 +199,6 @@ class _SettingsWizardState extends State { final firstName = DecoratedFormField( label: localization.firstName, - autovalidate: _autoValidate, controller: _firstNameController, keyboardType: TextInputType.name, autofillHints: [AutofillHints.givenName], @@ -215,7 +208,6 @@ class _SettingsWizardState extends State { final lastName = DecoratedFormField( label: localization.lastName, - autovalidate: _autoValidate, controller: _lastNameController, keyboardType: TextInputType.name, autofillHints: [AutofillHints.familyName], @@ -278,7 +270,6 @@ class _SettingsWizardState extends State { final subdomain = DecoratedFormField( label: localization.subdomain, - autovalidate: _autoValidate, controller: _subdomainController, keyboardType: TextInputType.text, validator: (value) { diff --git a/lib/ui/settings/user_details.dart b/lib/ui/settings/user_details.dart index ffb4356e5..185dcbe38 100644 --- a/lib/ui/settings/user_details.dart +++ b/lib/ui/settings/user_details.dart @@ -55,7 +55,6 @@ class _UserDetailsState extends State GlobalKey(debugLabel: '_userDetails'); final FocusScopeNode _focusNode = FocusScopeNode(); TabController _controller; - bool autoValidate = false; final _firstNameController = TextEditingController(); final _lastNameController = TextEditingController(); @@ -136,10 +135,6 @@ class _UserDetailsState extends State void _onSavePressed(BuildContext context) { final bool isValid = _formKey.currentState.validate(); - setState(() { - autoValidate = !isValid ?? false; - }); - if (!isValid) { return; } @@ -320,7 +315,6 @@ class _UserDetailsState extends State validator: (val) => val.isEmpty || val.trim().isEmpty ? localization.pleaseEnterAFirstName : null, - autovalidate: autoValidate, onSavePressed: _onSavePressed, keyboardType: TextInputType.name, ), @@ -330,7 +324,6 @@ class _UserDetailsState extends State validator: (val) => val.isEmpty || val.trim().isEmpty ? localization.pleaseEnterALastName : null, - autovalidate: autoValidate, onSavePressed: _onSavePressed, keyboardType: TextInputType.name, ), @@ -340,7 +333,6 @@ class _UserDetailsState extends State validator: (val) => val.isEmpty || val.trim().isEmpty ? localization.pleaseEnterYourEmail : null, - autovalidate: autoValidate, onSavePressed: _onSavePressed, keyboardType: TextInputType.emailAddress, ), @@ -352,7 +344,6 @@ class _UserDetailsState extends State ), PasswordFormField( controller: _passwordController, - autoValidate: autoValidate, onSavePressed: _onSavePressed, ), ]), diff --git a/lib/ui/task_status/edit/task_status_edit.dart b/lib/ui/task_status/edit/task_status_edit.dart index 6d42a2700..383ff2035 100644 --- a/lib/ui/task_status/edit/task_status_edit.dart +++ b/lib/ui/task_status/edit/task_status_edit.dart @@ -27,7 +27,6 @@ class _TaskStatusEditState extends State { static final GlobalKey _formKey = GlobalKey(debugLabel: '_taskStatusEdit'); final _debouncer = Debouncer(); - bool _autoValidate = false; final _nameController = TextEditingController(); @@ -84,10 +83,6 @@ class _TaskStatusEditState extends State { onSavePressed: (context) { final bool isValid = _formKey.currentState.validate(); - setState(() { - _autoValidate = !isValid; - }); - if (!isValid) { return; } @@ -104,7 +99,6 @@ class _TaskStatusEditState extends State { DecoratedFormField( autofocus: true, controller: _nameController, - autovalidate: _autoValidate, label: localization.name, keyboardType: TextInputType.text, validator: (val) => val.isEmpty || val.trim().isEmpty diff --git a/lib/ui/tax_rate/edit/tax_rate_edit.dart b/lib/ui/tax_rate/edit/tax_rate_edit.dart index eab1fac0b..693bcc5e9 100644 --- a/lib/ui/tax_rate/edit/tax_rate_edit.dart +++ b/lib/ui/tax_rate/edit/tax_rate_edit.dart @@ -28,7 +28,6 @@ class _TaxRateEditState extends State { GlobalKey(debugLabel: '_taxRateEdit'); FocusScopeNode _focusNode; - bool autoValidate = false; final _nameController = TextEditingController(); final _rateController = TextEditingController(); @@ -101,7 +100,6 @@ class _TaxRateEditState extends State { validator: (val) => val.isEmpty || val.trim().isEmpty ? localization.pleaseEnterAName : null, - autovalidate: autoValidate, onSavePressed: viewModel.onSavePressed, keyboardType: TextInputType.text, ), diff --git a/lib/ui/token/edit/token_edit.dart b/lib/ui/token/edit/token_edit.dart index 94115e7ff..ec2dc052c 100644 --- a/lib/ui/token/edit/token_edit.dart +++ b/lib/ui/token/edit/token_edit.dart @@ -30,7 +30,6 @@ class _TokenEditState extends State { final _nameController = TextEditingController(); List _controllers = []; - bool _autoValidate = false; @override void didChangeDependencies() { @@ -81,10 +80,6 @@ class _TokenEditState extends State { onSavePressed: (context) { final bool isValid = _formKey.currentState.validate(); - setState(() { - _autoValidate = !isValid; - }); - if (!isValid) { return; } @@ -102,7 +97,6 @@ class _TokenEditState extends State { autofocus: true, controller: _nameController, label: localization.name, - autovalidate: _autoValidate, validator: (value) => value.isEmpty || value.trim().isEmpty ? localization.pleaseEnterAName diff --git a/lib/ui/user/edit/user_edit.dart b/lib/ui/user/edit/user_edit.dart index 66d46200e..ce6bfc5e8 100644 --- a/lib/ui/user/edit/user_edit.dart +++ b/lib/ui/user/edit/user_edit.dart @@ -40,7 +40,6 @@ class _UserEditState extends State final _debouncer = Debouncer(); final FocusScopeNode _focusNode = FocusScopeNode(); TabController _controller; - bool autoValidate = false; final _firstNameController = TextEditingController(); final _lastNameController = TextEditingController(); @@ -171,10 +170,6 @@ class _UserEditState extends State onSavePressed: (context) { final bool isValid = _formKey.currentState.validate(); - setState(() { - autoValidate = !isValid ?? false; - }); - if (!isValid) { return; } @@ -197,7 +192,6 @@ class _UserEditState extends State validator: (val) => val.isEmpty || val.trim().isEmpty ? localization.pleaseEnterAFirstName : null, - autovalidate: autoValidate, onSavePressed: viewModel.onSavePressed, keyboardType: TextInputType.name, ), @@ -207,7 +201,6 @@ class _UserEditState extends State validator: (val) => val.isEmpty || val.trim().isEmpty ? localization.pleaseEnterALastName : null, - autovalidate: autoValidate, onSavePressed: viewModel.onSavePressed, keyboardType: TextInputType.name, ), @@ -217,7 +210,6 @@ class _UserEditState extends State validator: (val) => val.isEmpty || val.trim().isEmpty ? localization.pleaseEnterYourEmail : null, - autovalidate: autoValidate, onSavePressed: viewModel.onSavePressed, keyboardType: TextInputType.emailAddress, ), diff --git a/stubs/ui/stub/edit/stub_edit b/stubs/ui/stub/edit/stub_edit index 797befb53..e8a76de25 100644 --- a/stubs/ui/stub/edit/stub_edit +++ b/stubs/ui/stub/edit/stub_edit @@ -77,12 +77,6 @@ class _StubEditState extends State { onSavePressed: (context) { final bool isValid = _formKey.currentState.validate(); - /* - setState(() { - _autoValidate = !isValid; - }); - */ - if (!isValid) { return; }