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 cf14b3a..476abd1 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -169,11 +169,14 @@ class _DashboardScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ 9.height, - CountdownTimer( - endTime: model.endTime, - onEnd: null, - endWidget: "00:00:00".toText14(color: Colors.white, isBold: true), - textStyle: const TextStyle(color: Colors.white, fontSize: 14, letterSpacing: -0.48, fontWeight: FontWeight.bold), + Directionality( + textDirection: TextDirection.ltr, + child: CountdownTimer( + endTime: model.endTime, + onEnd: null, + endWidget: "00:00:00".toText14(color: Colors.white, isBold: true), + textStyle: const TextStyle(color: Colors.white, fontSize: 14, letterSpacing: -0.48, fontWeight: FontWeight.bold), + ), ), LocaleKeys.timeLeftToday.tr().toText12(color: Colors.white), 9.height, @@ -206,16 +209,18 @@ class _DashboardScreenState extends State { .toText14(color: Colors.white, isBold: true), 4.height, ], - ).paddingOnly(left: 12), + ).paddingOnly(left: 12, right: 12), ), Container( + margin: EdgeInsets.only(top: AppState().isArabic(context) ? 6 : 0), width: 45, height: 45, padding: const EdgeInsets.only(left: 14, right: 14), - decoration: const BoxDecoration( + decoration: BoxDecoration( color: Color(0xff259EA4), borderRadius: BorderRadius.only( - bottomRight: Radius.circular(15), + bottomRight: AppState().isArabic(context) ? Radius.circular(0) : Radius.circular(15), + bottomLeft: AppState().isArabic(context) ? Radius.circular(15) : Radius.circular(0), ), ), child: SvgPicture.asset(model.isTimeRemainingInSeconds == 0 ? "assets/images/play.svg" : "assets/images/stop.svg"), @@ -360,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/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index 81cfe0f..e1c58c2 100644 --- a/lib/ui/leave_balance/add_leave_balance_screen.dart +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -175,7 +175,7 @@ class _AddLeaveBalanceScreenState extends State { 12.height, DynamicTextFieldWidget( LocaleKeys.startDateT.tr() + "*", - startDateTime == null ? "Select date" : startDateTime.toString().split(' ')[0], + startDateTime == null ? LocaleKeys.pleaseSelectDate.tr() : startDateTime.toString().split(' ')[0], suffixIconData: Icons.calendar_today, isEnable: false, onTap: () async { @@ -189,7 +189,7 @@ class _AddLeaveBalanceScreenState extends State { 12.height, DynamicTextFieldWidget( LocaleKeys.endDateT.tr() + "*", - endDateTime == null ? "Select date" : endDateTime.toString().split(' ')[0], + endDateTime == null ? LocaleKeys.pleaseSelectDate.tr() : endDateTime.toString().split(' ')[0], suffixIconData: Icons.calendar_today, isEnable: false, isReadOnly: selectedAbsenceType == null || startDateTime == null, @@ -206,7 +206,7 @@ class _AddLeaveBalanceScreenState extends State { 12.height, DynamicTextFieldWidget( LocaleKeys.totalDays.tr(), - totalDays?.toString() ?? "Calculated days", + totalDays?.toString() ?? LocaleKeys.calculatedDays.tr(), isInputTypeNum: true, isEnable: false, onChange: (input) { diff --git a/lib/ui/my_team/employee_details.dart b/lib/ui/my_team/employee_details.dart index 3b65954..e33dad8 100644 --- a/lib/ui/my_team/employee_details.dart +++ b/lib/ui/my_team/employee_details.dart @@ -73,7 +73,7 @@ class _EmployeeDetailsState extends State { Container( height: 200, margin: EdgeInsets.only(top: 30), - decoration: BoxDecoration(image: DecorationImage(image: MemoryImage(Utils.getPostBytes(getEmployeeSubordinates!.eMPLOYEEIMAGE)), fit: BoxFit.cover)), + decoration: BoxDecoration(image: DecorationImage(image: MemoryImage(Utils.dataFromBase64String(getEmployeeSubordinates!.eMPLOYEEIMAGE!)), fit: BoxFit.cover)), child: new BackdropFilter( filter: new ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), child: new Container( diff --git a/lib/ui/my_team/my_team.dart b/lib/ui/my_team/my_team.dart index bbdce84..6e83972 100644 --- a/lib/ui/my_team/my_team.dart +++ b/lib/ui/my_team/my_team.dart @@ -141,7 +141,7 @@ class _MyTeamState extends State { width: 34, child: CircleAvatar( radius: 25, - backgroundImage: MemoryImage(Utils.getPostBytes(getEmployeeSListOnSearch[index].eMPLOYEEIMAGE)), + backgroundImage: MemoryImage(Utils.dataFromBase64String(getEmployeeSListOnSearch[index].eMPLOYEEIMAGE!)), backgroundColor: Colors.black, ).paddingOnly(top: 4), ), diff --git a/lib/ui/my_team/team_members.dart b/lib/ui/my_team/team_members.dart index 7ba015f..50bf7e7 100644 --- a/lib/ui/my_team/team_members.dart +++ b/lib/ui/my_team/team_members.dart @@ -85,7 +85,7 @@ class _TeamMembersState extends State { width: 34, child: CircleAvatar( radius: 25, - backgroundImage: MemoryImage(Utils.getPostBytes(getEmployeeSubordinatesList[index].eMPLOYEEIMAGE)), + backgroundImage: MemoryImage(Utils.dataFromBase64String(getEmployeeSubordinatesList[index].eMPLOYEEIMAGE!)), backgroundColor: Colors.black, ).paddingOnly(top: 4), ), diff --git a/lib/ui/profile/profile_screen.dart b/lib/ui/profile/profile_screen.dart index e72d3a9..690633b 100644 --- a/lib/ui/profile/profile_screen.dart +++ b/lib/ui/profile/profile_screen.dart @@ -50,7 +50,7 @@ class _ProfileScreenState extends State { decoration: BoxDecoration( image: DecorationImage( image: MemoryImage( - Utils.getPostBytes(memberInformationList.eMPLOYEEIMAGE), + Utils.dataFromBase64String(memberInformationList.eMPLOYEEIMAGE!), ), fit: BoxFit.cover), ), 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, ); }