Contacts
This commit is contained in:
parent
75e39b89c1
commit
27ba5a8a07
|
|
@ -33,9 +33,6 @@ class ClientEditContactsState extends State<ClientEditContacts>
|
|||
contactKeys = client.contacts
|
||||
.map((contact) => GlobalKey<ContactEditDetailsState>())
|
||||
.toList();
|
||||
|
||||
// Add initial blank contact
|
||||
_onAddPressed();
|
||||
}
|
||||
|
||||
List<ContactEntity> getContacts() {
|
||||
|
|
@ -47,32 +44,41 @@ class ClientEditContactsState extends State<ClientEditContacts>
|
|||
}
|
||||
|
||||
_onAddPressed() {
|
||||
print('onAddPressed..');
|
||||
setState(() {
|
||||
contacts.add(ContactEntity());
|
||||
contactKeys.add(GlobalKey<ContactEditDetailsState>());
|
||||
});
|
||||
}
|
||||
|
||||
_onRemovePressed() {
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var localization = AppLocalization.of(context);
|
||||
|
||||
List<Widget> items = [];
|
||||
|
||||
for (var i=0; i<contacts.length; i++) {
|
||||
for (var i = 0; i < contacts.length; i++) {
|
||||
var contact = contacts[i];
|
||||
var contactKey = contactKeys[i];
|
||||
items.add(ContactEditDetails(
|
||||
contact: contact,
|
||||
key: contactKey,
|
||||
onRemovePressed: _onRemovePressed(),
|
||||
));
|
||||
}
|
||||
|
||||
items.add(RaisedButton(
|
||||
items.add(Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: RaisedButton(
|
||||
elevation: 4.0,
|
||||
child: Text(localization.add),
|
||||
color: Theme.of(context).primaryColor,
|
||||
textColor: Theme.of(context).secondaryHeaderColor,
|
||||
child: Text(localization.addContact.toUpperCase()),
|
||||
onPressed: _onAddPressed,
|
||||
),
|
||||
));
|
||||
|
||||
return ListView(
|
||||
|
|
@ -85,9 +91,11 @@ class ContactEditDetails extends StatefulWidget {
|
|||
ContactEditDetails({
|
||||
Key key,
|
||||
@required this.contact,
|
||||
@required this.onRemovePressed,
|
||||
}) : super(key: key);
|
||||
|
||||
final ContactEntity contact;
|
||||
final Function onRemovePressed;
|
||||
|
||||
@override
|
||||
ContactEditDetailsState createState() => ContactEditDetailsState();
|
||||
|
|
@ -106,7 +114,13 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
|
|||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: Card(
|
||||
child: Stack(
|
||||
children: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.close),
|
||||
onPressed: widget.onRemovePressed,
|
||||
),
|
||||
Card(
|
||||
elevation: 2.0,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
|
|
@ -124,6 +138,8 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
|
|||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class AppLocalization {
|
|||
'additional': 'Additional',
|
||||
'first_name': 'First Name',
|
||||
'last_name': 'Last Name',
|
||||
'add': 'Add',
|
||||
'add_contact': 'Add Contact',
|
||||
|
||||
'product': 'Product',
|
||||
'products': 'Products',
|
||||
|
|
@ -149,7 +149,7 @@ class AppLocalization {
|
|||
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 add => _localizedValues[locale.languageCode]['add'];
|
||||
String get addContact => _localizedValues[locale.languageCode]['add_contact'];
|
||||
|
||||
String get product => _localizedValues[locale.languageCode]['product'];
|
||||
String get products => _localizedValues[locale.languageCode]['products'];
|
||||
|
|
|
|||
Loading…
Reference in New Issue