diff --git a/README.md b/README.md index a56b75a..19bde9b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

IronFlow

-

Cross-platform mobile app for strength training progress tracking.

+

Cross-platform app for strength training progress tracking.

@@ -12,14 +12,15 @@ ![CI](https://github.com/andreped/IronFlow/workflows/Linting/badge.svg)

-**IronFlow** was developed to allow free, private, and seemless tracking of training progress and activities. +**IronFlow** was developed to allow free, private, and seemless tracking of training progress and activities. +A live web demo is available at [andreped.pages.dev](https://andreped.pages.dev), deployed via Cloudflare Pages. ## [Features](https://github.com/andreped/IronFlow#Features) -The app is compatible with both Android and iOS. +The app is compatible with Android, iOS, and web (demo). - [x] Ability to save individual exercises with weight and number of reps and sets. - [x] All data is stored in a private SQLite database on the device. @@ -100,10 +101,10 @@ The web build output is in `build/web/`. Serve it locally with: npx serve build/web ``` -### Deploy web to GitHub Pages +### Deploy web to Cloudflare Pages Push to `main` or trigger the **Build & Deploy Web** workflow manually from the Actions tab. -The app will be live at `https://.github.io/IronFlow/`. +The app will be live at `https://andreped.pages.dev`. ## [Getting Started](https://github.com/andreped/IronFlow#Getting-Started) diff --git a/lib/core/database.dart b/lib/core/database.dart index fbf7c78..97409be 100644 --- a/lib/core/database.dart +++ b/lib/core/database.dart @@ -45,6 +45,9 @@ class DatabaseHelper { } Future _databasePath() async { + if (kIsWeb) { + return 'exercises.db'; + } return join(await getDatabasesPath(), 'exercises.db'); } @@ -462,14 +465,15 @@ class DatabaseHelper { final db = await database; final List> maxWeights = await db.rawQuery( ''' - SELECT exercise, weight, reps, sets - FROM exercises - WHERE (exercise, weight) IN ( - SELECT exercise, MAX(CAST(weight AS REAL)) as weight + SELECT e.exercise, e.weight, e.reps, e.sets + FROM exercises e + INNER JOIN ( + SELECT exercise, MAX(CAST(weight AS REAL)) AS max_weight FROM exercises GROUP BY exercise - ) - ORDER BY exercise, reps DESC + ) m ON e.exercise = m.exercise + AND CAST(e.weight AS REAL) = m.max_weight + ORDER BY e.exercise, e.reps DESC ''', ); diff --git a/lib/tabs/home_tab.dart b/lib/tabs/home_tab.dart index 62dfddd..9c742d9 100644 --- a/lib/tabs/home_tab.dart +++ b/lib/tabs/home_tab.dart @@ -98,6 +98,8 @@ class ExerciseStoreHomePageState extends State late TabController _tabController; late PageController _pageController; final PageStorageBucket bucket = PageStorageBucket(); + final GlobalKey _recordsTabKey = + GlobalKey(); void _refreshTable() { setState(() {}); @@ -108,6 +110,9 @@ class ExerciseStoreHomePageState extends State super.initState(); _tabController = TabController(length: 5, vsync: this, initialIndex: 2) ..addListener(() { + if (_tabController.index == 0) { + _recordsTabKey.currentState?.fetchAndSortRecords(); + } if (_tabController.index == 4) { _refreshTable(); } @@ -176,6 +181,7 @@ class ExerciseStoreHomePageState extends State }, children: [ RecordsTab( + key: _recordsTabKey, isKg: widget.isKg, bodyweightEnabledGlobal: widget.bodyweightEnabledGlobal), SummaryTab( @@ -190,6 +196,7 @@ class ExerciseStoreHomePageState extends State isKg: widget.isKg, onExerciseAdded: () { setState(() {}); + _recordsTabKey.currentState?.fetchAndSortRecords(); }, ), ), diff --git a/lib/tabs/records_tab.dart b/lib/tabs/records_tab.dart index 43fbb5c..e400a49 100644 --- a/lib/tabs/records_tab.dart +++ b/lib/tabs/records_tab.dart @@ -27,7 +27,7 @@ class RecordsTabState extends State { bool _isSearching = false; final TextEditingController _searchController = TextEditingController(); - Future _fetchAndSortRecords() async { + Future fetchAndSortRecords() async { setState(() { _isLoading = true; _errorMessage = null; @@ -124,7 +124,7 @@ class RecordsTabState extends State { @override void initState() { super.initState(); - _fetchAndSortRecords(); + fetchAndSortRecords(); } double _convertWeight(double weightInKg) {