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(
children: [
Container(
constraints: BoxConstraints(maxHeight: 100),
constraints: BoxConstraints(maxHeight: 100, maxWidth: 50),
color: category.backgroundColor,
child: SizedBox.expand(
child: Center(

View File

@ -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(),
],

View File

@ -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<HourFormField> {
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<HourFormField> {
),
);
super.initState();
}
@override
Widget build(BuildContext context) {
return Row(
children: [
SizedBox(
@ -536,26 +536,45 @@ class _HourFormFieldState extends State<HourFormField> {
SizedBox(
width: 50,
child: Consumer<DatabaseAPI>(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<CategoriesAPI>(
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),

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