12/24/1
This commit is contained in:
@@ -8,73 +8,82 @@ import '../themes/themes.dart';
|
||||
class LocaleController extends GetxController {
|
||||
Locale? language;
|
||||
String countryCode = '';
|
||||
void restartApp() {
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
ThemeData appTheme = themeEnglish;
|
||||
ThemeData appTheme = lightThemeEnglish;
|
||||
|
||||
changeLang(String langcode) {
|
||||
void changeLang(String langcode) {
|
||||
Locale locale;
|
||||
switch (langcode) {
|
||||
case "ar":
|
||||
locale = const Locale("ar");
|
||||
appTheme = themeArabic;
|
||||
appTheme = lightThemeArabic;
|
||||
box.write(BoxName.lang, 'ar');
|
||||
break;
|
||||
case "en":
|
||||
locale = const Locale("en");
|
||||
appTheme = themeEnglish;
|
||||
appTheme = lightThemeEnglish;
|
||||
box.write(BoxName.lang, 'en');
|
||||
break;
|
||||
case "tr":
|
||||
locale = const Locale("tr");
|
||||
appTheme = themeEnglish;
|
||||
appTheme = lightThemeEnglish;
|
||||
box.write(BoxName.lang, 'tr');
|
||||
break;
|
||||
case "fr":
|
||||
locale = const Locale("fr");
|
||||
appTheme = themeEnglish;
|
||||
appTheme = lightThemeEnglish;
|
||||
box.write(BoxName.lang, 'fr');
|
||||
break;
|
||||
case "it":
|
||||
locale = const Locale("it");
|
||||
appTheme = themeEnglish;
|
||||
appTheme = lightThemeEnglish;
|
||||
box.write(BoxName.lang, 'it');
|
||||
break;
|
||||
case "de":
|
||||
locale = const Locale("de");
|
||||
appTheme = themeEnglish;
|
||||
appTheme = lightThemeEnglish;
|
||||
box.write(BoxName.lang, 'de');
|
||||
break;
|
||||
case "el":
|
||||
locale = const Locale("el");
|
||||
appTheme = themeEnglish;
|
||||
appTheme = lightThemeEnglish;
|
||||
box.write(BoxName.lang, 'el');
|
||||
break;
|
||||
case "es":
|
||||
locale = const Locale("es");
|
||||
appTheme = themeEnglish;
|
||||
appTheme = lightThemeEnglish;
|
||||
box.write(BoxName.lang, 'es');
|
||||
break;
|
||||
case "fa":
|
||||
locale = const Locale("fa");
|
||||
appTheme = themeArabic;
|
||||
appTheme = lightThemeEnglish;
|
||||
box.write(BoxName.lang, 'fa');
|
||||
break;
|
||||
case "zh":
|
||||
locale = const Locale("zh");
|
||||
appTheme = themeEnglish;
|
||||
appTheme = lightThemeEnglish;
|
||||
box.write(BoxName.lang, 'zh');
|
||||
break;
|
||||
case "ru":
|
||||
locale = const Locale("ru");
|
||||
appTheme = themeEnglish;
|
||||
appTheme = lightThemeEnglish;
|
||||
box.write(BoxName.lang, 'ru');
|
||||
break;
|
||||
case "hi":
|
||||
locale = const Locale("hi");
|
||||
appTheme = themeEnglish;
|
||||
appTheme = lightThemeEnglish;
|
||||
box.write(BoxName.lang, 'hi');
|
||||
break;
|
||||
default:
|
||||
locale = Locale(Get.deviceLocale!.languageCode);
|
||||
appTheme = themeEnglish;
|
||||
box.write(BoxName.lang, Get.deviceLocale!.languageCode);
|
||||
appTheme = lightThemeEnglish;
|
||||
break;
|
||||
}
|
||||
|
||||
box.write(BoxName.lang, langcode);
|
||||
Get.changeTheme(appTheme);
|
||||
Get.updateLocale(locale);
|
||||
restartApp();
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -88,7 +97,94 @@ class LocaleController extends GetxController {
|
||||
}
|
||||
|
||||
changeLang(storedLang);
|
||||
|
||||
super.onInit();
|
||||
}
|
||||
}
|
||||
|
||||
// class LocaleController extends GetxController {
|
||||
// Locale? language;
|
||||
// String countryCode = '';
|
||||
// void restartApp() {
|
||||
// runApp(const MyApp());
|
||||
// }
|
||||
|
||||
// ThemeData appTheme = themeEnglish;
|
||||
|
||||
// changeLang(String langcode) {
|
||||
// Locale locale;
|
||||
// switch (langcode) {
|
||||
// case "ar":
|
||||
// locale = const Locale("ar");
|
||||
// appTheme = themeArabic;
|
||||
// break;
|
||||
// case "en":
|
||||
// locale = const Locale("en");
|
||||
// appTheme = themeEnglish;
|
||||
// break;
|
||||
// case "tr":
|
||||
// locale = const Locale("tr");
|
||||
// appTheme = themeEnglish;
|
||||
// break;
|
||||
// case "fr":
|
||||
// locale = const Locale("fr");
|
||||
// appTheme = themeEnglish;
|
||||
// break;
|
||||
// case "it":
|
||||
// locale = const Locale("it");
|
||||
// appTheme = themeEnglish;
|
||||
// break;
|
||||
// case "de":
|
||||
// locale = const Locale("de");
|
||||
// appTheme = themeEnglish;
|
||||
// break;
|
||||
// case "el":
|
||||
// locale = const Locale("el");
|
||||
// appTheme = themeEnglish;
|
||||
// break;
|
||||
// case "es":
|
||||
// locale = const Locale("es");
|
||||
// appTheme = themeEnglish;
|
||||
// break;
|
||||
// case "fa":
|
||||
// locale = const Locale("fa");
|
||||
// appTheme = themeArabic;
|
||||
// break;
|
||||
// case "zh":
|
||||
// locale = const Locale("zh");
|
||||
// appTheme = themeEnglish;
|
||||
// break;
|
||||
// case "ru":
|
||||
// locale = const Locale("ru");
|
||||
// appTheme = themeEnglish;
|
||||
// break;
|
||||
// case "hi":
|
||||
// locale = const Locale("hi");
|
||||
// appTheme = themeEnglish;
|
||||
// break;
|
||||
// default:
|
||||
// locale = Locale(Get.deviceLocale!.languageCode);
|
||||
// appTheme = themeEnglish;
|
||||
// break;
|
||||
// }
|
||||
|
||||
// box.write(BoxName.lang, langcode);
|
||||
// Get.changeTheme(appTheme);
|
||||
// Get.updateLocale(locale);
|
||||
// restartApp();
|
||||
// update();
|
||||
// }
|
||||
|
||||
// @override
|
||||
// void onInit() {
|
||||
// String? storedLang = box.read(BoxName.lang);
|
||||
// if (storedLang == null) {
|
||||
// // Use device language if no language is stored
|
||||
// storedLang = Get.deviceLocale!.languageCode;
|
||||
// box.write(BoxName.lang, storedLang);
|
||||
// }
|
||||
|
||||
// changeLang(storedLang);
|
||||
|
||||
// super.onInit();
|
||||
// }
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user