From 48f716cdb0f00429e160f8df08b0a7e9c767f0fb Mon Sep 17 00:00:00 2001 From: Joshua Burman Date: Thu, 2 Jan 2025 13:29:13 -0500 Subject: [PATCH] db changes, seed changes, media view work for local images, and video prep, initial achievement work --- android/app/src/main/AndroidManifest.xml | 1 + lib/database/database.dart | 4 +- lib/database/database.steps.dart | 141 ++ .../sendtrain/drift_schema_v10.json | 1 + lib/database/seed.dart | 5 +- lib/main.dart | 2 +- lib/widgets/media/media_card.dart | 62 +- lib/widgets/media/media_details.dart | 1 + lib/widgets/sessions/session_card_small.dart | 6 +- lib/widgets/sessions/session_editor.dart | 15 +- .../sessions/session_view_achievements.dart | 50 +- lib/widgets/sessions/session_view_media.dart | 19 +- pubspec.yaml | 2 + test/drift/sendtrain/generated/schema.dart | 5 +- .../drift/sendtrain/generated/schema_v10.dart | 2009 +++++++++++++++++ 15 files changed, 2286 insertions(+), 37 deletions(-) create mode 100644 lib/database/drift_schemas/sendtrain/drift_schema_v10.json create mode 100644 test/drift/sendtrain/generated/schema_v10.dart diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 568c3c4..cced782 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,7 @@ + 9; + int get schemaVersion => 10; @override MigrationStrategy get migration { @@ -141,7 +141,7 @@ class ObjectMediaItems extends Table { dateTime().withDefault(Variable(DateTime.now()))(); } -enum MediaType { youtube, image, location, localImage } +enum MediaType { youtube, image, location, localImage, localVideo } class MediaItems extends Table { IntColumn get id => integer().autoIncrement()(); diff --git a/lib/database/database.steps.dart b/lib/database/database.steps.dart index aac53e7..143b161 100644 --- a/lib/database/database.steps.dart +++ b/lib/database/database.steps.dart @@ -1355,6 +1355,139 @@ final class Schema9 extends i0.VersionedSchema { i1.GeneratedColumn _column_25(String aliasedName) => i1.GeneratedColumn('reference', aliasedName, false, type: i1.DriftSqlType.string); + +final class Schema10 extends i0.VersionedSchema { + Schema10({required super.database}) : super(version: 10); + @override + late final List entities = [ + sessions, + activities, + sessionActivities, + actions, + activityActions, + mediaItems, + objectMediaItems, + ]; + late final Shape11 sessions = Shape11( + source: i0.VersionedTable( + entityName: 'sessions', + withoutRowId: false, + isStrict: false, + tableConstraints: [], + columns: [ + _column_0, + _column_1, + _column_2, + _column_3, + _column_20, + _column_4, + _column_5, + ], + attachedDatabase: database, + ), + alias: null); + late final Shape1 activities = Shape1( + source: i0.VersionedTable( + entityName: 'activities', + withoutRowId: false, + isStrict: false, + tableConstraints: [], + columns: [ + _column_0, + _column_1, + _column_6, + _column_2, + _column_7, + _column_5, + ], + attachedDatabase: database, + ), + alias: null); + late final Shape9 sessionActivities = Shape9( + source: i0.VersionedTable( + entityName: 'session_activities', + withoutRowId: false, + isStrict: false, + tableConstraints: [], + columns: [ + _column_0, + _column_21, + _column_22, + _column_19, + _column_10, + _column_11, + _column_5, + ], + attachedDatabase: database, + ), + alias: null); + late final Shape3 actions = Shape3( + source: i0.VersionedTable( + entityName: 'actions', + withoutRowId: false, + isStrict: false, + tableConstraints: [], + columns: [ + _column_0, + _column_1, + _column_2, + _column_12, + _column_5, + ], + attachedDatabase: database, + ), + alias: null); + late final Shape10 activityActions = Shape10( + source: i0.VersionedTable( + entityName: 'activity_actions', + withoutRowId: false, + isStrict: false, + tableConstraints: [], + columns: [ + _column_0, + _column_22, + _column_23, + _column_19, + _column_5, + ], + attachedDatabase: database, + ), + alias: null); + late final Shape5 mediaItems = Shape5( + source: i0.VersionedTable( + entityName: 'media_items', + withoutRowId: false, + isStrict: false, + tableConstraints: [], + columns: [ + _column_0, + _column_1, + _column_2, + _column_25, + _column_6, + _column_5, + ], + attachedDatabase: database, + ), + alias: null); + late final Shape6 objectMediaItems = Shape6( + source: i0.VersionedTable( + entityName: 'object_media_items', + withoutRowId: false, + isStrict: false, + tableConstraints: [], + columns: [ + _column_0, + _column_15, + _column_16, + _column_24, + _column_5, + ], + attachedDatabase: database, + ), + alias: null); +} + i0.MigrationStepWithVersion migrationSteps({ required Future Function(i1.Migrator m, Schema2 schema) from1To2, required Future Function(i1.Migrator m, Schema3 schema) from2To3, @@ -1364,6 +1497,7 @@ i0.MigrationStepWithVersion migrationSteps({ required Future Function(i1.Migrator m, Schema7 schema) from6To7, required Future Function(i1.Migrator m, Schema8 schema) from7To8, required Future Function(i1.Migrator m, Schema9 schema) from8To9, + required Future Function(i1.Migrator m, Schema10 schema) from9To10, }) { return (currentVersion, database) async { switch (currentVersion) { @@ -1407,6 +1541,11 @@ i0.MigrationStepWithVersion migrationSteps({ final migrator = i1.Migrator(database, schema); await from8To9(migrator, schema); return 9; + case 9: + final schema = Schema10(database: database); + final migrator = i1.Migrator(database, schema); + await from9To10(migrator, schema); + return 10; default: throw ArgumentError.value('Unknown migration from $currentVersion'); } @@ -1422,6 +1561,7 @@ i1.OnUpgrade stepByStep({ required Future Function(i1.Migrator m, Schema7 schema) from6To7, required Future Function(i1.Migrator m, Schema8 schema) from7To8, required Future Function(i1.Migrator m, Schema9 schema) from8To9, + required Future Function(i1.Migrator m, Schema10 schema) from9To10, }) => i0.VersionedSchema.stepByStepHelper( step: migrationSteps( @@ -1433,4 +1573,5 @@ i1.OnUpgrade stepByStep({ from6To7: from6To7, from7To8: from7To8, from8To9: from8To9, + from9To10: from9To10, )); diff --git a/lib/database/drift_schemas/sendtrain/drift_schema_v10.json b/lib/database/drift_schemas/sendtrain/drift_schema_v10.json new file mode 100644 index 0000000..bc7a1b8 --- /dev/null +++ b/lib/database/drift_schemas/sendtrain/drift_schema_v10.json @@ -0,0 +1 @@ +{"_meta":{"description":"This file contains a serialized version of schema entities for drift.","version":"1.2.0"},"options":{"store_date_time_values_as_text":false},"entities":[{"id":0,"references":[],"type":"table","data":{"name":"sessions","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"title","getter_name":"title","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[{"allowed-lengths":{"min":3,"max":32}}]},{"name":"body","getter_name":"content","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"status","getter_name":"status","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const EnumNameConverter(SessionStatus.values)","dart_type_name":"SessionStatus"}},{"name":"address","getter_name":"address","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[{"allowed-lengths":{"min":3,"max":256}}]},{"name":"date","getter_name":"date","moor_type":"dateTime","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"created_at","getter_name":"createdAt","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"Variable(DateTime.now())","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":1,"references":[],"type":"table","data":{"name":"activities","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"title","getter_name":"title","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[{"allowed-lengths":{"min":3,"max":32}}]},{"name":"type","getter_name":"type","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const EnumNameConverter(ActivityType.values)","dart_type_name":"ActivityType"}},{"name":"body","getter_name":"description","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"category","getter_name":"category","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const EnumNameConverter(ActivityCategories.values)","dart_type_name":"ActivityCategories"}},{"name":"created_at","getter_name":"createdAt","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"Variable(DateTime.now())","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":2,"references":[0,1],"type":"table","data":{"name":"session_activities","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"session_id","getter_name":"sessionId","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES sessions (id) ON DELETE CASCADE","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES sessions (id) ON DELETE CASCADE"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"activity_id","getter_name":"activityId","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES activities (id) ON DELETE CASCADE","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES activities (id) ON DELETE CASCADE"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"position","getter_name":"position","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"results","getter_name":"results","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"achievements","getter_name":"achievements","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"created_at","getter_name":"createdAt","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"Variable(DateTime.now())","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":3,"references":[],"type":"table","data":{"name":"actions","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"title","getter_name":"title","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[{"allowed-lengths":{"min":3,"max":32}}]},{"name":"body","getter_name":"description","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"set","getter_name":"set","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"created_at","getter_name":"createdAt","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"Variable(DateTime.now())","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":4,"references":[1,3],"type":"table","data":{"name":"activity_actions","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"activity_id","getter_name":"activityId","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES activities (id) ON DELETE CASCADE","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES activities (id) ON DELETE CASCADE"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"action_id","getter_name":"actionId","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES actions (id) ON DELETE CASCADE","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES actions (id) ON DELETE CASCADE"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"position","getter_name":"position","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"created_at","getter_name":"createdAt","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"Variable(DateTime.now())","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":5,"references":[],"type":"table","data":{"name":"media_items","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"title","getter_name":"title","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[{"allowed-lengths":{"min":3,"max":32}}]},{"name":"body","getter_name":"description","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"reference","getter_name":"reference","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"type","getter_name":"type","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const EnumNameConverter(MediaType.values)","dart_type_name":"MediaType"}},{"name":"created_at","getter_name":"createdAt","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"Variable(DateTime.now())","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":6,"references":[5],"type":"table","data":{"name":"object_media_items","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"object_id","getter_name":"objectId","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"object_type","getter_name":"objectType","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const EnumNameConverter(ObjectType.values)","dart_type_name":"ObjectType"}},{"name":"media_id","getter_name":"mediaId","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES media_items (id) ON DELETE CASCADE","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES media_items (id) ON DELETE CASCADE"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"created_at","getter_name":"createdAt","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"Variable(DateTime.now())","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}}]} \ No newline at end of file diff --git a/lib/database/seed.dart b/lib/database/seed.dart index add9cc6..bca51cb 100644 --- a/lib/database/seed.dart +++ b/lib/database/seed.dart @@ -66,6 +66,7 @@ Future seedDb(AppDatabase database) async { title: sessionValue[0], content: sessionValue[1], status: status, + address: sessionValue[2], date: Value(DateTime.now()))) .then((sessionId) async { // activities things @@ -175,14 +176,14 @@ Future seedDb(AppDatabase database) async { description: '5155 Harvester Rd #1, Burlington, ON L7L 6V2, Canada', reference: - 'https://lh3.googleusercontent.com/places/ANXAkqHz0IeMrJnqjBwQJvYVHv9qSp0huWPCBcdeMZds66wpLofxGAIk3KrYFD2ShEZzqm1A-GO7BfmO3OtRdjSlnO6DAHgyDv_C_7w=s4800-w800', + 'https://lh3.googleusercontent.com/places/ANXAkqHwtb5oRMGG3haJkaHeTxdTI1lQ17RgvkCXwzA1dGV53BXPbHrdXIs1mLC_-4exyRW8dbYhMOeiOCHJqGeVBx-dNtABZAl9tQA=s4800-w800', type: MediaType.location)) .then((mediaId) async { await database.into(database.objectMediaItems).insert( ObjectMediaItemsCompanion.insert( objectId: sessionId, mediaId: mediaId, - objectType: ObjectType.activities)); + objectType: ObjectType.sessions)); }); }); } diff --git a/lib/main.dart b/lib/main.dart index e666920..bc8abea 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -89,7 +89,7 @@ class _AppState extends State { NavigationDestination( icon: Icon(Icons.sports), label: "Sessions"), NavigationDestination( - icon: Icon(Icons.landscape), label: "Activities"), + icon: Icon(Icons.sports_gymnastics_rounded), label: "Activities"), NavigationDestination( icon: Icon(Icons.calendar_month_rounded), label: "Plan"), NavigationDestination( diff --git a/lib/widgets/media/media_card.dart b/lib/widgets/media/media_card.dart index 73f5f71..5e95c1e 100644 --- a/lib/widgets/media/media_card.dart +++ b/lib/widgets/media/media_card.dart @@ -1,14 +1,55 @@ import 'dart:convert'; +import 'dart:io'; import 'dart:typed_data'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:sendtrain/daos/media_items_dao.dart'; import 'package:sendtrain/database/database.dart'; import 'package:sendtrain/helpers/widget_helpers.dart'; +import 'package:sendtrain/widgets/builders/dialogs.dart'; +import 'package:video_player/video_player.dart'; -class MediaCard extends StatelessWidget { - const MediaCard({super.key, required this.media}); +class MediaCard extends StatefulWidget { + const MediaCard({super.key, required this.media, this.callback}); final MediaItem media; + final Function? callback; + + @override + State createState() => _MediaCardState(); +} + +class _MediaCardState extends State { + // late VideoPlayerController _controller; + late MediaItem media; + late Function? callback; + + @override + void initState() { + super.initState(); + media = widget.media; + callback = widget.callback; + // _controller = VideoPlayerController.asset(dataSource) + // ..initialize().then((_) { + // setState(() {}); //when your thumbnail will show. + // }); + } + + // @override + // void dispose() { + // super.dispose(); + // _controller.dispose(); + // } + + // Future createVideoPlayer() async { + // final File file = + // await ImgB64Decoder.fileFromB64String(widget.encodedBytes); + // final VideoPlayerController controller = VideoPlayerController.file(file); + // await controller.initialize(); + // await controller.setLooping(true); + // return controller; + // } @override Widget build(BuildContext context) { @@ -20,7 +61,10 @@ class MediaCard extends StatelessWidget { } else if (media.type == MediaType.localImage) { image = Image.memory(base64Decode(media.reference)).image; } else if (media.type == MediaType.youtube) { - image = NetworkImage('https://img.youtube.com/vi/${media.reference}/0.jpg'); + image = + NetworkImage('https://img.youtube.com/vi/${media.reference}/0.jpg'); + } else if (media.type == MediaType.localVideo) { + } return DecorationImage(image: image, fit: BoxFit.cover); @@ -37,6 +81,18 @@ class MediaCard extends StatelessWidget { RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), shadowColor: const Color.fromARGB(0, 255, 255, 255), child: TextButton( + onLongPress: () => showRemovalDialog( + 'Media Removal', + 'Would you like to permanently remove this media from the current session?', + context, + MediaItemsDao(Provider.of(context, + listen: false)), + media) + .then((result) { + if (callback != null) { + callback!(); + } + }), onPressed: () => showMediaDetailWidget(context, media), child: const ListTile( title: Text(''), diff --git a/lib/widgets/media/media_details.dart b/lib/widgets/media/media_details.dart index 63666a5..51cb0ab 100644 --- a/lib/widgets/media/media_details.dart +++ b/lib/widgets/media/media_details.dart @@ -25,6 +25,7 @@ class MediaDetails extends StatelessWidget { media.description, style: const TextStyle(fontSize: 20), )), + const Divider( indent: 20, endIndent: 20, diff --git a/lib/widgets/sessions/session_card_small.dart b/lib/widgets/sessions/session_card_small.dart index 8ba6385..892b444 100644 --- a/lib/widgets/sessions/session_card_small.dart +++ b/lib/widgets/sessions/session_card_small.dart @@ -47,7 +47,11 @@ class _SessionCardSmallState extends State { // overlayColor: MaterialStateColor(Colors.deepPurple as int), splashColor: Colors.deepPurple, borderRadius: const BorderRadius.all(Radius.elliptical(10, 10)), - onLongPress: () => showMediaDetailWidget(context, sessionImage!), + onLongPress: () { + if (sessionImage != null) { + showMediaDetailWidget(context, sessionImage); + } + }, onTap: () => showGenericDialog(SessionView(session: session), context), child: Container( diff --git a/lib/widgets/sessions/session_editor.dart b/lib/widgets/sessions/session_editor.dart index fb713f0..c79c70c 100644 --- a/lib/widgets/sessions/session_editor.dart +++ b/lib/widgets/sessions/session_editor.dart @@ -1,11 +1,11 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:io'; import 'package:drift/drift.dart' hide Column; import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; +import 'package:mime/mime.dart'; import 'package:provider/provider.dart'; import 'package:sendtrain/daos/media_items_dao.dart'; import 'package:sendtrain/daos/object_media_items_dao.dart'; @@ -193,13 +193,13 @@ class _SessionEditorState extends State { borderSide: BorderSide.none, borderRadius: BorderRadius.circular(12), ), - labelText: 'Select Media (optional)', + labelText: 'Media (optional)', ), controller: sessionCreateController['media'], onTap: () async { FilePickerResult? result = await FilePicker.platform .pickFiles( - allowMultiple: true, type: FileType.media); + allowMultiple: true, type: FileType.image); if (result != null) { List files = result.files; @@ -246,14 +246,21 @@ class _SessionEditorState extends State { i++) { PlatformFile file = sessionPayload.files![i]; + String? type = lookupMimeType(file.path!)!.split('/').first; Uint8List fileBytes = await file.xFile.readAsBytes(); + + MediaType mediaType = MediaType.localImage; + if (type == "video") { + mediaType = MediaType.localVideo; + } + await createSessionMedia( 'Local Media', currentSessionId, file.name, base64Encode(fileBytes), - MediaType.localImage); + mediaType); } } diff --git a/lib/widgets/sessions/session_view_achievements.dart b/lib/widgets/sessions/session_view_achievements.dart index ca4275a..dd2449a 100644 --- a/lib/widgets/sessions/session_view_achievements.dart +++ b/lib/widgets/sessions/session_view_achievements.dart @@ -34,28 +34,42 @@ class SessionViewAchievements extends StatelessWidget { final sessionActivities = snapshot.data!; final achievements = getAchievements(sessionActivities); + Widget content; + if (achievements.isEmpty) { + content = Padding( + padding: const EdgeInsets.only(left: 10, right: 5), + child: ActionChip( + visualDensity: VisualDensity.compact, + avatar: const Icon(Icons.check_circle_outline), + label: Text(maxLines: 1, 'Add Achievements!'), + onPressed: () {}, + )); + } else { + content = ListView.builder( + scrollDirection: Axis.horizontal, + padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), + itemCount: achievements.length, + itemBuilder: (BuildContext context, int index) { + return Padding( + padding: const EdgeInsets.only(right: 5), + child: ActionChip( + visualDensity: VisualDensity.compact, + avatar: const Icon(Icons.check_circle_outline), + label: Text( + maxLines: 1, achievements[index].toTitleCase()), + onPressed: () { + // remove achievements + }, + )); + }, + ); + } + return Column( children: [ Padding( padding: const EdgeInsets.only(bottom: 10), - child: SizedBox( - height: 40, - child: ListView.builder( - scrollDirection: Axis.horizontal, - padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), - itemCount: achievements.length, - itemBuilder: (BuildContext context, int index) { - return Padding( - padding: const EdgeInsets.only(right: 5), - child: ActionChip( - visualDensity: VisualDensity.compact, - avatar: - const Icon(Icons.check_circle_outline), - label: Text(maxLines: 1, achievements[index].toTitleCase()), - onPressed: () {}, - )); - }, - ))), + child: SizedBox(height: 40, child: content)), ], ); } else { diff --git a/lib/widgets/sessions/session_view_media.dart b/lib/widgets/sessions/session_view_media.dart index 63a81c2..6dd57e1 100644 --- a/lib/widgets/sessions/session_view_media.dart +++ b/lib/widgets/sessions/session_view_media.dart @@ -4,22 +4,31 @@ import 'package:sendtrain/daos/media_items_dao.dart'; import 'package:sendtrain/database/database.dart'; import 'package:sendtrain/widgets/media/media_card.dart'; -class SessionViewMedia extends StatelessWidget { +class SessionViewMedia extends StatefulWidget { const SessionViewMedia({super.key, required this.session}); final Session session; + @override + State createState() => _SessionViewMediaState(); +} + +class _SessionViewMediaState extends State { + void resetState() { + setState(() {}); + } + @override Widget build(BuildContext context) { - return FutureBuilder>( - future: MediaItemsDao(Provider.of(context)) - .fromSession(session.id), + return StreamBuilder>( + stream: MediaItemsDao(Provider.of(context)) + .fromSession(widget.session.id).asStream(), builder: (context, snapshot) { if (snapshot.hasData) { final mediaItems = snapshot.data!; List mediaCards = List.generate( - mediaItems.length, (i) => MediaCard(media: mediaItems[i])); + mediaItems.length, (i) => MediaCard(media: mediaItems[i], callback: resetState)); return Column( children: [ diff --git a/pubspec.yaml b/pubspec.yaml index 9a25cb3..102d7cb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -48,6 +48,8 @@ dependencies: file_picker: ^8.1.7 http: ^1.2.2 uuid: ^4.5.1 + mime: ^2.0.0 + video_player: ^2.9.2 flutter_launcher_name: name: "SendTrain" diff --git a/test/drift/sendtrain/generated/schema.dart b/test/drift/sendtrain/generated/schema.dart index 413b440..76573e4 100644 --- a/test/drift/sendtrain/generated/schema.dart +++ b/test/drift/sendtrain/generated/schema.dart @@ -12,6 +12,7 @@ import 'schema_v6.dart' as v6; import 'schema_v7.dart' as v7; import 'schema_v8.dart' as v8; import 'schema_v9.dart' as v9; +import 'schema_v10.dart' as v10; class GeneratedHelper implements SchemaInstantiationHelper { @override @@ -35,10 +36,12 @@ class GeneratedHelper implements SchemaInstantiationHelper { return v8.DatabaseAtV8(db); case 9: return v9.DatabaseAtV9(db); + case 10: + return v10.DatabaseAtV10(db); default: throw MissingSchemaException(version, versions); } } - static const versions = const [1, 2, 3, 4, 5, 6, 7, 8, 9]; + static const versions = const [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; } diff --git a/test/drift/sendtrain/generated/schema_v10.dart b/test/drift/sendtrain/generated/schema_v10.dart new file mode 100644 index 0000000..d7473a7 --- /dev/null +++ b/test/drift/sendtrain/generated/schema_v10.dart @@ -0,0 +1,2009 @@ +// dart format width=80 +// GENERATED CODE, DO NOT EDIT BY HAND. +// ignore_for_file: type=lint +import 'package:drift/drift.dart'; + +class Sessions extends Table with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + Sessions(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); + late final GeneratedColumn title = GeneratedColumn( + 'title', aliasedName, false, + additionalChecks: + GeneratedColumn.checkTextLength(minTextLength: 3, maxTextLength: 32), + type: DriftSqlType.string, + requiredDuringInsert: true); + late final GeneratedColumn content = GeneratedColumn( + 'body', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + late final GeneratedColumn status = GeneratedColumn( + 'status', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + late final GeneratedColumn address = GeneratedColumn( + 'address', aliasedName, true, + additionalChecks: + GeneratedColumn.checkTextLength(minTextLength: 3, maxTextLength: 256), + type: DriftSqlType.string, + requiredDuringInsert: false); + late final GeneratedColumn date = GeneratedColumn( + 'date', aliasedName, true, + type: DriftSqlType.dateTime, requiredDuringInsert: false); + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', aliasedName, false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + defaultValue: Variable(DateTime.now())); + @override + List get $columns => + [id, title, content, status, address, date, createdAt]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'sessions'; + @override + Set get $primaryKey => {id}; + @override + SessionsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return SessionsData( + id: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + title: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}title'])!, + content: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}body'])!, + status: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}status'])!, + address: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}address']), + date: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}date']), + createdAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, + ); + } + + @override + Sessions createAlias(String alias) { + return Sessions(attachedDatabase, alias); + } +} + +class SessionsData extends DataClass implements Insertable { + final int id; + final String title; + final String content; + final String status; + final String? address; + final DateTime? date; + final DateTime createdAt; + const SessionsData( + {required this.id, + required this.title, + required this.content, + required this.status, + this.address, + this.date, + required this.createdAt}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['title'] = Variable(title); + map['body'] = Variable(content); + map['status'] = Variable(status); + if (!nullToAbsent || address != null) { + map['address'] = Variable(address); + } + if (!nullToAbsent || date != null) { + map['date'] = Variable(date); + } + map['created_at'] = Variable(createdAt); + return map; + } + + SessionsCompanion toCompanion(bool nullToAbsent) { + return SessionsCompanion( + id: Value(id), + title: Value(title), + content: Value(content), + status: Value(status), + address: address == null && nullToAbsent + ? const Value.absent() + : Value(address), + date: date == null && nullToAbsent ? const Value.absent() : Value(date), + createdAt: Value(createdAt), + ); + } + + factory SessionsData.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return SessionsData( + id: serializer.fromJson(json['id']), + title: serializer.fromJson(json['title']), + content: serializer.fromJson(json['content']), + status: serializer.fromJson(json['status']), + address: serializer.fromJson(json['address']), + date: serializer.fromJson(json['date']), + createdAt: serializer.fromJson(json['createdAt']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'title': serializer.toJson(title), + 'content': serializer.toJson(content), + 'status': serializer.toJson(status), + 'address': serializer.toJson(address), + 'date': serializer.toJson(date), + 'createdAt': serializer.toJson(createdAt), + }; + } + + SessionsData copyWith( + {int? id, + String? title, + String? content, + String? status, + Value address = const Value.absent(), + Value date = const Value.absent(), + DateTime? createdAt}) => + SessionsData( + id: id ?? this.id, + title: title ?? this.title, + content: content ?? this.content, + status: status ?? this.status, + address: address.present ? address.value : this.address, + date: date.present ? date.value : this.date, + createdAt: createdAt ?? this.createdAt, + ); + SessionsData copyWithCompanion(SessionsCompanion data) { + return SessionsData( + id: data.id.present ? data.id.value : this.id, + title: data.title.present ? data.title.value : this.title, + content: data.content.present ? data.content.value : this.content, + status: data.status.present ? data.status.value : this.status, + address: data.address.present ? data.address.value : this.address, + date: data.date.present ? data.date.value : this.date, + createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, + ); + } + + @override + String toString() { + return (StringBuffer('SessionsData(') + ..write('id: $id, ') + ..write('title: $title, ') + ..write('content: $content, ') + ..write('status: $status, ') + ..write('address: $address, ') + ..write('date: $date, ') + ..write('createdAt: $createdAt') + ..write(')')) + .toString(); + } + + @override + int get hashCode => + Object.hash(id, title, content, status, address, date, createdAt); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is SessionsData && + other.id == this.id && + other.title == this.title && + other.content == this.content && + other.status == this.status && + other.address == this.address && + other.date == this.date && + other.createdAt == this.createdAt); +} + +class SessionsCompanion extends UpdateCompanion { + final Value id; + final Value title; + final Value content; + final Value status; + final Value address; + final Value date; + final Value createdAt; + const SessionsCompanion({ + this.id = const Value.absent(), + this.title = const Value.absent(), + this.content = const Value.absent(), + this.status = const Value.absent(), + this.address = const Value.absent(), + this.date = const Value.absent(), + this.createdAt = const Value.absent(), + }); + SessionsCompanion.insert({ + this.id = const Value.absent(), + required String title, + required String content, + required String status, + this.address = const Value.absent(), + this.date = const Value.absent(), + this.createdAt = const Value.absent(), + }) : title = Value(title), + content = Value(content), + status = Value(status); + static Insertable custom({ + Expression? id, + Expression? title, + Expression? content, + Expression? status, + Expression? address, + Expression? date, + Expression? createdAt, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (title != null) 'title': title, + if (content != null) 'body': content, + if (status != null) 'status': status, + if (address != null) 'address': address, + if (date != null) 'date': date, + if (createdAt != null) 'created_at': createdAt, + }); + } + + SessionsCompanion copyWith( + {Value? id, + Value? title, + Value? content, + Value? status, + Value? address, + Value? date, + Value? createdAt}) { + return SessionsCompanion( + id: id ?? this.id, + title: title ?? this.title, + content: content ?? this.content, + status: status ?? this.status, + address: address ?? this.address, + date: date ?? this.date, + createdAt: createdAt ?? this.createdAt, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (title.present) { + map['title'] = Variable(title.value); + } + if (content.present) { + map['body'] = Variable(content.value); + } + if (status.present) { + map['status'] = Variable(status.value); + } + if (address.present) { + map['address'] = Variable(address.value); + } + if (date.present) { + map['date'] = Variable(date.value); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('SessionsCompanion(') + ..write('id: $id, ') + ..write('title: $title, ') + ..write('content: $content, ') + ..write('status: $status, ') + ..write('address: $address, ') + ..write('date: $date, ') + ..write('createdAt: $createdAt') + ..write(')')) + .toString(); + } +} + +class Activities extends Table with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + Activities(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); + late final GeneratedColumn title = GeneratedColumn( + 'title', aliasedName, false, + additionalChecks: + GeneratedColumn.checkTextLength(minTextLength: 3, maxTextLength: 32), + type: DriftSqlType.string, + requiredDuringInsert: true); + late final GeneratedColumn type = GeneratedColumn( + 'type', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + late final GeneratedColumn description = GeneratedColumn( + 'body', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + late final GeneratedColumn category = GeneratedColumn( + 'category', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', aliasedName, false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + defaultValue: Variable(DateTime.now())); + @override + List get $columns => + [id, title, type, description, category, createdAt]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'activities'; + @override + Set get $primaryKey => {id}; + @override + ActivitiesData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return ActivitiesData( + id: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + title: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}title'])!, + type: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}type'])!, + description: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}body'])!, + category: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}category'])!, + createdAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, + ); + } + + @override + Activities createAlias(String alias) { + return Activities(attachedDatabase, alias); + } +} + +class ActivitiesData extends DataClass implements Insertable { + final int id; + final String title; + final String type; + final String description; + final String category; + final DateTime createdAt; + const ActivitiesData( + {required this.id, + required this.title, + required this.type, + required this.description, + required this.category, + required this.createdAt}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['title'] = Variable(title); + map['type'] = Variable(type); + map['body'] = Variable(description); + map['category'] = Variable(category); + map['created_at'] = Variable(createdAt); + return map; + } + + ActivitiesCompanion toCompanion(bool nullToAbsent) { + return ActivitiesCompanion( + id: Value(id), + title: Value(title), + type: Value(type), + description: Value(description), + category: Value(category), + createdAt: Value(createdAt), + ); + } + + factory ActivitiesData.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return ActivitiesData( + id: serializer.fromJson(json['id']), + title: serializer.fromJson(json['title']), + type: serializer.fromJson(json['type']), + description: serializer.fromJson(json['description']), + category: serializer.fromJson(json['category']), + createdAt: serializer.fromJson(json['createdAt']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'title': serializer.toJson(title), + 'type': serializer.toJson(type), + 'description': serializer.toJson(description), + 'category': serializer.toJson(category), + 'createdAt': serializer.toJson(createdAt), + }; + } + + ActivitiesData copyWith( + {int? id, + String? title, + String? type, + String? description, + String? category, + DateTime? createdAt}) => + ActivitiesData( + id: id ?? this.id, + title: title ?? this.title, + type: type ?? this.type, + description: description ?? this.description, + category: category ?? this.category, + createdAt: createdAt ?? this.createdAt, + ); + ActivitiesData copyWithCompanion(ActivitiesCompanion data) { + return ActivitiesData( + id: data.id.present ? data.id.value : this.id, + title: data.title.present ? data.title.value : this.title, + type: data.type.present ? data.type.value : this.type, + description: + data.description.present ? data.description.value : this.description, + category: data.category.present ? data.category.value : this.category, + createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, + ); + } + + @override + String toString() { + return (StringBuffer('ActivitiesData(') + ..write('id: $id, ') + ..write('title: $title, ') + ..write('type: $type, ') + ..write('description: $description, ') + ..write('category: $category, ') + ..write('createdAt: $createdAt') + ..write(')')) + .toString(); + } + + @override + int get hashCode => + Object.hash(id, title, type, description, category, createdAt); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ActivitiesData && + other.id == this.id && + other.title == this.title && + other.type == this.type && + other.description == this.description && + other.category == this.category && + other.createdAt == this.createdAt); +} + +class ActivitiesCompanion extends UpdateCompanion { + final Value id; + final Value title; + final Value type; + final Value description; + final Value category; + final Value createdAt; + const ActivitiesCompanion({ + this.id = const Value.absent(), + this.title = const Value.absent(), + this.type = const Value.absent(), + this.description = const Value.absent(), + this.category = const Value.absent(), + this.createdAt = const Value.absent(), + }); + ActivitiesCompanion.insert({ + this.id = const Value.absent(), + required String title, + required String type, + required String description, + required String category, + this.createdAt = const Value.absent(), + }) : title = Value(title), + type = Value(type), + description = Value(description), + category = Value(category); + static Insertable custom({ + Expression? id, + Expression? title, + Expression? type, + Expression? description, + Expression? category, + Expression? createdAt, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (title != null) 'title': title, + if (type != null) 'type': type, + if (description != null) 'body': description, + if (category != null) 'category': category, + if (createdAt != null) 'created_at': createdAt, + }); + } + + ActivitiesCompanion copyWith( + {Value? id, + Value? title, + Value? type, + Value? description, + Value? category, + Value? createdAt}) { + return ActivitiesCompanion( + id: id ?? this.id, + title: title ?? this.title, + type: type ?? this.type, + description: description ?? this.description, + category: category ?? this.category, + createdAt: createdAt ?? this.createdAt, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (title.present) { + map['title'] = Variable(title.value); + } + if (type.present) { + map['type'] = Variable(type.value); + } + if (description.present) { + map['body'] = Variable(description.value); + } + if (category.present) { + map['category'] = Variable(category.value); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('ActivitiesCompanion(') + ..write('id: $id, ') + ..write('title: $title, ') + ..write('type: $type, ') + ..write('description: $description, ') + ..write('category: $category, ') + ..write('createdAt: $createdAt') + ..write(')')) + .toString(); + } +} + +class SessionActivities extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + SessionActivities(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); + late final GeneratedColumn sessionId = GeneratedColumn( + 'session_id', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: true, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'REFERENCES sessions (id) ON DELETE CASCADE')); + late final GeneratedColumn activityId = GeneratedColumn( + 'activity_id', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: true, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'REFERENCES activities (id) ON DELETE CASCADE')); + late final GeneratedColumn position = GeneratedColumn( + 'position', aliasedName, false, + type: DriftSqlType.int, requiredDuringInsert: true); + late final GeneratedColumn results = GeneratedColumn( + 'results', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false); + late final GeneratedColumn achievements = GeneratedColumn( + 'achievements', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false); + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', aliasedName, false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + defaultValue: Variable(DateTime.now())); + @override + List get $columns => + [id, sessionId, activityId, position, results, achievements, createdAt]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'session_activities'; + @override + Set get $primaryKey => {id}; + @override + SessionActivitiesData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return SessionActivitiesData( + id: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + sessionId: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}session_id'])!, + activityId: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}activity_id'])!, + position: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}position'])!, + results: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}results']), + achievements: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}achievements']), + createdAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, + ); + } + + @override + SessionActivities createAlias(String alias) { + return SessionActivities(attachedDatabase, alias); + } +} + +class SessionActivitiesData extends DataClass + implements Insertable { + final int id; + final int sessionId; + final int activityId; + final int position; + final String? results; + final String? achievements; + final DateTime createdAt; + const SessionActivitiesData( + {required this.id, + required this.sessionId, + required this.activityId, + required this.position, + this.results, + this.achievements, + required this.createdAt}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['session_id'] = Variable(sessionId); + map['activity_id'] = Variable(activityId); + map['position'] = Variable(position); + if (!nullToAbsent || results != null) { + map['results'] = Variable(results); + } + if (!nullToAbsent || achievements != null) { + map['achievements'] = Variable(achievements); + } + map['created_at'] = Variable(createdAt); + return map; + } + + SessionActivitiesCompanion toCompanion(bool nullToAbsent) { + return SessionActivitiesCompanion( + id: Value(id), + sessionId: Value(sessionId), + activityId: Value(activityId), + position: Value(position), + results: results == null && nullToAbsent + ? const Value.absent() + : Value(results), + achievements: achievements == null && nullToAbsent + ? const Value.absent() + : Value(achievements), + createdAt: Value(createdAt), + ); + } + + factory SessionActivitiesData.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return SessionActivitiesData( + id: serializer.fromJson(json['id']), + sessionId: serializer.fromJson(json['sessionId']), + activityId: serializer.fromJson(json['activityId']), + position: serializer.fromJson(json['position']), + results: serializer.fromJson(json['results']), + achievements: serializer.fromJson(json['achievements']), + createdAt: serializer.fromJson(json['createdAt']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'sessionId': serializer.toJson(sessionId), + 'activityId': serializer.toJson(activityId), + 'position': serializer.toJson(position), + 'results': serializer.toJson(results), + 'achievements': serializer.toJson(achievements), + 'createdAt': serializer.toJson(createdAt), + }; + } + + SessionActivitiesData copyWith( + {int? id, + int? sessionId, + int? activityId, + int? position, + Value results = const Value.absent(), + Value achievements = const Value.absent(), + DateTime? createdAt}) => + SessionActivitiesData( + id: id ?? this.id, + sessionId: sessionId ?? this.sessionId, + activityId: activityId ?? this.activityId, + position: position ?? this.position, + results: results.present ? results.value : this.results, + achievements: + achievements.present ? achievements.value : this.achievements, + createdAt: createdAt ?? this.createdAt, + ); + SessionActivitiesData copyWithCompanion(SessionActivitiesCompanion data) { + return SessionActivitiesData( + id: data.id.present ? data.id.value : this.id, + sessionId: data.sessionId.present ? data.sessionId.value : this.sessionId, + activityId: + data.activityId.present ? data.activityId.value : this.activityId, + position: data.position.present ? data.position.value : this.position, + results: data.results.present ? data.results.value : this.results, + achievements: data.achievements.present + ? data.achievements.value + : this.achievements, + createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, + ); + } + + @override + String toString() { + return (StringBuffer('SessionActivitiesData(') + ..write('id: $id, ') + ..write('sessionId: $sessionId, ') + ..write('activityId: $activityId, ') + ..write('position: $position, ') + ..write('results: $results, ') + ..write('achievements: $achievements, ') + ..write('createdAt: $createdAt') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + id, sessionId, activityId, position, results, achievements, createdAt); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is SessionActivitiesData && + other.id == this.id && + other.sessionId == this.sessionId && + other.activityId == this.activityId && + other.position == this.position && + other.results == this.results && + other.achievements == this.achievements && + other.createdAt == this.createdAt); +} + +class SessionActivitiesCompanion + extends UpdateCompanion { + final Value id; + final Value sessionId; + final Value activityId; + final Value position; + final Value results; + final Value achievements; + final Value createdAt; + const SessionActivitiesCompanion({ + this.id = const Value.absent(), + this.sessionId = const Value.absent(), + this.activityId = const Value.absent(), + this.position = const Value.absent(), + this.results = const Value.absent(), + this.achievements = const Value.absent(), + this.createdAt = const Value.absent(), + }); + SessionActivitiesCompanion.insert({ + this.id = const Value.absent(), + required int sessionId, + required int activityId, + required int position, + this.results = const Value.absent(), + this.achievements = const Value.absent(), + this.createdAt = const Value.absent(), + }) : sessionId = Value(sessionId), + activityId = Value(activityId), + position = Value(position); + static Insertable custom({ + Expression? id, + Expression? sessionId, + Expression? activityId, + Expression? position, + Expression? results, + Expression? achievements, + Expression? createdAt, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (sessionId != null) 'session_id': sessionId, + if (activityId != null) 'activity_id': activityId, + if (position != null) 'position': position, + if (results != null) 'results': results, + if (achievements != null) 'achievements': achievements, + if (createdAt != null) 'created_at': createdAt, + }); + } + + SessionActivitiesCompanion copyWith( + {Value? id, + Value? sessionId, + Value? activityId, + Value? position, + Value? results, + Value? achievements, + Value? createdAt}) { + return SessionActivitiesCompanion( + id: id ?? this.id, + sessionId: sessionId ?? this.sessionId, + activityId: activityId ?? this.activityId, + position: position ?? this.position, + results: results ?? this.results, + achievements: achievements ?? this.achievements, + createdAt: createdAt ?? this.createdAt, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (sessionId.present) { + map['session_id'] = Variable(sessionId.value); + } + if (activityId.present) { + map['activity_id'] = Variable(activityId.value); + } + if (position.present) { + map['position'] = Variable(position.value); + } + if (results.present) { + map['results'] = Variable(results.value); + } + if (achievements.present) { + map['achievements'] = Variable(achievements.value); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('SessionActivitiesCompanion(') + ..write('id: $id, ') + ..write('sessionId: $sessionId, ') + ..write('activityId: $activityId, ') + ..write('position: $position, ') + ..write('results: $results, ') + ..write('achievements: $achievements, ') + ..write('createdAt: $createdAt') + ..write(')')) + .toString(); + } +} + +class Actions extends Table with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + Actions(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); + late final GeneratedColumn title = GeneratedColumn( + 'title', aliasedName, false, + additionalChecks: + GeneratedColumn.checkTextLength(minTextLength: 3, maxTextLength: 32), + type: DriftSqlType.string, + requiredDuringInsert: true); + late final GeneratedColumn description = GeneratedColumn( + 'body', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + late final GeneratedColumn set = GeneratedColumn( + 'set', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', aliasedName, false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + defaultValue: Variable(DateTime.now())); + @override + List get $columns => + [id, title, description, set, createdAt]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'actions'; + @override + Set get $primaryKey => {id}; + @override + ActionsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return ActionsData( + id: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + title: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}title'])!, + description: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}body'])!, + set: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}set'])!, + createdAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, + ); + } + + @override + Actions createAlias(String alias) { + return Actions(attachedDatabase, alias); + } +} + +class ActionsData extends DataClass implements Insertable { + final int id; + final String title; + final String description; + final String set; + final DateTime createdAt; + const ActionsData( + {required this.id, + required this.title, + required this.description, + required this.set, + required this.createdAt}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['title'] = Variable(title); + map['body'] = Variable(description); + map['set'] = Variable(set); + map['created_at'] = Variable(createdAt); + return map; + } + + ActionsCompanion toCompanion(bool nullToAbsent) { + return ActionsCompanion( + id: Value(id), + title: Value(title), + description: Value(description), + set: Value(set), + createdAt: Value(createdAt), + ); + } + + factory ActionsData.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return ActionsData( + id: serializer.fromJson(json['id']), + title: serializer.fromJson(json['title']), + description: serializer.fromJson(json['description']), + set: serializer.fromJson(json['set']), + createdAt: serializer.fromJson(json['createdAt']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'title': serializer.toJson(title), + 'description': serializer.toJson(description), + 'set': serializer.toJson(set), + 'createdAt': serializer.toJson(createdAt), + }; + } + + ActionsData copyWith( + {int? id, + String? title, + String? description, + String? set, + DateTime? createdAt}) => + ActionsData( + id: id ?? this.id, + title: title ?? this.title, + description: description ?? this.description, + set: set ?? this.set, + createdAt: createdAt ?? this.createdAt, + ); + ActionsData copyWithCompanion(ActionsCompanion data) { + return ActionsData( + id: data.id.present ? data.id.value : this.id, + title: data.title.present ? data.title.value : this.title, + description: + data.description.present ? data.description.value : this.description, + set: data.set.present ? data.set.value : this.set, + createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, + ); + } + + @override + String toString() { + return (StringBuffer('ActionsData(') + ..write('id: $id, ') + ..write('title: $title, ') + ..write('description: $description, ') + ..write('set: $set, ') + ..write('createdAt: $createdAt') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, title, description, set, createdAt); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ActionsData && + other.id == this.id && + other.title == this.title && + other.description == this.description && + other.set == this.set && + other.createdAt == this.createdAt); +} + +class ActionsCompanion extends UpdateCompanion { + final Value id; + final Value title; + final Value description; + final Value set; + final Value createdAt; + const ActionsCompanion({ + this.id = const Value.absent(), + this.title = const Value.absent(), + this.description = const Value.absent(), + this.set = const Value.absent(), + this.createdAt = const Value.absent(), + }); + ActionsCompanion.insert({ + this.id = const Value.absent(), + required String title, + required String description, + required String set, + this.createdAt = const Value.absent(), + }) : title = Value(title), + description = Value(description), + set = Value(set); + static Insertable custom({ + Expression? id, + Expression? title, + Expression? description, + Expression? set, + Expression? createdAt, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (title != null) 'title': title, + if (description != null) 'body': description, + if (set != null) 'set': set, + if (createdAt != null) 'created_at': createdAt, + }); + } + + ActionsCompanion copyWith( + {Value? id, + Value? title, + Value? description, + Value? set, + Value? createdAt}) { + return ActionsCompanion( + id: id ?? this.id, + title: title ?? this.title, + description: description ?? this.description, + set: set ?? this.set, + createdAt: createdAt ?? this.createdAt, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (title.present) { + map['title'] = Variable(title.value); + } + if (description.present) { + map['body'] = Variable(description.value); + } + if (set.present) { + map['set'] = Variable(set.value); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('ActionsCompanion(') + ..write('id: $id, ') + ..write('title: $title, ') + ..write('description: $description, ') + ..write('set: $set, ') + ..write('createdAt: $createdAt') + ..write(')')) + .toString(); + } +} + +class ActivityActions extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + ActivityActions(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); + late final GeneratedColumn activityId = GeneratedColumn( + 'activity_id', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: true, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'REFERENCES activities (id) ON DELETE CASCADE')); + late final GeneratedColumn actionId = GeneratedColumn( + 'action_id', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: true, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'REFERENCES actions (id) ON DELETE CASCADE')); + late final GeneratedColumn position = GeneratedColumn( + 'position', aliasedName, false, + type: DriftSqlType.int, requiredDuringInsert: true); + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', aliasedName, false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + defaultValue: Variable(DateTime.now())); + @override + List get $columns => + [id, activityId, actionId, position, createdAt]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'activity_actions'; + @override + Set get $primaryKey => {id}; + @override + ActivityActionsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return ActivityActionsData( + id: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + activityId: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}activity_id'])!, + actionId: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}action_id'])!, + position: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}position'])!, + createdAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, + ); + } + + @override + ActivityActions createAlias(String alias) { + return ActivityActions(attachedDatabase, alias); + } +} + +class ActivityActionsData extends DataClass + implements Insertable { + final int id; + final int activityId; + final int actionId; + final int position; + final DateTime createdAt; + const ActivityActionsData( + {required this.id, + required this.activityId, + required this.actionId, + required this.position, + required this.createdAt}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['activity_id'] = Variable(activityId); + map['action_id'] = Variable(actionId); + map['position'] = Variable(position); + map['created_at'] = Variable(createdAt); + return map; + } + + ActivityActionsCompanion toCompanion(bool nullToAbsent) { + return ActivityActionsCompanion( + id: Value(id), + activityId: Value(activityId), + actionId: Value(actionId), + position: Value(position), + createdAt: Value(createdAt), + ); + } + + factory ActivityActionsData.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return ActivityActionsData( + id: serializer.fromJson(json['id']), + activityId: serializer.fromJson(json['activityId']), + actionId: serializer.fromJson(json['actionId']), + position: serializer.fromJson(json['position']), + createdAt: serializer.fromJson(json['createdAt']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'activityId': serializer.toJson(activityId), + 'actionId': serializer.toJson(actionId), + 'position': serializer.toJson(position), + 'createdAt': serializer.toJson(createdAt), + }; + } + + ActivityActionsData copyWith( + {int? id, + int? activityId, + int? actionId, + int? position, + DateTime? createdAt}) => + ActivityActionsData( + id: id ?? this.id, + activityId: activityId ?? this.activityId, + actionId: actionId ?? this.actionId, + position: position ?? this.position, + createdAt: createdAt ?? this.createdAt, + ); + ActivityActionsData copyWithCompanion(ActivityActionsCompanion data) { + return ActivityActionsData( + id: data.id.present ? data.id.value : this.id, + activityId: + data.activityId.present ? data.activityId.value : this.activityId, + actionId: data.actionId.present ? data.actionId.value : this.actionId, + position: data.position.present ? data.position.value : this.position, + createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, + ); + } + + @override + String toString() { + return (StringBuffer('ActivityActionsData(') + ..write('id: $id, ') + ..write('activityId: $activityId, ') + ..write('actionId: $actionId, ') + ..write('position: $position, ') + ..write('createdAt: $createdAt') + ..write(')')) + .toString(); + } + + @override + int get hashCode => + Object.hash(id, activityId, actionId, position, createdAt); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ActivityActionsData && + other.id == this.id && + other.activityId == this.activityId && + other.actionId == this.actionId && + other.position == this.position && + other.createdAt == this.createdAt); +} + +class ActivityActionsCompanion extends UpdateCompanion { + final Value id; + final Value activityId; + final Value actionId; + final Value position; + final Value createdAt; + const ActivityActionsCompanion({ + this.id = const Value.absent(), + this.activityId = const Value.absent(), + this.actionId = const Value.absent(), + this.position = const Value.absent(), + this.createdAt = const Value.absent(), + }); + ActivityActionsCompanion.insert({ + this.id = const Value.absent(), + required int activityId, + required int actionId, + required int position, + this.createdAt = const Value.absent(), + }) : activityId = Value(activityId), + actionId = Value(actionId), + position = Value(position); + static Insertable custom({ + Expression? id, + Expression? activityId, + Expression? actionId, + Expression? position, + Expression? createdAt, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (activityId != null) 'activity_id': activityId, + if (actionId != null) 'action_id': actionId, + if (position != null) 'position': position, + if (createdAt != null) 'created_at': createdAt, + }); + } + + ActivityActionsCompanion copyWith( + {Value? id, + Value? activityId, + Value? actionId, + Value? position, + Value? createdAt}) { + return ActivityActionsCompanion( + id: id ?? this.id, + activityId: activityId ?? this.activityId, + actionId: actionId ?? this.actionId, + position: position ?? this.position, + createdAt: createdAt ?? this.createdAt, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (activityId.present) { + map['activity_id'] = Variable(activityId.value); + } + if (actionId.present) { + map['action_id'] = Variable(actionId.value); + } + if (position.present) { + map['position'] = Variable(position.value); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('ActivityActionsCompanion(') + ..write('id: $id, ') + ..write('activityId: $activityId, ') + ..write('actionId: $actionId, ') + ..write('position: $position, ') + ..write('createdAt: $createdAt') + ..write(')')) + .toString(); + } +} + +class MediaItems extends Table with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + MediaItems(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); + late final GeneratedColumn title = GeneratedColumn( + 'title', aliasedName, false, + additionalChecks: + GeneratedColumn.checkTextLength(minTextLength: 3, maxTextLength: 32), + type: DriftSqlType.string, + requiredDuringInsert: true); + late final GeneratedColumn description = GeneratedColumn( + 'body', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + late final GeneratedColumn reference = GeneratedColumn( + 'reference', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + late final GeneratedColumn type = GeneratedColumn( + 'type', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', aliasedName, false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + defaultValue: Variable(DateTime.now())); + @override + List get $columns => + [id, title, description, reference, type, createdAt]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'media_items'; + @override + Set get $primaryKey => {id}; + @override + MediaItemsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return MediaItemsData( + id: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + title: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}title'])!, + description: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}body'])!, + reference: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}reference'])!, + type: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}type'])!, + createdAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, + ); + } + + @override + MediaItems createAlias(String alias) { + return MediaItems(attachedDatabase, alias); + } +} + +class MediaItemsData extends DataClass implements Insertable { + final int id; + final String title; + final String description; + final String reference; + final String type; + final DateTime createdAt; + const MediaItemsData( + {required this.id, + required this.title, + required this.description, + required this.reference, + required this.type, + required this.createdAt}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['title'] = Variable(title); + map['body'] = Variable(description); + map['reference'] = Variable(reference); + map['type'] = Variable(type); + map['created_at'] = Variable(createdAt); + return map; + } + + MediaItemsCompanion toCompanion(bool nullToAbsent) { + return MediaItemsCompanion( + id: Value(id), + title: Value(title), + description: Value(description), + reference: Value(reference), + type: Value(type), + createdAt: Value(createdAt), + ); + } + + factory MediaItemsData.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return MediaItemsData( + id: serializer.fromJson(json['id']), + title: serializer.fromJson(json['title']), + description: serializer.fromJson(json['description']), + reference: serializer.fromJson(json['reference']), + type: serializer.fromJson(json['type']), + createdAt: serializer.fromJson(json['createdAt']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'title': serializer.toJson(title), + 'description': serializer.toJson(description), + 'reference': serializer.toJson(reference), + 'type': serializer.toJson(type), + 'createdAt': serializer.toJson(createdAt), + }; + } + + MediaItemsData copyWith( + {int? id, + String? title, + String? description, + String? reference, + String? type, + DateTime? createdAt}) => + MediaItemsData( + id: id ?? this.id, + title: title ?? this.title, + description: description ?? this.description, + reference: reference ?? this.reference, + type: type ?? this.type, + createdAt: createdAt ?? this.createdAt, + ); + MediaItemsData copyWithCompanion(MediaItemsCompanion data) { + return MediaItemsData( + id: data.id.present ? data.id.value : this.id, + title: data.title.present ? data.title.value : this.title, + description: + data.description.present ? data.description.value : this.description, + reference: data.reference.present ? data.reference.value : this.reference, + type: data.type.present ? data.type.value : this.type, + createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, + ); + } + + @override + String toString() { + return (StringBuffer('MediaItemsData(') + ..write('id: $id, ') + ..write('title: $title, ') + ..write('description: $description, ') + ..write('reference: $reference, ') + ..write('type: $type, ') + ..write('createdAt: $createdAt') + ..write(')')) + .toString(); + } + + @override + int get hashCode => + Object.hash(id, title, description, reference, type, createdAt); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is MediaItemsData && + other.id == this.id && + other.title == this.title && + other.description == this.description && + other.reference == this.reference && + other.type == this.type && + other.createdAt == this.createdAt); +} + +class MediaItemsCompanion extends UpdateCompanion { + final Value id; + final Value title; + final Value description; + final Value reference; + final Value type; + final Value createdAt; + const MediaItemsCompanion({ + this.id = const Value.absent(), + this.title = const Value.absent(), + this.description = const Value.absent(), + this.reference = const Value.absent(), + this.type = const Value.absent(), + this.createdAt = const Value.absent(), + }); + MediaItemsCompanion.insert({ + this.id = const Value.absent(), + required String title, + required String description, + required String reference, + required String type, + this.createdAt = const Value.absent(), + }) : title = Value(title), + description = Value(description), + reference = Value(reference), + type = Value(type); + static Insertable custom({ + Expression? id, + Expression? title, + Expression? description, + Expression? reference, + Expression? type, + Expression? createdAt, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (title != null) 'title': title, + if (description != null) 'body': description, + if (reference != null) 'reference': reference, + if (type != null) 'type': type, + if (createdAt != null) 'created_at': createdAt, + }); + } + + MediaItemsCompanion copyWith( + {Value? id, + Value? title, + Value? description, + Value? reference, + Value? type, + Value? createdAt}) { + return MediaItemsCompanion( + id: id ?? this.id, + title: title ?? this.title, + description: description ?? this.description, + reference: reference ?? this.reference, + type: type ?? this.type, + createdAt: createdAt ?? this.createdAt, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (title.present) { + map['title'] = Variable(title.value); + } + if (description.present) { + map['body'] = Variable(description.value); + } + if (reference.present) { + map['reference'] = Variable(reference.value); + } + if (type.present) { + map['type'] = Variable(type.value); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('MediaItemsCompanion(') + ..write('id: $id, ') + ..write('title: $title, ') + ..write('description: $description, ') + ..write('reference: $reference, ') + ..write('type: $type, ') + ..write('createdAt: $createdAt') + ..write(')')) + .toString(); + } +} + +class ObjectMediaItems extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + ObjectMediaItems(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); + late final GeneratedColumn objectId = GeneratedColumn( + 'object_id', aliasedName, false, + type: DriftSqlType.int, requiredDuringInsert: true); + late final GeneratedColumn objectType = GeneratedColumn( + 'object_type', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + late final GeneratedColumn mediaId = GeneratedColumn( + 'media_id', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: true, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'REFERENCES media_items (id) ON DELETE CASCADE')); + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', aliasedName, false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + defaultValue: Variable(DateTime.now())); + @override + List get $columns => + [id, objectId, objectType, mediaId, createdAt]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'object_media_items'; + @override + Set get $primaryKey => {id}; + @override + ObjectMediaItemsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return ObjectMediaItemsData( + id: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + objectId: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}object_id'])!, + objectType: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}object_type'])!, + mediaId: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}media_id'])!, + createdAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, + ); + } + + @override + ObjectMediaItems createAlias(String alias) { + return ObjectMediaItems(attachedDatabase, alias); + } +} + +class ObjectMediaItemsData extends DataClass + implements Insertable { + final int id; + final int objectId; + final String objectType; + final int mediaId; + final DateTime createdAt; + const ObjectMediaItemsData( + {required this.id, + required this.objectId, + required this.objectType, + required this.mediaId, + required this.createdAt}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['object_id'] = Variable(objectId); + map['object_type'] = Variable(objectType); + map['media_id'] = Variable(mediaId); + map['created_at'] = Variable(createdAt); + return map; + } + + ObjectMediaItemsCompanion toCompanion(bool nullToAbsent) { + return ObjectMediaItemsCompanion( + id: Value(id), + objectId: Value(objectId), + objectType: Value(objectType), + mediaId: Value(mediaId), + createdAt: Value(createdAt), + ); + } + + factory ObjectMediaItemsData.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return ObjectMediaItemsData( + id: serializer.fromJson(json['id']), + objectId: serializer.fromJson(json['objectId']), + objectType: serializer.fromJson(json['objectType']), + mediaId: serializer.fromJson(json['mediaId']), + createdAt: serializer.fromJson(json['createdAt']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'objectId': serializer.toJson(objectId), + 'objectType': serializer.toJson(objectType), + 'mediaId': serializer.toJson(mediaId), + 'createdAt': serializer.toJson(createdAt), + }; + } + + ObjectMediaItemsData copyWith( + {int? id, + int? objectId, + String? objectType, + int? mediaId, + DateTime? createdAt}) => + ObjectMediaItemsData( + id: id ?? this.id, + objectId: objectId ?? this.objectId, + objectType: objectType ?? this.objectType, + mediaId: mediaId ?? this.mediaId, + createdAt: createdAt ?? this.createdAt, + ); + ObjectMediaItemsData copyWithCompanion(ObjectMediaItemsCompanion data) { + return ObjectMediaItemsData( + id: data.id.present ? data.id.value : this.id, + objectId: data.objectId.present ? data.objectId.value : this.objectId, + objectType: + data.objectType.present ? data.objectType.value : this.objectType, + mediaId: data.mediaId.present ? data.mediaId.value : this.mediaId, + createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, + ); + } + + @override + String toString() { + return (StringBuffer('ObjectMediaItemsData(') + ..write('id: $id, ') + ..write('objectId: $objectId, ') + ..write('objectType: $objectType, ') + ..write('mediaId: $mediaId, ') + ..write('createdAt: $createdAt') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, objectId, objectType, mediaId, createdAt); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ObjectMediaItemsData && + other.id == this.id && + other.objectId == this.objectId && + other.objectType == this.objectType && + other.mediaId == this.mediaId && + other.createdAt == this.createdAt); +} + +class ObjectMediaItemsCompanion extends UpdateCompanion { + final Value id; + final Value objectId; + final Value objectType; + final Value mediaId; + final Value createdAt; + const ObjectMediaItemsCompanion({ + this.id = const Value.absent(), + this.objectId = const Value.absent(), + this.objectType = const Value.absent(), + this.mediaId = const Value.absent(), + this.createdAt = const Value.absent(), + }); + ObjectMediaItemsCompanion.insert({ + this.id = const Value.absent(), + required int objectId, + required String objectType, + required int mediaId, + this.createdAt = const Value.absent(), + }) : objectId = Value(objectId), + objectType = Value(objectType), + mediaId = Value(mediaId); + static Insertable custom({ + Expression? id, + Expression? objectId, + Expression? objectType, + Expression? mediaId, + Expression? createdAt, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (objectId != null) 'object_id': objectId, + if (objectType != null) 'object_type': objectType, + if (mediaId != null) 'media_id': mediaId, + if (createdAt != null) 'created_at': createdAt, + }); + } + + ObjectMediaItemsCompanion copyWith( + {Value? id, + Value? objectId, + Value? objectType, + Value? mediaId, + Value? createdAt}) { + return ObjectMediaItemsCompanion( + id: id ?? this.id, + objectId: objectId ?? this.objectId, + objectType: objectType ?? this.objectType, + mediaId: mediaId ?? this.mediaId, + createdAt: createdAt ?? this.createdAt, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (objectId.present) { + map['object_id'] = Variable(objectId.value); + } + if (objectType.present) { + map['object_type'] = Variable(objectType.value); + } + if (mediaId.present) { + map['media_id'] = Variable(mediaId.value); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('ObjectMediaItemsCompanion(') + ..write('id: $id, ') + ..write('objectId: $objectId, ') + ..write('objectType: $objectType, ') + ..write('mediaId: $mediaId, ') + ..write('createdAt: $createdAt') + ..write(')')) + .toString(); + } +} + +class DatabaseAtV10 extends GeneratedDatabase { + DatabaseAtV10(QueryExecutor e) : super(e); + late final Sessions sessions = Sessions(this); + late final Activities activities = Activities(this); + late final SessionActivities sessionActivities = SessionActivities(this); + late final Actions actions = Actions(this); + late final ActivityActions activityActions = ActivityActions(this); + late final MediaItems mediaItems = MediaItems(this); + late final ObjectMediaItems objectMediaItems = ObjectMediaItems(this); + @override + Iterable> get allTables => + allSchemaEntities.whereType>(); + @override + List get allSchemaEntities => [ + sessions, + activities, + sessionActivities, + actions, + activityActions, + mediaItems, + objectMediaItems + ]; + @override + int get schemaVersion => 10; +}