2022-09-06 16:31:22 -06:00
|
|
|
import 'package:wonders/common_libs.dart';
|
|
|
|
|
2022-09-07 13:28:41 -06:00
|
|
|
class LocaleSwitcher extends StatelessWidget with GetItMixin {
|
2024-02-20 13:56:39 -08:00
|
|
|
LocaleSwitcher({super.key});
|
2022-09-06 16:31:22 -06:00
|
|
|
|
|
|
|
@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');
|
2022-09-08 12:14:28 -06:00
|
|
|
await settingsLogic.changeLocale(newLocale);
|
2022-09-07 13:26:30 -06:00
|
|
|
}
|
|
|
|
|
2024-02-20 13:56:39 -08:00
|
|
|
return AppBtn.from(
|
|
|
|
text: $strings.localeSwapButton, onPressed: handleSwapLocale, padding: EdgeInsets.all($styles.insets.sm));
|
2022-09-06 16:31:22 -06:00
|
|
|
}
|
|
|
|
}
|