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": "المواعيد القادمة"},
"noUpcomingAppointment": {"en": "No upcoming appointments", "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>();
List<AppoitmentAllHistoryResultList> get appoitmentAllHistoryResultList => _medicalService.appoitmentAllHistoryResultList;
List<DoctorScheduleResponse> get getDoctorScheduleList => _medicalService.doctorScheduleResponse;
List<String> 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);
}
//}
//}
}

@ -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;

@ -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];
}

@ -40,23 +40,16 @@ class _TimeLineViewState extends State<TimeLineView> {
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<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) {
tempList.clear();
if (isAll) {
@ -110,6 +92,7 @@ class _TimeLineViewState extends State<TimeLineView> {
@override
Widget build(BuildContext context) {
projectViewModel = Provider.of(context);
return Container(
width: double.infinity,
height: 210,
@ -192,28 +175,70 @@ class _TimeLineViewState extends State<TimeLineView> {
),
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,

@ -338,6 +338,7 @@ class _AppDrawerState extends State<AppDrawer> {
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<GAnalytics>().hamburgerMenu.logMenuItemClick('change language to english');
@ -608,6 +609,7 @@ class _AppDrawerState extends State<AppDrawer> {
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<GAnalytics>().hamburgerMenu.logMenuItemClick('logout');

Loading…
Cancel
Save