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,42 +110,47 @@ 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: Row( child: ConstrainedBox(
mainAxisAlignment: MainAxisAlignment.center, constraints: BoxConstraints(
children: [ maxWidth: MediaQuery.of(context).size.width,
IconButton( ),
tooltip: "Previous day", child: Row(
icon: Icon(Icons.arrow_left), mainAxisAlignment: MainAxisAlignment.center,
onPressed: () => _incrementDate(-1), children: [
), IconButton(
SizedBox( tooltip: "Previous day",
width: 250, icon: Icon(Icons.arrow_left),
child: Text( onPressed: () => _incrementDate(-1),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20,
),
formatDate(
format: 'EEEEE, LLLL dd, yyyy',
dateISO: _date.toIso8601String()),
), ),
), SizedBox(
IconButton( width: 0.5 * MediaQuery.of(context).size.width,
tooltip: "Next day", child: Text(
icon: Icon(Icons.arrow_right), textAlign: TextAlign.center,
onPressed: () => _incrementDate(1), style: TextStyle(
), fontSize: 20,
Expanded( ),
child: SizedBox(width: 5), formatDate(
), format: 'EEEEE, LLLL dd, yyyy',
Text("Edit"), dateISO: _date.toIso8601String()),
Switch( ),
value: _editable, ),
onChanged: (value) => setState(() { IconButton(
_editable = !_editable; tooltip: "Next day",
}), icon: Icon(Icons.arrow_right),
), onPressed: () => _incrementDate(1),
], ),
Expanded(
child: SizedBox(width: 5),
),
Text("Edit"),
Switch(
value: _editable,
onChanged: (value) => setState(() {
_editable = !_editable;
}),
),
],
),
), ),
), ),
), ),
@ -208,28 +213,33 @@ class _DayViewState extends State<DayView> {
), ),
SizedBox(width: 30), SizedBox(width: 30),
Expanded( Expanded(
child: TextFormField( child: _editable
decoration: InputDecoration(hintText: "Comments"), ? TextFormField(
textCapitalization: TextCapitalization.sentences, decoration: InputDecoration(hintText: "Comments"),
smartQuotesType: SmartQuotesType.enabled, textCapitalization: TextCapitalization.sentences,
enableInteractiveSelection: true, smartQuotesType: SmartQuotesType.enabled,
controller: commentsController, enableInteractiveSelection: true,
minLines: 2, controller: commentsController,
maxLines: 4, minLines: 2,
onFieldSubmitted: (value) { maxLines: 4,
database.updateEntry( onFieldSubmitted: (value) {
dateISO: dayEntry!.data['date'], comments: value); database.updateEntry(
}, dateISO: dayEntry!.data['date'],
), comments: value);
},
)
: Text(comments.isEmpty ? "No comments yet." : comments),
), ),
SizedBox(width: 30), SizedBox(width: 30),
IconButton( _editable
tooltip: "Save", ? IconButton(
onPressed: () => database.updateEntry( tooltip: "Save",
dateISO: dayEntry!.data['date'], onPressed: () => database.updateEntry(
comments: commentsController.value.text.toString()), dateISO: dayEntry!.data['date'],
icon: Icon(Icons.save), comments: commentsController.value.text.toString()),
) 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,
); );
}), }),
), ),