feat: 实现起卦、设置与积分系统

This commit is contained in:
qzl
2026-04-03 16:56:47 +08:00
parent 31594558eb
commit f245eec5f6
170 changed files with 20728 additions and 328 deletions
+19 -3
View File
@@ -10,6 +10,7 @@ import '../features/auth/presentation/bloc/auth_bloc.dart';
import '../features/auth/presentation/bloc/auth_state.dart';
import '../features/auth/presentation/screens/login_screen.dart';
import '../features/home/presentation/screens/home_screen.dart';
import '../features/settings/data/models/profile_settings.dart';
import '../l10n/app_localizations.dart';
import '../shared/widgets/app_loading_indicator.dart';
import 'app_theme.dart';
@@ -26,6 +27,9 @@ class _EryaoAppState extends State<EryaoApp> {
final SessionStore _sessionStore = SessionStore(LocalKvStore());
late final AuthBloc _authBloc;
Locale _locale = const Locale('zh');
ProfileSettingsV1 _profileSettings = ProfileSettingsV1.defaultsForLocale(
const Locale('zh'),
);
@override
void initState() {
@@ -54,21 +58,29 @@ class _EryaoAppState extends State<EryaoApp> {
Future<void> _bootstrap() async {
final localeCode = await _sessionStore.getLocaleCode();
final locale = localeCode == 'en' ? const Locale('en') : const Locale('zh');
if (mounted) {
setState(() {
_locale = localeCode == 'en' ? const Locale('en') : const Locale('zh');
_locale = locale;
_profileSettings = ProfileSettingsV1.defaultsForLocale(locale);
});
}
await _authBloc.start();
}
Future<void> _handleLocaleChanged(Locale locale) async {
Future<void> _handleInterfaceLanguageChanged(String languageTag) async {
final locale = localeFromLanguageTag(languageTag);
await _sessionStore.saveLocaleCode(locale.languageCode);
if (!mounted) {
return;
}
setState(() {
_locale = locale;
_profileSettings = _profileSettings.copyWith(
preferences: _profileSettings.preferences.copyWith(
interfaceLanguage: languageTag,
),
);
});
}
@@ -109,13 +121,17 @@ class _EryaoAppState extends State<EryaoApp> {
return HomeScreen(
account: state.user!.email,
sessionStore: _sessionStore,
currentLocale: _locale,
profileSettings: _profileSettings,
coinBalance: 100,
onLocaleChanged: _handleInterfaceLanguageChanged,
onLogout: _authBloc.logout,
);
}
return LoginScreen(
currentLocale: _locale,
onLocaleChanged: _handleLocaleChanged,
onLocaleChanged: (_) {},
onRequestOtp: _authBloc.sendOtp,
onLoginWithOtp: (email, otp) {
return _authBloc.loginWithOtp(email: email, otp: otp);