diff --git a/lib/src/app/focus_seed_app.dart b/lib/src/app/focus_seed_app.dart index 9395eed..74e2880 100644 --- a/lib/src/app/focus_seed_app.dart +++ b/lib/src/app/focus_seed_app.dart @@ -6,6 +6,7 @@ import 'package:flutter_localizations/flutter_localizations.dart'; import '../core/ambience.dart'; import '../data/app_preferences_store.dart'; +import '../data/focus_seed_store.dart'; import '../features/shell/focus_seed_home.dart'; import '../l10n/generated/app_localizations.dart'; import '../models/appearance_preference.dart'; @@ -18,9 +19,10 @@ Locale focusSeedDefaultLocale({bool isRelease = kReleaseMode}) { } class FocusSeedApp extends StatefulWidget { - const FocusSeedApp({this.locale, super.key}); + const FocusSeedApp({this.locale, this.focusSeedStore, super.key}); final Locale? locale; + final FocusSeedStore? focusSeedStore; @override State createState() => _FocusSeedAppState(); @@ -114,6 +116,7 @@ class _FocusSeedAppState extends State ], supportedLocales: AppLocalizations.supportedLocales, home: FocusSeedHome( + focusSeedStore: widget.focusSeedStore, appearance: _appearance, onAppearanceChanged: _setAppearance, language: _language, diff --git a/lib/src/data/focus_seed_store.dart b/lib/src/data/focus_seed_store.dart index 732766e..71c3709 100644 --- a/lib/src/data/focus_seed_store.dart +++ b/lib/src/data/focus_seed_store.dart @@ -1,33 +1,245 @@ import 'dart:convert'; +import 'package:drift/drift.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import '../core/json_utils.dart'; +import '../core/date_keys.dart' as date_keys; import '../models/app_state.dart'; +import '../models/focus_session.dart'; +import '../models/habit.dart'; +import '../models/mood.dart'; +import '../models/reflection_entry.dart'; +import 'local/focus_seed_database.dart'; class FocusSeedStore { - static const _storageKey = 'focus_seed_state_v1'; + FocusSeedStore({FocusSeedDatabase? database}) + : _database = database ?? FocusSeedDatabase(); + + static const _legacyStorageKey = 'focus_seed_state_v1'; + static const _legacyMigrationKey = 'focus_seed_state_v1_migrated_to_sqlite'; + + final FocusSeedDatabase _database; Future load({List? defaultHabitTitles}) async { - final prefs = await SharedPreferences.getInstance(); - final raw = prefs.getString(_storageKey); - if (raw == null || raw.isEmpty) { - return AppState.starter(defaultHabitTitles: defaultHabitTitles); - } - try { - return AppState.fromJson(jsonDecode(raw) as Map); - } on Object { - return AppState.starter(defaultHabitTitles: defaultHabitTitles); + await _migrateLegacyJsonIfNeeded(); + final snapshot = await _readSnapshot(); + if (!snapshot.isFreshStart) { + return snapshot; } + + final starter = AppState.starter(defaultHabitTitles: defaultHabitTitles); + await save(starter); + return starter; } Future save(AppState state) async { - final prefs = await SharedPreferences.getInstance(); - await prefs.setString(_storageKey, prettyJson(state.toJson())); + await _database.transaction(() async { + await _database.delete(_database.habitLogRows).go(); + await _database.delete(_database.reflectionRows).go(); + await _database.delete(_database.focusSessionRows).go(); + await _database.delete(_database.habitRows).go(); + await _database.delete(_database.dailyIntentionRows).go(); + + if (state.anchor.trim().isNotEmpty) { + final now = DateTime.now(); + await _database + .into(_database.dailyIntentionRows) + .insert( + DailyIntentionRowsCompanion.insert( + dateKey: state.anchorDateKey, + intentionText: state.anchor, + createdAt: now, + updatedAt: now, + ), + ); + } + + for (final (index, habit) in state.habits.indexed) { + await _database + .into(_database.habitRows) + .insert( + HabitRowsCompanion.insert( + id: habit.id, + title: habit.title, + sortOrder: index, + createdAt: habit.createdAt, + ), + ); + for (final completedDate in habit.completedDates) { + await _database + .into(_database.habitLogRows) + .insert( + HabitLogRowsCompanion.insert( + id: '${habit.id}-$completedDate', + habitId: habit.id, + dateKey: completedDate, + completedAt: DateTime.parse('$completedDate 12:00:00'), + ), + ); + } + } + + for (final session in state.sessions) { + await _database + .into(_database.focusSessionRows) + .insert(_focusSessionCompanion(session)); + } + + for (final reflection in state.reflections) { + await _database + .into(_database.reflectionRows) + .insert( + ReflectionRowsCompanion.insert( + id: reflection.id, + dateKey: reflection.dateKey, + mood: reflection.mood.name, + note: reflection.note, + createdAt: reflection.createdAt, + updatedAt: reflection.createdAt, + ), + ); + } + }); + + final preferences = await SharedPreferences.getInstance(); + await preferences.setBool(_legacyMigrationKey, true); + await preferences.remove(_legacyStorageKey); } Future clear() async { - final prefs = await SharedPreferences.getInstance(); - await prefs.remove(_storageKey); + await _database.clearProductData(); + final preferences = await SharedPreferences.getInstance(); + await preferences.remove(_legacyStorageKey); + await preferences.setBool(_legacyMigrationKey, true); + } + + Future _readSnapshot() async { + final intentionRows = + await (_database.select(_database.dailyIntentionRows) + ..orderBy([(row) => OrderingTerm.desc(row.dateKey)]) + ..limit(1)) + .get(); + final latestIntention = intentionRows.firstOrNull; + final habitRows = + await (_database.select(_database.habitRows) + ..where((row) => row.archivedAt.isNull()) + ..orderBy([ + (row) => OrderingTerm.asc(row.sortOrder), + (row) => OrderingTerm.asc(row.createdAt), + ])) + .get(); + final habitLogRows = + await (_database.select(_database.habitLogRows) + ..orderBy([(row) => OrderingTerm.asc(row.dateKey)])).get(); + final focusSessionRows = + await (_database.select(_database.focusSessionRows) + ..orderBy([(row) => OrderingTerm.asc(row.endedAt)])).get(); + final reflectionRows = + await (_database.select(_database.reflectionRows) + ..orderBy([(row) => OrderingTerm.asc(row.createdAt)])).get(); + + final completedDatesByHabit = >{}; + for (final log in habitLogRows) { + completedDatesByHabit.putIfAbsent(log.habitId, () => {}).add(log.dateKey); + } + + return AppState( + anchor: latestIntention?.intentionText ?? '', + anchorDateKey: latestIntention?.dateKey ?? date_keys.todayKey(), + habits: [ + for (final habit in habitRows) + Habit( + id: habit.id, + title: habit.title, + createdAt: habit.createdAt, + completedDates: completedDatesByHabit[habit.id] ?? const {}, + ), + ], + sessions: [ + for (final session in focusSessionRows) + FocusSession( + id: session.id, + minutes: session.plannedMinutes, + completedAt: session.endedAt, + ), + ], + reflections: [ + for (final reflection in reflectionRows) + ReflectionEntry( + id: reflection.id, + dateKey: reflection.dateKey, + note: reflection.note, + mood: Mood.values.firstWhere( + (mood) => mood.name == reflection.mood, + orElse: () => Mood.clear, + ), + createdAt: reflection.createdAt, + ), + ], + ); + } + + Future _migrateLegacyJsonIfNeeded() async { + final preferences = await SharedPreferences.getInstance(); + if (preferences.getBool(_legacyMigrationKey) ?? false) { + return; + } + if (await _hasDatabaseContent()) { + await preferences.setBool(_legacyMigrationKey, true); + return; + } + + final raw = preferences.getString(_legacyStorageKey); + if (raw == null || raw.isEmpty) { + await preferences.setBool(_legacyMigrationKey, true); + return; + } + + try { + final legacyState = AppState.fromJson( + jsonDecode(raw) as Map, + ); + await save(legacyState); + } on Object { + await preferences.setBool(_legacyMigrationKey, true); + } + } + + Future _hasDatabaseContent() async { + final intention = + await (_database.select(_database.dailyIntentionRows) + ..limit(1)).getSingleOrNull(); + if (intention != null) { + return true; + } + final habit = + await (_database.select(_database.habitRows) + ..limit(1)).getSingleOrNull(); + if (habit != null) { + return true; + } + final session = + await (_database.select(_database.focusSessionRows) + ..limit(1)).getSingleOrNull(); + if (session != null) { + return true; + } + final reflection = + await (_database.select(_database.reflectionRows) + ..limit(1)).getSingleOrNull(); + return reflection != null; + } + + FocusSessionRowsCompanion _focusSessionCompanion(FocusSession session) { + final completedAt = session.completedAt; + return FocusSessionRowsCompanion.insert( + id: session.id, + dateKey: date_keys.dateKey(completedAt), + plannedMinutes: session.minutes, + actualSeconds: session.minutes * 60, + startedAt: completedAt.subtract(Duration(minutes: session.minutes)), + endedAt: completedAt, + status: 'completed', + ); } } diff --git a/lib/src/data/local/focus_seed_database.dart b/lib/src/data/local/focus_seed_database.dart new file mode 100644 index 0000000..c57cf03 --- /dev/null +++ b/lib/src/data/local/focus_seed_database.dart @@ -0,0 +1,126 @@ +import 'dart:io'; + +import 'package:drift/drift.dart'; +import 'package:drift/native.dart'; +import 'package:path/path.dart' as path; +import 'package:path_provider/path_provider.dart'; + +part 'focus_seed_database.g.dart'; + +class DailyIntentionRows extends Table { + @override + String get tableName => 'daily_intentions'; + + TextColumn get dateKey => text()(); + TextColumn get intentionText => text().named('text')(); + DateTimeColumn get createdAt => dateTime()(); + DateTimeColumn get updatedAt => dateTime()(); + + @override + Set> get primaryKey => {dateKey}; +} + +class FocusSessionRows extends Table { + @override + String get tableName => 'focus_sessions'; + + TextColumn get id => text()(); + TextColumn get dateKey => text()(); + IntColumn get plannedMinutes => integer()(); + IntColumn get actualSeconds => integer()(); + DateTimeColumn get startedAt => dateTime()(); + DateTimeColumn get endedAt => dateTime()(); + TextColumn get status => text()(); + + @override + Set> get primaryKey => {id}; +} + +class HabitRows extends Table { + @override + String get tableName => 'habits'; + + TextColumn get id => text()(); + TextColumn get title => text()(); + IntColumn get sortOrder => integer()(); + DateTimeColumn get createdAt => dateTime()(); + DateTimeColumn get archivedAt => dateTime().nullable()(); + + @override + Set> get primaryKey => {id}; +} + +class HabitLogRows extends Table { + @override + String get tableName => 'habit_logs'; + + TextColumn get id => text()(); + TextColumn get habitId => text()(); + TextColumn get dateKey => text()(); + DateTimeColumn get completedAt => dateTime()(); + + @override + Set> get primaryKey => {id}; +} + +class ReflectionRows extends Table { + @override + String get tableName => 'reflections'; + + TextColumn get id => text()(); + TextColumn get dateKey => text()(); + TextColumn get mood => text()(); + TextColumn get note => text()(); + DateTimeColumn get createdAt => dateTime()(); + DateTimeColumn get updatedAt => dateTime()(); + + @override + Set> get primaryKey => {id}; +} + +class AppSettingRows extends Table { + @override + String get tableName => 'app_settings'; + + TextColumn get key => text()(); + TextColumn get value => text()(); + + @override + Set> get primaryKey => {key}; +} + +@DriftDatabase( + tables: [ + DailyIntentionRows, + FocusSessionRows, + HabitRows, + HabitLogRows, + ReflectionRows, + AppSettingRows, + ], +) +class FocusSeedDatabase extends _$FocusSeedDatabase { + FocusSeedDatabase([QueryExecutor? executor]) + : super(executor ?? _openConnection()); + + @override + int get schemaVersion => 1; + + Future clearProductData() async { + await transaction(() async { + await delete(habitLogRows).go(); + await delete(reflectionRows).go(); + await delete(focusSessionRows).go(); + await delete(habitRows).go(); + await delete(dailyIntentionRows).go(); + }); + } +} + +LazyDatabase _openConnection() { + return LazyDatabase(() async { + final directory = await getApplicationDocumentsDirectory(); + final file = File(path.join(directory.path, 'focus_seed.sqlite')); + return NativeDatabase.createInBackground(file); + }); +} diff --git a/lib/src/data/local/focus_seed_database.g.dart b/lib/src/data/local/focus_seed_database.g.dart new file mode 100644 index 0000000..5a1fe56 --- /dev/null +++ b/lib/src/data/local/focus_seed_database.g.dart @@ -0,0 +1,3446 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'focus_seed_database.dart'; + +// ignore_for_file: type=lint +class $DailyIntentionRowsTable extends DailyIntentionRows + with TableInfo<$DailyIntentionRowsTable, DailyIntentionRow> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $DailyIntentionRowsTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _dateKeyMeta = const VerificationMeta( + 'dateKey', + ); + @override + late final GeneratedColumn dateKey = GeneratedColumn( + 'date_key', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + ); + static const VerificationMeta _intentionTextMeta = const VerificationMeta( + 'intentionText', + ); + @override + late final GeneratedColumn intentionText = GeneratedColumn( + 'text', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + ); + static const VerificationMeta _createdAtMeta = const VerificationMeta( + 'createdAt', + ); + @override + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: true, + ); + static const VerificationMeta _updatedAtMeta = const VerificationMeta( + 'updatedAt', + ); + @override + late final GeneratedColumn updatedAt = GeneratedColumn( + 'updated_at', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: true, + ); + @override + List get $columns => [ + dateKey, + intentionText, + createdAt, + updatedAt, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'daily_intentions'; + @override + VerificationContext validateIntegrity( + Insertable instance, { + bool isInserting = false, + }) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('date_key')) { + context.handle( + _dateKeyMeta, + dateKey.isAcceptableOrUnknown(data['date_key']!, _dateKeyMeta), + ); + } else if (isInserting) { + context.missing(_dateKeyMeta); + } + if (data.containsKey('text')) { + context.handle( + _intentionTextMeta, + intentionText.isAcceptableOrUnknown(data['text']!, _intentionTextMeta), + ); + } else if (isInserting) { + context.missing(_intentionTextMeta); + } + if (data.containsKey('created_at')) { + context.handle( + _createdAtMeta, + createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta), + ); + } else if (isInserting) { + context.missing(_createdAtMeta); + } + if (data.containsKey('updated_at')) { + context.handle( + _updatedAtMeta, + updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta), + ); + } else if (isInserting) { + context.missing(_updatedAtMeta); + } + return context; + } + + @override + Set get $primaryKey => {dateKey}; + @override + DailyIntentionRow map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return DailyIntentionRow( + dateKey: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}date_key'], + )!, + intentionText: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}text'], + )!, + createdAt: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}created_at'], + )!, + updatedAt: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}updated_at'], + )!, + ); + } + + @override + $DailyIntentionRowsTable createAlias(String alias) { + return $DailyIntentionRowsTable(attachedDatabase, alias); + } +} + +class DailyIntentionRow extends DataClass + implements Insertable { + final String dateKey; + final String intentionText; + final DateTime createdAt; + final DateTime updatedAt; + const DailyIntentionRow({ + required this.dateKey, + required this.intentionText, + required this.createdAt, + required this.updatedAt, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['date_key'] = Variable(dateKey); + map['text'] = Variable(intentionText); + map['created_at'] = Variable(createdAt); + map['updated_at'] = Variable(updatedAt); + return map; + } + + DailyIntentionRowsCompanion toCompanion(bool nullToAbsent) { + return DailyIntentionRowsCompanion( + dateKey: Value(dateKey), + intentionText: Value(intentionText), + createdAt: Value(createdAt), + updatedAt: Value(updatedAt), + ); + } + + factory DailyIntentionRow.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return DailyIntentionRow( + dateKey: serializer.fromJson(json['dateKey']), + intentionText: serializer.fromJson(json['intentionText']), + createdAt: serializer.fromJson(json['createdAt']), + updatedAt: serializer.fromJson(json['updatedAt']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'dateKey': serializer.toJson(dateKey), + 'intentionText': serializer.toJson(intentionText), + 'createdAt': serializer.toJson(createdAt), + 'updatedAt': serializer.toJson(updatedAt), + }; + } + + DailyIntentionRow copyWith({ + String? dateKey, + String? intentionText, + DateTime? createdAt, + DateTime? updatedAt, + }) => DailyIntentionRow( + dateKey: dateKey ?? this.dateKey, + intentionText: intentionText ?? this.intentionText, + createdAt: createdAt ?? this.createdAt, + updatedAt: updatedAt ?? this.updatedAt, + ); + DailyIntentionRow copyWithCompanion(DailyIntentionRowsCompanion data) { + return DailyIntentionRow( + dateKey: data.dateKey.present ? data.dateKey.value : this.dateKey, + intentionText: + data.intentionText.present + ? data.intentionText.value + : this.intentionText, + createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, + updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, + ); + } + + @override + String toString() { + return (StringBuffer('DailyIntentionRow(') + ..write('dateKey: $dateKey, ') + ..write('intentionText: $intentionText, ') + ..write('createdAt: $createdAt, ') + ..write('updatedAt: $updatedAt') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(dateKey, intentionText, createdAt, updatedAt); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is DailyIntentionRow && + other.dateKey == this.dateKey && + other.intentionText == this.intentionText && + other.createdAt == this.createdAt && + other.updatedAt == this.updatedAt); +} + +class DailyIntentionRowsCompanion extends UpdateCompanion { + final Value dateKey; + final Value intentionText; + final Value createdAt; + final Value updatedAt; + final Value rowid; + const DailyIntentionRowsCompanion({ + this.dateKey = const Value.absent(), + this.intentionText = const Value.absent(), + this.createdAt = const Value.absent(), + this.updatedAt = const Value.absent(), + this.rowid = const Value.absent(), + }); + DailyIntentionRowsCompanion.insert({ + required String dateKey, + required String intentionText, + required DateTime createdAt, + required DateTime updatedAt, + this.rowid = const Value.absent(), + }) : dateKey = Value(dateKey), + intentionText = Value(intentionText), + createdAt = Value(createdAt), + updatedAt = Value(updatedAt); + static Insertable custom({ + Expression? dateKey, + Expression? intentionText, + Expression? createdAt, + Expression? updatedAt, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (dateKey != null) 'date_key': dateKey, + if (intentionText != null) 'text': intentionText, + if (createdAt != null) 'created_at': createdAt, + if (updatedAt != null) 'updated_at': updatedAt, + if (rowid != null) 'rowid': rowid, + }); + } + + DailyIntentionRowsCompanion copyWith({ + Value? dateKey, + Value? intentionText, + Value? createdAt, + Value? updatedAt, + Value? rowid, + }) { + return DailyIntentionRowsCompanion( + dateKey: dateKey ?? this.dateKey, + intentionText: intentionText ?? this.intentionText, + createdAt: createdAt ?? this.createdAt, + updatedAt: updatedAt ?? this.updatedAt, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (dateKey.present) { + map['date_key'] = Variable(dateKey.value); + } + if (intentionText.present) { + map['text'] = Variable(intentionText.value); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + if (updatedAt.present) { + map['updated_at'] = Variable(updatedAt.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('DailyIntentionRowsCompanion(') + ..write('dateKey: $dateKey, ') + ..write('intentionText: $intentionText, ') + ..write('createdAt: $createdAt, ') + ..write('updatedAt: $updatedAt, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class $FocusSessionRowsTable extends FocusSessionRows + with TableInfo<$FocusSessionRowsTable, FocusSessionRow> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $FocusSessionRowsTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + ); + static const VerificationMeta _dateKeyMeta = const VerificationMeta( + 'dateKey', + ); + @override + late final GeneratedColumn dateKey = GeneratedColumn( + 'date_key', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + ); + static const VerificationMeta _plannedMinutesMeta = const VerificationMeta( + 'plannedMinutes', + ); + @override + late final GeneratedColumn plannedMinutes = GeneratedColumn( + 'planned_minutes', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + ); + static const VerificationMeta _actualSecondsMeta = const VerificationMeta( + 'actualSeconds', + ); + @override + late final GeneratedColumn actualSeconds = GeneratedColumn( + 'actual_seconds', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + ); + static const VerificationMeta _startedAtMeta = const VerificationMeta( + 'startedAt', + ); + @override + late final GeneratedColumn startedAt = GeneratedColumn( + 'started_at', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: true, + ); + static const VerificationMeta _endedAtMeta = const VerificationMeta( + 'endedAt', + ); + @override + late final GeneratedColumn endedAt = GeneratedColumn( + 'ended_at', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: true, + ); + static const VerificationMeta _statusMeta = const VerificationMeta('status'); + @override + late final GeneratedColumn status = GeneratedColumn( + 'status', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + ); + @override + List get $columns => [ + id, + dateKey, + plannedMinutes, + actualSeconds, + startedAt, + endedAt, + status, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'focus_sessions'; + @override + VerificationContext validateIntegrity( + Insertable instance, { + bool isInserting = false, + }) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('id')) { + context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); + } else if (isInserting) { + context.missing(_idMeta); + } + if (data.containsKey('date_key')) { + context.handle( + _dateKeyMeta, + dateKey.isAcceptableOrUnknown(data['date_key']!, _dateKeyMeta), + ); + } else if (isInserting) { + context.missing(_dateKeyMeta); + } + if (data.containsKey('planned_minutes')) { + context.handle( + _plannedMinutesMeta, + plannedMinutes.isAcceptableOrUnknown( + data['planned_minutes']!, + _plannedMinutesMeta, + ), + ); + } else if (isInserting) { + context.missing(_plannedMinutesMeta); + } + if (data.containsKey('actual_seconds')) { + context.handle( + _actualSecondsMeta, + actualSeconds.isAcceptableOrUnknown( + data['actual_seconds']!, + _actualSecondsMeta, + ), + ); + } else if (isInserting) { + context.missing(_actualSecondsMeta); + } + if (data.containsKey('started_at')) { + context.handle( + _startedAtMeta, + startedAt.isAcceptableOrUnknown(data['started_at']!, _startedAtMeta), + ); + } else if (isInserting) { + context.missing(_startedAtMeta); + } + if (data.containsKey('ended_at')) { + context.handle( + _endedAtMeta, + endedAt.isAcceptableOrUnknown(data['ended_at']!, _endedAtMeta), + ); + } else if (isInserting) { + context.missing(_endedAtMeta); + } + if (data.containsKey('status')) { + context.handle( + _statusMeta, + status.isAcceptableOrUnknown(data['status']!, _statusMeta), + ); + } else if (isInserting) { + context.missing(_statusMeta); + } + return context; + } + + @override + Set get $primaryKey => {id}; + @override + FocusSessionRow map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return FocusSessionRow( + id: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + dateKey: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}date_key'], + )!, + plannedMinutes: + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}planned_minutes'], + )!, + actualSeconds: + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}actual_seconds'], + )!, + startedAt: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}started_at'], + )!, + endedAt: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}ended_at'], + )!, + status: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}status'], + )!, + ); + } + + @override + $FocusSessionRowsTable createAlias(String alias) { + return $FocusSessionRowsTable(attachedDatabase, alias); + } +} + +class FocusSessionRow extends DataClass implements Insertable { + final String id; + final String dateKey; + final int plannedMinutes; + final int actualSeconds; + final DateTime startedAt; + final DateTime endedAt; + final String status; + const FocusSessionRow({ + required this.id, + required this.dateKey, + required this.plannedMinutes, + required this.actualSeconds, + required this.startedAt, + required this.endedAt, + required this.status, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['date_key'] = Variable(dateKey); + map['planned_minutes'] = Variable(plannedMinutes); + map['actual_seconds'] = Variable(actualSeconds); + map['started_at'] = Variable(startedAt); + map['ended_at'] = Variable(endedAt); + map['status'] = Variable(status); + return map; + } + + FocusSessionRowsCompanion toCompanion(bool nullToAbsent) { + return FocusSessionRowsCompanion( + id: Value(id), + dateKey: Value(dateKey), + plannedMinutes: Value(plannedMinutes), + actualSeconds: Value(actualSeconds), + startedAt: Value(startedAt), + endedAt: Value(endedAt), + status: Value(status), + ); + } + + factory FocusSessionRow.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return FocusSessionRow( + id: serializer.fromJson(json['id']), + dateKey: serializer.fromJson(json['dateKey']), + plannedMinutes: serializer.fromJson(json['plannedMinutes']), + actualSeconds: serializer.fromJson(json['actualSeconds']), + startedAt: serializer.fromJson(json['startedAt']), + endedAt: serializer.fromJson(json['endedAt']), + status: serializer.fromJson(json['status']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'dateKey': serializer.toJson(dateKey), + 'plannedMinutes': serializer.toJson(plannedMinutes), + 'actualSeconds': serializer.toJson(actualSeconds), + 'startedAt': serializer.toJson(startedAt), + 'endedAt': serializer.toJson(endedAt), + 'status': serializer.toJson(status), + }; + } + + FocusSessionRow copyWith({ + String? id, + String? dateKey, + int? plannedMinutes, + int? actualSeconds, + DateTime? startedAt, + DateTime? endedAt, + String? status, + }) => FocusSessionRow( + id: id ?? this.id, + dateKey: dateKey ?? this.dateKey, + plannedMinutes: plannedMinutes ?? this.plannedMinutes, + actualSeconds: actualSeconds ?? this.actualSeconds, + startedAt: startedAt ?? this.startedAt, + endedAt: endedAt ?? this.endedAt, + status: status ?? this.status, + ); + FocusSessionRow copyWithCompanion(FocusSessionRowsCompanion data) { + return FocusSessionRow( + id: data.id.present ? data.id.value : this.id, + dateKey: data.dateKey.present ? data.dateKey.value : this.dateKey, + plannedMinutes: + data.plannedMinutes.present + ? data.plannedMinutes.value + : this.plannedMinutes, + actualSeconds: + data.actualSeconds.present + ? data.actualSeconds.value + : this.actualSeconds, + startedAt: data.startedAt.present ? data.startedAt.value : this.startedAt, + endedAt: data.endedAt.present ? data.endedAt.value : this.endedAt, + status: data.status.present ? data.status.value : this.status, + ); + } + + @override + String toString() { + return (StringBuffer('FocusSessionRow(') + ..write('id: $id, ') + ..write('dateKey: $dateKey, ') + ..write('plannedMinutes: $plannedMinutes, ') + ..write('actualSeconds: $actualSeconds, ') + ..write('startedAt: $startedAt, ') + ..write('endedAt: $endedAt, ') + ..write('status: $status') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + id, + dateKey, + plannedMinutes, + actualSeconds, + startedAt, + endedAt, + status, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is FocusSessionRow && + other.id == this.id && + other.dateKey == this.dateKey && + other.plannedMinutes == this.plannedMinutes && + other.actualSeconds == this.actualSeconds && + other.startedAt == this.startedAt && + other.endedAt == this.endedAt && + other.status == this.status); +} + +class FocusSessionRowsCompanion extends UpdateCompanion { + final Value id; + final Value dateKey; + final Value plannedMinutes; + final Value actualSeconds; + final Value startedAt; + final Value endedAt; + final Value status; + final Value rowid; + const FocusSessionRowsCompanion({ + this.id = const Value.absent(), + this.dateKey = const Value.absent(), + this.plannedMinutes = const Value.absent(), + this.actualSeconds = const Value.absent(), + this.startedAt = const Value.absent(), + this.endedAt = const Value.absent(), + this.status = const Value.absent(), + this.rowid = const Value.absent(), + }); + FocusSessionRowsCompanion.insert({ + required String id, + required String dateKey, + required int plannedMinutes, + required int actualSeconds, + required DateTime startedAt, + required DateTime endedAt, + required String status, + this.rowid = const Value.absent(), + }) : id = Value(id), + dateKey = Value(dateKey), + plannedMinutes = Value(plannedMinutes), + actualSeconds = Value(actualSeconds), + startedAt = Value(startedAt), + endedAt = Value(endedAt), + status = Value(status); + static Insertable custom({ + Expression? id, + Expression? dateKey, + Expression? plannedMinutes, + Expression? actualSeconds, + Expression? startedAt, + Expression? endedAt, + Expression? status, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (dateKey != null) 'date_key': dateKey, + if (plannedMinutes != null) 'planned_minutes': plannedMinutes, + if (actualSeconds != null) 'actual_seconds': actualSeconds, + if (startedAt != null) 'started_at': startedAt, + if (endedAt != null) 'ended_at': endedAt, + if (status != null) 'status': status, + if (rowid != null) 'rowid': rowid, + }); + } + + FocusSessionRowsCompanion copyWith({ + Value? id, + Value? dateKey, + Value? plannedMinutes, + Value? actualSeconds, + Value? startedAt, + Value? endedAt, + Value? status, + Value? rowid, + }) { + return FocusSessionRowsCompanion( + id: id ?? this.id, + dateKey: dateKey ?? this.dateKey, + plannedMinutes: plannedMinutes ?? this.plannedMinutes, + actualSeconds: actualSeconds ?? this.actualSeconds, + startedAt: startedAt ?? this.startedAt, + endedAt: endedAt ?? this.endedAt, + status: status ?? this.status, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (dateKey.present) { + map['date_key'] = Variable(dateKey.value); + } + if (plannedMinutes.present) { + map['planned_minutes'] = Variable(plannedMinutes.value); + } + if (actualSeconds.present) { + map['actual_seconds'] = Variable(actualSeconds.value); + } + if (startedAt.present) { + map['started_at'] = Variable(startedAt.value); + } + if (endedAt.present) { + map['ended_at'] = Variable(endedAt.value); + } + if (status.present) { + map['status'] = Variable(status.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('FocusSessionRowsCompanion(') + ..write('id: $id, ') + ..write('dateKey: $dateKey, ') + ..write('plannedMinutes: $plannedMinutes, ') + ..write('actualSeconds: $actualSeconds, ') + ..write('startedAt: $startedAt, ') + ..write('endedAt: $endedAt, ') + ..write('status: $status, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class $HabitRowsTable extends HabitRows + with TableInfo<$HabitRowsTable, HabitRow> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $HabitRowsTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + ); + static const VerificationMeta _titleMeta = const VerificationMeta('title'); + @override + late final GeneratedColumn title = GeneratedColumn( + 'title', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + ); + static const VerificationMeta _sortOrderMeta = const VerificationMeta( + 'sortOrder', + ); + @override + late final GeneratedColumn sortOrder = GeneratedColumn( + 'sort_order', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + ); + static const VerificationMeta _createdAtMeta = const VerificationMeta( + 'createdAt', + ); + @override + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: true, + ); + static const VerificationMeta _archivedAtMeta = const VerificationMeta( + 'archivedAt', + ); + @override + late final GeneratedColumn archivedAt = GeneratedColumn( + 'archived_at', + aliasedName, + true, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + ); + @override + List get $columns => [ + id, + title, + sortOrder, + createdAt, + archivedAt, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'habits'; + @override + VerificationContext validateIntegrity( + Insertable instance, { + bool isInserting = false, + }) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('id')) { + context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); + } else if (isInserting) { + context.missing(_idMeta); + } + if (data.containsKey('title')) { + context.handle( + _titleMeta, + title.isAcceptableOrUnknown(data['title']!, _titleMeta), + ); + } else if (isInserting) { + context.missing(_titleMeta); + } + if (data.containsKey('sort_order')) { + context.handle( + _sortOrderMeta, + sortOrder.isAcceptableOrUnknown(data['sort_order']!, _sortOrderMeta), + ); + } else if (isInserting) { + context.missing(_sortOrderMeta); + } + if (data.containsKey('created_at')) { + context.handle( + _createdAtMeta, + createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta), + ); + } else if (isInserting) { + context.missing(_createdAtMeta); + } + if (data.containsKey('archived_at')) { + context.handle( + _archivedAtMeta, + archivedAt.isAcceptableOrUnknown(data['archived_at']!, _archivedAtMeta), + ); + } + return context; + } + + @override + Set get $primaryKey => {id}; + @override + HabitRow map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return HabitRow( + id: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + title: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}title'], + )!, + sortOrder: + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}sort_order'], + )!, + createdAt: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}created_at'], + )!, + archivedAt: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}archived_at'], + ), + ); + } + + @override + $HabitRowsTable createAlias(String alias) { + return $HabitRowsTable(attachedDatabase, alias); + } +} + +class HabitRow extends DataClass implements Insertable { + final String id; + final String title; + final int sortOrder; + final DateTime createdAt; + final DateTime? archivedAt; + const HabitRow({ + required this.id, + required this.title, + required this.sortOrder, + required this.createdAt, + this.archivedAt, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['title'] = Variable(title); + map['sort_order'] = Variable(sortOrder); + map['created_at'] = Variable(createdAt); + if (!nullToAbsent || archivedAt != null) { + map['archived_at'] = Variable(archivedAt); + } + return map; + } + + HabitRowsCompanion toCompanion(bool nullToAbsent) { + return HabitRowsCompanion( + id: Value(id), + title: Value(title), + sortOrder: Value(sortOrder), + createdAt: Value(createdAt), + archivedAt: + archivedAt == null && nullToAbsent + ? const Value.absent() + : Value(archivedAt), + ); + } + + factory HabitRow.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return HabitRow( + id: serializer.fromJson(json['id']), + title: serializer.fromJson(json['title']), + sortOrder: serializer.fromJson(json['sortOrder']), + createdAt: serializer.fromJson(json['createdAt']), + archivedAt: serializer.fromJson(json['archivedAt']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'title': serializer.toJson(title), + 'sortOrder': serializer.toJson(sortOrder), + 'createdAt': serializer.toJson(createdAt), + 'archivedAt': serializer.toJson(archivedAt), + }; + } + + HabitRow copyWith({ + String? id, + String? title, + int? sortOrder, + DateTime? createdAt, + Value archivedAt = const Value.absent(), + }) => HabitRow( + id: id ?? this.id, + title: title ?? this.title, + sortOrder: sortOrder ?? this.sortOrder, + createdAt: createdAt ?? this.createdAt, + archivedAt: archivedAt.present ? archivedAt.value : this.archivedAt, + ); + HabitRow copyWithCompanion(HabitRowsCompanion data) { + return HabitRow( + id: data.id.present ? data.id.value : this.id, + title: data.title.present ? data.title.value : this.title, + sortOrder: data.sortOrder.present ? data.sortOrder.value : this.sortOrder, + createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, + archivedAt: + data.archivedAt.present ? data.archivedAt.value : this.archivedAt, + ); + } + + @override + String toString() { + return (StringBuffer('HabitRow(') + ..write('id: $id, ') + ..write('title: $title, ') + ..write('sortOrder: $sortOrder, ') + ..write('createdAt: $createdAt, ') + ..write('archivedAt: $archivedAt') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, title, sortOrder, createdAt, archivedAt); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is HabitRow && + other.id == this.id && + other.title == this.title && + other.sortOrder == this.sortOrder && + other.createdAt == this.createdAt && + other.archivedAt == this.archivedAt); +} + +class HabitRowsCompanion extends UpdateCompanion { + final Value id; + final Value title; + final Value sortOrder; + final Value createdAt; + final Value archivedAt; + final Value rowid; + const HabitRowsCompanion({ + this.id = const Value.absent(), + this.title = const Value.absent(), + this.sortOrder = const Value.absent(), + this.createdAt = const Value.absent(), + this.archivedAt = const Value.absent(), + this.rowid = const Value.absent(), + }); + HabitRowsCompanion.insert({ + required String id, + required String title, + required int sortOrder, + required DateTime createdAt, + this.archivedAt = const Value.absent(), + this.rowid = const Value.absent(), + }) : id = Value(id), + title = Value(title), + sortOrder = Value(sortOrder), + createdAt = Value(createdAt); + static Insertable custom({ + Expression? id, + Expression? title, + Expression? sortOrder, + Expression? createdAt, + Expression? archivedAt, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (title != null) 'title': title, + if (sortOrder != null) 'sort_order': sortOrder, + if (createdAt != null) 'created_at': createdAt, + if (archivedAt != null) 'archived_at': archivedAt, + if (rowid != null) 'rowid': rowid, + }); + } + + HabitRowsCompanion copyWith({ + Value? id, + Value? title, + Value? sortOrder, + Value? createdAt, + Value? archivedAt, + Value? rowid, + }) { + return HabitRowsCompanion( + id: id ?? this.id, + title: title ?? this.title, + sortOrder: sortOrder ?? this.sortOrder, + createdAt: createdAt ?? this.createdAt, + archivedAt: archivedAt ?? this.archivedAt, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (title.present) { + map['title'] = Variable(title.value); + } + if (sortOrder.present) { + map['sort_order'] = Variable(sortOrder.value); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + if (archivedAt.present) { + map['archived_at'] = Variable(archivedAt.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('HabitRowsCompanion(') + ..write('id: $id, ') + ..write('title: $title, ') + ..write('sortOrder: $sortOrder, ') + ..write('createdAt: $createdAt, ') + ..write('archivedAt: $archivedAt, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class $HabitLogRowsTable extends HabitLogRows + with TableInfo<$HabitLogRowsTable, HabitLogRow> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $HabitLogRowsTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + ); + static const VerificationMeta _habitIdMeta = const VerificationMeta( + 'habitId', + ); + @override + late final GeneratedColumn habitId = GeneratedColumn( + 'habit_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + ); + static const VerificationMeta _dateKeyMeta = const VerificationMeta( + 'dateKey', + ); + @override + late final GeneratedColumn dateKey = GeneratedColumn( + 'date_key', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + ); + static const VerificationMeta _completedAtMeta = const VerificationMeta( + 'completedAt', + ); + @override + late final GeneratedColumn completedAt = GeneratedColumn( + 'completed_at', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: true, + ); + @override + List get $columns => [id, habitId, dateKey, completedAt]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'habit_logs'; + @override + VerificationContext validateIntegrity( + Insertable instance, { + bool isInserting = false, + }) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('id')) { + context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); + } else if (isInserting) { + context.missing(_idMeta); + } + if (data.containsKey('habit_id')) { + context.handle( + _habitIdMeta, + habitId.isAcceptableOrUnknown(data['habit_id']!, _habitIdMeta), + ); + } else if (isInserting) { + context.missing(_habitIdMeta); + } + if (data.containsKey('date_key')) { + context.handle( + _dateKeyMeta, + dateKey.isAcceptableOrUnknown(data['date_key']!, _dateKeyMeta), + ); + } else if (isInserting) { + context.missing(_dateKeyMeta); + } + if (data.containsKey('completed_at')) { + context.handle( + _completedAtMeta, + completedAt.isAcceptableOrUnknown( + data['completed_at']!, + _completedAtMeta, + ), + ); + } else if (isInserting) { + context.missing(_completedAtMeta); + } + return context; + } + + @override + Set get $primaryKey => {id}; + @override + HabitLogRow map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return HabitLogRow( + id: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + habitId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}habit_id'], + )!, + dateKey: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}date_key'], + )!, + completedAt: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}completed_at'], + )!, + ); + } + + @override + $HabitLogRowsTable createAlias(String alias) { + return $HabitLogRowsTable(attachedDatabase, alias); + } +} + +class HabitLogRow extends DataClass implements Insertable { + final String id; + final String habitId; + final String dateKey; + final DateTime completedAt; + const HabitLogRow({ + required this.id, + required this.habitId, + required this.dateKey, + required this.completedAt, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['habit_id'] = Variable(habitId); + map['date_key'] = Variable(dateKey); + map['completed_at'] = Variable(completedAt); + return map; + } + + HabitLogRowsCompanion toCompanion(bool nullToAbsent) { + return HabitLogRowsCompanion( + id: Value(id), + habitId: Value(habitId), + dateKey: Value(dateKey), + completedAt: Value(completedAt), + ); + } + + factory HabitLogRow.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return HabitLogRow( + id: serializer.fromJson(json['id']), + habitId: serializer.fromJson(json['habitId']), + dateKey: serializer.fromJson(json['dateKey']), + completedAt: serializer.fromJson(json['completedAt']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'habitId': serializer.toJson(habitId), + 'dateKey': serializer.toJson(dateKey), + 'completedAt': serializer.toJson(completedAt), + }; + } + + HabitLogRow copyWith({ + String? id, + String? habitId, + String? dateKey, + DateTime? completedAt, + }) => HabitLogRow( + id: id ?? this.id, + habitId: habitId ?? this.habitId, + dateKey: dateKey ?? this.dateKey, + completedAt: completedAt ?? this.completedAt, + ); + HabitLogRow copyWithCompanion(HabitLogRowsCompanion data) { + return HabitLogRow( + id: data.id.present ? data.id.value : this.id, + habitId: data.habitId.present ? data.habitId.value : this.habitId, + dateKey: data.dateKey.present ? data.dateKey.value : this.dateKey, + completedAt: + data.completedAt.present ? data.completedAt.value : this.completedAt, + ); + } + + @override + String toString() { + return (StringBuffer('HabitLogRow(') + ..write('id: $id, ') + ..write('habitId: $habitId, ') + ..write('dateKey: $dateKey, ') + ..write('completedAt: $completedAt') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, habitId, dateKey, completedAt); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is HabitLogRow && + other.id == this.id && + other.habitId == this.habitId && + other.dateKey == this.dateKey && + other.completedAt == this.completedAt); +} + +class HabitLogRowsCompanion extends UpdateCompanion { + final Value id; + final Value habitId; + final Value dateKey; + final Value completedAt; + final Value rowid; + const HabitLogRowsCompanion({ + this.id = const Value.absent(), + this.habitId = const Value.absent(), + this.dateKey = const Value.absent(), + this.completedAt = const Value.absent(), + this.rowid = const Value.absent(), + }); + HabitLogRowsCompanion.insert({ + required String id, + required String habitId, + required String dateKey, + required DateTime completedAt, + this.rowid = const Value.absent(), + }) : id = Value(id), + habitId = Value(habitId), + dateKey = Value(dateKey), + completedAt = Value(completedAt); + static Insertable custom({ + Expression? id, + Expression? habitId, + Expression? dateKey, + Expression? completedAt, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (habitId != null) 'habit_id': habitId, + if (dateKey != null) 'date_key': dateKey, + if (completedAt != null) 'completed_at': completedAt, + if (rowid != null) 'rowid': rowid, + }); + } + + HabitLogRowsCompanion copyWith({ + Value? id, + Value? habitId, + Value? dateKey, + Value? completedAt, + Value? rowid, + }) { + return HabitLogRowsCompanion( + id: id ?? this.id, + habitId: habitId ?? this.habitId, + dateKey: dateKey ?? this.dateKey, + completedAt: completedAt ?? this.completedAt, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (habitId.present) { + map['habit_id'] = Variable(habitId.value); + } + if (dateKey.present) { + map['date_key'] = Variable(dateKey.value); + } + if (completedAt.present) { + map['completed_at'] = Variable(completedAt.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('HabitLogRowsCompanion(') + ..write('id: $id, ') + ..write('habitId: $habitId, ') + ..write('dateKey: $dateKey, ') + ..write('completedAt: $completedAt, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class $ReflectionRowsTable extends ReflectionRows + with TableInfo<$ReflectionRowsTable, ReflectionRow> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $ReflectionRowsTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + ); + static const VerificationMeta _dateKeyMeta = const VerificationMeta( + 'dateKey', + ); + @override + late final GeneratedColumn dateKey = GeneratedColumn( + 'date_key', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + ); + static const VerificationMeta _moodMeta = const VerificationMeta('mood'); + @override + late final GeneratedColumn mood = GeneratedColumn( + 'mood', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + ); + static const VerificationMeta _noteMeta = const VerificationMeta('note'); + @override + late final GeneratedColumn note = GeneratedColumn( + 'note', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + ); + static const VerificationMeta _createdAtMeta = const VerificationMeta( + 'createdAt', + ); + @override + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: true, + ); + static const VerificationMeta _updatedAtMeta = const VerificationMeta( + 'updatedAt', + ); + @override + late final GeneratedColumn updatedAt = GeneratedColumn( + 'updated_at', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: true, + ); + @override + List get $columns => [ + id, + dateKey, + mood, + note, + createdAt, + updatedAt, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'reflections'; + @override + VerificationContext validateIntegrity( + Insertable instance, { + bool isInserting = false, + }) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('id')) { + context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); + } else if (isInserting) { + context.missing(_idMeta); + } + if (data.containsKey('date_key')) { + context.handle( + _dateKeyMeta, + dateKey.isAcceptableOrUnknown(data['date_key']!, _dateKeyMeta), + ); + } else if (isInserting) { + context.missing(_dateKeyMeta); + } + if (data.containsKey('mood')) { + context.handle( + _moodMeta, + mood.isAcceptableOrUnknown(data['mood']!, _moodMeta), + ); + } else if (isInserting) { + context.missing(_moodMeta); + } + if (data.containsKey('note')) { + context.handle( + _noteMeta, + note.isAcceptableOrUnknown(data['note']!, _noteMeta), + ); + } else if (isInserting) { + context.missing(_noteMeta); + } + if (data.containsKey('created_at')) { + context.handle( + _createdAtMeta, + createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta), + ); + } else if (isInserting) { + context.missing(_createdAtMeta); + } + if (data.containsKey('updated_at')) { + context.handle( + _updatedAtMeta, + updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta), + ); + } else if (isInserting) { + context.missing(_updatedAtMeta); + } + return context; + } + + @override + Set get $primaryKey => {id}; + @override + ReflectionRow map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return ReflectionRow( + id: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + dateKey: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}date_key'], + )!, + mood: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}mood'], + )!, + note: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}note'], + )!, + createdAt: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}created_at'], + )!, + updatedAt: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}updated_at'], + )!, + ); + } + + @override + $ReflectionRowsTable createAlias(String alias) { + return $ReflectionRowsTable(attachedDatabase, alias); + } +} + +class ReflectionRow extends DataClass implements Insertable { + final String id; + final String dateKey; + final String mood; + final String note; + final DateTime createdAt; + final DateTime updatedAt; + const ReflectionRow({ + required this.id, + required this.dateKey, + required this.mood, + required this.note, + required this.createdAt, + required this.updatedAt, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['date_key'] = Variable(dateKey); + map['mood'] = Variable(mood); + map['note'] = Variable(note); + map['created_at'] = Variable(createdAt); + map['updated_at'] = Variable(updatedAt); + return map; + } + + ReflectionRowsCompanion toCompanion(bool nullToAbsent) { + return ReflectionRowsCompanion( + id: Value(id), + dateKey: Value(dateKey), + mood: Value(mood), + note: Value(note), + createdAt: Value(createdAt), + updatedAt: Value(updatedAt), + ); + } + + factory ReflectionRow.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return ReflectionRow( + id: serializer.fromJson(json['id']), + dateKey: serializer.fromJson(json['dateKey']), + mood: serializer.fromJson(json['mood']), + note: serializer.fromJson(json['note']), + createdAt: serializer.fromJson(json['createdAt']), + updatedAt: serializer.fromJson(json['updatedAt']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'dateKey': serializer.toJson(dateKey), + 'mood': serializer.toJson(mood), + 'note': serializer.toJson(note), + 'createdAt': serializer.toJson(createdAt), + 'updatedAt': serializer.toJson(updatedAt), + }; + } + + ReflectionRow copyWith({ + String? id, + String? dateKey, + String? mood, + String? note, + DateTime? createdAt, + DateTime? updatedAt, + }) => ReflectionRow( + id: id ?? this.id, + dateKey: dateKey ?? this.dateKey, + mood: mood ?? this.mood, + note: note ?? this.note, + createdAt: createdAt ?? this.createdAt, + updatedAt: updatedAt ?? this.updatedAt, + ); + ReflectionRow copyWithCompanion(ReflectionRowsCompanion data) { + return ReflectionRow( + id: data.id.present ? data.id.value : this.id, + dateKey: data.dateKey.present ? data.dateKey.value : this.dateKey, + mood: data.mood.present ? data.mood.value : this.mood, + note: data.note.present ? data.note.value : this.note, + createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, + updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, + ); + } + + @override + String toString() { + return (StringBuffer('ReflectionRow(') + ..write('id: $id, ') + ..write('dateKey: $dateKey, ') + ..write('mood: $mood, ') + ..write('note: $note, ') + ..write('createdAt: $createdAt, ') + ..write('updatedAt: $updatedAt') + ..write(')')) + .toString(); + } + + @override + int get hashCode => + Object.hash(id, dateKey, mood, note, createdAt, updatedAt); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ReflectionRow && + other.id == this.id && + other.dateKey == this.dateKey && + other.mood == this.mood && + other.note == this.note && + other.createdAt == this.createdAt && + other.updatedAt == this.updatedAt); +} + +class ReflectionRowsCompanion extends UpdateCompanion { + final Value id; + final Value dateKey; + final Value mood; + final Value note; + final Value createdAt; + final Value updatedAt; + final Value rowid; + const ReflectionRowsCompanion({ + this.id = const Value.absent(), + this.dateKey = const Value.absent(), + this.mood = const Value.absent(), + this.note = const Value.absent(), + this.createdAt = const Value.absent(), + this.updatedAt = const Value.absent(), + this.rowid = const Value.absent(), + }); + ReflectionRowsCompanion.insert({ + required String id, + required String dateKey, + required String mood, + required String note, + required DateTime createdAt, + required DateTime updatedAt, + this.rowid = const Value.absent(), + }) : id = Value(id), + dateKey = Value(dateKey), + mood = Value(mood), + note = Value(note), + createdAt = Value(createdAt), + updatedAt = Value(updatedAt); + static Insertable custom({ + Expression? id, + Expression? dateKey, + Expression? mood, + Expression? note, + Expression? createdAt, + Expression? updatedAt, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (dateKey != null) 'date_key': dateKey, + if (mood != null) 'mood': mood, + if (note != null) 'note': note, + if (createdAt != null) 'created_at': createdAt, + if (updatedAt != null) 'updated_at': updatedAt, + if (rowid != null) 'rowid': rowid, + }); + } + + ReflectionRowsCompanion copyWith({ + Value? id, + Value? dateKey, + Value? mood, + Value? note, + Value? createdAt, + Value? updatedAt, + Value? rowid, + }) { + return ReflectionRowsCompanion( + id: id ?? this.id, + dateKey: dateKey ?? this.dateKey, + mood: mood ?? this.mood, + note: note ?? this.note, + createdAt: createdAt ?? this.createdAt, + updatedAt: updatedAt ?? this.updatedAt, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (dateKey.present) { + map['date_key'] = Variable(dateKey.value); + } + if (mood.present) { + map['mood'] = Variable(mood.value); + } + if (note.present) { + map['note'] = Variable(note.value); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + if (updatedAt.present) { + map['updated_at'] = Variable(updatedAt.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('ReflectionRowsCompanion(') + ..write('id: $id, ') + ..write('dateKey: $dateKey, ') + ..write('mood: $mood, ') + ..write('note: $note, ') + ..write('createdAt: $createdAt, ') + ..write('updatedAt: $updatedAt, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class $AppSettingRowsTable extends AppSettingRows + with TableInfo<$AppSettingRowsTable, AppSettingRow> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $AppSettingRowsTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _keyMeta = const VerificationMeta('key'); + @override + late final GeneratedColumn key = GeneratedColumn( + 'key', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + ); + static const VerificationMeta _valueMeta = const VerificationMeta('value'); + @override + late final GeneratedColumn value = GeneratedColumn( + 'value', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + ); + @override + List get $columns => [key, value]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'app_settings'; + @override + VerificationContext validateIntegrity( + Insertable instance, { + bool isInserting = false, + }) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('key')) { + context.handle( + _keyMeta, + key.isAcceptableOrUnknown(data['key']!, _keyMeta), + ); + } else if (isInserting) { + context.missing(_keyMeta); + } + if (data.containsKey('value')) { + context.handle( + _valueMeta, + value.isAcceptableOrUnknown(data['value']!, _valueMeta), + ); + } else if (isInserting) { + context.missing(_valueMeta); + } + return context; + } + + @override + Set get $primaryKey => {key}; + @override + AppSettingRow map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return AppSettingRow( + key: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}key'], + )!, + value: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}value'], + )!, + ); + } + + @override + $AppSettingRowsTable createAlias(String alias) { + return $AppSettingRowsTable(attachedDatabase, alias); + } +} + +class AppSettingRow extends DataClass implements Insertable { + final String key; + final String value; + const AppSettingRow({required this.key, required this.value}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['key'] = Variable(key); + map['value'] = Variable(value); + return map; + } + + AppSettingRowsCompanion toCompanion(bool nullToAbsent) { + return AppSettingRowsCompanion(key: Value(key), value: Value(value)); + } + + factory AppSettingRow.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return AppSettingRow( + key: serializer.fromJson(json['key']), + value: serializer.fromJson(json['value']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'key': serializer.toJson(key), + 'value': serializer.toJson(value), + }; + } + + AppSettingRow copyWith({String? key, String? value}) => + AppSettingRow(key: key ?? this.key, value: value ?? this.value); + AppSettingRow copyWithCompanion(AppSettingRowsCompanion data) { + return AppSettingRow( + key: data.key.present ? data.key.value : this.key, + value: data.value.present ? data.value.value : this.value, + ); + } + + @override + String toString() { + return (StringBuffer('AppSettingRow(') + ..write('key: $key, ') + ..write('value: $value') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(key, value); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is AppSettingRow && + other.key == this.key && + other.value == this.value); +} + +class AppSettingRowsCompanion extends UpdateCompanion { + final Value key; + final Value value; + final Value rowid; + const AppSettingRowsCompanion({ + this.key = const Value.absent(), + this.value = const Value.absent(), + this.rowid = const Value.absent(), + }); + AppSettingRowsCompanion.insert({ + required String key, + required String value, + this.rowid = const Value.absent(), + }) : key = Value(key), + value = Value(value); + static Insertable custom({ + Expression? key, + Expression? value, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (key != null) 'key': key, + if (value != null) 'value': value, + if (rowid != null) 'rowid': rowid, + }); + } + + AppSettingRowsCompanion copyWith({ + Value? key, + Value? value, + Value? rowid, + }) { + return AppSettingRowsCompanion( + key: key ?? this.key, + value: value ?? this.value, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (key.present) { + map['key'] = Variable(key.value); + } + if (value.present) { + map['value'] = Variable(value.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('AppSettingRowsCompanion(') + ..write('key: $key, ') + ..write('value: $value, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +abstract class _$FocusSeedDatabase extends GeneratedDatabase { + _$FocusSeedDatabase(QueryExecutor e) : super(e); + $FocusSeedDatabaseManager get managers => $FocusSeedDatabaseManager(this); + late final $DailyIntentionRowsTable dailyIntentionRows = + $DailyIntentionRowsTable(this); + late final $FocusSessionRowsTable focusSessionRows = $FocusSessionRowsTable( + this, + ); + late final $HabitRowsTable habitRows = $HabitRowsTable(this); + late final $HabitLogRowsTable habitLogRows = $HabitLogRowsTable(this); + late final $ReflectionRowsTable reflectionRows = $ReflectionRowsTable(this); + late final $AppSettingRowsTable appSettingRows = $AppSettingRowsTable(this); + @override + Iterable> get allTables => + allSchemaEntities.whereType>(); + @override + List get allSchemaEntities => [ + dailyIntentionRows, + focusSessionRows, + habitRows, + habitLogRows, + reflectionRows, + appSettingRows, + ]; +} + +typedef $$DailyIntentionRowsTableCreateCompanionBuilder = + DailyIntentionRowsCompanion Function({ + required String dateKey, + required String intentionText, + required DateTime createdAt, + required DateTime updatedAt, + Value rowid, + }); +typedef $$DailyIntentionRowsTableUpdateCompanionBuilder = + DailyIntentionRowsCompanion Function({ + Value dateKey, + Value intentionText, + Value createdAt, + Value updatedAt, + Value rowid, + }); + +class $$DailyIntentionRowsTableFilterComposer + extends Composer<_$FocusSeedDatabase, $DailyIntentionRowsTable> { + $$DailyIntentionRowsTableFilterComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnFilters get dateKey => $composableBuilder( + column: $table.dateKey, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get intentionText => $composableBuilder( + column: $table.intentionText, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get createdAt => $composableBuilder( + column: $table.createdAt, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get updatedAt => $composableBuilder( + column: $table.updatedAt, + builder: (column) => ColumnFilters(column), + ); +} + +class $$DailyIntentionRowsTableOrderingComposer + extends Composer<_$FocusSeedDatabase, $DailyIntentionRowsTable> { + $$DailyIntentionRowsTableOrderingComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnOrderings get dateKey => $composableBuilder( + column: $table.dateKey, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get intentionText => $composableBuilder( + column: $table.intentionText, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get createdAt => $composableBuilder( + column: $table.createdAt, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get updatedAt => $composableBuilder( + column: $table.updatedAt, + builder: (column) => ColumnOrderings(column), + ); +} + +class $$DailyIntentionRowsTableAnnotationComposer + extends Composer<_$FocusSeedDatabase, $DailyIntentionRowsTable> { + $$DailyIntentionRowsTableAnnotationComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + GeneratedColumn get dateKey => + $composableBuilder(column: $table.dateKey, builder: (column) => column); + + GeneratedColumn get intentionText => $composableBuilder( + column: $table.intentionText, + builder: (column) => column, + ); + + GeneratedColumn get createdAt => + $composableBuilder(column: $table.createdAt, builder: (column) => column); + + GeneratedColumn get updatedAt => + $composableBuilder(column: $table.updatedAt, builder: (column) => column); +} + +class $$DailyIntentionRowsTableTableManager + extends + RootTableManager< + _$FocusSeedDatabase, + $DailyIntentionRowsTable, + DailyIntentionRow, + $$DailyIntentionRowsTableFilterComposer, + $$DailyIntentionRowsTableOrderingComposer, + $$DailyIntentionRowsTableAnnotationComposer, + $$DailyIntentionRowsTableCreateCompanionBuilder, + $$DailyIntentionRowsTableUpdateCompanionBuilder, + ( + DailyIntentionRow, + BaseReferences< + _$FocusSeedDatabase, + $DailyIntentionRowsTable, + DailyIntentionRow + >, + ), + DailyIntentionRow, + PrefetchHooks Function() + > { + $$DailyIntentionRowsTableTableManager( + _$FocusSeedDatabase db, + $DailyIntentionRowsTable table, + ) : super( + TableManagerState( + db: db, + table: table, + createFilteringComposer: + () => $$DailyIntentionRowsTableFilterComposer( + $db: db, + $table: table, + ), + createOrderingComposer: + () => $$DailyIntentionRowsTableOrderingComposer( + $db: db, + $table: table, + ), + createComputedFieldComposer: + () => $$DailyIntentionRowsTableAnnotationComposer( + $db: db, + $table: table, + ), + updateCompanionCallback: + ({ + Value dateKey = const Value.absent(), + Value intentionText = const Value.absent(), + Value createdAt = const Value.absent(), + Value updatedAt = const Value.absent(), + Value rowid = const Value.absent(), + }) => DailyIntentionRowsCompanion( + dateKey: dateKey, + intentionText: intentionText, + createdAt: createdAt, + updatedAt: updatedAt, + rowid: rowid, + ), + createCompanionCallback: + ({ + required String dateKey, + required String intentionText, + required DateTime createdAt, + required DateTime updatedAt, + Value rowid = const Value.absent(), + }) => DailyIntentionRowsCompanion.insert( + dateKey: dateKey, + intentionText: intentionText, + createdAt: createdAt, + updatedAt: updatedAt, + rowid: rowid, + ), + withReferenceMapper: + (p0) => + p0 + .map( + (e) => ( + e.readTable(table), + BaseReferences(db, table, e), + ), + ) + .toList(), + prefetchHooksCallback: null, + ), + ); +} + +typedef $$DailyIntentionRowsTableProcessedTableManager = + ProcessedTableManager< + _$FocusSeedDatabase, + $DailyIntentionRowsTable, + DailyIntentionRow, + $$DailyIntentionRowsTableFilterComposer, + $$DailyIntentionRowsTableOrderingComposer, + $$DailyIntentionRowsTableAnnotationComposer, + $$DailyIntentionRowsTableCreateCompanionBuilder, + $$DailyIntentionRowsTableUpdateCompanionBuilder, + ( + DailyIntentionRow, + BaseReferences< + _$FocusSeedDatabase, + $DailyIntentionRowsTable, + DailyIntentionRow + >, + ), + DailyIntentionRow, + PrefetchHooks Function() + >; +typedef $$FocusSessionRowsTableCreateCompanionBuilder = + FocusSessionRowsCompanion Function({ + required String id, + required String dateKey, + required int plannedMinutes, + required int actualSeconds, + required DateTime startedAt, + required DateTime endedAt, + required String status, + Value rowid, + }); +typedef $$FocusSessionRowsTableUpdateCompanionBuilder = + FocusSessionRowsCompanion Function({ + Value id, + Value dateKey, + Value plannedMinutes, + Value actualSeconds, + Value startedAt, + Value endedAt, + Value status, + Value rowid, + }); + +class $$FocusSessionRowsTableFilterComposer + extends Composer<_$FocusSeedDatabase, $FocusSessionRowsTable> { + $$FocusSessionRowsTableFilterComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnFilters get id => $composableBuilder( + column: $table.id, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get dateKey => $composableBuilder( + column: $table.dateKey, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get plannedMinutes => $composableBuilder( + column: $table.plannedMinutes, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get actualSeconds => $composableBuilder( + column: $table.actualSeconds, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get startedAt => $composableBuilder( + column: $table.startedAt, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get endedAt => $composableBuilder( + column: $table.endedAt, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get status => $composableBuilder( + column: $table.status, + builder: (column) => ColumnFilters(column), + ); +} + +class $$FocusSessionRowsTableOrderingComposer + extends Composer<_$FocusSeedDatabase, $FocusSessionRowsTable> { + $$FocusSessionRowsTableOrderingComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnOrderings get id => $composableBuilder( + column: $table.id, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get dateKey => $composableBuilder( + column: $table.dateKey, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get plannedMinutes => $composableBuilder( + column: $table.plannedMinutes, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get actualSeconds => $composableBuilder( + column: $table.actualSeconds, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get startedAt => $composableBuilder( + column: $table.startedAt, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get endedAt => $composableBuilder( + column: $table.endedAt, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get status => $composableBuilder( + column: $table.status, + builder: (column) => ColumnOrderings(column), + ); +} + +class $$FocusSessionRowsTableAnnotationComposer + extends Composer<_$FocusSeedDatabase, $FocusSessionRowsTable> { + $$FocusSessionRowsTableAnnotationComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + GeneratedColumn get id => + $composableBuilder(column: $table.id, builder: (column) => column); + + GeneratedColumn get dateKey => + $composableBuilder(column: $table.dateKey, builder: (column) => column); + + GeneratedColumn get plannedMinutes => $composableBuilder( + column: $table.plannedMinutes, + builder: (column) => column, + ); + + GeneratedColumn get actualSeconds => $composableBuilder( + column: $table.actualSeconds, + builder: (column) => column, + ); + + GeneratedColumn get startedAt => + $composableBuilder(column: $table.startedAt, builder: (column) => column); + + GeneratedColumn get endedAt => + $composableBuilder(column: $table.endedAt, builder: (column) => column); + + GeneratedColumn get status => + $composableBuilder(column: $table.status, builder: (column) => column); +} + +class $$FocusSessionRowsTableTableManager + extends + RootTableManager< + _$FocusSeedDatabase, + $FocusSessionRowsTable, + FocusSessionRow, + $$FocusSessionRowsTableFilterComposer, + $$FocusSessionRowsTableOrderingComposer, + $$FocusSessionRowsTableAnnotationComposer, + $$FocusSessionRowsTableCreateCompanionBuilder, + $$FocusSessionRowsTableUpdateCompanionBuilder, + ( + FocusSessionRow, + BaseReferences< + _$FocusSeedDatabase, + $FocusSessionRowsTable, + FocusSessionRow + >, + ), + FocusSessionRow, + PrefetchHooks Function() + > { + $$FocusSessionRowsTableTableManager( + _$FocusSeedDatabase db, + $FocusSessionRowsTable table, + ) : super( + TableManagerState( + db: db, + table: table, + createFilteringComposer: + () => + $$FocusSessionRowsTableFilterComposer($db: db, $table: table), + createOrderingComposer: + () => $$FocusSessionRowsTableOrderingComposer( + $db: db, + $table: table, + ), + createComputedFieldComposer: + () => $$FocusSessionRowsTableAnnotationComposer( + $db: db, + $table: table, + ), + updateCompanionCallback: + ({ + Value id = const Value.absent(), + Value dateKey = const Value.absent(), + Value plannedMinutes = const Value.absent(), + Value actualSeconds = const Value.absent(), + Value startedAt = const Value.absent(), + Value endedAt = const Value.absent(), + Value status = const Value.absent(), + Value rowid = const Value.absent(), + }) => FocusSessionRowsCompanion( + id: id, + dateKey: dateKey, + plannedMinutes: plannedMinutes, + actualSeconds: actualSeconds, + startedAt: startedAt, + endedAt: endedAt, + status: status, + rowid: rowid, + ), + createCompanionCallback: + ({ + required String id, + required String dateKey, + required int plannedMinutes, + required int actualSeconds, + required DateTime startedAt, + required DateTime endedAt, + required String status, + Value rowid = const Value.absent(), + }) => FocusSessionRowsCompanion.insert( + id: id, + dateKey: dateKey, + plannedMinutes: plannedMinutes, + actualSeconds: actualSeconds, + startedAt: startedAt, + endedAt: endedAt, + status: status, + rowid: rowid, + ), + withReferenceMapper: + (p0) => + p0 + .map( + (e) => ( + e.readTable(table), + BaseReferences(db, table, e), + ), + ) + .toList(), + prefetchHooksCallback: null, + ), + ); +} + +typedef $$FocusSessionRowsTableProcessedTableManager = + ProcessedTableManager< + _$FocusSeedDatabase, + $FocusSessionRowsTable, + FocusSessionRow, + $$FocusSessionRowsTableFilterComposer, + $$FocusSessionRowsTableOrderingComposer, + $$FocusSessionRowsTableAnnotationComposer, + $$FocusSessionRowsTableCreateCompanionBuilder, + $$FocusSessionRowsTableUpdateCompanionBuilder, + ( + FocusSessionRow, + BaseReferences< + _$FocusSeedDatabase, + $FocusSessionRowsTable, + FocusSessionRow + >, + ), + FocusSessionRow, + PrefetchHooks Function() + >; +typedef $$HabitRowsTableCreateCompanionBuilder = + HabitRowsCompanion Function({ + required String id, + required String title, + required int sortOrder, + required DateTime createdAt, + Value archivedAt, + Value rowid, + }); +typedef $$HabitRowsTableUpdateCompanionBuilder = + HabitRowsCompanion Function({ + Value id, + Value title, + Value sortOrder, + Value createdAt, + Value archivedAt, + Value rowid, + }); + +class $$HabitRowsTableFilterComposer + extends Composer<_$FocusSeedDatabase, $HabitRowsTable> { + $$HabitRowsTableFilterComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnFilters get id => $composableBuilder( + column: $table.id, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get title => $composableBuilder( + column: $table.title, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get sortOrder => $composableBuilder( + column: $table.sortOrder, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get createdAt => $composableBuilder( + column: $table.createdAt, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get archivedAt => $composableBuilder( + column: $table.archivedAt, + builder: (column) => ColumnFilters(column), + ); +} + +class $$HabitRowsTableOrderingComposer + extends Composer<_$FocusSeedDatabase, $HabitRowsTable> { + $$HabitRowsTableOrderingComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnOrderings get id => $composableBuilder( + column: $table.id, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get title => $composableBuilder( + column: $table.title, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get sortOrder => $composableBuilder( + column: $table.sortOrder, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get createdAt => $composableBuilder( + column: $table.createdAt, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get archivedAt => $composableBuilder( + column: $table.archivedAt, + builder: (column) => ColumnOrderings(column), + ); +} + +class $$HabitRowsTableAnnotationComposer + extends Composer<_$FocusSeedDatabase, $HabitRowsTable> { + $$HabitRowsTableAnnotationComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + GeneratedColumn get id => + $composableBuilder(column: $table.id, builder: (column) => column); + + GeneratedColumn get title => + $composableBuilder(column: $table.title, builder: (column) => column); + + GeneratedColumn get sortOrder => + $composableBuilder(column: $table.sortOrder, builder: (column) => column); + + GeneratedColumn get createdAt => + $composableBuilder(column: $table.createdAt, builder: (column) => column); + + GeneratedColumn get archivedAt => $composableBuilder( + column: $table.archivedAt, + builder: (column) => column, + ); +} + +class $$HabitRowsTableTableManager + extends + RootTableManager< + _$FocusSeedDatabase, + $HabitRowsTable, + HabitRow, + $$HabitRowsTableFilterComposer, + $$HabitRowsTableOrderingComposer, + $$HabitRowsTableAnnotationComposer, + $$HabitRowsTableCreateCompanionBuilder, + $$HabitRowsTableUpdateCompanionBuilder, + ( + HabitRow, + BaseReferences<_$FocusSeedDatabase, $HabitRowsTable, HabitRow>, + ), + HabitRow, + PrefetchHooks Function() + > { + $$HabitRowsTableTableManager(_$FocusSeedDatabase db, $HabitRowsTable table) + : super( + TableManagerState( + db: db, + table: table, + createFilteringComposer: + () => $$HabitRowsTableFilterComposer($db: db, $table: table), + createOrderingComposer: + () => $$HabitRowsTableOrderingComposer($db: db, $table: table), + createComputedFieldComposer: + () => $$HabitRowsTableAnnotationComposer($db: db, $table: table), + updateCompanionCallback: + ({ + Value id = const Value.absent(), + Value title = const Value.absent(), + Value sortOrder = const Value.absent(), + Value createdAt = const Value.absent(), + Value archivedAt = const Value.absent(), + Value rowid = const Value.absent(), + }) => HabitRowsCompanion( + id: id, + title: title, + sortOrder: sortOrder, + createdAt: createdAt, + archivedAt: archivedAt, + rowid: rowid, + ), + createCompanionCallback: + ({ + required String id, + required String title, + required int sortOrder, + required DateTime createdAt, + Value archivedAt = const Value.absent(), + Value rowid = const Value.absent(), + }) => HabitRowsCompanion.insert( + id: id, + title: title, + sortOrder: sortOrder, + createdAt: createdAt, + archivedAt: archivedAt, + rowid: rowid, + ), + withReferenceMapper: + (p0) => + p0 + .map( + (e) => ( + e.readTable(table), + BaseReferences(db, table, e), + ), + ) + .toList(), + prefetchHooksCallback: null, + ), + ); +} + +typedef $$HabitRowsTableProcessedTableManager = + ProcessedTableManager< + _$FocusSeedDatabase, + $HabitRowsTable, + HabitRow, + $$HabitRowsTableFilterComposer, + $$HabitRowsTableOrderingComposer, + $$HabitRowsTableAnnotationComposer, + $$HabitRowsTableCreateCompanionBuilder, + $$HabitRowsTableUpdateCompanionBuilder, + ( + HabitRow, + BaseReferences<_$FocusSeedDatabase, $HabitRowsTable, HabitRow>, + ), + HabitRow, + PrefetchHooks Function() + >; +typedef $$HabitLogRowsTableCreateCompanionBuilder = + HabitLogRowsCompanion Function({ + required String id, + required String habitId, + required String dateKey, + required DateTime completedAt, + Value rowid, + }); +typedef $$HabitLogRowsTableUpdateCompanionBuilder = + HabitLogRowsCompanion Function({ + Value id, + Value habitId, + Value dateKey, + Value completedAt, + Value rowid, + }); + +class $$HabitLogRowsTableFilterComposer + extends Composer<_$FocusSeedDatabase, $HabitLogRowsTable> { + $$HabitLogRowsTableFilterComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnFilters get id => $composableBuilder( + column: $table.id, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get habitId => $composableBuilder( + column: $table.habitId, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get dateKey => $composableBuilder( + column: $table.dateKey, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get completedAt => $composableBuilder( + column: $table.completedAt, + builder: (column) => ColumnFilters(column), + ); +} + +class $$HabitLogRowsTableOrderingComposer + extends Composer<_$FocusSeedDatabase, $HabitLogRowsTable> { + $$HabitLogRowsTableOrderingComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnOrderings get id => $composableBuilder( + column: $table.id, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get habitId => $composableBuilder( + column: $table.habitId, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get dateKey => $composableBuilder( + column: $table.dateKey, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get completedAt => $composableBuilder( + column: $table.completedAt, + builder: (column) => ColumnOrderings(column), + ); +} + +class $$HabitLogRowsTableAnnotationComposer + extends Composer<_$FocusSeedDatabase, $HabitLogRowsTable> { + $$HabitLogRowsTableAnnotationComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + GeneratedColumn get id => + $composableBuilder(column: $table.id, builder: (column) => column); + + GeneratedColumn get habitId => + $composableBuilder(column: $table.habitId, builder: (column) => column); + + GeneratedColumn get dateKey => + $composableBuilder(column: $table.dateKey, builder: (column) => column); + + GeneratedColumn get completedAt => $composableBuilder( + column: $table.completedAt, + builder: (column) => column, + ); +} + +class $$HabitLogRowsTableTableManager + extends + RootTableManager< + _$FocusSeedDatabase, + $HabitLogRowsTable, + HabitLogRow, + $$HabitLogRowsTableFilterComposer, + $$HabitLogRowsTableOrderingComposer, + $$HabitLogRowsTableAnnotationComposer, + $$HabitLogRowsTableCreateCompanionBuilder, + $$HabitLogRowsTableUpdateCompanionBuilder, + ( + HabitLogRow, + BaseReferences< + _$FocusSeedDatabase, + $HabitLogRowsTable, + HabitLogRow + >, + ), + HabitLogRow, + PrefetchHooks Function() + > { + $$HabitLogRowsTableTableManager( + _$FocusSeedDatabase db, + $HabitLogRowsTable table, + ) : super( + TableManagerState( + db: db, + table: table, + createFilteringComposer: + () => $$HabitLogRowsTableFilterComposer($db: db, $table: table), + createOrderingComposer: + () => $$HabitLogRowsTableOrderingComposer($db: db, $table: table), + createComputedFieldComposer: + () => + $$HabitLogRowsTableAnnotationComposer($db: db, $table: table), + updateCompanionCallback: + ({ + Value id = const Value.absent(), + Value habitId = const Value.absent(), + Value dateKey = const Value.absent(), + Value completedAt = const Value.absent(), + Value rowid = const Value.absent(), + }) => HabitLogRowsCompanion( + id: id, + habitId: habitId, + dateKey: dateKey, + completedAt: completedAt, + rowid: rowid, + ), + createCompanionCallback: + ({ + required String id, + required String habitId, + required String dateKey, + required DateTime completedAt, + Value rowid = const Value.absent(), + }) => HabitLogRowsCompanion.insert( + id: id, + habitId: habitId, + dateKey: dateKey, + completedAt: completedAt, + rowid: rowid, + ), + withReferenceMapper: + (p0) => + p0 + .map( + (e) => ( + e.readTable(table), + BaseReferences(db, table, e), + ), + ) + .toList(), + prefetchHooksCallback: null, + ), + ); +} + +typedef $$HabitLogRowsTableProcessedTableManager = + ProcessedTableManager< + _$FocusSeedDatabase, + $HabitLogRowsTable, + HabitLogRow, + $$HabitLogRowsTableFilterComposer, + $$HabitLogRowsTableOrderingComposer, + $$HabitLogRowsTableAnnotationComposer, + $$HabitLogRowsTableCreateCompanionBuilder, + $$HabitLogRowsTableUpdateCompanionBuilder, + ( + HabitLogRow, + BaseReferences<_$FocusSeedDatabase, $HabitLogRowsTable, HabitLogRow>, + ), + HabitLogRow, + PrefetchHooks Function() + >; +typedef $$ReflectionRowsTableCreateCompanionBuilder = + ReflectionRowsCompanion Function({ + required String id, + required String dateKey, + required String mood, + required String note, + required DateTime createdAt, + required DateTime updatedAt, + Value rowid, + }); +typedef $$ReflectionRowsTableUpdateCompanionBuilder = + ReflectionRowsCompanion Function({ + Value id, + Value dateKey, + Value mood, + Value note, + Value createdAt, + Value updatedAt, + Value rowid, + }); + +class $$ReflectionRowsTableFilterComposer + extends Composer<_$FocusSeedDatabase, $ReflectionRowsTable> { + $$ReflectionRowsTableFilterComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnFilters get id => $composableBuilder( + column: $table.id, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get dateKey => $composableBuilder( + column: $table.dateKey, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get mood => $composableBuilder( + column: $table.mood, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get note => $composableBuilder( + column: $table.note, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get createdAt => $composableBuilder( + column: $table.createdAt, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get updatedAt => $composableBuilder( + column: $table.updatedAt, + builder: (column) => ColumnFilters(column), + ); +} + +class $$ReflectionRowsTableOrderingComposer + extends Composer<_$FocusSeedDatabase, $ReflectionRowsTable> { + $$ReflectionRowsTableOrderingComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnOrderings get id => $composableBuilder( + column: $table.id, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get dateKey => $composableBuilder( + column: $table.dateKey, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get mood => $composableBuilder( + column: $table.mood, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get note => $composableBuilder( + column: $table.note, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get createdAt => $composableBuilder( + column: $table.createdAt, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get updatedAt => $composableBuilder( + column: $table.updatedAt, + builder: (column) => ColumnOrderings(column), + ); +} + +class $$ReflectionRowsTableAnnotationComposer + extends Composer<_$FocusSeedDatabase, $ReflectionRowsTable> { + $$ReflectionRowsTableAnnotationComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + GeneratedColumn get id => + $composableBuilder(column: $table.id, builder: (column) => column); + + GeneratedColumn get dateKey => + $composableBuilder(column: $table.dateKey, builder: (column) => column); + + GeneratedColumn get mood => + $composableBuilder(column: $table.mood, builder: (column) => column); + + GeneratedColumn get note => + $composableBuilder(column: $table.note, builder: (column) => column); + + GeneratedColumn get createdAt => + $composableBuilder(column: $table.createdAt, builder: (column) => column); + + GeneratedColumn get updatedAt => + $composableBuilder(column: $table.updatedAt, builder: (column) => column); +} + +class $$ReflectionRowsTableTableManager + extends + RootTableManager< + _$FocusSeedDatabase, + $ReflectionRowsTable, + ReflectionRow, + $$ReflectionRowsTableFilterComposer, + $$ReflectionRowsTableOrderingComposer, + $$ReflectionRowsTableAnnotationComposer, + $$ReflectionRowsTableCreateCompanionBuilder, + $$ReflectionRowsTableUpdateCompanionBuilder, + ( + ReflectionRow, + BaseReferences< + _$FocusSeedDatabase, + $ReflectionRowsTable, + ReflectionRow + >, + ), + ReflectionRow, + PrefetchHooks Function() + > { + $$ReflectionRowsTableTableManager( + _$FocusSeedDatabase db, + $ReflectionRowsTable table, + ) : super( + TableManagerState( + db: db, + table: table, + createFilteringComposer: + () => $$ReflectionRowsTableFilterComposer($db: db, $table: table), + createOrderingComposer: + () => + $$ReflectionRowsTableOrderingComposer($db: db, $table: table), + createComputedFieldComposer: + () => $$ReflectionRowsTableAnnotationComposer( + $db: db, + $table: table, + ), + updateCompanionCallback: + ({ + Value id = const Value.absent(), + Value dateKey = const Value.absent(), + Value mood = const Value.absent(), + Value note = const Value.absent(), + Value createdAt = const Value.absent(), + Value updatedAt = const Value.absent(), + Value rowid = const Value.absent(), + }) => ReflectionRowsCompanion( + id: id, + dateKey: dateKey, + mood: mood, + note: note, + createdAt: createdAt, + updatedAt: updatedAt, + rowid: rowid, + ), + createCompanionCallback: + ({ + required String id, + required String dateKey, + required String mood, + required String note, + required DateTime createdAt, + required DateTime updatedAt, + Value rowid = const Value.absent(), + }) => ReflectionRowsCompanion.insert( + id: id, + dateKey: dateKey, + mood: mood, + note: note, + createdAt: createdAt, + updatedAt: updatedAt, + rowid: rowid, + ), + withReferenceMapper: + (p0) => + p0 + .map( + (e) => ( + e.readTable(table), + BaseReferences(db, table, e), + ), + ) + .toList(), + prefetchHooksCallback: null, + ), + ); +} + +typedef $$ReflectionRowsTableProcessedTableManager = + ProcessedTableManager< + _$FocusSeedDatabase, + $ReflectionRowsTable, + ReflectionRow, + $$ReflectionRowsTableFilterComposer, + $$ReflectionRowsTableOrderingComposer, + $$ReflectionRowsTableAnnotationComposer, + $$ReflectionRowsTableCreateCompanionBuilder, + $$ReflectionRowsTableUpdateCompanionBuilder, + ( + ReflectionRow, + BaseReferences< + _$FocusSeedDatabase, + $ReflectionRowsTable, + ReflectionRow + >, + ), + ReflectionRow, + PrefetchHooks Function() + >; +typedef $$AppSettingRowsTableCreateCompanionBuilder = + AppSettingRowsCompanion Function({ + required String key, + required String value, + Value rowid, + }); +typedef $$AppSettingRowsTableUpdateCompanionBuilder = + AppSettingRowsCompanion Function({ + Value key, + Value value, + Value rowid, + }); + +class $$AppSettingRowsTableFilterComposer + extends Composer<_$FocusSeedDatabase, $AppSettingRowsTable> { + $$AppSettingRowsTableFilterComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnFilters get key => $composableBuilder( + column: $table.key, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get value => $composableBuilder( + column: $table.value, + builder: (column) => ColumnFilters(column), + ); +} + +class $$AppSettingRowsTableOrderingComposer + extends Composer<_$FocusSeedDatabase, $AppSettingRowsTable> { + $$AppSettingRowsTableOrderingComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnOrderings get key => $composableBuilder( + column: $table.key, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get value => $composableBuilder( + column: $table.value, + builder: (column) => ColumnOrderings(column), + ); +} + +class $$AppSettingRowsTableAnnotationComposer + extends Composer<_$FocusSeedDatabase, $AppSettingRowsTable> { + $$AppSettingRowsTableAnnotationComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + GeneratedColumn get key => + $composableBuilder(column: $table.key, builder: (column) => column); + + GeneratedColumn get value => + $composableBuilder(column: $table.value, builder: (column) => column); +} + +class $$AppSettingRowsTableTableManager + extends + RootTableManager< + _$FocusSeedDatabase, + $AppSettingRowsTable, + AppSettingRow, + $$AppSettingRowsTableFilterComposer, + $$AppSettingRowsTableOrderingComposer, + $$AppSettingRowsTableAnnotationComposer, + $$AppSettingRowsTableCreateCompanionBuilder, + $$AppSettingRowsTableUpdateCompanionBuilder, + ( + AppSettingRow, + BaseReferences< + _$FocusSeedDatabase, + $AppSettingRowsTable, + AppSettingRow + >, + ), + AppSettingRow, + PrefetchHooks Function() + > { + $$AppSettingRowsTableTableManager( + _$FocusSeedDatabase db, + $AppSettingRowsTable table, + ) : super( + TableManagerState( + db: db, + table: table, + createFilteringComposer: + () => $$AppSettingRowsTableFilterComposer($db: db, $table: table), + createOrderingComposer: + () => + $$AppSettingRowsTableOrderingComposer($db: db, $table: table), + createComputedFieldComposer: + () => $$AppSettingRowsTableAnnotationComposer( + $db: db, + $table: table, + ), + updateCompanionCallback: + ({ + Value key = const Value.absent(), + Value value = const Value.absent(), + Value rowid = const Value.absent(), + }) => + AppSettingRowsCompanion(key: key, value: value, rowid: rowid), + createCompanionCallback: + ({ + required String key, + required String value, + Value rowid = const Value.absent(), + }) => AppSettingRowsCompanion.insert( + key: key, + value: value, + rowid: rowid, + ), + withReferenceMapper: + (p0) => + p0 + .map( + (e) => ( + e.readTable(table), + BaseReferences(db, table, e), + ), + ) + .toList(), + prefetchHooksCallback: null, + ), + ); +} + +typedef $$AppSettingRowsTableProcessedTableManager = + ProcessedTableManager< + _$FocusSeedDatabase, + $AppSettingRowsTable, + AppSettingRow, + $$AppSettingRowsTableFilterComposer, + $$AppSettingRowsTableOrderingComposer, + $$AppSettingRowsTableAnnotationComposer, + $$AppSettingRowsTableCreateCompanionBuilder, + $$AppSettingRowsTableUpdateCompanionBuilder, + ( + AppSettingRow, + BaseReferences< + _$FocusSeedDatabase, + $AppSettingRowsTable, + AppSettingRow + >, + ), + AppSettingRow, + PrefetchHooks Function() + >; + +class $FocusSeedDatabaseManager { + final _$FocusSeedDatabase _db; + $FocusSeedDatabaseManager(this._db); + $$DailyIntentionRowsTableTableManager get dailyIntentionRows => + $$DailyIntentionRowsTableTableManager(_db, _db.dailyIntentionRows); + $$FocusSessionRowsTableTableManager get focusSessionRows => + $$FocusSessionRowsTableTableManager(_db, _db.focusSessionRows); + $$HabitRowsTableTableManager get habitRows => + $$HabitRowsTableTableManager(_db, _db.habitRows); + $$HabitLogRowsTableTableManager get habitLogRows => + $$HabitLogRowsTableTableManager(_db, _db.habitLogRows); + $$ReflectionRowsTableTableManager get reflectionRows => + $$ReflectionRowsTableTableManager(_db, _db.reflectionRows); + $$AppSettingRowsTableTableManager get appSettingRows => + $$AppSettingRowsTableTableManager(_db, _db.appSettingRows); +} diff --git a/lib/src/features/shell/focus_seed_home.dart b/lib/src/features/shell/focus_seed_home.dart index 213c801..da8b44b 100644 --- a/lib/src/features/shell/focus_seed_home.dart +++ b/lib/src/features/shell/focus_seed_home.dart @@ -3,6 +3,7 @@ import 'package:flutter/services.dart'; import '../../application/focus_seed_controller.dart'; import '../../application/focus_timer_controller.dart'; +import '../../data/focus_seed_store.dart'; import '../../l10n/l10n.dart'; import '../../models/appearance_preference.dart'; import '../../models/language_preference.dart'; @@ -18,6 +19,7 @@ class FocusSeedHome extends StatefulWidget { required this.language, required this.showLanguageTools, required this.onLanguageChanged, + this.focusSeedStore, super.key, }); @@ -26,6 +28,7 @@ class FocusSeedHome extends StatefulWidget { final LanguagePreference language; final bool showLanguageTools; final ValueChanged onLanguageChanged; + final FocusSeedStore? focusSeedStore; @override State createState() => _FocusSeedHomeState(); @@ -43,6 +46,7 @@ class _FocusSeedHomeState extends State { return; } _controller = FocusSeedController( + store: widget.focusSeedStore, defaultHabitTitles: localizedStarterHabits(context.l10n), ); _timerController = FocusTimerController( diff --git a/lib/src/models/app_state.dart b/lib/src/models/app_state.dart index 41fff17..77d71f2 100644 --- a/lib/src/models/app_state.dart +++ b/lib/src/models/app_state.dart @@ -17,7 +17,11 @@ class AppState { final List sessions; final List reflections; - bool get isFreshStart => habits.isEmpty && sessions.isEmpty && anchor.isEmpty; + bool get isFreshStart => + habits.isEmpty && + sessions.isEmpty && + reflections.isEmpty && + anchor.isEmpty; String activeAnchor(String dateKey) { return anchorDateKey == dateKey ? anchor : ''; diff --git a/pubspec.lock b/pubspec.lock index 88cf3a4..3d12958 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,30 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: f0bb5d1648339c8308cc0b9838d8456b3cfe5c91f9dc1a735b4d003269e5da9a + url: "https://pub.flutter-io.cn" + source: hosted + version: "88.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: "0b7b9c329d2879f8f05d6c05b32ee9ec025f39b077864bdb5ac9a7b63418a98f" + url: "https://pub.flutter-io.cn" + source: hosted + version: "8.1.1" + args: + dependency: transitive + description: + name: args + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.7.0" async: dependency: transitive description: @@ -17,6 +41,54 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.1.2" + build: + dependency: transitive + description: + name: build + sha256: a156715e7cd728130c592f30552575908aae5b100005fbc1f0fb16b3c03a3d10 + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.0.6" + build_config: + dependency: transitive + description: + name: build_config + sha256: "4070d2a59f8eec34c97c86ceb44403834899075f66e8a9d59706f8e7834f6f71" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.3.0" + build_daemon: + dependency: transitive + description: + name: build_daemon + sha256: bf05f6e12cfea92d3c09308d7bcdab1906cd8a179b023269eed00c071004b957 + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.1.1" + build_runner: + dependency: "direct dev" + description: + name: build_runner + sha256: "1523ce62448ebac2c15a8ba5fbad8acac169788658a7dd2a1c2d9c2a9318b9a6" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.15.0" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.flutter-io.cn" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: "34e4067d30ce212937df995f03b69992eea683539ceeac7f679a1f1eba055b56" + url: "https://pub.flutter-io.cn" + source: hosted + version: "8.12.6" characters: dependency: transitive description: @@ -25,6 +97,30 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.4.0" + charcode: + dependency: transitive + description: + name: charcode + sha256: fb0f1107cac15a5ea6ef0a6ef71a807b9e4267c713bb93e00e92d737cc8dbd8a + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.4.0" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.3" + cli_util: + dependency: transitive + description: + name: cli_util + sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.4.2" clock: dependency: transitive description: @@ -41,6 +137,22 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.19.1" + convert: + dependency: transitive + description: + name: convert + sha256: b30acd5944035672bc15c6b7a8b47d773e41e2f17de064350988c5d02adb1c68 + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.1.2" + crypto: + dependency: transitive + description: + name: crypto + sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.7" cupertino_icons: dependency: "direct main" description: @@ -49,6 +161,30 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.0.8" + dart_style: + dependency: transitive + description: + name: dart_style + sha256: c87dfe3d56f183ffe9106a18aebc6db431fc7c98c31a54b952a77f3d54a85697 + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.1.2" + drift: + dependency: "direct main" + description: + name: drift + sha256: "970cd188fddb111b26ea6a9b07a62bf5c2432d74147b8122c67044ae3b97e99e" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.31.0" + drift_dev: + dependency: "direct dev" + description: + name: drift_dev + sha256: "917184b2fb867b70a548a83bf0d36268423b38d39968c06cce4905683da49587" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.31.0" fake_async: dependency: transitive description: @@ -73,6 +209,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "7.0.1" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.1" flutter: dependency: "direct main" description: flutter @@ -101,6 +245,38 @@ packages: description: flutter source: sdk version: "0.0.0" + glob: + dependency: transitive + description: + name: glob + sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.3" + graphs: + dependency: transitive + description: + name: graphs + sha256: "741bbf84165310a68ff28fe9e727332eef1407342fca52759cb21ad8177bb8d0" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.3.2" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: aa6199f908078bb1c5efb8d8638d4ae191aac11b311132c3ef48ce352fb52ef8 + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.2.2" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.1.2" intl: dependency: "direct main" description: @@ -109,6 +285,22 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.19.0" + io: + dependency: transitive + description: + name: io + sha256: dfd5a80599cf0165756e3181807ed3e77daf6dd4137caaad72d0b7931597650b + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.5" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.9.0" leak_tracker: dependency: transitive description: @@ -141,6 +333,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "5.1.1" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.3.0" matcher: dependency: transitive description: @@ -165,14 +365,54 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.16.0" - path: + mime: dependency: transitive + description: + name: mime + sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.0" + package_config: + dependency: transitive + description: + name: package_config + sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.0" + path: + dependency: "direct main" description: name: path sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" url: "https://pub.flutter-io.cn" source: hosted version: "1.9.1" + path_provider: + dependency: "direct main" + description: + name: path_provider + sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.5" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: "3b4c1fc3aa55ddc9cd4aa6759984330d5c8e66aa7702a6223c61540dc6380c37" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.19" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: "16eef174aacb07e09c351502740fa6254c165757638eba1e9116b0a781201bbd" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.4.2" path_provider_linux: dependency: transitive description: @@ -213,6 +453,38 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.1.8" + pool: + dependency: transitive + description: + name: pool + sha256: "978783255c543aa3586a1b3c21f6e9d720eb315376a915872c61ef8b5c20177d" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.5.2" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.0" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + sha256: "0560ba233314abbed0a48a2956f7f022cce7c3e1e73df540277da7544cad4082" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.5.0" + recase: + dependency: transitive + description: + name: recase + sha256: e4eb4ec2dcdee52dcf99cb4ceabaffc631d7424ee55e56f280bc039737f89213 + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.1.0" shared_preferences: dependency: "direct main" description: @@ -269,11 +541,35 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.4.1" + shelf: + dependency: transitive + description: + name: shelf + sha256: e7dd780a7ffb623c57850b33f43309312fc863fb6aa3d276a754bb299839ef12 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.4.2" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: "3632775c8e90d6c9712f883e633716432a27758216dfb61bd86a8321c0580925" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.0" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.0" + source_gen: + dependency: transitive + description: + name: source_gen + sha256: "1d562a3c1f713904ebbed50d2760217fd8a51ca170ac4b05b0db490699dbac17" + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.2.0" source_span: dependency: transitive description: @@ -282,6 +578,30 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.10.1" + sqlite3: + dependency: transitive + description: + name: sqlite3 + sha256: "3145bd74dcdb4fd6f5c6dda4d4e4490a8087d7f286a14dee5d37087290f0f8a2" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.9.4" + sqlite3_flutter_libs: + dependency: "direct main" + description: + name: sqlite3_flutter_libs + sha256: eeb9e3a45207649076b808f8a5a74d68770d0b7f26ccef6d5f43106eee5375ad + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.5.42" + sqlparser: + dependency: transitive + description: + name: sqlparser + sha256: "337e9997f7141ffdd054259128553c348635fa318f7ca492f07a4ab76f850d19" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.43.1" stack_trace: dependency: transitive description: @@ -298,6 +618,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.1.4" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: ad47125e588cfd37a9a7f86c7d6356dde8dfe89d071d293f80ca9e9273a33871 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.1" string_scanner: dependency: transitive description: @@ -322,6 +650,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.7.4" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.4.0" vector_math: dependency: transitive description: @@ -338,6 +674,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "14.3.1" + watcher: + dependency: transitive + description: + name: watcher + sha256: "1398c9f081a753f9226febe8900fce8f7d0a67163334e1c94a2438339d79d635" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.2.1" web: dependency: transitive description: @@ -346,6 +690,22 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.1.1" + web_socket: + dependency: transitive + description: + name: web_socket + sha256: "34d64019aa8e36bf9842ac014bb5d2f5586ca73df5e4d9bf5c936975cae6982c" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.1" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: d645757fb0f4773d602444000a8131ff5d48c9e47adfe9772652dd1a4f2d45c8 + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.3" xdg_directories: dependency: transitive description: @@ -354,6 +714,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.1.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.1.3" sdks: dart: ">=3.7.2 <4.0.0" flutter: ">=3.29.0" diff --git a/pubspec.yaml b/pubspec.yaml index 747a580..975a1a5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -38,10 +38,16 @@ dependencies: cupertino_icons: ^1.0.8 intl: any shared_preferences: ^2.5.3 + drift: ^2.31.0 + sqlite3_flutter_libs: ^0.5.42 + path_provider: ^2.1.5 + path: ^1.9.1 dev_dependencies: flutter_test: sdk: flutter + build_runner: ^2.10.4 + drift_dev: ^2.31.0 # The "flutter_lints" package below contains a set of recommended lints to # encourage good coding practices. The lint set provided by the package is diff --git a/test/focus_seed_store_test.dart b/test/focus_seed_store_test.dart new file mode 100644 index 0000000..fd1be83 --- /dev/null +++ b/test/focus_seed_store_test.dart @@ -0,0 +1,115 @@ +import 'dart:convert'; + +import 'package:drift/native.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:focus_seed/src/data/focus_seed_store.dart'; +import 'package:focus_seed/src/data/local/focus_seed_database.dart'; +import 'package:focus_seed/src/models/app_state.dart'; +import 'package:focus_seed/src/models/focus_session.dart'; +import 'package:focus_seed/src/models/habit.dart'; +import 'package:focus_seed/src/models/mood.dart'; +import 'package:focus_seed/src/models/reflection_entry.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +void main() { + setUp(() { + SharedPreferences.setMockInitialValues({}); + }); + + test('new installs seed localized starter habits into sqlite', () async { + final database = FocusSeedDatabase(NativeDatabase.memory()); + addTearDown(database.close); + final store = FocusSeedStore(database: database); + + final state = await store.load( + defaultHabitTitles: const ['Plan', 'Focus', 'Reflect'], + ); + + expect(state.anchor, isEmpty); + expect(state.habits.map((habit) => habit.title), [ + 'Plan', + 'Focus', + 'Reflect', + ]); + }); + + test( + 'sqlite snapshot round-trips focus, habit, and reflection data', + () async { + final database = FocusSeedDatabase(NativeDatabase.memory()); + addTearDown(database.close); + final store = FocusSeedStore(database: database); + final now = DateTime(2026, 6, 12, 10, 30); + final state = AppState( + anchor: 'Ship the local database', + anchorDateKey: '2026-06-12', + habits: [ + Habit( + id: 'habit-1', + title: 'Review the plan', + createdAt: now.subtract(const Duration(days: 2)), + completedDates: const {'2026-06-11', '2026-06-12'}, + ), + ], + sessions: [ + FocusSession(id: 'session-1', minutes: 25, completedAt: now), + ], + reflections: [ + ReflectionEntry( + id: 'reflection-1', + dateKey: '2026-06-12', + note: 'Small scope kept it clean.', + mood: Mood.clear, + createdAt: now.add(const Duration(minutes: 1)), + ), + ], + ); + + await store.save(state); + final loaded = await store.load(); + + expect(loaded.anchor, 'Ship the local database'); + expect(loaded.anchorDateKey, '2026-06-12'); + expect(loaded.habits.single.completedDates, {'2026-06-11', '2026-06-12'}); + expect(loaded.sessions.single.minutes, 25); + expect(loaded.reflections.single.note, 'Small scope kept it clean.'); + }, + ); + + test('legacy shared preferences json migrates once and is removed', () async { + final legacyState = AppState( + anchor: 'Migrate safely', + anchorDateKey: '2026-06-12', + habits: [ + Habit( + id: 'habit-legacy', + title: 'Keep existing data', + createdAt: DateTime(2026, 6, 10), + completedDates: const {'2026-06-12'}, + ), + ], + sessions: [ + FocusSession( + id: 'session-legacy', + minutes: 15, + completedAt: DateTime(2026, 6, 12, 8), + ), + ], + reflections: const [], + ); + SharedPreferences.setMockInitialValues({ + 'focus_seed_state_v1': jsonEncode(legacyState.toJson()), + }); + final database = FocusSeedDatabase(NativeDatabase.memory()); + addTearDown(database.close); + final store = FocusSeedStore(database: database); + + final migrated = await store.load(); + final preferences = await SharedPreferences.getInstance(); + + expect(migrated.anchor, 'Migrate safely'); + expect(migrated.habits.single.title, 'Keep existing data'); + expect(migrated.sessions.single.minutes, 15); + expect(preferences.getString('focus_seed_state_v1'), isNull); + }); +} diff --git a/test/widget_test.dart b/test/widget_test.dart index 38a5ecb..bfef17c 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -1,6 +1,9 @@ +import 'package:drift/native.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:focus_seed/src/app/focus_seed_app.dart'; +import 'package:focus_seed/src/data/focus_seed_store.dart'; +import 'package:focus_seed/src/data/local/focus_seed_database.dart'; import 'package:shared_preferences/shared_preferences.dart'; void main() { @@ -14,8 +17,7 @@ void main() { }); testWidgets('Today guides the user from intention to focus', (tester) async { - await tester.pumpWidget(const FocusSeedApp(locale: Locale('en'))); - await tester.pumpAndSettle(); + await pumpFocusSeedApp(tester, locale: const Locale('en')); expect(find.text('Focus Seed'), findsOneWidget); expect(find.text("TODAY'S INTENTION"), findsOneWidget); @@ -35,8 +37,7 @@ void main() { }); testWidgets('bottom navigation exposes Journey and Me', (tester) async { - await tester.pumpWidget(const FocusSeedApp(locale: Locale('en'))); - await tester.pumpAndSettle(); + await pumpFocusSeedApp(tester, locale: const Locale('en')); await tester.tap(find.text('Journey')); await tester.pumpAndSettle(); @@ -60,8 +61,7 @@ void main() { tester.platformDispatcher.clearTextScaleFactorTestValue(); }); - await tester.pumpWidget(const FocusSeedApp(locale: Locale('en'))); - await tester.pumpAndSettle(); + await pumpFocusSeedApp(tester, locale: const Locale('en')); expect(find.text('Focus Seed'), findsOneWidget); expect(find.byType(Scrollable), findsWidgets); @@ -69,8 +69,7 @@ void main() { }); testWidgets('development default uses concise Chinese copy', (tester) async { - await tester.pumpWidget(const FocusSeedApp()); - await tester.pumpAndSettle(); + await pumpFocusSeedApp(tester); expect(find.text('Focus Seed'), findsOneWidget); expect(find.text('\u4eca\u65e5\u76ee\u6807'), findsOneWidget); @@ -88,8 +87,7 @@ void main() { testWidgets('development language switch changes the active locale', ( tester, ) async { - await tester.pumpWidget(const FocusSeedApp()); - await tester.pumpAndSettle(); + await pumpFocusSeedApp(tester); await tester.tap(find.text('\u6211\u7684')); await tester.pumpAndSettle(); @@ -102,3 +100,15 @@ void main() { expect(find.text('Language'), findsOneWidget); }); } + +Future pumpFocusSeedApp(WidgetTester tester, {Locale? locale}) async { + final database = FocusSeedDatabase(NativeDatabase.memory()); + addTearDown(database.close); + await tester.pumpWidget( + FocusSeedApp( + locale: locale, + focusSeedStore: FocusSeedStore(database: database), + ), + ); + await tester.pumpAndSettle(); +}