2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-16 04:05:28 +00:00

Refactor showFormDialog function

This commit is contained in:
Oliver
2021-07-30 11:09:46 +10:00
parent 07017c4745
commit d290f98445
2 changed files with 31 additions and 102 deletions

View File

@ -39,14 +39,6 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
// TODO
}
void _saveCompany(Map<String, String> 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<CompanyDetailWidget> {
var _description;
var _website;
showFormDialog(L10().edit,
key: _editCompanyKey,
actions: <Widget>[
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: <Widget>[
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<Widget> _companyTiles() {