|
|
|
|
@ -2,6 +2,7 @@ import 'package:auto_size_text/auto_size_text.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/analytics/google-analytics.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/config/config.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/medical/medical_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart';
|
|
|
|
|
@ -25,8 +26,9 @@ import 'package:provider/provider.dart';
|
|
|
|
|
class TimeLineView extends StatefulWidget {
|
|
|
|
|
bool isLogged, isArabic;
|
|
|
|
|
List<AppoitmentAllHistoryResultList> appoitmentAllHistoryResultList;
|
|
|
|
|
MedicalViewModel medicalViewModel;
|
|
|
|
|
|
|
|
|
|
TimeLineView(this.isLogged, this.isArabic, this.appoitmentAllHistoryResultList);
|
|
|
|
|
TimeLineView(this.isLogged, this.isArabic, this.appoitmentAllHistoryResultList, this.medicalViewModel);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_TimeLineViewState createState() => _TimeLineViewState();
|
|
|
|
|
@ -38,17 +40,31 @@ class _TimeLineViewState extends State<TimeLineView> {
|
|
|
|
|
DateObj selectedDateObj = null;
|
|
|
|
|
final authService = new auth.AuthProvider();
|
|
|
|
|
|
|
|
|
|
static const _scrollThreshold = 1.00;
|
|
|
|
|
ScrollController _scrollController;
|
|
|
|
|
|
|
|
|
|
bool isAllAppointmentsLoaded = false;
|
|
|
|
|
|
|
|
|
|
@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.appoitmentAllHistoryResultList.length; i++) {
|
|
|
|
|
tempList.add(widget.appoitmentAllHistoryResultList[i]);
|
|
|
|
|
for (int i = 0; i < widget.medicalViewModel.appoitmentAllHistoryResultList.length; i++) {
|
|
|
|
|
tempList.add(widget.medicalViewModel.appoitmentAllHistoryResultList[i]);
|
|
|
|
|
dateObjs.add(new DateObj(
|
|
|
|
|
DateUtil.convertStringToDate(widget.appoitmentAllHistoryResultList[i].appointmentDate).month,
|
|
|
|
|
DateUtil.convertStringToDate(widget.appoitmentAllHistoryResultList[i].appointmentDate).year,
|
|
|
|
|
DateUtil.convertStringToDate(widget.medicalViewModel.appoitmentAllHistoryResultList[i].appointmentDate).month,
|
|
|
|
|
DateUtil.convertStringToDate(widget.medicalViewModel.appoitmentAllHistoryResultList[i].appointmentDate).year,
|
|
|
|
|
DateUtil.getMonthYearLangDateFormatted(
|
|
|
|
|
DateUtil.convertStringToDate(widget.appoitmentAllHistoryResultList[i].appointmentDate),
|
|
|
|
|
DateUtil.convertStringToDate(widget.medicalViewModel.appoitmentAllHistoryResultList[i].appointmentDate),
|
|
|
|
|
widget.isArabic ? "ar" : "en",
|
|
|
|
|
)));
|
|
|
|
|
}
|
|
|
|
|
@ -61,20 +77,31 @@ 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) {
|
|
|
|
|
for (int i = 0; i < widget.appoitmentAllHistoryResultList.length; i++) {
|
|
|
|
|
tempList.add(widget.appoitmentAllHistoryResultList[i]);
|
|
|
|
|
for (int i = 0; i < widget.medicalViewModel.appoitmentAllHistoryResultList.length; i++) {
|
|
|
|
|
tempList.add(widget.medicalViewModel.appoitmentAllHistoryResultList[i]);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
for (int i = 0; i < widget.appoitmentAllHistoryResultList.length; i++) {
|
|
|
|
|
for (int i = 0; i < widget.medicalViewModel.appoitmentAllHistoryResultList.length; i++) {
|
|
|
|
|
if (DateUtil.getMonthYearLangDateFormatted(
|
|
|
|
|
DateUtil.convertStringToDate(widget.appoitmentAllHistoryResultList[i].appointmentDate),
|
|
|
|
|
DateUtil.convertStringToDate(widget.medicalViewModel.appoitmentAllHistoryResultList[i].appointmentDate),
|
|
|
|
|
widget.isArabic ? "ar" : "en",
|
|
|
|
|
) ==
|
|
|
|
|
selectedDateObj.monthYear) {
|
|
|
|
|
tempList.add(widget.appoitmentAllHistoryResultList[i]);
|
|
|
|
|
tempList.add(widget.medicalViewModel.appoitmentAllHistoryResultList[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -182,6 +209,7 @@ class _TimeLineViewState extends State<TimeLineView> {
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
shrinkWrap: false,
|
|
|
|
|
physics: BouncingScrollPhysics(),
|
|
|
|
|
controller: _scrollController,
|
|
|
|
|
separatorBuilder: (BuildContext context, int index) {
|
|
|
|
|
return mWidth(8);
|
|
|
|
|
},
|
|
|
|
|
@ -244,9 +272,9 @@ class _TimeLineViewState extends State<TimeLineView> {
|
|
|
|
|
height: MediaQuery.of(context).size.width / 14,
|
|
|
|
|
width: MediaQuery.of(context).size.width / (widget.isArabic ? 4 : 6),
|
|
|
|
|
child: CustomTextButton(
|
|
|
|
|
shape: cardRadiusNew(8),
|
|
|
|
|
elevation: 0,
|
|
|
|
|
backgroundColor: Color(0xFFFBF2E31),
|
|
|
|
|
shape: cardRadiusNew(8),
|
|
|
|
|
elevation: 0,
|
|
|
|
|
backgroundColor: Color(0xFFFBF2E31),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
// onLoginClick();
|
|
|
|
|
login();
|
|
|
|
|
|