diff --git a/lib/widget/company_detail.dart b/lib/widget/company_detail.dart index 1b7c2e72..123c9072 100644 --- a/lib/widget/company_detail.dart +++ b/lib/widget/company_detail.dart @@ -39,14 +39,6 @@ class _CompanyDetailState extends RefreshableState { // TODO } - void _saveCompany(Map values) async { - Navigator.of(context).pop(); - - await company.update(values: values); - - refresh(); - } - void editCompanyDialog() { // Values which can be edited @@ -54,55 +46,7 @@ class _CompanyDetailState extends RefreshableState { var _description; var _website; - showFormDialog(L10().edit, - key: _editCompanyKey, - actions: [ - TextButton( - child: Text(L10().cancel), - onPressed: () { - Navigator.pop(context); - }, - ), - TextButton( - child: Text(L10().save), - onPressed: () { - if (_editCompanyKey.currentState!.validate()) { - _editCompanyKey.currentState!.save(); - - _saveCompany({ - "name": _name, - "description": _description, - "website": _website, - }); - } - }, - ), - ], - fields: [ - StringField( - label: L10().name, - initial: company.name, - onSaved: (value) { - _name = value; - }, - ), - StringField( - label: L10().description, - initial: company.description, - onSaved: (value) { - _description = value; - }, - ), - StringField( - label: L10().website, - initial: company.website, - allowEmpty: true, - onSaved: (value) { - _website = value; - }, - ) - ] - ); + // TODO - API form } List _companyTiles() { diff --git a/lib/widget/dialogs.dart b/lib/widget/dialogs.dart index 8b0a6156..641a55c9 100644 --- a/lib/widget/dialogs.dart +++ b/lib/widget/dialogs.dart @@ -184,62 +184,47 @@ Future showTimeoutError() async { await showServerError(L10().timeout, L10().noResponse); } -void showFormDialog(String title, {String? acceptText, String? cancelText, GlobalKey? key, List? fields, List? actions, Function? callback}) { +void showFormDialog(String title, {String? acceptText, String? cancelText, GlobalKey? key, List? fields, Function? callback}) { - BuildContext? dialogContext; String _accept = acceptText ?? L10().save; String _cancel = cancelText ?? L10().cancel; - // Undefined actions = OK + Cancel - if (actions == null) { - actions = [ - TextButton( - child: Text(_cancel), - onPressed: () { - // Close the form - var _ctx = dialogContext; - if (_ctx != null) { - Navigator.pop(_ctx); - } - } - ), - TextButton( - child: Text(_accept), - onPressed: () { - - var _key = key; - - if (_key != null && _key.currentState != null) { - if (_key.currentState!.validate()) { - _key.currentState!.save(); - - // Close the dialog - var _ctx = dialogContext; - - if (_ctx != null) { - Navigator.pop(_ctx); - } - - // Callback - if (callback != null) { - callback(); - } - } - } - } - ) - ]; - } - List _fields = fields ?? []; OneContext().showDialog( builder: (BuildContext context) { - dialogContext = context; return AlertDialog( title: Text(title), - actions: actions, + actions: [ + TextButton( + child: Text(_cancel), + onPressed: () { + // Close the form + Navigator.pop(context); + } + ), + TextButton( + child: Text(_accept), + onPressed: () { + + var _key = key; + + if (_key != null && _key.currentState != null) { + if (_key.currentState!.validate()) { + _key.currentState!.save(); + + Navigator.pop(context); + + // Callback + if (callback != null) { + callback(); + } + } + } + } + ) + ], content: Form( key: key, child: SingleChildScrollView(