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 {
|
|
|
|
LocaleSwitcher({Key? key}) : super(key: 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');
|
|
|
|
await settingsLogic.setLocale(newLocale);
|
|
|
|
}
|
|
|
|
|
|
|
|
return AppBtn.from(
|
|
|
|
padding: EdgeInsets.symmetric(vertical: $styles.insets.sm, horizontal: $styles.insets.sm),
|
|
|
|
text: $strings.localeSwapButton,
|
|
|
|
onPressed: handleSwapLocale);
|
2022-09-06 16:31:22 -06:00
|
|
|
}
|
|
|
|
}
|