This commit is contained in:
unknown 2018-06-11 14:08:05 -07:00
parent b94db5268c
commit 2bc286bda6
4 changed files with 98 additions and 91 deletions

View File

@ -1,12 +1,12 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:invoiceninja/data/models/models.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_details.dart';
import 'package:invoiceninja/ui/client/edit/client_edit_vm.dart'; import 'package:invoiceninja/ui/client/edit/client_edit_vm.dart';
import 'package:invoiceninja/utils/localization.dart'; import 'package:invoiceninja/utils/localization.dart';
import 'client_edit_billing_address.dart'; import 'client_edit_billing_address.dart';
import 'client_edit_contacts.dart';
import 'client_edit_shipping_address.dart'; import 'client_edit_shipping_address.dart';
class ClientEdit extends StatefulWidget { class ClientEdit extends StatefulWidget {
@ -31,6 +31,8 @@ class _ClientEditState extends State<ClientEdit>
GlobalKey<ClientEditBillingAddressState>(); GlobalKey<ClientEditBillingAddressState>();
static final GlobalKey<ClientEditShippingAddressState> _shippingAddressKey = static final GlobalKey<ClientEditShippingAddressState> _shippingAddressKey =
GlobalKey<ClientEditShippingAddressState>(); GlobalKey<ClientEditShippingAddressState>();
static final GlobalKey<ClientEditContactsState> _contactsKey =
GlobalKey<ClientEditContactsState>();
@override @override
void initState() { void initState() {
@ -54,12 +56,15 @@ class _ClientEditState extends State<ClientEdit>
client: client, client: client,
key: _detailsKey, key: _detailsKey,
), ),
//ClientEditContacts(client), ClientEditContacts(
client: client,
key: _contactsKey,
),
/*
ClientEditBillingAddress( ClientEditBillingAddress(
client: client, client: client,
key: _billingAddressKey, key: _billingAddressKey,
), ),
/*
ClientEditShippingAddress( ClientEditShippingAddress(
client: client, client: client,
key: _shippingAddressKey, key: _shippingAddressKey,
@ -127,6 +132,7 @@ class SaveButton extends StatelessWidget {
final List<Widget> editors; final List<Widget> editors;
final GlobalKey<FormState> formKey; final GlobalKey<FormState> formKey;
final GlobalKey<ClientEditDetailsState> detailsKey; final GlobalKey<ClientEditDetailsState> detailsKey;
final GlobalKey<ClientEditContactsState> contactsKey;
final GlobalKey<ClientEditBillingAddressState> billingAddressKey; final GlobalKey<ClientEditBillingAddressState> billingAddressKey;
final GlobalKey<ClientEditShippingAddressState> shippingAddressKey; final GlobalKey<ClientEditShippingAddressState> shippingAddressKey;
@ -135,6 +141,7 @@ class SaveButton extends StatelessWidget {
this.editors, this.editors,
this.formKey, this.formKey,
this.detailsKey, this.detailsKey,
this.contactsKey,
this.billingAddressKey, this.billingAddressKey,
this.shippingAddressKey, this.shippingAddressKey,
}); });

View File

@ -6,7 +6,6 @@ import 'package:invoiceninja/ui/client/edit/client_edit.dart';
import 'package:invoiceninja/utils/localization.dart'; import 'package:invoiceninja/utils/localization.dart';
class ClientEditContacts extends StatefulWidget { class ClientEditContacts extends StatefulWidget {
ClientEditContacts({ ClientEditContacts({
Key key, Key key,
@required this.client, @required this.client,
@ -15,11 +14,11 @@ class ClientEditContacts extends StatefulWidget {
final ClientEntity client; final ClientEntity client;
@override @override
_ClientEditContactsState createState() => new _ClientEditContactsState(); ClientEditContactsState createState() => new ClientEditContactsState();
} }
class _ClientEditContactsState extends State<ClientEditContacts> with AutomaticKeepAliveClientMixin{ class ClientEditContactsState extends State<ClientEditContacts>
with AutomaticKeepAliveClientMixin {
@override @override
bool get wantKeepAlive => true; bool get wantKeepAlive => true;
@ -28,26 +27,29 @@ class _ClientEditContactsState extends State<ClientEditContacts> with AutomaticK
var localization = AppLocalization.of(context); var localization = AppLocalization.of(context);
var client = widget.client; var client = widget.client;
return KeyboardAwarePadding(
child: ListView(
children: client.contacts
.map((contact) => ContactSettings(contact))
.toList()),
);
return KeyboardAwarePadding( return KeyboardAwarePadding(
child: Card( child: Card(
elevation: 2.0, elevation: 2.0,
child: Padding( child: Padding(
padding: EdgeInsets.all(16.0), padding: EdgeInsets.all(16.0),
child: ListView( child: ListView(
children: client.contacts.map((contact) => ContactSettings(contact)).toList() children: client.contacts
), .map((contact) => ContactSettings(contact))
.toList()),
), ),
), ),
); );
} }
} }
class ContactSettings extends StatelessWidget { class ContactSettings extends StatelessWidget {
static final GlobalKey<FormFieldState<String>> firstNameKey =
GlobalKey<FormFieldState<String>>();
ContactSettings(this.contact); ContactSettings(this.contact);
ContactEntity contact; ContactEntity contact;
@ -55,28 +57,22 @@ class ContactSettings extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
var localization = AppLocalization.of(context); var localization = AppLocalization.of(context);
return TextFormField(
autocorrect: false,
key: ContactSettings.firstNameKey,
initialValue: contact.firstName,
decoration: InputDecoration(
labelText: localization.website,
),
);
return Card( return Card(
child: Column( elevation: 2.0,
children: <Widget>[ child: Padding(
TextFormField( padding: const EdgeInsets.all(12.0),
autocorrect: false, child: Column(
key: ContactSettings.firstNameKey, children: <Widget>[
initialValue: contact.firstName, TextFormField(
decoration: InputDecoration( autocorrect: false,
labelText: localization.website, initialValue: contact.firstName,
), decoration: InputDecoration(
labelText: localization.website,
), ),
], ),
],
),
), ),
); );
} }
} }

View File

@ -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/ui/client/edit/client_edit_vm.dart';
import 'package:invoiceninja/utils/localization.dart'; import 'package:invoiceninja/utils/localization.dart';
class ClientEditDetails extends StatefulWidget { class ClientEditDetails extends StatefulWidget {
ClientEditDetails({ ClientEditDetails({
Key key, Key key,
@required this.client, @required this.client,
}) : super(key: key); }) : super(key: key);
final ClientEntity client; final ClientEntity client;
@override @override
ClientEditDetailsState createState() => new ClientEditDetailsState(); ClientEditDetailsState createState() => new ClientEditDetailsState();
} }
class ClientEditDetailsState extends State<ClientEditDetails> with AutomaticKeepAliveClientMixin{ class ClientEditDetailsState extends State<ClientEditDetails>
with AutomaticKeepAliveClientMixin {
String name; String name;
String idNumber; String idNumber;
String vatNumber; String vatNumber;
@ -37,58 +35,61 @@ class ClientEditDetailsState extends State<ClientEditDetails> with AutomaticKeep
var client = widget.client; var client = widget.client;
return KeyboardAwarePadding( return KeyboardAwarePadding(
child: Card( child: ListView(
elevation: 2.0, shrinkWrap: true,
child: Padding( children: <Widget>[
padding: EdgeInsets.all(16.0), Card(
child: ListView( elevation: 2.0,
shrinkWrap: true, child: Padding(
children: <Widget>[ padding: const EdgeInsets.all(12.0),
TextFormField( child: Column(
autocorrect: false, children: <Widget>[
onSaved: (value) => name = value.trim(), TextFormField(
initialValue: client.name, autocorrect: false,
decoration: InputDecoration( onSaved: (value) => name = value.trim(),
labelText: localization.name, initialValue: client.name,
), decoration: InputDecoration(
), labelText: localization.name,
TextFormField( ),
autocorrect: false, ),
onSaved: (value) => idNumber = value.trim(), TextFormField(
initialValue: client.idNumber, autocorrect: false,
decoration: InputDecoration( onSaved: (value) => idNumber = value.trim(),
labelText: localization.idNumber, initialValue: client.idNumber,
), decoration: InputDecoration(
), labelText: localization.idNumber,
TextFormField( ),
autocorrect: false, ),
onSaved: (value) => vatNumber = value.trim(), TextFormField(
initialValue: client.vatNumber, autocorrect: false,
decoration: InputDecoration( onSaved: (value) => vatNumber = value.trim(),
labelText: localization.vatNumber, initialValue: client.vatNumber,
), decoration: InputDecoration(
), labelText: localization.vatNumber,
TextFormField( ),
autocorrect: false, ),
onSaved: (value) => website = value.trim(), TextFormField(
initialValue: client.website, autocorrect: false,
decoration: InputDecoration( onSaved: (value) => website = value.trim(),
labelText: localization.website, initialValue: client.website,
), decoration: InputDecoration(
keyboardType: TextInputType.url, labelText: localization.website,
), ),
TextFormField( keyboardType: TextInputType.url,
autocorrect: false, ),
onSaved: (value) => phone = value.trim(), TextFormField(
initialValue: client.workPhone, autocorrect: false,
decoration: InputDecoration( onSaved: (value) => phone = value.trim(),
labelText: localization.phone, initialValue: client.workPhone,
), decoration: InputDecoration(
keyboardType: TextInputType.phone, labelText: localization.phone,
), ),
], keyboardType: TextInputType.phone,
),
],
)),
), ),
), ],
), ),
); );
} }

View File

@ -61,7 +61,8 @@ class AppLocalization {
'could_not_launch': 'Could not aunch', 'could_not_launch': 'Could not aunch',
'contacts': 'Contacts', 'contacts': 'Contacts',
'additional': 'Additional', 'additional': 'Additional',
'first_name': 'First Name',
'last_name': 'Last Name',
'product': 'Product', 'product': 'Product',
'products': 'Products', 'products': 'Products',
'new_product': 'New Product', 'new_product': 'New Product',
@ -144,6 +145,8 @@ class AppLocalization {
String get couldNotLaunch => _localizedValues[locale.languageCode]['could_not_launch']; String get couldNotLaunch => _localizedValues[locale.languageCode]['could_not_launch'];
String get contacts => _localizedValues[locale.languageCode]['contacts']; String get contacts => _localizedValues[locale.languageCode]['contacts'];
String get additional => _localizedValues[locale.languageCode]['additional']; 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 product => _localizedValues[locale.languageCode]['product'];
String get products => _localizedValues[locale.languageCode]['products']; String get products => _localizedValues[locale.languageCode]['products'];