Contacts
This commit is contained in:
parent
27ba5a8a07
commit
4328f814a7
|
|
@ -49,9 +49,13 @@ class ClientEditContactsState extends State<ClientEditContacts>
|
||||||
contactKeys.add(GlobalKey<ContactEditDetailsState>());
|
contactKeys.add(GlobalKey<ContactEditDetailsState>());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_onRemovePressed() {
|
_onRemovePressed(GlobalKey<ContactEditDetailsState> key) {
|
||||||
|
setState(() {
|
||||||
|
var index = contactKeys.indexOf(key);
|
||||||
|
contactKeys.removeAt(index);
|
||||||
|
contacts.removeAt(index);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -66,7 +70,7 @@ class ClientEditContactsState extends State<ClientEditContacts>
|
||||||
items.add(ContactEditDetails(
|
items.add(ContactEditDetails(
|
||||||
contact: contact,
|
contact: contact,
|
||||||
key: contactKey,
|
key: contactKey,
|
||||||
onRemovePressed: _onRemovePressed(),
|
onRemovePressed: (key) => _onRemovePressed(key),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,7 +99,7 @@ class ContactEditDetails extends StatefulWidget {
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final ContactEntity contact;
|
final ContactEntity contact;
|
||||||
final Function onRemovePressed;
|
final Function(GlobalKey<ContactEditDetailsState>) onRemovePressed;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ContactEditDetailsState createState() => ContactEditDetailsState();
|
ContactEditDetailsState createState() => ContactEditDetailsState();
|
||||||
|
|
@ -114,32 +118,33 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 8.0),
|
padding: const EdgeInsets.only(bottom: 8.0),
|
||||||
child: Stack(
|
child: Card(
|
||||||
children: [
|
elevation: 2.0,
|
||||||
IconButton(
|
child: Padding(
|
||||||
icon: Icon(Icons.close),
|
padding: const EdgeInsets.only(
|
||||||
onPressed: widget.onRemovePressed,
|
left: 12.0, right: 12.0, top: 12.0, bottom: 18.0),
|
||||||
),
|
child: Column(
|
||||||
Card(
|
children: <Widget>[
|
||||||
elevation: 2.0,
|
TextFormField(
|
||||||
child: Padding(
|
autocorrect: false,
|
||||||
padding: const EdgeInsets.only(
|
initialValue: widget.contact.firstName,
|
||||||
left: 12.0, right: 12.0, top: 12.0, bottom: 18.0),
|
onSaved: (value) => _firstName = value.trim(),
|
||||||
child: Column(
|
decoration: InputDecoration(
|
||||||
children: <Widget>[
|
labelText: localization.firstName,
|
||||||
TextFormField(
|
),
|
||||||
autocorrect: false,
|
|
||||||
initialValue: widget.contact.firstName,
|
|
||||||
onSaved: (value) => _firstName = value.trim(),
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: localization.firstName,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
Row(
|
||||||
)
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
],
|
children: <Widget>[
|
||||||
|
OutlineButton(
|
||||||
|
child: Text(localization.delete),
|
||||||
|
onPressed: () => widget.onRemovePressed(widget.key),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue