diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 6bd06889..f05b94f3 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1907,4 +1907,5 @@ const Map localizedValues = { "upcoming": {"en": "Upcoming", "ar": "المواعيد القادمة"}, "noUpcomingAppointment": {"en": "No upcoming appointments", "ar": "لا توجد مواعيد القادمة"}, "locationTimeoutError": {"en": "Unable to fetch your location, Please try again.", "ar": "غير قادر على جلب موقعك، يرجى المحاولة مرة أخرى."}, + "loadMore": {"en": "Load More", "ar": "تحميل المزيد"}, }; \ No newline at end of file diff --git a/lib/core/viewModels/medical/medical_view_model.dart b/lib/core/viewModels/medical/medical_view_model.dart index bdf40509..a52af93b 100644 --- a/lib/core/viewModels/medical/medical_view_model.dart +++ b/lib/core/viewModels/medical/medical_view_model.dart @@ -10,8 +10,11 @@ class MedicalViewModel extends BaseViewModel { MedicalService _medicalService = locator(); List get appoitmentAllHistoryResultList => _medicalService.appoitmentAllHistoryResultList; + List get getDoctorScheduleList => _medicalService.doctorScheduleResponse; + List get freeSlots => _medicalService.freeSlots; + getAppointmentHistory({bool isForTimeLine = false}) async { if (authenticatedUserObject.isLogin) { setState(ViewState.Busy); @@ -46,5 +49,5 @@ class MedicalViewModel extends BaseViewModel { } else setState(ViewState.Idle); } - //} +//} } diff --git a/lib/core/viewModels/project_view_model.dart b/lib/core/viewModels/project_view_model.dart index aff0faff..684af151 100644 --- a/lib/core/viewModels/project_view_model.dart +++ b/lib/core/viewModels/project_view_model.dart @@ -38,6 +38,14 @@ class ProjectViewModel extends BaseViewModel { dynamic searchvalue; bool isLogin = false; int laserSelectionDuration; + bool _isAllAppointmentsLoaded = false; + + bool get isAllAppointmentsLoaded => _isAllAppointmentsLoaded; + + void setIsAllAppointmentsLoaded(bool value) { + _isAllAppointmentsLoaded = value; + notifyListeners(); + } double _latitude; double _longitude; diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 0dd0c97d..3ab3fa66 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2916,6 +2916,7 @@ class TranslationBase { String get upcoming => localizedValues["upcoming"][locale.languageCode]; String get noUpcomingAppointment => localizedValues["noUpcomingAppointment"][locale.languageCode]; String get locationTimeoutError => localizedValues["locationTimeoutError"][locale.languageCode]; + String get loadMore => localizedValues["loadMore"][locale.languageCode]; } diff --git a/lib/widgets/data_display/medical/time_line_new_widget.dart b/lib/widgets/data_display/medical/time_line_new_widget.dart index a15eecd4..d2f64dfd 100644 --- a/lib/widgets/data_display/medical/time_line_new_widget.dart +++ b/lib/widgets/data_display/medical/time_line_new_widget.dart @@ -40,23 +40,16 @@ class _TimeLineViewState extends State { DateObj selectedDateObj = null; final authService = new auth.AuthProvider(); - static const _scrollThreshold = 1.00; - ScrollController _scrollController; - - bool isAllAppointmentsLoaded = false; + ProjectViewModel projectViewModel; @override void dispose() { - _scrollController.removeListener(_scrollListener); - _scrollController.dispose(); super.dispose(); } @override void initState() { super.initState(); - _scrollController = ScrollController(); - _scrollController.addListener(_scrollListener); dateObjs.add(new DateObj(0, 0, widget.isArabic ? "الكل" : "All")); for (int i = 0; i < widget.medicalViewModel.appoitmentAllHistoryResultList.length; i++) { tempList.add(widget.medicalViewModel.appoitmentAllHistoryResultList[i]); @@ -77,17 +70,6 @@ class _TimeLineViewState extends State { // } } - void _scrollListener() async { - if (_scrollController.offset >= _scrollController.position.maxScrollExtent * _scrollThreshold && !_scrollController.position.outOfRange) { - print('Scroll position is at ${_scrollThreshold * 100}%.'); - if(!isAllAppointmentsLoaded) { - await sharedPref.remove(APPOINTMENT_HISTORY_MEDICAL); - widget.medicalViewModel.getAppointmentHistory(isForTimeLine: false); - isAllAppointmentsLoaded = true; - } - } - } - applyFilter(bool isAll) { tempList.clear(); if (isAll) { @@ -110,6 +92,7 @@ class _TimeLineViewState extends State { @override Widget build(BuildContext context) { + projectViewModel = Provider.of(context); return Container( width: double.infinity, height: 210, @@ -192,28 +175,70 @@ class _TimeLineViewState extends State { ), mFlex(1), widget.isLogged - ? Container( - height: widget.isArabic ? 130 : 110, - width: double.infinity, - child: ListView.separated( - itemBuilder: (context, index) => Padding( - padding: widget.isArabic - ? EdgeInsets.only(left: index == 0 ? 0 : 12, right: (tempList.length - 1) == index ? 0 : 12) - : EdgeInsets.only(left: index == 0 ? 12 : 0, right: (tempList.length - 1) == index ? 12 : 0), - child: TimelineNewWidget( - appoitmentAllHistoryResul: tempList[index], - isLast: tempList.length - 1 == index ? true : false, + ? Row( + children: [ + Container( + height: widget.isArabic ? 130 : 110, + // width: double.infinity, + width: MediaQuery.of(context).size.width, + child: ListView.separated( + itemBuilder: (context, index) => Padding( + padding: widget.isArabic + ? EdgeInsets.only(left: index == 0 ? 0 : 12, right: (tempList.length - 1) == index ? 0 : 12) + : EdgeInsets.only(left: index == 0 ? 12 : 0, right: (tempList.length - 1) == index ? 12 : 0), + child: index < tempList.length + ? TimelineNewWidget( + appoitmentAllHistoryResul: tempList[index], + isLast: tempList.length - 1 == index ? true : false, + ) + : !projectViewModel.isAllAppointmentsLoaded + ? InkWell( + onTap: () async { + await sharedPref.remove(APPOINTMENT_HISTORY_MEDICAL); + widget.medicalViewModel.getAppointmentHistory(isForTimeLine: false); + projectViewModel.setIsAllAppointmentsLoaded(true); + }, + child: Row( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + mHeight(22.0), + Container( + child: Icon( + Icons.arrow_forward_outlined, + color: CustomColors.white, + size: 30, + ), + ), + mHeight(6.0), + Text( + TranslationBase.of(context).loadMore, + style: TextStyle( + color: CustomColors.white, + fontSize: 10, + fontWeight: FontWeight.w600, + letterSpacing: -0.36, + ), + ), + ], + ), + mWidth(24.0) + ], + ), + ) + : Container(), + ), + itemCount: (tempList.length + 1), + scrollDirection: Axis.horizontal, + shrinkWrap: false, + physics: BouncingScrollPhysics(), + separatorBuilder: (BuildContext context, int index) { + return index < tempList.length ? mWidth(8) : Container(); + }, ), ), - itemCount: tempList.length, - scrollDirection: Axis.horizontal, - shrinkWrap: false, - physics: BouncingScrollPhysics(), - controller: _scrollController, - separatorBuilder: (BuildContext context, int index) { - return mWidth(8); - }, - ), + ], ) : Container(), ], @@ -344,7 +369,7 @@ class TimelineNewWidget extends StatelessWidget { Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); return Container( - width: MediaQuery.of(context).size.width / 2.3, + width: isLast ? MediaQuery.of(context).size.width / 3.5 : MediaQuery.of(context).size.width / 2.5, child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, diff --git a/lib/widgets/drawer/app_drawer_widget.dart b/lib/widgets/drawer/app_drawer_widget.dart index bbc1e55f..f16e3cbc 100644 --- a/lib/widgets/drawer/app_drawer_widget.dart +++ b/lib/widgets/drawer/app_drawer_widget.dart @@ -338,6 +338,7 @@ class _AppDrawerState extends State { sharedPref.remove(APPOINTMENT_HISTORY_MEDICAL); sharedPref.remove(CLINICS_LIST); sharedPref.setBool(IS_ROBOT_INIT, null); + projectProvider.setIsAllAppointmentsLoaded(false); if (projectProvider.isArabic) { projectProvider.changeLanguage('en'); locator().hamburgerMenu.logMenuItemClick('change language to english'); @@ -608,6 +609,7 @@ class _AppDrawerState extends State { await sharedPref.clear(); await sharedPref.setString(APP_LANGUAGE, appLanguage); await sharedPref.remove(APPOINTMENT_HISTORY_MEDICAL); + projectProvider.setIsAllAppointmentsLoaded(false); this.user = null; Navigator.of(context).pushNamed(HOME); locator().hamburgerMenu.logMenuItemClick('logout');