feat(settings): 설정 화면 및 저장소 추가
- SettingsScreen 구현 (테마, 언어, 사운드, 애니메이션 속도) - SettingsRepository에 BGM/SFX 볼륨, 애니메이션 속도 저장 추가 - 설정 관련 l10n 텍스트 추가 (한/영/일)
This commit is contained in:
@@ -3,10 +3,13 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
/// 앱 설정 저장소 (SharedPreferences 기반)
|
||||
///
|
||||
/// 테마, 언어 등 사용자 설정을 로컬에 저장
|
||||
/// 테마, 언어, 사운드 등 사용자 설정을 로컬에 저장
|
||||
class SettingsRepository {
|
||||
static const _keyThemeMode = 'theme_mode';
|
||||
static const _keyLocale = 'locale';
|
||||
static const _keyBgmVolume = 'bgm_volume';
|
||||
static const _keySfxVolume = 'sfx_volume';
|
||||
static const _keyAnimationSpeed = 'animation_speed';
|
||||
|
||||
SharedPreferences? _prefs;
|
||||
|
||||
@@ -49,4 +52,40 @@ class SettingsRepository {
|
||||
await init();
|
||||
return _prefs!.getString(_keyLocale);
|
||||
}
|
||||
|
||||
/// BGM 볼륨 저장 (0.0 ~ 1.0)
|
||||
Future<void> saveBgmVolume(double volume) async {
|
||||
await init();
|
||||
await _prefs!.setDouble(_keyBgmVolume, volume.clamp(0.0, 1.0));
|
||||
}
|
||||
|
||||
/// BGM 볼륨 불러오기 (기본값: 0.7)
|
||||
Future<double> loadBgmVolume() async {
|
||||
await init();
|
||||
return _prefs!.getDouble(_keyBgmVolume) ?? 0.7;
|
||||
}
|
||||
|
||||
/// SFX 볼륨 저장 (0.0 ~ 1.0)
|
||||
Future<void> saveSfxVolume(double volume) async {
|
||||
await init();
|
||||
await _prefs!.setDouble(_keySfxVolume, volume.clamp(0.0, 1.0));
|
||||
}
|
||||
|
||||
/// SFX 볼륨 불러오기 (기본값: 0.8)
|
||||
Future<double> loadSfxVolume() async {
|
||||
await init();
|
||||
return _prefs!.getDouble(_keySfxVolume) ?? 0.8;
|
||||
}
|
||||
|
||||
/// 애니메이션 속도 저장 (0.5 ~ 2.0, 1.0이 기본)
|
||||
Future<void> saveAnimationSpeed(double speed) async {
|
||||
await init();
|
||||
await _prefs!.setDouble(_keyAnimationSpeed, speed.clamp(0.5, 2.0));
|
||||
}
|
||||
|
||||
/// 애니메이션 속도 불러오기 (기본값: 1.0)
|
||||
Future<double> loadAnimationSpeed() async {
|
||||
await init();
|
||||
return _prefs!.getDouble(_keyAnimationSpeed) ?? 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user