Clients
This commit is contained in:
parent
b94db5268c
commit
2bc286bda6
|
|
@ -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<ClientEdit>
|
|||
GlobalKey<ClientEditBillingAddressState>();
|
||||
static final GlobalKey<ClientEditShippingAddressState> _shippingAddressKey =
|
||||
GlobalKey<ClientEditShippingAddressState>();
|
||||
static final GlobalKey<ClientEditContactsState> _contactsKey =
|
||||
GlobalKey<ClientEditContactsState>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
@ -54,12 +56,15 @@ class _ClientEditState extends State<ClientEdit>
|
|||
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<Widget> editors;
|
||||
final GlobalKey<FormState> formKey;
|
||||
final GlobalKey<ClientEditDetailsState> detailsKey;
|
||||
final GlobalKey<ClientEditContactsState> contactsKey;
|
||||
final GlobalKey<ClientEditBillingAddressState> billingAddressKey;
|
||||
final GlobalKey<ClientEditShippingAddressState> shippingAddressKey;
|
||||
|
||||
|
|
@ -135,6 +141,7 @@ class SaveButton extends StatelessWidget {
|
|||
this.editors,
|
||||
this.formKey,
|
||||
this.detailsKey,
|
||||
this.contactsKey,
|
||||
this.billingAddressKey,
|
||||
this.shippingAddressKey,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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<ClientEditContacts> with AutomaticKeepAliveClientMixin{
|
||||
|
||||
class ClientEditContactsState extends State<ClientEditContacts>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
|
|
@ -28,26 +27,29 @@ class _ClientEditContactsState extends State<ClientEditContacts> 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<FormFieldState<String>> firstNameKey =
|
||||
GlobalKey<FormFieldState<String>>();
|
||||
|
||||
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: <Widget>[
|
||||
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: <Widget>[
|
||||
TextFormField(
|
||||
autocorrect: false,
|
||||
initialValue: contact.firstName,
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.website,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<ClientEditDetails> with AutomaticKeepAliveClientMixin{
|
||||
|
||||
class ClientEditDetailsState extends State<ClientEditDetails>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
String name;
|
||||
String idNumber;
|
||||
String vatNumber;
|
||||
|
|
@ -37,58 +35,61 @@ class ClientEditDetailsState extends State<ClientEditDetails> 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: <Widget>[
|
||||
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: <Widget>[
|
||||
Card(
|
||||
elevation: 2.0,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
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,
|
||||
),
|
||||
],
|
||||
)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'];
|
||||
|
|
|
|||
Loading…
Reference in New Issue