diff --git a/ltx_flutter/lib/appwrite/database_api.dart b/ltx_flutter/lib/appwrite/database_api.dart index 6087ca0..ef5a6e6 100644 --- a/ltx_flutter/lib/appwrite/database_api.dart +++ b/ltx_flutter/lib/appwrite/database_api.dart @@ -27,13 +27,15 @@ class DatabaseAPI { Future getEntries({int limit = 100, String dateISO = ""}) { if (dateISO == "") { - dateISO = formatter.format(DateTime.now()); + dateISO = DateTime.now().toIso8601String(); } - final date = DateTime.parse(dateISO); - final offset = date.difference(DateTime.now()).inDays; + var referenceDate = DateTime.parse("2023-01-01"); - print("Getting ${limit} entries starting from ${offset}"); + final date = DateTime.parse(dateISO); + final offset = date.difference(referenceDate).inDays; + + print("Getting $limit entries starting from $offset"); return databases.listDocuments( databaseId: APPWRITE_DATABASE_ID, diff --git a/ltx_flutter/lib/pages/categories_page.dart b/ltx_flutter/lib/pages/categories_page.dart index 977033e..708a0ff 100644 --- a/ltx_flutter/lib/pages/categories_page.dart +++ b/ltx_flutter/lib/pages/categories_page.dart @@ -1,10 +1,6 @@ -import 'package:appwrite/appwrite.dart'; -import 'package:ltx_flutter/appwrite/appwrite.dart'; import 'package:ltx_flutter/appwrite/categories_api.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import 'package:appwrite/models.dart'; -import 'package:intl/intl.dart'; class CategoriesPage extends StatefulWidget { const CategoriesPage({Key? key}) : super(key: key); @@ -54,15 +50,12 @@ class _CategoriesPageState extends State { ? Colors.black : Colors.white; return ListTile( - onLongPress: , tileColor: backgroundColor, textColor: textColor, - titleTextStyle: TextStyle(fontWeight: FontWeight.w600), leading: Text(category.data['number'].toString()), title: Text(category.data['name']), ); } - ; }, ), ), diff --git a/ltx_flutter/lib/pages/login_page.dart b/ltx_flutter/lib/pages/login_page.dart index e127905..b2be6bc 100644 --- a/ltx_flutter/lib/pages/login_page.dart +++ b/ltx_flutter/lib/pages/login_page.dart @@ -1,7 +1,6 @@ import 'package:appwrite/appwrite.dart'; import 'package:ltx_flutter/appwrite/appwrite.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; import 'package:provider/provider.dart'; class LoginPage extends StatefulWidget { diff --git a/ltx_flutter/lib/pages/table_page.dart b/ltx_flutter/lib/pages/table_page.dart index 3b72949..e7d3461 100644 --- a/ltx_flutter/lib/pages/table_page.dart +++ b/ltx_flutter/lib/pages/table_page.dart @@ -254,7 +254,7 @@ class SpreadsheetWidget extends StatelessWidget { List hours = entry?.data['hours']; if (col == 0) { - return Center(child: Text('$day')); + return Center(child: Text(day)); } else if (col > 0 && col < 25) { return Center(child: Text(hours[col - 1].toString())); } else { diff --git a/ltx_flutter/lib/pages/tabs_page.dart b/ltx_flutter/lib/pages/tabs_page.dart index 3459a4f..7b30d5f 100644 --- a/ltx_flutter/lib/pages/tabs_page.dart +++ b/ltx_flutter/lib/pages/tabs_page.dart @@ -1,9 +1,7 @@ -import 'package:ltx_flutter/pages/table_page.dart'; import 'package:ltx_flutter/pages/account_page.dart'; import 'package:ltx_flutter/pages/categories_page.dart'; import 'package:ltx_flutter/pages/today_page.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; class TabsPage extends StatefulWidget { const TabsPage({Key? key}) : super(key: key); diff --git a/ltx_flutter/lib/pages/today_page.dart b/ltx_flutter/lib/pages/today_page.dart index d850f83..7e293b1 100644 --- a/ltx_flutter/lib/pages/today_page.dart +++ b/ltx_flutter/lib/pages/today_page.dart @@ -1,4 +1,3 @@ -import 'package:appwrite/appwrite.dart'; import 'package:ltx_flutter/appwrite/appwrite.dart'; import 'package:ltx_flutter/appwrite/database_api.dart'; import 'package:flutter/material.dart'; @@ -15,23 +14,40 @@ class TodayPage extends StatefulWidget { class _TodayPageState extends State { final database = DatabaseAPI(); - late List? entries = []; - AuthStatus authStatus = AuthStatus.uninitialized; + DateTime? date; + Document? entry; + + var hours = List.generate(24, (i) => i).map((e) { + var meridien = "AM"; + var hour = 12; + if (e > 12) { + hour = e - 12; + } else if (e > 0) { + hour = e; + } + if (e > 11) { + meridien = "PM"; + } + return { + "string": "${hour.toString()} $meridien", + "index": e.toInt(), + }; + }).toList(); @override void initState() { super.initState(); final AuthAPI appwrite = context.read(); authStatus = appwrite.status; - loadEntries(); + loadEntry(); } - loadEntries() async { + loadEntry() async { try { - final value = await database.getEntries(limit: 25); + final value = await database.getEntries(limit: 1, dateISO: ""); setState(() { - entries = value.documents; + entry = value.documents[0]; }); } catch (e) { print(e); @@ -47,11 +63,37 @@ class _TodayPageState extends State { @override Widget build(BuildContext context) { return Center( - child: Column( - children: [ - Text("Entries: ${entries?.length}"), - ], - ), + child: entry == null + ? CircularProgressIndicator() + : Column( + children: [ + Text( + style: TextStyle( + fontSize: 40, + ), + formatDate( + format: "E, MMM dd, yyyy", + dateISO: entry?.data['date'], + ), + ), + Expanded( + child: ListView( + children: hours.map( + (e) { + int h = e["index"] as int; + List hoursData = entry!.data['hours']; + String hourData = (h >= hoursData.length) + ? "" + : hoursData[h].toString(); + return ListTile( + leading: Text(e["string"] as String), + title: Text(hourData), + ); + }, + ).toList()), + ), + ], + ), ); } }