import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:provider/provider.dart'; import 'package:sxchnge_wallet/sxchnge_wallet.dart'; import '../providers/locale.dart'; import '../generated/i18n/app_localizations.dart'; class SettingsPage extends StatelessWidget { const SettingsPage({super.key}); @override Widget build(BuildContext context) { final p = context.watch(); final locale = context.watch(); final l = AppLocalizations.of(context)!; final t = Theme.of(context); return SingleChildScrollView( padding: const EdgeInsets.all(24), child: Center( child: ConstrainedBox( constraints: const BoxConstraints(maxWidth: 720), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ if (context.canPop()) Align( alignment: Alignment.centerLeft, child: TextButton.icon( onPressed: () => context.pop(), icon: const Icon(Icons.arrow_back), label: Text(l.kycBack), ), ), Text(l.wPreferences, style: t.textTheme.displayMedium), const SizedBox(height: 28), Card( child: Padding( padding: const EdgeInsets.all(24), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Text(l.wLanguage, style: t.textTheme.titleLarge), const SizedBox(height: 8), Text(l.wLanguageHelp), const SizedBox(height: 20), if (p.profileLoading) const LinearProgressIndicator(), if (p.profileFailed) ...[ Text(l.wProfileError), TextButton( onPressed: () => locale.loadAccount(p), child: Text(l.wRefresh), ), ], DropdownButtonFormField( key: ValueKey( 'account-language-${locale.locale.languageCode}', ), initialValue: locale.locale.languageCode, isExpanded: true, items: const [ DropdownMenuItem(value: 'en', child: Text('English')), DropdownMenuItem(value: 'ru', child: Text('Русский')), ], onChanged: p.saving || p.profileLoading ? null : (value) { if (value != null) { locale.saveAccountLocale(p, Locale(value)); } }, decoration: InputDecoration(labelText: l.wLanguage), ), if (p.saving) const LinearProgressIndicator(), if (p.saveFailed) ...[ const SizedBox(height: 12), Semantics( liveRegion: true, child: Text(l.wLanguageFailed), ), TextButton( onPressed: p.saving ? null : () => locale.saveAccountLocale(p, locale.locale), child: Text(l.wRefresh), ), ], ], ), ), ), const SizedBox(height: 16), Card( child: ListTile( contentPadding: const EdgeInsets.all(24), leading: const Icon(Icons.verified_user_outlined), title: Text(l.wIdentity), subtitle: Text(l.wIdentityHelp), trailing: const Icon(Icons.chevron_right), onTap: () => context.go('/identity'), ), ), const SizedBox(height: 16), Card( child: Padding( padding: const EdgeInsets.all(24), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(l.wSecurity, style: t.textTheme.titleLarge), const SizedBox(height: 12), Text(l.wSecurityBody), ], ), ), ), const SizedBox(height: 20), TextButton( onPressed: () => context.go('/'), child: Text(l.wBackLogin), ), ], ), ), ), ); } }