From 8161b237557a73bb5cc5ae17fb4f44cbae1ca1d6 Mon Sep 17 00:00:00 2001 From: Ryan Pandya Date: Wed, 12 Jul 2023 14:53:47 -0700 Subject: [PATCH] Smashed the input bug! --- ltx_flutter/lib/pages/categories_page.dart | 2 +- ltx_flutter/lib/pages/today_page.dart | 3 +- .../lib/pages/today_views/day_view.dart | 71 ++++++++++++------- .../lib/pages/today_views/week_view.dart | 30 ++++++++ 4 files changed, 78 insertions(+), 28 deletions(-) create mode 100644 ltx_flutter/lib/pages/today_views/week_view.dart diff --git a/ltx_flutter/lib/pages/categories_page.dart b/ltx_flutter/lib/pages/categories_page.dart index 8cc6179..017898b 100644 --- a/ltx_flutter/lib/pages/categories_page.dart +++ b/ltx_flutter/lib/pages/categories_page.dart @@ -82,7 +82,7 @@ class CategoryRow extends StatelessWidget { child: Row( children: [ Container( - constraints: BoxConstraints(maxHeight: 100), + constraints: BoxConstraints(maxHeight: 100, maxWidth: 50), color: category.backgroundColor, child: SizedBox.expand( child: Center( diff --git a/ltx_flutter/lib/pages/today_page.dart b/ltx_flutter/lib/pages/today_page.dart index 5c15942..54abed3 100644 --- a/ltx_flutter/lib/pages/today_page.dart +++ b/ltx_flutter/lib/pages/today_page.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'today_views/day_view.dart'; import 'today_views/infinity_view.dart'; +import 'today_views/week_view.dart'; class TodayPage extends StatefulWidget { const TodayPage({Key? key}) : super(key: key); @@ -57,7 +58,7 @@ class NarrowView extends StatelessWidget { physics: const NeverScrollableScrollPhysics(), children: [ DayView(), - Icon(Icons.directions_transit, size: 350), + WeekView(), Icon(Icons.directions_car, size: 350), InfinityView(), ], diff --git a/ltx_flutter/lib/pages/today_views/day_view.dart b/ltx_flutter/lib/pages/today_views/day_view.dart index 67de65c..99e9d65 100644 --- a/ltx_flutter/lib/pages/today_views/day_view.dart +++ b/ltx_flutter/lib/pages/today_views/day_view.dart @@ -487,7 +487,7 @@ class HourFormField extends StatefulWidget { required this.dayEntry, }); - final Category? category; + Category? category; int index; Document dayEntry; @@ -511,11 +511,6 @@ class _HourFormFieldState extends State { TextSelection(baseOffset: 0, extentOffset: _controller.text.length); } }); - super.initState(); - } - - @override - Widget build(BuildContext context) { if (widget.category != null) { catNum = widget.category!.number.toString(); fgColor = widget.category!.foregroundColor; @@ -528,6 +523,11 @@ class _HourFormFieldState extends State { ), ); + super.initState(); + } + + @override + Widget build(BuildContext context) { return Row( children: [ SizedBox( @@ -536,26 +536,45 @@ class _HourFormFieldState extends State { SizedBox( width: 50, child: Consumer(builder: (context, database, child) { - return TextFormField( - showCursor: false, - autofillHints: [], - key: Key( - "hourField-${widget.dayEntry.$id}-${widget.index.toString()}"), - onTap: () {}, - onEditingComplete: () { - String value = _controller.value.text; - database.updateHours(widget.dayEntry, widget.index, value); - _node.nextFocus(); - }, - style: TextStyle( - color: fgColor, fontFamily: "Monospace", height: 35), - textAlign: TextAlign.center, - keyboardType: TextInputType.numberWithOptions( - signed: false, - ), - controller: _controller, - focusNode: _node, - ); + // return TextField( + // controller: _controller, + // focusNode: _node, + // onEditingComplete: () async { + // String value = _controller.value.text; + // database.updateHours(widget.dayEntry, widget.index, value); + + // _node.nextFocus(); + // }, + // keyboardType: TextInputType.number, + // textAlign: TextAlign.center, + // ); + return Consumer( + builder: (context, categories, child) { + return TextFormField( + showCursor: false, + autofillHints: [], + key: Key( + "hourField-${widget.dayEntry.$id}-${widget.index.toString()}"), + textInputAction: TextInputAction.next, + onEditingComplete: () { + String value = _controller.value.text; + database.updateHours(widget.dayEntry, widget.index, value); + setState(() { + widget.category = categories.lookUp(num.parse(value)); + catName = widget.category!.name; + }); + _node.nextFocus(); + }, + style: TextStyle( + color: fgColor, fontFamily: "Monospace", height: 35), + textAlign: TextAlign.center, + keyboardType: TextInputType.numberWithOptions( + signed: false, + ), + controller: _controller, + focusNode: _node, + ); + }); }), ), SizedBox(width: 40), diff --git a/ltx_flutter/lib/pages/today_views/week_view.dart b/ltx_flutter/lib/pages/today_views/week_view.dart new file mode 100644 index 0000000..e28897a --- /dev/null +++ b/ltx_flutter/lib/pages/today_views/week_view.dart @@ -0,0 +1,30 @@ +import 'package:ltx_flutter/appwrite/categories_api.dart'; +import 'package:ltx_flutter/appwrite/database_api.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:appwrite/models.dart'; +import 'package:ltx_flutter/helpers.dart'; + +class WeekView extends StatelessWidget { + const WeekView({ + super.key, + }); + + @override + Widget build(BuildContext context) { + return TextFormField( + showCursor: false, + autofillHints: [], + autocorrect: false, + onEditingComplete: () { + print("Test"); + }, + style: + TextStyle(color: Colors.amber, fontFamily: "Monospace", height: 35), + textAlign: TextAlign.center, + keyboardType: TextInputType.numberWithOptions( + signed: false, + ), + ); + } +}