diff --git a/lib/extensions/string_extensions.dart b/lib/extensions/string_extensions.dart index fea613e..a485e2a 100644 --- a/lib/extensions/string_extensions.dart +++ b/lib/extensions/string_extensions.dart @@ -159,10 +159,55 @@ extension FormatDate on String { return "${dates[2]} ${getMonth(int.parse(dates[1]))} ${dates[0]} ${DateFormat('hh:mm a', "en_US").format(DateFormat('hh:mm:ss', "en_US").parse(time))}"; } - String toFormattedDateWithoutTime() { + // String toFormattedDateWithoutTime() { + // String date = split("T")[0]; + // var dates = date.split("-"); + // return "${dates[2]} ${getMonth(int.parse(dates[1]))}, ${dates[0]}"; + // } + + String toFormattedDateWithoutTime({bool isArabic = false}) { String date = split("T")[0]; var dates = date.split("-"); - return "${dates[2]} ${getMonth(int.parse(dates[1]))}, ${dates[0]}"; + + final monthNumber = int.parse(dates[1]); + + final monthsEn = [ + '', + 'January', + 'February', + 'March', + 'April', + 'May', + 'June', + 'July', + 'August', + 'September', + 'October', + 'November', + 'December', + ]; + + final monthsAr = [ + '', + 'يناير', + 'فبراير', + 'مارس', + 'أبريل', + 'مايو', + 'يونيو', + 'يوليو', + 'أغسطس', + 'سبتمبر', + 'أكتوبر', + 'نوفمبر', + 'ديسمبر', + ]; + + final month = isArabic + ? monthsAr[monthNumber] + : monthsEn[monthNumber]; + + return "${dates[2]} $month, ${dates[0]}"; } String toLocalizedFormattedDateWithoutTime(BuildContext context) { diff --git a/lib/views/appointments/appointment_detail_view.dart b/lib/views/appointments/appointment_detail_view.dart index 9bc8fd1..ae992b6 100644 --- a/lib/views/appointments/appointment_detail_view.dart +++ b/lib/views/appointments/appointment_detail_view.dart @@ -294,7 +294,7 @@ class AppointmentDetailView extends StatelessWidget { fit: BoxFit.fill, ), 5.width, - "${appointmentListModel.duration ?? ""} ${appointmentListModel.appointmentDate!.toFormattedDateWithoutTime()}".toText(fontSize: 12, isBold: true, color: MyColors.lightTextColor), + "${appointmentListModel.duration ?? ""} ${appointmentListModel.appointmentDate!.toFormattedDateWithoutTime( isArabic: context.locale.languageCode == 'ar',)}".toText(fontSize: 12, isBold: true, color: MyColors.lightTextColor), ], ), 13.height, diff --git a/lib/views/appointments/widgets/common_appointment_slider_widget.dart b/lib/views/appointments/widgets/common_appointment_slider_widget.dart index 37ed270..6baaaef 100644 --- a/lib/views/appointments/widgets/common_appointment_slider_widget.dart +++ b/lib/views/appointments/widgets/common_appointment_slider_widget.dart @@ -135,7 +135,7 @@ class AppointmentHomeTileWidget extends StatelessWidget { if (appointmentListModel.appointmentServicesList!.length > 1) { servicesList.add( - showServices("+ ${appointmentListModel.appointmentServicesList!.length - 1} More", "", isMoreText: true), + showServices("+ ${appointmentListModel.appointmentServicesList!.length - 1} ${ LocaleKeys.more.tr() }", "", isMoreText: true), ); } return servicesList; @@ -329,7 +329,7 @@ class AppointmentFragmentTileWidget extends StatelessWidget { children: [ MyAssets.miniClock.buildSvg(height: 12), 2.width, - " ${appointmentListModel!.duration ?? ""} ${appointmentListModel!.appointmentDate!.toFormattedDateWithoutTime()}" + " ${appointmentListModel!.duration ?? ""} ${appointmentListModel!.appointmentDate!.toFormattedDateWithoutTime( isArabic: AppState().isArabic(context),)}" .toText(color: MyColors.lightTextColor, fontSize: 12, letterSpacing: -0.48, height: 19 / 12), ], ),