Gitea CI / Assemble and validate CI artifacts (push) Successful in 1m47s
Gitea CI / Check code and tests (push) Successful in 7m15s
Gitea CI / Build Android APK (push) Successful in 4m6s
Gitea CI / Build Windows x64 app (push) Successful in 3m34s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m29s
Gitea CI / Gitea CI passed (push) Successful in 1s
Gitea Release / Prepare draft Release (push) Failing after 8s
Gitea Release / Upload Android to draft Release (push) Skipped
Gitea Release / Upload Windows to draft Release (push) Skipped
Gitea Release / Verify and publish Release (push) Skipped
52 lines
1.6 KiB
Dart
52 lines
1.6 KiB
Dart
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart'
|
|
show TimelineRulerTimecodeLayout;
|
|
import 'package:drift/drift.dart';
|
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|
|
|
import '../app_database.dart';
|
|
|
|
part 'timeline_ruler_settings_repository.g.dart';
|
|
|
|
abstract interface class TimelineRulerSettingsRepository {
|
|
Future<TimelineRulerTimecodeLayout> load();
|
|
Future<void> save(TimelineRulerTimecodeLayout layout);
|
|
}
|
|
|
|
@Riverpod(keepAlive: true)
|
|
TimelineRulerSettingsRepository timelineRulerSettingsRepository(Ref ref) =>
|
|
DriftTimelineRulerSettingsRepository(ref.watch(appDatabaseProvider));
|
|
|
|
class DriftTimelineRulerSettingsRepository
|
|
implements TimelineRulerSettingsRepository {
|
|
DriftTimelineRulerSettingsRepository(this._database);
|
|
|
|
final AppDatabase _database;
|
|
|
|
@override
|
|
Future<TimelineRulerTimecodeLayout> load() async {
|
|
final row = await (_database.select(
|
|
_database.appearanceConfigurations,
|
|
)..where((table) => table.id.equals(0))).getSingleOrNull();
|
|
return TimelineRulerTimecodeLayout.values.firstWhere(
|
|
(layout) => layout.name == row?.timelineRulerLayout,
|
|
orElse: () => TimelineRulerTimecodeLayout.inline,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Future<void> save(TimelineRulerTimecodeLayout layout) => _database
|
|
.into(_database.appearanceConfigurations)
|
|
.insert(
|
|
AppearanceConfigurationsCompanion.insert(
|
|
id: const Value(0),
|
|
themeMode: 'system',
|
|
timelineRulerLayout: Value(layout.name),
|
|
),
|
|
onConflict: DoUpdate(
|
|
(_) => AppearanceConfigurationsCompanion(
|
|
timelineRulerLayout: Value(layout.name),
|
|
),
|
|
),
|
|
);
|
|
}
|