You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.8 KiB
Dart
63 lines
1.8 KiB
Dart
|
1 month ago
|
import 'package:flutter/material.dart';
|
||
|
|
import 'package:get/get.dart';
|
||
|
|
|
||
|
|
import '../../../core/constants/app_contants.dart';
|
||
|
|
import '../../../core/local_stoarge/app_storage.dart';
|
||
|
|
import '../../../custom_widgets/custom_dialog.dart';
|
||
|
|
import '../../../routes/app_pages.dart';
|
||
|
|
|
||
|
|
|
||
|
|
class AppSettingController extends GetxController {
|
||
|
|
static bool isDarkMode = false;
|
||
|
|
static RxBool isRTL = false.obs;
|
||
|
|
static RxString selectedLocale = "en".obs;
|
||
|
|
|
||
|
|
// LocaleController localeController = LocaleController();
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
updateLanguage(Locale locale) async {
|
||
|
|
Get.updateLocale(locale);
|
||
|
|
// Get.find<LocaleController>().saveLocale(locale.toString());
|
||
|
|
// localeController.selectedLocale.value = locale.toString();
|
||
|
|
AppSettingController.isRTL.value = Get.locale!.languageCode == "ar" || Get.locale!.languageCode == "ur";
|
||
|
|
AppSettingController.selectedLocale.value = Get.locale!.languageCode;
|
||
|
|
await AppStorage.putString(AppConstants.SELECTED_LOCALE, AppSettingController.selectedLocale.value);
|
||
|
|
await AppStorage.putBoolean(AppConstants.IS_RTL, AppSettingController.isRTL.value);
|
||
|
|
Get.forceAppUpdate();
|
||
|
|
update();
|
||
|
|
}
|
||
|
|
|
||
|
|
@override
|
||
|
|
void onInit() {
|
||
|
|
super.onInit();
|
||
|
|
}
|
||
|
|
|
||
|
|
void changeAppMode(bool value) async {
|
||
|
|
AppStorage.putBoolean(AppConstants.IS_DARK_MODE, value);
|
||
|
|
isDarkMode = value;
|
||
|
|
}
|
||
|
|
|
||
|
|
void showLogoutDialog(BuildContext context) {
|
||
|
|
CustomDialog.showLogoutDialog(
|
||
|
|
context: context,
|
||
|
|
onTapPositive: () {
|
||
|
|
Navigator.of(context, rootNavigator: true).pop();
|
||
|
|
Get.offAllNamed(Routes.LOGIN_SCREEN);
|
||
|
|
},
|
||
|
|
onTapNegative: () {
|
||
|
|
Navigator.of(context, rootNavigator: true).pop();
|
||
|
|
},
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
class AppSettings {
|
||
|
|
String title;
|
||
|
|
String description;
|
||
|
|
Icon icon;
|
||
|
|
Function() onTap;
|
||
|
|
|
||
|
|
AppSettings({required this.title, required this.description, required this.icon, required this.onTap});
|
||
|
|
}
|