This commit is contained in:
Hillel Coren 2018-12-17 10:41:01 +02:00
parent 4ca0c613ab
commit 22a31a9da1
2 changed files with 84 additions and 73 deletions

View File

@ -71,7 +71,8 @@ class _ProjectEditState extends State<ProjectEdit> {
}
void _onChanged() {
final project = widget.viewModel.project.rebuild((b) => b
final project = widget.viewModel.project.rebuild((b) =>
b
..name = _nameController.text.trim()
..budgetedHours = parseDouble(_hoursController.text)
..taskRate = parseDouble(_taskRateController.text)
@ -118,7 +119,8 @@ class _ProjectEditState extends State<ProjectEdit> {
),
body: Form(
key: _formKey,
child: ListView(
child: Builder(builder: (BuildContext context) {
return ListView(
children: <Widget>[
FormCard(
children: <Widget>[
@ -131,7 +133,10 @@ class _ProjectEditState extends State<ProjectEdit> {
entityMap: state.clientState.map,
entityList: memoizedDropdownClientList(
state.clientState.map, state.clientState.list),
validator: (String val) => val.trim().isEmpty
validator: (String val) =>
val
.trim()
.isEmpty
? localization.pleaseSelectAClient
: null,
onSelected: (clientId) {
@ -145,7 +150,10 @@ class _ProjectEditState extends State<ProjectEdit> {
TextFormField(
autocorrect: false,
controller: _nameController,
validator: (String val) => val.trim().isEmpty
validator: (String val) =>
val
.trim()
.isEmpty
? localization.pleaseEnterAName
: null,
decoration: InputDecoration(
@ -156,8 +164,8 @@ class _ProjectEditState extends State<ProjectEdit> {
labelText: localization.dueDate,
selectedDate: project.dueDate,
onSelected: (date) {
viewModel
.onChanged(project.rebuild((b) => b..dueDate = date));
viewModel.onChanged(
project.rebuild((b) => b..dueDate = date));
},
),
TextFormField(
@ -185,7 +193,8 @@ class _ProjectEditState extends State<ProjectEdit> {
],
),
],
),
);
}),
),
),
);

View File

@ -96,7 +96,8 @@ class _StubEditState extends State<StubEdit> {
),
body: Form(
key: _formKey,
child: ListView(
child: Builder(builder: (BuildContext context) {
return ListView(
children: <Widget>[
FormCard(
children: <Widget>[
@ -104,7 +105,8 @@ class _StubEditState extends State<StubEdit> {
],
),
],
),
);
})
),
),
);