diff --git a/lib/ui/client/edit/client_edit.dart b/lib/ui/client/edit/client_edit.dart index 62c467d54..51c282540 100644 --- a/lib/ui/client/edit/client_edit.dart +++ b/lib/ui/client/edit/client_edit.dart @@ -1,12 +1,12 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:invoiceninja/data/models/models.dart'; -import 'package:invoiceninja/ui/client/edit/client_edit_contacts.dart'; import 'package:invoiceninja/ui/client/edit/client_edit_details.dart'; import 'package:invoiceninja/ui/client/edit/client_edit_vm.dart'; import 'package:invoiceninja/utils/localization.dart'; import 'client_edit_billing_address.dart'; +import 'client_edit_contacts.dart'; import 'client_edit_shipping_address.dart'; class ClientEdit extends StatefulWidget { @@ -31,6 +31,8 @@ class _ClientEditState extends State GlobalKey(); static final GlobalKey _shippingAddressKey = GlobalKey(); + static final GlobalKey _contactsKey = + GlobalKey(); @override void initState() { @@ -54,12 +56,15 @@ class _ClientEditState extends State client: client, key: _detailsKey, ), - //ClientEditContacts(client), + ClientEditContacts( + client: client, + key: _contactsKey, + ), + /* ClientEditBillingAddress( client: client, key: _billingAddressKey, ), - /* ClientEditShippingAddress( client: client, key: _shippingAddressKey, @@ -127,6 +132,7 @@ class SaveButton extends StatelessWidget { final List editors; final GlobalKey formKey; final GlobalKey detailsKey; + final GlobalKey contactsKey; final GlobalKey billingAddressKey; final GlobalKey shippingAddressKey; @@ -135,6 +141,7 @@ class SaveButton extends StatelessWidget { this.editors, this.formKey, this.detailsKey, + this.contactsKey, this.billingAddressKey, this.shippingAddressKey, }); diff --git a/lib/ui/client/edit/client_edit_contacts.dart b/lib/ui/client/edit/client_edit_contacts.dart index e959ba080..498c1a57e 100644 --- a/lib/ui/client/edit/client_edit_contacts.dart +++ b/lib/ui/client/edit/client_edit_contacts.dart @@ -6,7 +6,6 @@ import 'package:invoiceninja/ui/client/edit/client_edit.dart'; import 'package:invoiceninja/utils/localization.dart'; class ClientEditContacts extends StatefulWidget { - ClientEditContacts({ Key key, @required this.client, @@ -15,11 +14,11 @@ class ClientEditContacts extends StatefulWidget { final ClientEntity client; @override - _ClientEditContactsState createState() => new _ClientEditContactsState(); + ClientEditContactsState createState() => new ClientEditContactsState(); } -class _ClientEditContactsState extends State with AutomaticKeepAliveClientMixin{ - +class ClientEditContactsState extends State + with AutomaticKeepAliveClientMixin { @override bool get wantKeepAlive => true; @@ -28,26 +27,29 @@ class _ClientEditContactsState extends State with AutomaticK var localization = AppLocalization.of(context); var client = widget.client; + return KeyboardAwarePadding( + child: ListView( + children: client.contacts + .map((contact) => ContactSettings(contact)) + .toList()), + ); + return KeyboardAwarePadding( child: Card( elevation: 2.0, child: Padding( padding: EdgeInsets.all(16.0), child: ListView( - children: client.contacts.map((contact) => ContactSettings(contact)).toList() - ), + children: client.contacts + .map((contact) => ContactSettings(contact)) + .toList()), ), ), ); } } - class ContactSettings extends StatelessWidget { - - static final GlobalKey> firstNameKey = - GlobalKey>(); - ContactSettings(this.contact); ContactEntity contact; @@ -55,28 +57,22 @@ class ContactSettings extends StatelessWidget { Widget build(BuildContext context) { var localization = AppLocalization.of(context); - return TextFormField( - autocorrect: false, - key: ContactSettings.firstNameKey, - initialValue: contact.firstName, - decoration: InputDecoration( - labelText: localization.website, - ), - ); - return Card( - child: Column( - children: [ - TextFormField( - autocorrect: false, - key: ContactSettings.firstNameKey, - initialValue: contact.firstName, - decoration: InputDecoration( - labelText: localization.website, - ), + elevation: 2.0, + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Column( + children: [ + TextFormField( + autocorrect: false, + initialValue: contact.firstName, + decoration: InputDecoration( + labelText: localization.website, ), - ], + ), + ], + ), ), ); } -} \ No newline at end of file +} diff --git a/lib/ui/client/edit/client_edit_details.dart b/lib/ui/client/edit/client_edit_details.dart index a4d8cfd64..9363914fc 100644 --- a/lib/ui/client/edit/client_edit_details.dart +++ b/lib/ui/client/edit/client_edit_details.dart @@ -6,22 +6,20 @@ import 'package:invoiceninja/ui/client/edit/client_edit.dart'; import 'package:invoiceninja/ui/client/edit/client_edit_vm.dart'; import 'package:invoiceninja/utils/localization.dart'; - class ClientEditDetails extends StatefulWidget { - ClientEditDetails({ Key key, @required this.client, }) : super(key: key); final ClientEntity client; - + @override ClientEditDetailsState createState() => new ClientEditDetailsState(); } -class ClientEditDetailsState extends State with AutomaticKeepAliveClientMixin{ - +class ClientEditDetailsState extends State + with AutomaticKeepAliveClientMixin { String name; String idNumber; String vatNumber; @@ -37,58 +35,61 @@ class ClientEditDetailsState extends State with AutomaticKeep var client = widget.client; return KeyboardAwarePadding( - child: Card( - elevation: 2.0, - child: Padding( - padding: EdgeInsets.all(16.0), - child: ListView( - shrinkWrap: true, - children: [ - TextFormField( - autocorrect: false, - onSaved: (value) => name = value.trim(), - initialValue: client.name, - decoration: InputDecoration( - labelText: localization.name, - ), - ), - TextFormField( - autocorrect: false, - onSaved: (value) => idNumber = value.trim(), - initialValue: client.idNumber, - decoration: InputDecoration( - labelText: localization.idNumber, - ), - ), - TextFormField( - autocorrect: false, - onSaved: (value) => vatNumber = value.trim(), - initialValue: client.vatNumber, - decoration: InputDecoration( - labelText: localization.vatNumber, - ), - ), - TextFormField( - autocorrect: false, - onSaved: (value) => website = value.trim(), - initialValue: client.website, - decoration: InputDecoration( - labelText: localization.website, - ), - keyboardType: TextInputType.url, - ), - TextFormField( - autocorrect: false, - onSaved: (value) => phone = value.trim(), - initialValue: client.workPhone, - decoration: InputDecoration( - labelText: localization.phone, - ), - keyboardType: TextInputType.phone, - ), - ], + child: ListView( + shrinkWrap: true, + children: [ + Card( + elevation: 2.0, + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Column( + children: [ + TextFormField( + autocorrect: false, + onSaved: (value) => name = value.trim(), + initialValue: client.name, + decoration: InputDecoration( + labelText: localization.name, + ), + ), + TextFormField( + autocorrect: false, + onSaved: (value) => idNumber = value.trim(), + initialValue: client.idNumber, + decoration: InputDecoration( + labelText: localization.idNumber, + ), + ), + TextFormField( + autocorrect: false, + onSaved: (value) => vatNumber = value.trim(), + initialValue: client.vatNumber, + decoration: InputDecoration( + labelText: localization.vatNumber, + ), + ), + TextFormField( + autocorrect: false, + onSaved: (value) => website = value.trim(), + initialValue: client.website, + decoration: InputDecoration( + labelText: localization.website, + ), + keyboardType: TextInputType.url, + ), + TextFormField( + autocorrect: false, + onSaved: (value) => phone = value.trim(), + initialValue: client.workPhone, + decoration: InputDecoration( + labelText: localization.phone, + ), + keyboardType: TextInputType.phone, + ), + ], + )), ), - ), + ], ), ); } diff --git a/lib/utils/localization.dart b/lib/utils/localization.dart index ec58c9526..0b869e243 100644 --- a/lib/utils/localization.dart +++ b/lib/utils/localization.dart @@ -61,7 +61,8 @@ class AppLocalization { 'could_not_launch': 'Could not aunch', 'contacts': 'Contacts', 'additional': 'Additional', - + 'first_name': 'First Name', + 'last_name': 'Last Name', 'product': 'Product', 'products': 'Products', 'new_product': 'New Product', @@ -144,6 +145,8 @@ class AppLocalization { String get couldNotLaunch => _localizedValues[locale.languageCode]['could_not_launch']; String get contacts => _localizedValues[locale.languageCode]['contacts']; String get additional => _localizedValues[locale.languageCode]['additional']; + String get firstName => _localizedValues[locale.languageCode]['first_name']; + String get lastName => _localizedValues[locale.languageCode]['last_name']; String get product => _localizedValues[locale.languageCode]['product']; String get products => _localizedValues[locale.languageCode]['products'];