Integrate themed login/signup, EN/RU localization, shared dummy providers, verification recovery screens and named URL routes. Store frontend guidelines, workflow skills, validation and delivery documentation. Related to #2, #3, #5 and #6.
55 lines
1.6 KiB
Dart
55 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../providers/locale.dart';
|
|
|
|
import '../generated/i18n/app_localizations.dart';
|
|
|
|
class LocaleSelector extends StatelessWidget {
|
|
const LocaleSelector({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final provider = context.watch<LocaleProvider>();
|
|
return PopupMenuButton<Locale>(
|
|
key: const ValueKey('locale-selector'),
|
|
tooltip: AppLocalizations.of(context)!.language,
|
|
onSelected: (locale) async {
|
|
final saved = await provider.setLocale(locale);
|
|
if (!saved && context.mounted) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text(AppLocalizations.of(context)!.preferenceNotSaved),
|
|
),
|
|
);
|
|
}
|
|
},
|
|
itemBuilder: (_) => AppLocalizations.supportedLocales
|
|
.map(
|
|
(locale) => CheckedPopupMenuItem(
|
|
value: locale,
|
|
checked: locale == provider.locale,
|
|
child: Text(locale.languageCode == 'ru' ? 'Русский' : 'English'),
|
|
),
|
|
)
|
|
.toList(),
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 14),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const Icon(Icons.language, size: 20),
|
|
const SizedBox(width: 8),
|
|
Text(
|
|
provider.locale.languageCode.toUpperCase(),
|
|
style: Theme.of(context).textTheme.labelLarge,
|
|
),
|
|
const Icon(Icons.expand_more, size: 20),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|