UI tweaks for Samsung

This commit is contained in:
Ryan Pandya 2023-07-08 16:26:02 -07:00
parent 03382d2cb9
commit b110ea0cb9
5 changed files with 147 additions and 64 deletions

28
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,28 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "ltx_flutter",
"cwd": "ltx_flutter",
"request": "launch",
"type": "dart"
},
{
"name": "ltx_flutter (profile mode)",
"cwd": "ltx_flutter",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "ltx_flutter (release mode)",
"cwd": "ltx_flutter",
"request": "launch",
"type": "dart",
"flutterMode": "release"
}
]
}

18
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,18 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "flutter",
"command": "flutter",
"args": [
"build",
"apk",
"--split-per-abi"
],
"group": "build",
"problemMatcher": [],
"label": "flutter: flutter build apk",
"detail": "ltx_flutter"
}
]
}

View File

@ -159,6 +159,8 @@ class DatabaseAPI extends ChangeNotifier {
data: {'hours': hours, 'mood': mood, 'comments': comments}, data: {'hours': hours, 'mood': mood, 'comments': comments},
); );
print("Updated $date.");
_entries.removeAt(entryIndex); _entries.removeAt(entryIndex);
_entries.add(newEntry); _entries.add(newEntry);
notifyListeners(); notifyListeners();
@ -173,8 +175,6 @@ class DatabaseAPI extends ChangeNotifier {
if (hours.length == index) { if (hours.length == index) {
hours.add(num.parse(value)); hours.add(num.parse(value));
} else { } else {
print(List.generate(index - hours.length, (i) => -1));
hours.addAll(List.generate(index - hours.length, (i) => -1)); hours.addAll(List.generate(index - hours.length, (i) => -1));
hours.add(num.parse(value)); hours.add(num.parse(value));
} }

View File

@ -97,6 +97,7 @@ class _LoginPageState extends State<LoginPage> {
border: OutlineInputBorder(), border: OutlineInputBorder(),
), ),
obscureText: true, obscureText: true,
onSubmitted: (str) => signIn(),
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
ElevatedButton.icon( ElevatedButton.icon(

View File

@ -21,7 +21,7 @@ class _DayViewState extends State<DayView> {
late CategoriesAPI categories; late CategoriesAPI categories;
late List<Document> entries = []; late List<Document> entries = [];
late Document? dayEntry = null; late Document? dayEntry;
late List<num> hours = []; late List<num> hours = [];
late num? mood = 0; late num? mood = 0;
late String comments = ""; late String comments = "";
@ -59,13 +59,13 @@ class _DayViewState extends State<DayView> {
dayEntry = entries.singleWhere((element) => element.$id == formattedDate); dayEntry = entries.singleWhere((element) => element.$id == formattedDate);
String date = formatDate( String date = formatDate(
format: "LLL d", dateISO: dayEntry?.data['date'].toString()); format: "LLL d", dateISO: dayEntry?.data['date'].toString());
print("Got entry for $date"); // print("Got entry for $date");
} catch (e) { } catch (e) {
database.getOne(date: formattedDate).then((value) { database.getOne(date: formattedDate).then((value) {
dayEntry = value; dayEntry = value;
}); });
} }
print(entries.length); // print(entries.length);
setState(() { setState(() {
if (dayEntry != null) { if (dayEntry != null) {
@ -110,6 +110,10 @@ class _DayViewState extends State<DayView> {
lastDate: DateTime.now().add(Duration(days: 7)), lastDate: DateTime.now().add(Duration(days: 7)),
).then((value) => _setDate(value)); ).then((value) => _setDate(value));
}, },
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width,
),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
@ -119,7 +123,7 @@ class _DayViewState extends State<DayView> {
onPressed: () => _incrementDate(-1), onPressed: () => _incrementDate(-1),
), ),
SizedBox( SizedBox(
width: 250, width: 0.5 * MediaQuery.of(context).size.width,
child: Text( child: Text(
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
@ -149,6 +153,7 @@ class _DayViewState extends State<DayView> {
), ),
), ),
), ),
),
Expanded( Expanded(
child: categories.ready child: categories.ready
? HourGenerator( ? HourGenerator(
@ -208,7 +213,8 @@ class _DayViewState extends State<DayView> {
), ),
SizedBox(width: 30), SizedBox(width: 30),
Expanded( Expanded(
child: TextFormField( child: _editable
? TextFormField(
decoration: InputDecoration(hintText: "Comments"), decoration: InputDecoration(hintText: "Comments"),
textCapitalization: TextCapitalization.sentences, textCapitalization: TextCapitalization.sentences,
smartQuotesType: SmartQuotesType.enabled, smartQuotesType: SmartQuotesType.enabled,
@ -218,18 +224,22 @@ class _DayViewState extends State<DayView> {
maxLines: 4, maxLines: 4,
onFieldSubmitted: (value) { onFieldSubmitted: (value) {
database.updateEntry( database.updateEntry(
dateISO: dayEntry!.data['date'], comments: value); dateISO: dayEntry!.data['date'],
comments: value);
}, },
), )
: Text(comments.isEmpty ? "No comments yet." : comments),
), ),
SizedBox(width: 30), SizedBox(width: 30),
IconButton( _editable
? IconButton(
tooltip: "Save", tooltip: "Save",
onPressed: () => database.updateEntry( onPressed: () => database.updateEntry(
dateISO: dayEntry!.data['date'], dateISO: dayEntry!.data['date'],
comments: commentsController.value.text.toString()), comments: commentsController.value.text.toString()),
icon: Icon(Icons.save), icon: Icon(Icons.save),
) )
: Container()
], ],
), ),
), ),
@ -460,7 +470,10 @@ class _HourGeneratorState extends State<HourGenerator> {
return hourWidgets; return hourWidgets;
} }
return ListView(children: generateHours(widget.dayEntry, widget.editable)); return FocusTraversalGroup(
child:
ListView(children: generateHours(widget.dayEntry, widget.editable)),
);
} }
} }
@ -486,6 +499,18 @@ class _HourFormFieldState extends State<HourFormField> {
String catNum = ""; String catNum = "";
String catName = "[Empty]"; String catName = "[Empty]";
FocusNode _node = FocusNode();
late TextEditingController _controller;
@override
void initState() {
_node.addListener(() {
if (_node.hasFocus) {
_controller.selection =
TextSelection(baseOffset: 0, extentOffset: _controller.text.length);
}
});
super.initState();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -495,6 +520,12 @@ class _HourFormFieldState extends State<HourFormField> {
catName = widget.category!.name; catName = widget.category!.name;
} }
_controller = TextEditingController.fromValue(
TextEditingValue(
text: catNum,
),
);
return Row( return Row(
children: [ children: [
SizedBox( SizedBox(
@ -505,8 +536,13 @@ class _HourFormFieldState extends State<HourFormField> {
child: Consumer<DatabaseAPI>(builder: (context, database, child) { child: Consumer<DatabaseAPI>(builder: (context, database, child) {
return TextFormField( return TextFormField(
showCursor: false, showCursor: false,
onFieldSubmitted: (value) { key: Key(
"hourField-${widget.dayEntry.$id}-${widget.index.toString()}"),
onTap: () {},
onEditingComplete: () {
String value = _controller.value.text;
database.updateHours(widget.dayEntry, widget.index, value); database.updateHours(widget.dayEntry, widget.index, value);
_node.nextFocus();
}, },
style: TextStyle( style: TextStyle(
color: fgColor, fontFamily: "Monospace", height: 35), color: fgColor, fontFamily: "Monospace", height: 35),
@ -514,8 +550,8 @@ class _HourFormFieldState extends State<HourFormField> {
keyboardType: TextInputType.numberWithOptions( keyboardType: TextInputType.numberWithOptions(
signed: false, signed: false,
), ),
controller: TextEditingController.fromValue( controller: _controller,
TextEditingValue(text: catNum)), focusNode: _node,
); );
}), }),
), ),