Clean up layout; fix colors and auto-populate

This commit is contained in:
2023-10-13 12:53:31 -07:00
parent 7b8cb39567
commit d7ecab3415
5 changed files with 135 additions and 34 deletions
@@ -528,6 +528,12 @@ class _HourFormFieldState extends State<HourFormField> {
@override
Widget build(BuildContext context) {
if (widget.category != null) {
catNum = widget.category!.number.toString();
fgColor = widget.category!.foregroundColor;
catName = widget.category!.name;
}
return Row(
children: [
SizedBox(
@@ -557,7 +563,14 @@ class _HourFormFieldState extends State<HourFormField> {
"hourField-${widget.dayEntry.$id}-${widget.index.toString()}"),
textInputAction: TextInputAction.next,
onEditingComplete: () {
String value = _controller.value.text;
String value;
String current = _controller.value.text;
if(current == ""){
value = getPreviousHourValue(widget);
}
else{
value = current;
}
database.updateHours(widget.dayEntry, widget.index, value);
setState(() {
widget.category = categories.lookUp(num.parse(value));
@@ -588,3 +601,10 @@ class _HourFormFieldState extends State<HourFormField> {
);
}
}
String getPreviousHourValue(widget) {
int prevIndex = widget.index - 1;
if(prevIndex < 0){ return "0";}
else{
return widget.dayEntry.data['hours'][prevIndex].toString();
}
}