Add app source and tests
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
23
lib/Peach/configs/ThemeController.dart
Normal file
23
lib/Peach/configs/ThemeController.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// App-wide theme mode. `main.dart` listens to this and rebuilds MaterialApp;
|
||||
/// any screen can set it. Persisting the choice is the ViewModel's job — this
|
||||
/// only carries the live value.
|
||||
class ThemeController {
|
||||
ThemeController._();
|
||||
|
||||
static final ValueNotifier<ThemeMode> mode = ValueNotifier<ThemeMode>(
|
||||
ThemeMode.dark,
|
||||
);
|
||||
|
||||
/// The stored string ('dark' | 'light' | 'system') for the current mode.
|
||||
static String get name => mode.value.name;
|
||||
|
||||
static void apply(String stored) {
|
||||
mode.value = switch (stored) {
|
||||
'light' => ThemeMode.light,
|
||||
'system' => ThemeMode.system,
|
||||
_ => ThemeMode.dark,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user