Refactor
This commit is contained in:
parent
649a58f648
commit
fe6c74e479
|
|
@ -44,10 +44,19 @@ class DecoratedFormField extends StatelessWidget {
|
|||
autovalidate: autovalidate,
|
||||
autocorrect: autocorrect,
|
||||
obscureText: obscureText,
|
||||
textInputAction: textInputAction ?? TextInputAction.next,
|
||||
onFieldSubmitted: (value) => onFieldSubmitted != null
|
||||
? onFieldSubmitted(value)
|
||||
: FocusScope.of(context).nextFocus(),
|
||||
textInputAction: textInputAction ??
|
||||
(keyboardType == TextInputType.multiline
|
||||
? TextInputAction.newline
|
||||
: TextInputAction.next),
|
||||
onFieldSubmitted: (value) {
|
||||
if (onFieldSubmitted != null) {
|
||||
return onFieldSubmitted(value);
|
||||
} else if (keyboardType == TextInputType.multiline) {
|
||||
return null;
|
||||
} else {
|
||||
FocusScope.of(context).nextFocus();
|
||||
}
|
||||
},
|
||||
enabled: enabled,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -304,12 +304,9 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
|
|||
: null,
|
||||
)
|
||||
: SizedBox(),
|
||||
TextFormField(
|
||||
autocorrect: false,
|
||||
DecoratedFormField(
|
||||
controller: _phoneController,
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.phone,
|
||||
),
|
||||
label: localization.phone,
|
||||
keyboardType: TextInputType.phone,
|
||||
),
|
||||
CustomField(
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
|
|||
import 'package:invoiceninja_flutter/data/models/entities.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/entity_dropdown.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/app_dropdown_button.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/decorated_form_field.dart';
|
||||
import 'package:invoiceninja_flutter/ui/client/edit/client_edit_vm.dart';
|
||||
import 'package:invoiceninja_flutter/utils/completers.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
|
|
@ -82,21 +83,17 @@ class ClientEditNotesState extends State<ClientEditNotes> {
|
|||
children: <Widget>[
|
||||
FormCard(
|
||||
children: <Widget>[
|
||||
TextFormField(
|
||||
DecoratedFormField(
|
||||
maxLines: 4,
|
||||
controller: _publicNotesController,
|
||||
keyboardType: TextInputType.multiline,
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.publicNotes,
|
||||
),
|
||||
label: localization.publicNotes,
|
||||
),
|
||||
TextFormField(
|
||||
DecoratedFormField(
|
||||
maxLines: 4,
|
||||
controller: _privateNotesController,
|
||||
keyboardType: TextInputType.multiline,
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.privateNotes,
|
||||
),
|
||||
label: localization.privateNotes,
|
||||
),
|
||||
AppDropdownButton(
|
||||
value: client.sizeId,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import 'package:invoiceninja_flutter/constants.dart';
|
|||
import 'package:invoiceninja_flutter/data/models/company_model.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/entities.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/entity_dropdown.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/decorated_form_field.dart';
|
||||
import 'package:invoiceninja_flutter/ui/client/edit/client_edit_vm.dart';
|
||||
import 'package:invoiceninja_flutter/utils/completers.dart';
|
||||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||
|
|
@ -141,12 +142,10 @@ class ClientEditSettingsState extends State<ClientEditSettings> {
|
|||
),
|
||||
),
|
||||
),
|
||||
TextFormField(
|
||||
DecoratedFormField(
|
||||
controller: _taskRateController,
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.taskRate,
|
||||
),
|
||||
label: localization.taskRate,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:invoiceninja_flutter/data/models/entities.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/buttons/elevated_button.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/entity_dropdown.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/decorated_form_field.dart';
|
||||
import 'package:invoiceninja_flutter/ui/client/edit/client_edit_vm.dart';
|
||||
import 'package:invoiceninja_flutter/utils/completers.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
|
|
@ -91,40 +92,25 @@ class ClientEditShippingAddressState extends State<ClientEditShippingAddress> {
|
|||
return ListView(shrinkWrap: true, children: <Widget>[
|
||||
FormCard(
|
||||
children: <Widget>[
|
||||
TextFormField(
|
||||
autocorrect: false,
|
||||
DecoratedFormField(
|
||||
controller: _shippingAddress1Controller,
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.address1,
|
||||
),
|
||||
label: localization.address1,
|
||||
),
|
||||
TextFormField(
|
||||
autocorrect: false,
|
||||
DecoratedFormField(
|
||||
controller: _shippingAddress2Controller,
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.address2,
|
||||
),
|
||||
label: localization.address2,
|
||||
),
|
||||
TextFormField(
|
||||
autocorrect: false,
|
||||
DecoratedFormField(
|
||||
controller: _shippingCityController,
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.city,
|
||||
),
|
||||
label: localization.city,
|
||||
),
|
||||
TextFormField(
|
||||
autocorrect: false,
|
||||
DecoratedFormField(
|
||||
controller: _shippingStateController,
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.state,
|
||||
),
|
||||
label: localization.state,
|
||||
),
|
||||
TextFormField(
|
||||
autocorrect: false,
|
||||
DecoratedFormField(
|
||||
controller: _shippingPostalCodeController,
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.postalCode,
|
||||
),
|
||||
label: localization.postalCode,
|
||||
),
|
||||
EntityDropdown(
|
||||
key: ValueKey(client.shippingCountryId),
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:invoiceninja_flutter/data/models/entities.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/entity_dropdown.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/form_card.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/decorated_form_field.dart';
|
||||
import 'package:invoiceninja_flutter/ui/vendor/edit/vendor_edit_vm.dart';
|
||||
import 'package:invoiceninja_flutter/utils/completers.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
|
|
@ -88,40 +89,25 @@ class VendorEditAddressState extends State<VendorEditAddress> {
|
|||
return ListView(shrinkWrap: true, children: <Widget>[
|
||||
FormCard(
|
||||
children: <Widget>[
|
||||
TextFormField(
|
||||
autocorrect: false,
|
||||
DecoratedFormField(
|
||||
controller: _address1Controller,
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.address1,
|
||||
),
|
||||
label: localization.address1,
|
||||
),
|
||||
TextFormField(
|
||||
autocorrect: false,
|
||||
DecoratedFormField(
|
||||
controller: _address2Controller,
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.address2,
|
||||
),
|
||||
label: localization.address2,
|
||||
),
|
||||
TextFormField(
|
||||
autocorrect: false,
|
||||
DecoratedFormField(
|
||||
controller: _cityController,
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.city,
|
||||
),
|
||||
label: localization.city,
|
||||
),
|
||||
TextFormField(
|
||||
autocorrect: false,
|
||||
DecoratedFormField(
|
||||
controller: _stateController,
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.state,
|
||||
),
|
||||
label: localization.state,
|
||||
),
|
||||
TextFormField(
|
||||
autocorrect: false,
|
||||
DecoratedFormField(
|
||||
controller: _postalCodeController,
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.postalCode,
|
||||
),
|
||||
label: localization.postalCode,
|
||||
),
|
||||
EntityDropdown(
|
||||
key: ValueKey(vendor.countryId),
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
|
|||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/buttons/elevated_button.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/form_card.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/decorated_form_field.dart';
|
||||
import 'package:invoiceninja_flutter/ui/vendor/edit/vendor_edit_contacts_vm.dart';
|
||||
import 'package:invoiceninja_flutter/utils/completers.dart';
|
||||
import 'package:invoiceninja_flutter/utils/dialogs.dart';
|
||||
|
|
@ -242,10 +243,13 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
|
|||
color: Colors.red,
|
||||
icon: Icons.delete,
|
||||
label: localization.remove,
|
||||
onPressed: () => confirmCallback(context: context, callback: () {
|
||||
widget.viewModel.onRemoveContactPressed(widget.index);
|
||||
Navigator.pop(context);
|
||||
}),
|
||||
onPressed: () => confirmCallback(
|
||||
context: context,
|
||||
callback: () {
|
||||
widget.viewModel
|
||||
.onRemoveContactPressed(widget.index);
|
||||
Navigator.pop(context);
|
||||
}),
|
||||
),
|
||||
SizedBox(
|
||||
width: 10.0,
|
||||
|
|
@ -261,50 +265,35 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
|
|||
],
|
||||
)
|
||||
: Container(),
|
||||
TextFormField(
|
||||
autocorrect: false,
|
||||
DecoratedFormField(
|
||||
controller: _firstNameController,
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.firstName,
|
||||
),
|
||||
label: localization.firstName,
|
||||
),
|
||||
TextFormField(
|
||||
autocorrect: false,
|
||||
DecoratedFormField(
|
||||
controller: _lastNameController,
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.lastName,
|
||||
),
|
||||
label: localization.lastName,
|
||||
),
|
||||
TextFormField(
|
||||
autocorrect: false,
|
||||
DecoratedFormField(
|
||||
controller: _emailController,
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.email,
|
||||
),
|
||||
label: localization.email,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
validator: (value) => value.isNotEmpty && !value.contains('@')
|
||||
? localization.emailIsInvalid
|
||||
: null,
|
||||
),
|
||||
company.settings.enablePortalPassword ?? false
|
||||
? TextFormField(
|
||||
autocorrect: false,
|
||||
? DecoratedFormField(
|
||||
controller: _passwordController,
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.password,
|
||||
),
|
||||
label: localization.password,
|
||||
obscureText: true,
|
||||
validator: (value) => value.isNotEmpty && value.length < 8
|
||||
? localization.passwordIsTooShort
|
||||
: null,
|
||||
)
|
||||
: SizedBox(),
|
||||
TextFormField(
|
||||
autocorrect: false,
|
||||
DecoratedFormField(
|
||||
controller: _phoneController,
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.phone,
|
||||
),
|
||||
label: localization.phone,
|
||||
keyboardType: TextInputType.phone,
|
||||
),
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue