Update gym_set schema
This commit is contained in:
parent
3978359dc4
commit
11eff63314
File diff suppressed because it is too large
Load Diff
|
@ -103,8 +103,8 @@ class _EditGymSetPageState extends State<EditGymSetPage> {
|
||||||
},
|
},
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
gymSet =
|
gymSet = gymSet.copyWith(
|
||||||
gymSet.copyWith(weight: Value(int.tryParse(value) ?? 0));
|
weight: Value(double.tryParse(value) ?? 0));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -4,13 +4,14 @@ class GymSets extends Table {
|
||||||
IntColumn get id => integer().autoIncrement()();
|
IntColumn get id => integer().autoIncrement()();
|
||||||
TextColumn get name => text()();
|
TextColumn get name => text()();
|
||||||
IntColumn get reps => integer()();
|
IntColumn get reps => integer()();
|
||||||
IntColumn get weight => integer()();
|
RealColumn get weight => real()();
|
||||||
IntColumn get sets => integer().withDefault(const Constant(3))();
|
IntColumn get sets => integer().withDefault(const Constant(3))();
|
||||||
IntColumn get minutes => integer().withDefault(const Constant(3))();
|
IntColumn get minutes => integer().withDefault(const Constant(3))();
|
||||||
IntColumn get seconds => integer().withDefault(const Constant(30))();
|
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 created => text()();
|
||||||
TextColumn get unit => text().withDefault(const Constant('kg'))();
|
TextColumn get unit => text().withDefault(const Constant('kg'))();
|
||||||
TextColumn get image => text()();
|
TextColumn get image => text().nullable()();
|
||||||
TextColumn get steps => text().nullable()();
|
TextColumn get steps => text().nullable()();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ class _SettingsPageState extends State<_SettingsPage> {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
stream = db.select(db.settings).watchSingle();
|
stream = (db.select(db.settings)..limit(1)).watchSingle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -50,6 +50,7 @@ class _SettingsPageState extends State<_SettingsPage> {
|
||||||
stream: stream,
|
stream: stream,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
final settings = snapshot.data;
|
final settings = snapshot.data;
|
||||||
|
print('build: $settings');
|
||||||
|
|
||||||
if (settings == null)
|
if (settings == null)
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
@ -96,6 +97,9 @@ class _SettingsPageState extends State<_SettingsPage> {
|
||||||
db = MyDatabase();
|
db = MyDatabase();
|
||||||
final migrator = db.createMigrator();
|
final migrator = db.createMigrator();
|
||||||
await migrator.createAll();
|
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.');
|
print('Migrated.');
|
||||||
},
|
},
|
||||||
child: const Text("Import")));
|
child: const Text("Import")));
|
||||||
|
@ -115,7 +119,7 @@ class _SettingsPageState extends State<_SettingsPage> {
|
||||||
|
|
||||||
return SwitchListTile(
|
return SwitchListTile(
|
||||||
title: Text(item['title'].toString()),
|
title: Text(item['title'].toString()),
|
||||||
value: item['value'] as bool,
|
value: (item['value'] ?? false) as bool,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
switch (item['title']) {
|
switch (item['title']) {
|
||||||
case 'Alarm':
|
case 'Alarm':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user