feat(01-01): add core infrastructure, localization, and Wave 0 tests
- AppDatabase with schemaVersion 1, in-memory executor for testing - Database provider with @Riverpod(keepAlive: true) - AppTheme with sage green seed ColorScheme and warm surface overrides - ThemeNotifier with SharedPreferences persistence, defaults to system - Full German ARB localization (15 keys) with proper umlauts - Minimal main.dart with ProviderScope placeholder - Drift schema v1 captured via make-migrations - All .g.dart files generated via build_runner - Wave 0 tests: database (3), color scheme (6), theme (3), localization (2) -- 14 total, all passing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
45
lib/core/theme/app_theme.dart
Normal file
45
lib/core/theme/app_theme.dart
Normal file
@@ -0,0 +1,45 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AppTheme {
|
||||
AppTheme._();
|
||||
|
||||
static ThemeData lightTheme() {
|
||||
final colorScheme = ColorScheme.fromSeed(
|
||||
seedColor: const Color(0xFF7A9A6D),
|
||||
brightness: Brightness.light,
|
||||
dynamicSchemeVariant: DynamicSchemeVariant.tonalSpot,
|
||||
).copyWith(
|
||||
surface: const Color(0xFFF5F0E8),
|
||||
surfaceContainerLowest: const Color(0xFFFAF7F2),
|
||||
surfaceContainerLow: const Color(0xFFF2EDE4),
|
||||
surfaceContainer: const Color(0xFFEDE7DC),
|
||||
surfaceContainerHigh: const Color(0xFFE7E0D5),
|
||||
surfaceContainerHighest: const Color(0xFFE0D9CE),
|
||||
);
|
||||
|
||||
return ThemeData(
|
||||
useMaterial3: true,
|
||||
colorScheme: colorScheme,
|
||||
);
|
||||
}
|
||||
|
||||
static ThemeData darkTheme() {
|
||||
final colorScheme = ColorScheme.fromSeed(
|
||||
seedColor: const Color(0xFF7A9A6D),
|
||||
brightness: Brightness.dark,
|
||||
dynamicSchemeVariant: DynamicSchemeVariant.tonalSpot,
|
||||
).copyWith(
|
||||
surface: const Color(0xFF2A2520),
|
||||
surfaceContainerLowest: const Color(0xFF1E1A16),
|
||||
surfaceContainerLow: const Color(0xFF322D27),
|
||||
surfaceContainer: const Color(0xFF3A342E),
|
||||
surfaceContainerHigh: const Color(0xFF433D36),
|
||||
surfaceContainerHighest: const Color(0xFF4D463F),
|
||||
);
|
||||
|
||||
return ThemeData(
|
||||
useMaterial3: true,
|
||||
colorScheme: colorScheme,
|
||||
);
|
||||
}
|
||||
}
|
||||
53
lib/core/theme/theme_provider.dart
Normal file
53
lib/core/theme/theme_provider.dart
Normal file
@@ -0,0 +1,53 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
part 'theme_provider.g.dart';
|
||||
|
||||
const _themeModeKey = 'theme_mode';
|
||||
|
||||
@riverpod
|
||||
class ThemeNotifier extends _$ThemeNotifier {
|
||||
@override
|
||||
ThemeMode build() {
|
||||
_loadPersistedThemeMode();
|
||||
return ThemeMode.system;
|
||||
}
|
||||
|
||||
Future<void> _loadPersistedThemeMode() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final persisted = prefs.getString(_themeModeKey);
|
||||
if (persisted != null) {
|
||||
state = _themeModeFromString(persisted);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setThemeMode(ThemeMode mode) async {
|
||||
state = mode;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString(_themeModeKey, _themeModeToString(mode));
|
||||
}
|
||||
|
||||
static ThemeMode _themeModeFromString(String? value) {
|
||||
switch (value) {
|
||||
case 'light':
|
||||
return ThemeMode.light;
|
||||
case 'dark':
|
||||
return ThemeMode.dark;
|
||||
case 'system':
|
||||
default:
|
||||
return ThemeMode.system;
|
||||
}
|
||||
}
|
||||
|
||||
static String _themeModeToString(ThemeMode mode) {
|
||||
switch (mode) {
|
||||
case ThemeMode.light:
|
||||
return 'light';
|
||||
case ThemeMode.dark:
|
||||
return 'dark';
|
||||
case ThemeMode.system:
|
||||
return 'system';
|
||||
}
|
||||
}
|
||||
}
|
||||
62
lib/core/theme/theme_provider.g.dart
Normal file
62
lib/core/theme/theme_provider.g.dart
Normal file
@@ -0,0 +1,62 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'theme_provider.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(ThemeNotifier)
|
||||
final themeProvider = ThemeNotifierProvider._();
|
||||
|
||||
final class ThemeNotifierProvider
|
||||
extends $NotifierProvider<ThemeNotifier, ThemeMode> {
|
||||
ThemeNotifierProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
retry: null,
|
||||
name: r'themeProvider',
|
||||
isAutoDispose: true,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@override
|
||||
String debugGetCreateSourceHash() => _$themeNotifierHash();
|
||||
|
||||
@$internal
|
||||
@override
|
||||
ThemeNotifier create() => ThemeNotifier();
|
||||
|
||||
/// {@macro riverpod.override_with_value}
|
||||
Override overrideWithValue(ThemeMode value) {
|
||||
return $ProviderOverride(
|
||||
origin: this,
|
||||
providerOverride: $SyncValueProvider<ThemeMode>(value),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _$themeNotifierHash() => r'060f7d104905995da8c785d2f50f15a4db2d7022';
|
||||
|
||||
abstract class _$ThemeNotifier extends $Notifier<ThemeMode> {
|
||||
ThemeMode build();
|
||||
@$mustCallSuper
|
||||
@override
|
||||
void runBuild() {
|
||||
final ref = this.ref as $Ref<ThemeMode, ThemeMode>;
|
||||
final element =
|
||||
ref.element
|
||||
as $ClassProviderElement<
|
||||
AnyNotifier<ThemeMode, ThemeMode>,
|
||||
ThemeMode,
|
||||
Object?,
|
||||
Object?
|
||||
>;
|
||||
element.handleCreate(ref, build);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user