Load more added in appointments timeline.

dev_3.3_Floward
haroon amjad 2 years ago
parent 5256d8873f
commit d6dacfb743

@ -1907,4 +1907,5 @@ const Map localizedValues = {
"upcoming": {"en": "Upcoming", "ar": "المواعيد القادمة"}, "upcoming": {"en": "Upcoming", "ar": "المواعيد القادمة"},
"noUpcomingAppointment": {"en": "No upcoming appointments", "ar": "لا توجد مواعيد القادمة"}, "noUpcomingAppointment": {"en": "No upcoming appointments", "ar": "لا توجد مواعيد القادمة"},
"locationTimeoutError": {"en": "Unable to fetch your location, Please try again.", "ar": "غير قادر على جلب موقعك، يرجى المحاولة مرة أخرى."}, "locationTimeoutError": {"en": "Unable to fetch your location, Please try again.", "ar": "غير قادر على جلب موقعك، يرجى المحاولة مرة أخرى."},
"loadMore": {"en": "Load More", "ar": "تحميل المزيد"},
}; };

@ -10,8 +10,11 @@ class MedicalViewModel extends BaseViewModel {
MedicalService _medicalService = locator<MedicalService>(); MedicalService _medicalService = locator<MedicalService>();
List<AppoitmentAllHistoryResultList> get appoitmentAllHistoryResultList => _medicalService.appoitmentAllHistoryResultList; List<AppoitmentAllHistoryResultList> get appoitmentAllHistoryResultList => _medicalService.appoitmentAllHistoryResultList;
List<DoctorScheduleResponse> get getDoctorScheduleList => _medicalService.doctorScheduleResponse; List<DoctorScheduleResponse> get getDoctorScheduleList => _medicalService.doctorScheduleResponse;
List<String> get freeSlots => _medicalService.freeSlots; List<String> get freeSlots => _medicalService.freeSlots;
getAppointmentHistory({bool isForTimeLine = false}) async { getAppointmentHistory({bool isForTimeLine = false}) async {
if (authenticatedUserObject.isLogin) { if (authenticatedUserObject.isLogin) {
setState(ViewState.Busy); setState(ViewState.Busy);

@ -38,6 +38,14 @@ class ProjectViewModel extends BaseViewModel {
dynamic searchvalue; dynamic searchvalue;
bool isLogin = false; bool isLogin = false;
int laserSelectionDuration; int laserSelectionDuration;
bool _isAllAppointmentsLoaded = false;
bool get isAllAppointmentsLoaded => _isAllAppointmentsLoaded;
void setIsAllAppointmentsLoaded(bool value) {
_isAllAppointmentsLoaded = value;
notifyListeners();
}
double _latitude; double _latitude;
double _longitude; double _longitude;

@ -2916,6 +2916,7 @@ class TranslationBase {
String get upcoming => localizedValues["upcoming"][locale.languageCode]; String get upcoming => localizedValues["upcoming"][locale.languageCode];
String get noUpcomingAppointment => localizedValues["noUpcomingAppointment"][locale.languageCode]; String get noUpcomingAppointment => localizedValues["noUpcomingAppointment"][locale.languageCode];
String get locationTimeoutError => localizedValues["locationTimeoutError"][locale.languageCode]; String get locationTimeoutError => localizedValues["locationTimeoutError"][locale.languageCode];
String get loadMore => localizedValues["loadMore"][locale.languageCode];
} }

@ -40,23 +40,16 @@ class _TimeLineViewState extends State<TimeLineView> {
DateObj selectedDateObj = null; DateObj selectedDateObj = null;
final authService = new auth.AuthProvider(); final authService = new auth.AuthProvider();
static const _scrollThreshold = 1.00; ProjectViewModel projectViewModel;
ScrollController _scrollController;
bool isAllAppointmentsLoaded = false;
@override @override
void dispose() { void dispose() {
_scrollController.removeListener(_scrollListener);
_scrollController.dispose();
super.dispose(); super.dispose();
} }
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_scrollController = ScrollController();
_scrollController.addListener(_scrollListener);
dateObjs.add(new DateObj(0, 0, widget.isArabic ? "الكل" : "All")); dateObjs.add(new DateObj(0, 0, widget.isArabic ? "الكل" : "All"));
for (int i = 0; i < widget.medicalViewModel.appoitmentAllHistoryResultList.length; i++) { for (int i = 0; i < widget.medicalViewModel.appoitmentAllHistoryResultList.length; i++) {
tempList.add(widget.medicalViewModel.appoitmentAllHistoryResultList[i]); tempList.add(widget.medicalViewModel.appoitmentAllHistoryResultList[i]);
@ -77,17 +70,6 @@ class _TimeLineViewState extends State<TimeLineView> {
// } // }
} }
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) { applyFilter(bool isAll) {
tempList.clear(); tempList.clear();
if (isAll) { if (isAll) {
@ -110,6 +92,7 @@ class _TimeLineViewState extends State<TimeLineView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
projectViewModel = Provider.of(context);
return Container( return Container(
width: double.infinity, width: double.infinity,
height: 210, height: 210,
@ -192,28 +175,70 @@ class _TimeLineViewState extends State<TimeLineView> {
), ),
mFlex(1), mFlex(1),
widget.isLogged widget.isLogged
? Container( ? Row(
children: [
Container(
height: widget.isArabic ? 130 : 110, height: widget.isArabic ? 130 : 110,
width: double.infinity, // width: double.infinity,
width: MediaQuery.of(context).size.width,
child: ListView.separated( child: ListView.separated(
itemBuilder: (context, index) => Padding( itemBuilder: (context, index) => Padding(
padding: widget.isArabic padding: widget.isArabic
? EdgeInsets.only(left: index == 0 ? 0 : 12, right: (tempList.length - 1) == index ? 0 : 12) ? 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), : EdgeInsets.only(left: index == 0 ? 12 : 0, right: (tempList.length - 1) == index ? 12 : 0),
child: TimelineNewWidget( child: index < tempList.length
? TimelineNewWidget(
appoitmentAllHistoryResul: tempList[index], appoitmentAllHistoryResul: tempList[index],
isLast: tempList.length - 1 == index ? true : false, 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,
), ),
), ),
itemCount: tempList.length, ],
),
mWidth(24.0)
],
),
)
: Container(),
),
itemCount: (tempList.length + 1),
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
shrinkWrap: false, shrinkWrap: false,
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
controller: _scrollController,
separatorBuilder: (BuildContext context, int index) { separatorBuilder: (BuildContext context, int index) {
return mWidth(8); return index < tempList.length ? mWidth(8) : Container();
}, },
), ),
),
],
) )
: Container(), : Container(),
], ],
@ -344,7 +369,7 @@ class TimelineNewWidget extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context);
return Container( 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( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,

@ -338,6 +338,7 @@ class _AppDrawerState extends State<AppDrawer> {
sharedPref.remove(APPOINTMENT_HISTORY_MEDICAL); sharedPref.remove(APPOINTMENT_HISTORY_MEDICAL);
sharedPref.remove(CLINICS_LIST); sharedPref.remove(CLINICS_LIST);
sharedPref.setBool(IS_ROBOT_INIT, null); sharedPref.setBool(IS_ROBOT_INIT, null);
projectProvider.setIsAllAppointmentsLoaded(false);
if (projectProvider.isArabic) { if (projectProvider.isArabic) {
projectProvider.changeLanguage('en'); projectProvider.changeLanguage('en');
locator<GAnalytics>().hamburgerMenu.logMenuItemClick('change language to english'); locator<GAnalytics>().hamburgerMenu.logMenuItemClick('change language to english');
@ -608,6 +609,7 @@ class _AppDrawerState extends State<AppDrawer> {
await sharedPref.clear(); await sharedPref.clear();
await sharedPref.setString(APP_LANGUAGE, appLanguage); await sharedPref.setString(APP_LANGUAGE, appLanguage);
await sharedPref.remove(APPOINTMENT_HISTORY_MEDICAL); await sharedPref.remove(APPOINTMENT_HISTORY_MEDICAL);
projectProvider.setIsAllAppointmentsLoaded(false);
this.user = null; this.user = null;
Navigator.of(context).pushNamed(HOME); Navigator.of(context).pushNamed(HOME);
locator<GAnalytics>().hamburgerMenu.logMenuItemClick('logout'); locator<GAnalytics>().hamburgerMenu.logMenuItemClick('logout');

Loading…
Cancel
Save