wonders/lib/ui/common/controls/locale_switcher.dart

17 lines
528 B
Dart
Raw Normal View History

import 'package:wonders/common_libs.dart';
class LocaleSwitcher extends StatelessWidget with GetItMixin {
LocaleSwitcher({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
2022-09-07 13:26:30 -06:00
final locale = watchX((SettingsLogic s) => s.currentLocale);
Future<void> handleSwapLocale() async {
final newLocale = Locale(locale == 'en' ? 'zh' : 'en');
await settingsLogic.changeLocale(newLocale);
2022-09-07 13:26:30 -06:00
}
2022-10-27 10:22:43 -06:00
return AppBtn.from(text: $strings.localeSwapButton, onPressed: handleSwapLocale);
}
}