Compare commits
2 Commits
0f7d938ad7
...
1445c19933
Author | SHA1 | Date | |
---|---|---|---|
1445c19933 | |||
e834499644 |
|
@ -4,6 +4,7 @@ import 'package:flutter/services.dart';
|
||||||
import 'package:fmassive/database.dart';
|
import 'package:fmassive/database.dart';
|
||||||
import 'package:fmassive/main.dart';
|
import 'package:fmassive/main.dart';
|
||||||
import 'package:moor_flutter/moor_flutter.dart';
|
import 'package:moor_flutter/moor_flutter.dart';
|
||||||
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
|
|
||||||
class EditGymSetPage extends StatefulWidget {
|
class EditGymSetPage extends StatefulWidget {
|
||||||
final GymSetsCompanion gymSet;
|
final GymSetsCompanion gymSet;
|
||||||
|
@ -121,6 +122,7 @@ class _EditGymSetPageState extends State<EditGymSetPage> {
|
||||||
if (gymSet.id.present)
|
if (gymSet.id.present)
|
||||||
await db.update(db.gymSets).write(gymSet);
|
await db.update(db.gymSets).write(gymSet);
|
||||||
else {
|
else {
|
||||||
|
await Permission.notification.request();
|
||||||
await db.into(db.gymSets).insert(gymSet);
|
await db.into(db.gymSets).insert(gymSet);
|
||||||
const platform = MethodChannel('com.massive/android');
|
const platform = MethodChannel('com.massive/android');
|
||||||
platform.invokeMethod('timer', [3000]);
|
platform.invokeMethod('timer', [3000]);
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:fmassive/best_page.dart';
|
import 'package:fmassive/best_page.dart';
|
||||||
import 'package:fmassive/database.dart';
|
|
||||||
import 'package:fmassive/edit_set.dart';
|
|
||||||
import 'package:fmassive/main.dart';
|
|
||||||
import 'package:fmassive/plans_page.dart';
|
import 'package:fmassive/plans_page.dart';
|
||||||
import 'package:fmassive/settings_page.dart';
|
import 'package:fmassive/settings_page.dart';
|
||||||
import 'package:fmassive/timer_page.dart';
|
import 'package:fmassive/timer_page.dart';
|
||||||
import 'package:fmassive/workouts_page.dart';
|
import 'package:fmassive/workouts_page.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:fmassive/set_list.dart';
|
||||||
import 'package:moor_flutter/moor_flutter.dart';
|
|
||||||
|
|
||||||
class HomePage extends StatefulWidget {
|
class HomePage extends StatefulWidget {
|
||||||
const HomePage({super.key});
|
const HomePage({super.key});
|
||||||
|
@ -53,7 +49,7 @@ class RootPage extends State<HomePage> {
|
||||||
case 'Plans':
|
case 'Plans':
|
||||||
return PlansPage(search: search);
|
return PlansPage(search: search);
|
||||||
default:
|
default:
|
||||||
return _HomePageWidget(search: search);
|
return SetList(search: search);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,92 +103,3 @@ class RootPage extends State<HomePage> {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _HomePageWidget extends StatefulWidget {
|
|
||||||
final String search;
|
|
||||||
|
|
||||||
const _HomePageWidget({Key? key, required this.search}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
createState() => _HomePage();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _HomePage extends State<_HomePageWidget> {
|
|
||||||
bool showSearch = false;
|
|
||||||
late Stream<List<GymSet>> stream;
|
|
||||||
|
|
||||||
@override
|
|
||||||
initState() {
|
|
||||||
super.initState();
|
|
||||||
setStream();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setStream() {
|
|
||||||
stream = (db.select(db.gymSets)
|
|
||||||
..where((gymSet) => gymSet.name.contains(widget.search))
|
|
||||||
..limit(10, offset: 0))
|
|
||||||
.watch();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
didUpdateWidget(covariant _HomePageWidget oldWidget) {
|
|
||||||
super.didUpdateWidget(oldWidget);
|
|
||||||
setStream();
|
|
||||||
}
|
|
||||||
|
|
||||||
void toggleSearch() {
|
|
||||||
setState(() {
|
|
||||||
showSearch = !showSearch;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
body: StreamBuilder<List<GymSet>>(
|
|
||||||
stream: stream,
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
final gymSets = snapshot.data;
|
|
||||||
|
|
||||||
if (gymSets == null)
|
|
||||||
return const Center(child: CircularProgressIndicator());
|
|
||||||
|
|
||||||
return ListView.builder(
|
|
||||||
itemCount: gymSets.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
return ListTile(
|
|
||||||
title: Text(gymSets[index].name),
|
|
||||||
subtitle: Text(
|
|
||||||
"${gymSets[index].reps} x ${gymSets[index].weight}kg"),
|
|
||||||
trailing: Text(DateFormat("yyyy-MM-dd")
|
|
||||||
.format(DateTime.parse(gymSets[index].created))),
|
|
||||||
onTap: () async {
|
|
||||||
await Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => EditGymSetPage(
|
|
||||||
gymSet: gymSets[index].toCompanion(false)),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
floatingActionButton: FloatingActionButton(
|
|
||||||
onPressed: () async {
|
|
||||||
await Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => EditGymSetPage(
|
|
||||||
gymSet: GymSetsCompanion(
|
|
||||||
name: const Value(''),
|
|
||||||
reps: const Value(0),
|
|
||||||
weight: const Value(0),
|
|
||||||
image: const Value(''),
|
|
||||||
created: Value(DateTime.now().toString()))),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: const Icon(Icons.add)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
95
lib/set_list.dart
Normal file
95
lib/set_list.dart
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:fmassive/database.dart';
|
||||||
|
import 'package:fmassive/edit_set.dart';
|
||||||
|
import 'package:fmassive/main.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:moor_flutter/moor_flutter.dart';
|
||||||
|
|
||||||
|
class SetList extends StatefulWidget {
|
||||||
|
final String search;
|
||||||
|
|
||||||
|
const SetList({Key? key, required this.search}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
createState() => _SetList();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SetList extends State<SetList> {
|
||||||
|
bool showSearch = false;
|
||||||
|
late Stream<List<GymSet>> stream;
|
||||||
|
|
||||||
|
@override
|
||||||
|
initState() {
|
||||||
|
super.initState();
|
||||||
|
setStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setStream() {
|
||||||
|
stream = (db.select(db.gymSets)
|
||||||
|
..where((gymSet) => gymSet.name.contains(widget.search))
|
||||||
|
..limit(10, offset: 0))
|
||||||
|
.watch();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
didUpdateWidget(covariant SetList oldWidget) {
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
setStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
void toggleSearch() {
|
||||||
|
setState(() {
|
||||||
|
showSearch = !showSearch;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
body: StreamBuilder<List<GymSet>>(
|
||||||
|
stream: stream,
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
final gymSets = snapshot.data;
|
||||||
|
|
||||||
|
if (gymSets == null)
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
|
||||||
|
return ListView.builder(
|
||||||
|
itemCount: gymSets.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return ListTile(
|
||||||
|
title: Text(gymSets[index].name),
|
||||||
|
subtitle: Text(
|
||||||
|
"${gymSets[index].reps} x ${gymSets[index].weight}kg"),
|
||||||
|
trailing: Text(DateFormat("yyyy-MM-dd")
|
||||||
|
.format(DateTime.parse(gymSets[index].created))),
|
||||||
|
onTap: () async {
|
||||||
|
await Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => EditGymSetPage(
|
||||||
|
gymSet: gymSets[index].toCompanion(false)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
floatingActionButton: FloatingActionButton(
|
||||||
|
onPressed: () async {
|
||||||
|
await Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => EditGymSetPage(
|
||||||
|
gymSet: GymSetsCompanion(
|
||||||
|
name: const Value(''),
|
||||||
|
reps: const Value(0),
|
||||||
|
weight: const Value(0),
|
||||||
|
image: const Value(''),
|
||||||
|
created: Value(DateTime.now().toString()))),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: const Icon(Icons.add)));
|
||||||
|
}
|
||||||
|
}
|
40
pubspec.lock
40
pubspec.lock
|
@ -560,6 +560,46 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.5"
|
version: "2.1.5"
|
||||||
|
permission_handler:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: permission_handler
|
||||||
|
sha256: "33c6a1253d1f95fd06fa74b65b7ba907ae9811f9d5c1d3150e51417d04b8d6a8"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "10.2.0"
|
||||||
|
permission_handler_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: permission_handler_android
|
||||||
|
sha256: "8028362b40c4a45298f1cbfccd227c8dd6caf0e27088a69f2ba2ab15464159e2"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "10.2.0"
|
||||||
|
permission_handler_apple:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: permission_handler_apple
|
||||||
|
sha256: ee96ac32f5a8e6f80756e25b25b9f8e535816c8e6665a96b6d70681f8c4f7e85
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "9.0.8"
|
||||||
|
permission_handler_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: permission_handler_platform_interface
|
||||||
|
sha256: "68abbc472002b5e6dfce47fe9898c6b7d8328d58b5d2524f75e277c07a97eb84"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.9.0"
|
||||||
|
permission_handler_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: permission_handler_windows
|
||||||
|
sha256: f67cab14b4328574938ecea2db3475dad7af7ead6afab6338772c5f88963e38b
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.1.2"
|
||||||
platform:
|
platform:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -45,6 +45,7 @@ dependencies:
|
||||||
file_picker: ^5.2.9
|
file_picker: ^5.2.9
|
||||||
audioplayers: ^4.0.1
|
audioplayers: ^4.0.1
|
||||||
intl: ^0.18.0
|
intl: ^0.18.0
|
||||||
|
permission_handler: ^10.2.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
|
@ -7,11 +7,14 @@
|
||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <audioplayers_windows/audioplayers_windows_plugin.h>
|
#include <audioplayers_windows/audioplayers_windows_plugin.h>
|
||||||
|
#include <permission_handler_windows/permission_handler_windows_plugin.h>
|
||||||
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
||||||
|
|
||||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||||
AudioplayersWindowsPluginRegisterWithRegistrar(
|
AudioplayersWindowsPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin"));
|
registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin"));
|
||||||
|
PermissionHandlerWindowsPluginRegisterWithRegistrar(
|
||||||
|
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
||||||
Sqlite3FlutterLibsPluginRegisterWithRegistrar(
|
Sqlite3FlutterLibsPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin"));
|
registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
audioplayers_windows
|
audioplayers_windows
|
||||||
|
permission_handler_windows
|
||||||
sqlite3_flutter_libs
|
sqlite3_flutter_libs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user