Smashed the input bug!

This commit is contained in:
Ryan Pandya 2023-07-12 14:53:47 -07:00
parent a7830aec27
commit 8161b23755
4 changed files with 78 additions and 28 deletions

View File

@ -82,7 +82,7 @@ class CategoryRow extends StatelessWidget {
child: Row( child: Row(
children: [ children: [
Container( Container(
constraints: BoxConstraints(maxHeight: 100), constraints: BoxConstraints(maxHeight: 100, maxWidth: 50),
color: category.backgroundColor, color: category.backgroundColor,
child: SizedBox.expand( child: SizedBox.expand(
child: Center( child: Center(

View File

@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'today_views/day_view.dart'; import 'today_views/day_view.dart';
import 'today_views/infinity_view.dart'; import 'today_views/infinity_view.dart';
import 'today_views/week_view.dart';
class TodayPage extends StatefulWidget { class TodayPage extends StatefulWidget {
const TodayPage({Key? key}) : super(key: key); const TodayPage({Key? key}) : super(key: key);
@ -57,7 +58,7 @@ class NarrowView extends StatelessWidget {
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
children: [ children: [
DayView(), DayView(),
Icon(Icons.directions_transit, size: 350), WeekView(),
Icon(Icons.directions_car, size: 350), Icon(Icons.directions_car, size: 350),
InfinityView(), InfinityView(),
], ],

View File

@ -487,7 +487,7 @@ class HourFormField extends StatefulWidget {
required this.dayEntry, required this.dayEntry,
}); });
final Category? category; Category? category;
int index; int index;
Document dayEntry; Document dayEntry;
@ -511,11 +511,6 @@ class _HourFormFieldState extends State<HourFormField> {
TextSelection(baseOffset: 0, extentOffset: _controller.text.length); TextSelection(baseOffset: 0, extentOffset: _controller.text.length);
} }
}); });
super.initState();
}
@override
Widget build(BuildContext context) {
if (widget.category != null) { if (widget.category != null) {
catNum = widget.category!.number.toString(); catNum = widget.category!.number.toString();
fgColor = widget.category!.foregroundColor; fgColor = widget.category!.foregroundColor;
@ -528,6 +523,11 @@ class _HourFormFieldState extends State<HourFormField> {
), ),
); );
super.initState();
}
@override
Widget build(BuildContext context) {
return Row( return Row(
children: [ children: [
SizedBox( SizedBox(
@ -536,26 +536,45 @@ class _HourFormFieldState extends State<HourFormField> {
SizedBox( SizedBox(
width: 50, width: 50,
child: Consumer<DatabaseAPI>(builder: (context, database, child) { child: Consumer<DatabaseAPI>(builder: (context, database, child) {
return TextFormField( // return TextField(
showCursor: false, // controller: _controller,
autofillHints: [], // focusNode: _node,
key: Key( // onEditingComplete: () async {
"hourField-${widget.dayEntry.$id}-${widget.index.toString()}"), // String value = _controller.value.text;
onTap: () {}, // database.updateHours(widget.dayEntry, widget.index, value);
onEditingComplete: () {
String value = _controller.value.text; // _node.nextFocus();
database.updateHours(widget.dayEntry, widget.index, value); // },
_node.nextFocus(); // keyboardType: TextInputType.number,
}, // textAlign: TextAlign.center,
style: TextStyle( // );
color: fgColor, fontFamily: "Monospace", height: 35), return Consumer<CategoriesAPI>(
textAlign: TextAlign.center, builder: (context, categories, child) {
keyboardType: TextInputType.numberWithOptions( return TextFormField(
signed: false, showCursor: false,
), autofillHints: [],
controller: _controller, key: Key(
focusNode: _node, "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), SizedBox(width: 40),

View File

@ -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,
),
);
}
}