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

View File

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