This commit is contained in:
unknown 2018-06-12 03:42:37 -07:00
parent 27ba5a8a07
commit 4328f814a7
1 changed files with 35 additions and 30 deletions

View File

@ -50,8 +50,12 @@ class ClientEditContactsState extends State<ClientEditContacts>
});
}
_onRemovePressed() {
_onRemovePressed(GlobalKey<ContactEditDetailsState> key) {
setState(() {
var index = contactKeys.indexOf(key);
contactKeys.removeAt(index);
contacts.removeAt(index);
});
}
@override
@ -66,7 +70,7 @@ class ClientEditContactsState extends State<ClientEditContacts>
items.add(ContactEditDetails(
contact: contact,
key: contactKey,
onRemovePressed: _onRemovePressed(),
onRemovePressed: (key) => _onRemovePressed(key),
));
}
@ -95,7 +99,7 @@ class ContactEditDetails extends StatefulWidget {
}) : super(key: key);
final ContactEntity contact;
final Function onRemovePressed;
final Function(GlobalKey<ContactEditDetailsState>) onRemovePressed;
@override
ContactEditDetailsState createState() => ContactEditDetailsState();
@ -114,13 +118,7 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
return Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Stack(
children: [
IconButton(
icon: Icon(Icons.close),
onPressed: widget.onRemovePressed,
),
Card(
child: Card(
elevation: 2.0,
child: Padding(
padding: const EdgeInsets.only(
@ -135,11 +133,18 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
labelText: localization.firstName,
),
),
],
),
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
OutlineButton(
child: Text(localization.delete),
onPressed: () => widget.onRemovePressed(widget.key),
)
],
)
],
),
),
),
);
}