Correct enter clearing
This commit is contained in:
parent
c0fc509691
commit
c24bfbf778
|
|
@ -20,7 +20,6 @@ class DecoratedFormField extends StatelessWidget {
|
|||
this.keyboardType,
|
||||
this.minLines,
|
||||
this.maxLines,
|
||||
this.textInputAction,
|
||||
this.onFieldSubmitted,
|
||||
this.initialValue,
|
||||
this.enabled = true,
|
||||
|
|
@ -50,7 +49,6 @@ class DecoratedFormField extends StatelessWidget {
|
|||
final bool obscureText;
|
||||
final bool expands;
|
||||
final bool autofocus;
|
||||
final TextInputAction textInputAction;
|
||||
final ValueChanged<String> onFieldSubmitted;
|
||||
final ValueChanged<String> onChanged;
|
||||
final Icon suffixIcon;
|
||||
|
|
@ -65,14 +63,18 @@ class DecoratedFormField extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget suffixIconButton;
|
||||
|
||||
final hasValue =
|
||||
(initialValue ?? '').isNotEmpty || (controller?.text ?? '').isNotEmpty;
|
||||
final enterShouldSubmit =
|
||||
kIsWeb && isDesktop(context) && onSavePressed != null;
|
||||
|
||||
if (hasValue && key == null) {
|
||||
if (suffixIcon == null && enabled) {
|
||||
suffixIconButton = IconButton(
|
||||
icon: Icon(Icons.clear),
|
||||
onPressed: () =>
|
||||
controller != null ? controller.text = '' : onChanged(''),
|
||||
//onPressed: () => controller != null ? controller.text = '' : onChanged(''),
|
||||
onPressed: () => null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -124,17 +126,18 @@ class DecoratedFormField extends StatelessWidget {
|
|||
autocorrect: isMoney || isPercent ? false : autocorrect,
|
||||
obscureText: obscureText,
|
||||
initialValue: initialValue,
|
||||
textInputAction: textInputAction ??
|
||||
(keyboardType == TextInputType.multiline
|
||||
? TextInputAction.newline
|
||||
: TextInputAction.next),
|
||||
textInputAction: keyboardType == TextInputType.multiline
|
||||
? TextInputAction.newline
|
||||
: enterShouldSubmit
|
||||
? TextInputAction.done
|
||||
: TextInputAction.next,
|
||||
onChanged: onChanged,
|
||||
onFieldSubmitted: (value) {
|
||||
if (onFieldSubmitted != null) {
|
||||
return onFieldSubmitted(value);
|
||||
} else if (keyboardType == TextInputType.multiline) {
|
||||
return null;
|
||||
} else if (kIsWeb && isDesktop(context) && onSavePressed != null) {
|
||||
} else if (enterShouldSubmit) {
|
||||
onSavePressed(context);
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -5,14 +5,12 @@ import 'package:invoiceninja_flutter/utils/localization.dart';
|
|||
class PasswordFormField extends StatefulWidget {
|
||||
const PasswordFormField({
|
||||
this.controller,
|
||||
this.textInputAction,
|
||||
this.autoValidate,
|
||||
this.newPassword = true,
|
||||
this.labelText,
|
||||
});
|
||||
|
||||
final TextEditingController controller;
|
||||
final TextInputAction textInputAction;
|
||||
final bool autoValidate;
|
||||
final bool newPassword;
|
||||
final String labelText;
|
||||
|
|
@ -36,7 +34,6 @@ class _PasswordFormFieldState extends State<PasswordFormField> {
|
|||
|
||||
return DecoratedFormField(
|
||||
controller: widget.controller,
|
||||
textInputAction: widget.textInputAction,
|
||||
autocorrect: false,
|
||||
autovalidate: widget.autoValidate,
|
||||
decoration: InputDecoration(
|
||||
|
|
|
|||
|
|
@ -401,10 +401,6 @@ class _LoginState extends State<LoginView> {
|
|||
DecoratedFormField(
|
||||
controller: _emailController,
|
||||
autocorrect: false,
|
||||
textInputAction:
|
||||
_isFormComplete && !_createAccount
|
||||
? TextInputAction.done
|
||||
: TextInputAction.next,
|
||||
label: localization.email,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
autovalidate: _autoValidate,
|
||||
|
|
@ -418,10 +414,6 @@ class _LoginState extends State<LoginView> {
|
|||
if (_emailLogin && !_recoverPassword)
|
||||
PasswordFormField(
|
||||
controller: _passwordController,
|
||||
textInputAction:
|
||||
_isFormComplete && !_createAccount
|
||||
? TextInputAction.done
|
||||
: TextInputAction.next,
|
||||
autoValidate: _autoValidate,
|
||||
newPassword: _createAccount,
|
||||
),
|
||||
|
|
@ -429,9 +421,6 @@ class _LoginState extends State<LoginView> {
|
|||
DecoratedFormField(
|
||||
controller: _urlController,
|
||||
autocorrect: false,
|
||||
textInputAction: _isFormComplete
|
||||
? TextInputAction.done
|
||||
: TextInputAction.next,
|
||||
label: localization.url,
|
||||
validator: (val) =>
|
||||
val.isEmpty || val.trim().isEmpty
|
||||
|
|
@ -444,7 +433,6 @@ class _LoginState extends State<LoginView> {
|
|||
labelText:
|
||||
'${localization.secret} (${localization.optional})',
|
||||
controller: _secretController,
|
||||
textInputAction: TextInputAction.done,
|
||||
autoValidate: _autoValidate,
|
||||
),
|
||||
if (_createAccount)
|
||||
|
|
|
|||
|
|
@ -251,32 +251,27 @@ class _CompanyDetailsState extends State<CompanyDetails>
|
|||
? localization.pleaseEnterAName
|
||||
: null,
|
||||
autovalidate: autoValidate,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (String value) => _focusNode.nextFocus(),
|
||||
),
|
||||
DecoratedFormField(
|
||||
label: localization.idNumber,
|
||||
controller: _idNumberController,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (String value) => _focusNode.nextFocus(),
|
||||
),
|
||||
DecoratedFormField(
|
||||
label: localization.vatNumber,
|
||||
controller: _vatNumberController,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (String value) => _focusNode.nextFocus(),
|
||||
),
|
||||
DecoratedFormField(
|
||||
label: localization.website,
|
||||
controller: _websiteController,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (String value) => _focusNode.nextFocus(),
|
||||
),
|
||||
DecoratedFormField(
|
||||
label: localization.email,
|
||||
controller: _emailController,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (String value) => _focusNode.nextFocus(),
|
||||
),
|
||||
DecoratedFormField(
|
||||
|
|
@ -352,7 +347,6 @@ class _CompanyDetailsState extends State<CompanyDetails>
|
|||
DecoratedFormField(
|
||||
label: localization.address1,
|
||||
controller: _address1Controller,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (String value) =>
|
||||
_focusNode.nextFocus(),
|
||||
autofillHints: [AutofillHints.streetAddressLine1],
|
||||
|
|
@ -360,7 +354,6 @@ class _CompanyDetailsState extends State<CompanyDetails>
|
|||
DecoratedFormField(
|
||||
label: localization.address2,
|
||||
controller: _address2Controller,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (String value) =>
|
||||
_focusNode.nextFocus(),
|
||||
autofillHints: [AutofillHints.streetAddressLine2],
|
||||
|
|
@ -368,7 +361,6 @@ class _CompanyDetailsState extends State<CompanyDetails>
|
|||
DecoratedFormField(
|
||||
label: localization.city,
|
||||
controller: _cityController,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (String value) =>
|
||||
_focusNode.nextFocus(),
|
||||
autofillHints: [AutofillHints.addressCity],
|
||||
|
|
@ -376,7 +368,6 @@ class _CompanyDetailsState extends State<CompanyDetails>
|
|||
DecoratedFormField(
|
||||
label: localization.state,
|
||||
controller: _stateController,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (String value) =>
|
||||
_focusNode.nextFocus(),
|
||||
autofillHints: [AutofillHints.addressState],
|
||||
|
|
@ -384,7 +375,6 @@ class _CompanyDetailsState extends State<CompanyDetails>
|
|||
DecoratedFormField(
|
||||
label: localization.postalCode,
|
||||
controller: _postalCodeController,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (String value) =>
|
||||
_focusNode.nextFocus(),
|
||||
autofillHints: [AutofillHints.postalCode],
|
||||
|
|
|
|||
21
pubspec.lock
21
pubspec.lock
|
|
@ -63,7 +63,7 @@ packages:
|
|||
name: build_daemon
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.6"
|
||||
version: "2.1.7"
|
||||
build_resolvers:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -442,7 +442,7 @@ packages:
|
|||
name: flutter_styled_toast
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.4.0+1"
|
||||
version: "1.5.0+1"
|
||||
flutter_test:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
|
|
@ -593,13 +593,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.1.1"
|
||||
json_rpc_2:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: json_rpc_2
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.2.2"
|
||||
local_auth:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -767,14 +760,14 @@ packages:
|
|||
name: permission_handler
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "5.0.1+1"
|
||||
version: "5.1.0+2"
|
||||
permission_handler_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: permission_handler_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
version: "2.0.2"
|
||||
petitparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -921,7 +914,7 @@ packages:
|
|||
name: shared_preferences_windows
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.2+2"
|
||||
version: "0.0.2+3"
|
||||
shelf:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -989,7 +982,7 @@ packages:
|
|||
name: sqflite
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.2+2"
|
||||
version: "1.3.2+3"
|
||||
sqflite_common:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -1178,7 +1171,7 @@ packages:
|
|||
name: web_socket_channel
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.2.0"
|
||||
webdriver:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
Loading…
Reference in New Issue