diff --git a/lib/ui/add_page/widgets/owner_popup.dart b/lib/ui/add_page/widgets/owner_popup.dart index f6133a2..2fdfcea 100644 --- a/lib/ui/add_page/widgets/owner_popup.dart +++ b/lib/ui/add_page/widgets/owner_popup.dart @@ -22,6 +22,7 @@ class _OwnerPopupState extends State { String? firstName; String? lastName; String? contact; + @override Widget build(BuildContext context) { final theme = Theme.of(context); @@ -68,18 +69,8 @@ class _OwnerPopupState extends State { onSelected: (Owner? owner) { widget.viewModel.currentOwner = owner; }, + enableSearch: true, ), - SizedBox(height: 20), - TextButton( - onPressed: () { - setState(() { - showNewOwner = !showNewOwner; - }); - }, - child: Text( - (showNewOwner) ? "Annuler" : "Ajouter un propriétaire", - ), - ), (!showNewOwner) ? SizedBox() : Form( @@ -139,23 +130,6 @@ class _OwnerPopupState extends State { return null; }, ), - SizedBox(height: 10), - ElevatedButton( - onPressed: () async { - if (_formKey.currentState!.validate()) { - _formKey.currentState!.save(); - await widget.viewModel.addOwner( - firstName!, - lastName!, - contact!, - ); - setState(() { - showNewOwner = false; - }); - } - }, - child: Text("Créer"), - ), ], ), ), @@ -166,7 +140,29 @@ class _OwnerPopupState extends State { actions: [ TextButton( onPressed: () { - widget.onPressAccept(context); + setState(() { + showNewOwner = !showNewOwner; + }); + }, + child: Text((showNewOwner) ? "Annuler" : "Ajouter un propriétaire"), + ), + TextButton( + onPressed: () async { + if (showNewOwner) { + if (_formKey.currentState!.validate()) { + _formKey.currentState!.save(); + await widget.viewModel.addOwner( + firstName!, + lastName!, + contact!, + ); + setState(() { + showNewOwner = false; + }); + } + } else { + widget.onPressAccept(context); + } }, child: Text("Valider"), ),