Update gym_set schema

This commit is contained in:
Brandon Presley 2023-11-10 16:16:12 +13:00
parent 3978359dc4
commit 11eff63314
4 changed files with 493 additions and 483 deletions

File diff suppressed because it is too large Load Diff

View File

@ -103,8 +103,8 @@ class _EditGymSetPageState extends State<EditGymSetPage> {
},
onChanged: (value) {
setState(() {
gymSet =
gymSet.copyWith(weight: Value(int.tryParse(value) ?? 0));
gymSet = gymSet.copyWith(
weight: Value(double.tryParse(value) ?? 0));
});
},
),

View File

@ -4,13 +4,14 @@ class GymSets extends Table {
IntColumn get id => integer().autoIncrement()();
TextColumn get name => text()();
IntColumn get reps => integer()();
IntColumn get weight => integer()();
RealColumn get weight => real()();
IntColumn get sets => integer().withDefault(const Constant(3))();
IntColumn get minutes => integer().withDefault(const Constant(3))();
IntColumn get seconds => integer().withDefault(const Constant(30))();
BoolColumn get hidden => boolean().withDefault(const Constant(false))();
BoolColumn get hidden =>
boolean().nullable().withDefault(const Constant(false))();
TextColumn get created => text()();
TextColumn get unit => text().withDefault(const Constant('kg'))();
TextColumn get image => text()();
TextColumn get image => text().nullable()();
TextColumn get steps => text().nullable()();
}

View File

@ -40,7 +40,7 @@ class _SettingsPageState extends State<_SettingsPage> {
@override
void initState() {
super.initState();
stream = db.select(db.settings).watchSingle();
stream = (db.select(db.settings)..limit(1)).watchSingle();
}
@override
@ -50,6 +50,7 @@ class _SettingsPageState extends State<_SettingsPage> {
stream: stream,
builder: (context, snapshot) {
final settings = snapshot.data;
print('build: $settings');
if (settings == null)
return const Center(child: CircularProgressIndicator());
@ -96,6 +97,9 @@ class _SettingsPageState extends State<_SettingsPage> {
db = MyDatabase();
final migrator = db.createMigrator();
await migrator.createAll();
await db.customInsert('''
INSERT INTO gym_sets(id, name, reps, weight, created, unit, hidden, image, sets, minutes, seconds, steps)
SELECT id, name, reps, weight, created, unit, hidden, image, sets, minutes, seconds, steps FROM sets''');
print('Migrated.');
},
child: const Text("Import")));
@ -115,7 +119,7 @@ class _SettingsPageState extends State<_SettingsPage> {
return SwitchListTile(
title: Text(item['title'].toString()),
value: item['value'] as bool,
value: (item['value'] ?? false) as bool,
onChanged: (value) {
switch (item['title']) {
case 'Alarm':