Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
36 lines
1.1 KiB
Dart
36 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|
|
|
import '../../persistence/settings/appearance_settings_repository.dart';
|
|
import '../../settings/appearance.dart';
|
|
import '../../settings/settings_write_queue.dart';
|
|
|
|
export '../../settings/appearance.dart';
|
|
|
|
part 'appearance_settings.g.dart';
|
|
|
|
extension AppAppearanceTheme on AppAppearance {
|
|
ThemeMode get themeMode => switch (this) {
|
|
AppAppearance.system => ThemeMode.system,
|
|
AppAppearance.penLight => ThemeMode.light,
|
|
AppAppearance.penDark => ThemeMode.dark,
|
|
};
|
|
}
|
|
|
|
@Riverpod(keepAlive: true)
|
|
class AppearanceSettings extends _$AppearanceSettings {
|
|
final _writes = SettingsWriteQueue();
|
|
|
|
@override
|
|
Future<AppAppearance> build() =>
|
|
ref.watch(appearanceSettingsRepositoryProvider).load();
|
|
|
|
Future<void> setMode(AppAppearance appearance) => _writes.run(() async {
|
|
if (!ref.mounted) return;
|
|
await future;
|
|
if (!ref.mounted) return;
|
|
await ref.read(appearanceSettingsRepositoryProvider).save(appearance);
|
|
if (ref.mounted) state = AsyncData(appearance);
|
|
});
|
|
}
|