This commit is contained in:
2025-11-26 18:10:10 +09:00
parent 283f08786e
commit bf40c42c2c
43 changed files with 4454 additions and 971 deletions
+19 -18
View File
@@ -29,7 +29,8 @@ class SettingsNotifier with ChangeNotifier {
static const String _keyThemeColor = 'theme_color';
static const String _keyDarkMode = 'is_dark_mode';
static const String _keyFontScale = 'font_scale';
static const String _keyProfileImage = 'profile_image_base64'; // [추가] 키
static const String _keyProfileImage = 'profile_image_base64';
static const String _keyShowDebug = 'show_debug_log'; // [추가] 키
// --- 상태 변수 (State) ---
@@ -37,8 +38,9 @@ class SettingsNotifier with ChangeNotifier {
int _avatarIndex = 0;
String _themeColorName = 'Blue';
bool _isDarkMode = false;
double _fontScale = 1.0; // 1.0 = 기본, 0.8 = 작게, 1.5 = 크게
String? _profileImageBase64; // [추가] 상태 변수
double _fontScale = 1.0;
String? _profileImageBase64;
bool _isShowDebugLog = false; // [추가] 디버그 로그 표시 여부 (기본값 false)
// --- Getters ---
String get nickname => _nickname;
@@ -46,11 +48,11 @@ class SettingsNotifier with ChangeNotifier {
String get themeColorName => _themeColorName;
bool get isDarkMode => _isDarkMode;
double get fontScale => _fontScale;
String? get profileImageBase64 => _profileImageBase64; // Getter 추가
String? get profileImageBase64 => _profileImageBase64;
bool get isShowDebugLog => _isShowDebugLog; // [추가] Getter
MaterialColor get currentColor => appColors[_themeColorName] ?? Colors.blue;
// 테마 데이터 생성 (Main에서 사용)
ThemeData get currentTheme {
final base = ThemeData(
useMaterial3: true,
@@ -60,8 +62,6 @@ class SettingsNotifier with ChangeNotifier {
),
brightness: _isDarkMode ? Brightness.dark : Brightness.light,
);
// 폰트 사이즈 적용 안된 버전 반환 (TextTheme은 Builder에서 MediaQuery로 적용하는 게 더 깔끔함)
return base;
}
@@ -76,12 +76,11 @@ class SettingsNotifier with ChangeNotifier {
_themeColorName = prefs.getString(_keyThemeColor) ?? 'Blue';
_isDarkMode = prefs.getBool(_keyDarkMode) ?? false;
_fontScale = prefs.getDouble(_keyFontScale) ?? 1.0;
_profileImageBase64 = prefs.getString(_keyProfileImage); // 로드
_profileImageBase64 = prefs.getString(_keyProfileImage);
_isShowDebugLog = prefs.getBool(_keyShowDebug) ?? false; // [추가] 로드
notifyListeners();
}
// 프로필 설정
// [수정] 프로필 텍스트/인덱스 설정
Future<void> setProfile(String nick, int avatarIdx) async {
_nickname = nick;
_avatarIndex = avatarIdx;
@@ -91,15 +90,13 @@ class SettingsNotifier with ChangeNotifier {
await prefs.setInt(_keyAvatarIdx, avatarIdx);
}
// [추가] 프로필 이미지 설정 (500x500 리사이징)
Future<void> pickProfileImage() async {
final picker = ImagePicker();
// maxWidth/maxHeight를 지정하면 알아서 리사이징 해줌 (비율 유지)
final XFile? image = await picker.pickImage(
source: ImageSource.gallery,
maxWidth: 500,
maxHeight: 500,
imageQuality: 70, // 용량 최적화
imageQuality: 70,
);
if (image != null) {
@@ -114,7 +111,6 @@ class SettingsNotifier with ChangeNotifier {
}
}
// [추가] 프로필 이미지 삭제 (기본 아바타로 복귀)
Future<void> clearProfileImage() async {
_profileImageBase64 = null;
notifyListeners();
@@ -122,7 +118,6 @@ class SettingsNotifier with ChangeNotifier {
await prefs.remove(_keyProfileImage);
}
// 테마 색상 설정
Future<void> setThemeColor(String colorName) async {
if (!appColors.containsKey(colorName)) return;
_themeColorName = colorName;
@@ -131,7 +126,6 @@ class SettingsNotifier with ChangeNotifier {
await prefs.setString(_keyThemeColor, colorName);
}
// 다크 모드 토글
Future<void> toggleDarkMode(bool value) async {
_isDarkMode = value;
notifyListeners();
@@ -139,11 +133,18 @@ class SettingsNotifier with ChangeNotifier {
await prefs.setBool(_keyDarkMode, value);
}
// 폰트 크기 설정
Future<void> setFontScale(double scale) async {
_fontScale = scale.clamp(0.8, 2.0); // 최소 0.8배 ~ 최대 2.0배 제한
_fontScale = scale.clamp(0.8, 2.0);
notifyListeners();
final prefs = await SharedPreferences.getInstance();
await prefs.setDouble(_keyFontScale, _fontScale);
}
// [추가] 디버그 로그 토글 함수
Future<void> toggleDebugLog(bool value) async {
_isShowDebugLog = value;
notifyListeners();
final prefs = await SharedPreferences.getInstance();
await prefs.setBool(_keyShowDebug, value);
}
}