diff --git a/lib/app_state/app_state.dart b/lib/app_state/app_state.dart index ceb4881..44de36f 100644 --- a/lib/app_state/app_state.dart +++ b/lib/app_state/app_state.dart @@ -73,6 +73,8 @@ class AppState { bool isArabic(context) => EasyLocalization.of(context)?.locale.languageCode == "ar"; + int getLanguageID(context) => EasyLocalization.of(context)?.locale.languageCode == "ar" ? 1 : 2; + String? _username; // todo ''sikander' added password for now, later will remove & improve diff --git a/lib/models/post_params_model.dart b/lib/models/post_params_model.dart index b44bec9..05356c2 100644 --- a/lib/models/post_params_model.dart +++ b/lib/models/post_params_model.dart @@ -1,3 +1,5 @@ +import 'package:mohem_flutter_app/app_state/app_state.dart'; + class PostParamsModel { double? versionID; int? channel; diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 70893ec..476abd1 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -365,7 +365,7 @@ class _DashboardScreenState extends State { ], ), drawer: SafeArea( - child: AppDrawer(), + child: AppDrawer(onLanguageChange: _onRefresh), ), bottomNavigationBar: SizedBox( height: Platform.isAndroid ? 70 : 100, diff --git a/lib/ui/landing/widget/app_drawer.dart b/lib/ui/landing/widget/app_drawer.dart index d828270..67adfcb 100644 --- a/lib/ui/landing/widget/app_drawer.dart +++ b/lib/ui/landing/widget/app_drawer.dart @@ -18,6 +18,10 @@ import 'package:mohem_flutter_app/widgets/dialogs/dialogs.dart'; import 'package:provider/provider.dart'; class AppDrawer extends StatefulWidget { + final Function onLanguageChange; + + AppDrawer({required this.onLanguageChange}); + @override _AppDrawerState createState() => _AppDrawerState(); } @@ -65,6 +69,28 @@ class _AppDrawerState extends State { ).expanded ], ).paddingOnly(left: 14, right: 14, top: 21, bottom: 21), + Row( + children: [ + Row( + children: [ + LocaleKeys.english.tr().toText14(color: AppState().isArabic(context) ? null : MyColors.textMixColor).onPress(() { + context.setLocale(const Locale("en", "US")); + postLanguageChange(context); + }), + Container( + width: 1, + color: MyColors.darkWhiteColor, + height: 16, + margin: const EdgeInsets.only(left: 10, right: 10), + ), + LocaleKeys.arabic.tr().toText14(color: !AppState().isArabic(context) ? null : MyColors.textMixColor).onPress(() { + context.setLocale(const Locale("ar", "SA")); + postLanguageChange(context); + }), + ], + ), + ], + ).paddingOnly(left: 14, right: 14, bottom: 14), const Divider( height: 1, thickness: 1, @@ -132,6 +158,14 @@ class _AppDrawerState extends State { : onPress!); } + void postLanguageChange(BuildContext context) { + var obj = AppState().postParamsObject; + obj?.languageID = EasyLocalization.of(context)?.locale.languageCode == "ar" ? 1 : 2; + AppState().setPostParamsModel(obj!); + Navigator.pop(context); + widget.onLanguageChange(); + } + void performLogout() async { AppState().isAuthenticated = false; AppState().isLogged = false; diff --git a/lib/ui/profile/widgets/profile_panel.dart b/lib/ui/profile/widgets/profile_panel.dart index 2678599..5018171 100644 --- a/lib/ui/profile/widgets/profile_panel.dart +++ b/lib/ui/profile/widgets/profile_panel.dart @@ -49,7 +49,7 @@ class ProfilePanel extends StatelessWidget { width: 68,) : CircleAvatar( radius: 68, - backgroundImage: MemoryImage(Utils.getPostBytes(memberInformationList.eMPLOYEEIMAGE)), + backgroundImage: MemoryImage(Utils.dataFromBase64String(memberInformationList.eMPLOYEEIMAGE!)), backgroundColor: Colors.black, ); }