style: apply dart format across project
This commit is contained in:
@@ -7,24 +7,24 @@ import '../theme/adaptive_theme.dart';
|
||||
class ThemeProvider extends ChangeNotifier {
|
||||
static const String _themeBoxName = 'theme_settings';
|
||||
static const String _themeKey = 'theme_settings';
|
||||
|
||||
|
||||
late Box<Map> _themeBox;
|
||||
ThemeSettings _themeSettings = const ThemeSettings();
|
||||
|
||||
|
||||
ThemeSettings get themeSettings => _themeSettings;
|
||||
|
||||
|
||||
AppThemeMode get themeMode => _themeSettings.mode;
|
||||
bool get useSystemColors => _themeSettings.useSystemColors;
|
||||
bool get largeText => _themeSettings.largeText;
|
||||
bool get reduceMotion => _themeSettings.reduceMotion;
|
||||
bool get highContrast => _themeSettings.highContrast;
|
||||
|
||||
|
||||
/// Provider 초기화
|
||||
Future<void> initialize() async {
|
||||
_themeBox = await Hive.openBox<Map>(_themeBoxName);
|
||||
await _loadThemeSettings();
|
||||
}
|
||||
|
||||
|
||||
/// 저장된 테마 설정 로드
|
||||
Future<void> _loadThemeSettings() async {
|
||||
final savedSettings = _themeBox.get(_themeKey);
|
||||
@@ -35,53 +35,53 @@ class ThemeProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// 테마 설정 저장
|
||||
Future<void> _saveThemeSettings() async {
|
||||
await _themeBox.put(_themeKey, _themeSettings.toJson());
|
||||
}
|
||||
|
||||
|
||||
/// 테마 모드 변경
|
||||
Future<void> setThemeMode(AppThemeMode mode) async {
|
||||
_themeSettings = _themeSettings.copyWith(mode: mode);
|
||||
await _saveThemeSettings();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
/// 시스템 색상 사용 설정
|
||||
Future<void> setUseSystemColors(bool value) async {
|
||||
_themeSettings = _themeSettings.copyWith(useSystemColors: value);
|
||||
await _saveThemeSettings();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
/// 큰 텍스트 설정
|
||||
Future<void> setLargeText(bool value) async {
|
||||
_themeSettings = _themeSettings.copyWith(largeText: value);
|
||||
await _saveThemeSettings();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
/// 모션 감소 설정
|
||||
Future<void> setReduceMotion(bool value) async {
|
||||
_themeSettings = _themeSettings.copyWith(reduceMotion: value);
|
||||
await _saveThemeSettings();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
/// 고대비 설정
|
||||
Future<void> setHighContrast(bool value) async {
|
||||
_themeSettings = _themeSettings.copyWith(highContrast: value);
|
||||
await _saveThemeSettings();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
/// 현재 설정에 따른 테마 가져오기
|
||||
ThemeData getTheme(BuildContext context) {
|
||||
final platformBrightness = MediaQuery.of(context).platformBrightness;
|
||||
|
||||
|
||||
ThemeData baseTheme;
|
||||
|
||||
|
||||
switch (_themeSettings.mode) {
|
||||
case AppThemeMode.light:
|
||||
baseTheme = AdaptiveTheme.lightTheme;
|
||||
@@ -98,7 +98,7 @@ class ThemeProvider extends ChangeNotifier {
|
||||
: AdaptiveTheme.lightTheme;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// 접근성 설정 적용
|
||||
return AdaptiveTheme.getAccessibleTheme(
|
||||
baseTheme,
|
||||
@@ -107,11 +107,11 @@ class ThemeProvider extends ChangeNotifier {
|
||||
highContrast: _themeSettings.highContrast,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/// 현재 테마가 다크 모드인지 확인
|
||||
bool isDarkMode(BuildContext context) {
|
||||
final platformBrightness = MediaQuery.of(context).platformBrightness;
|
||||
|
||||
|
||||
switch (_themeSettings.mode) {
|
||||
case AppThemeMode.light:
|
||||
return false;
|
||||
@@ -122,7 +122,7 @@ class ThemeProvider extends ChangeNotifier {
|
||||
return platformBrightness == Brightness.dark;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// 테마 토글 (라이트/다크)
|
||||
Future<void> toggleTheme() async {
|
||||
if (_themeSettings.mode == AppThemeMode.light) {
|
||||
@@ -137,7 +137,7 @@ class ThemeProvider extends ChangeNotifier {
|
||||
class AnimatedThemeBuilder extends StatelessWidget {
|
||||
final Widget Function(BuildContext, ThemeData) builder;
|
||||
final Duration duration;
|
||||
|
||||
|
||||
const AnimatedThemeBuilder({
|
||||
super.key,
|
||||
required this.builder,
|
||||
@@ -148,7 +148,7 @@ class AnimatedThemeBuilder extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final themeProvider = context.watch<ThemeProvider>();
|
||||
final theme = themeProvider.getTheme(context);
|
||||
|
||||
|
||||
return AnimatedTheme(
|
||||
data: theme,
|
||||
duration: duration,
|
||||
@@ -164,7 +164,7 @@ class ThemedColor extends StatelessWidget {
|
||||
final Color lightColor;
|
||||
final Color darkColor;
|
||||
final Widget child;
|
||||
|
||||
|
||||
const ThemedColor({
|
||||
super.key,
|
||||
required this.lightColor,
|
||||
@@ -175,7 +175,7 @@ class ThemedColor extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isDark = context.read<ThemeProvider>().isDarkMode(context);
|
||||
|
||||
|
||||
return Theme(
|
||||
data: Theme.of(context).copyWith(
|
||||
primaryColor: isDark ? darkColor : lightColor,
|
||||
@@ -183,4 +183,4 @@ class ThemedColor extends StatelessWidget {
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user