diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 268df750..9a9824a0 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -57,9 +57,14 @@ const Map localizedValues = { 'gender': {'en': 'Gender', 'ar': 'الجنس'}, 'nationality': {'en': 'Nationality', 'ar': 'الجنسية'}, 'neverWait': {'en': 'Never wait in queue', 'ar': 'لا تنتظر في قائمة الانتظار'}, + 'reminderTitle': {'en': 'You have appointment with Dr. ', 'ar': 'لديك موعد مع د'}, + 'appointmentCalendar': {'en': 'Would you like to set a reminder for this appointment in your calendar?', 'ar': 'هل ترغب في تعيين تذكير لهذا الموعد في التقويم الخاص بك؟'}, + 'appointmentSuccess': {'en': 'Appointment is successfully booked', 'ar': 'تم حجز الموعد بنجاح'}, 'docQualifications': {'en': 'Doctor Qualifications', 'ar': 'مؤهلات الطبيب'}, + 'pressAgain': {'en': 'Press again to exit the app', 'ar': 'اضغط مرة أخرى للخروج من التطبيق'}, 'confirmAppoHeading': {'en': 'Kindly review your Appointment', 'ar': 'يرجى تأكيد موعدك'}, 'patientInfo': {'en': 'Patient Information', 'ar': 'معلومات المريض'}, + 'doctorFilter': {'en': 'Doctors will be filtered based on your gender and age', 'ar': 'سيتم تصفية الأطباء بناءً على جنسك وعمرك'}, 'bookSuccess': {'en': 'Book Success', 'ar': 'تم حجز الموعد بنجاح'}, 'patientShare': {'en': 'Patient Share', 'ar': 'المبلغ المستحق'}, 'patientShareWithTax': {'en': 'Patient Share with Tax', 'ar': 'المبلغ الإجمالي المستحق'}, diff --git a/lib/pages/BookAppointment/BookConfirm.dart b/lib/pages/BookAppointment/BookConfirm.dart index 037b2e43..afeb1241 100644 --- a/lib/pages/BookAppointment/BookConfirm.dart +++ b/lib/pages/BookAppointment/BookConfirm.dart @@ -117,7 +117,7 @@ class _BookConfirmState extends State { Text( TranslationBase.of(context).appoInfo, style: TextStyle( - fontSize: 12.0, + fontSize: 14.0, color: Colors.black, letterSpacing: -0.36, fontWeight: FontWeight.w600, @@ -151,7 +151,7 @@ class _BookConfirmState extends State { Text( TranslationBase.of(context).patientInfo, style: TextStyle( - fontSize: 12.0, + fontSize: 14.0, color: Colors.black, letterSpacing: -0.36, fontWeight: FontWeight.w600, @@ -219,7 +219,7 @@ class _BookConfirmState extends State { Text( title + ": ", style: TextStyle( - fontSize: 12, + fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xFF575757), letterSpacing: -0.4, @@ -228,7 +228,7 @@ class _BookConfirmState extends State { Text( des, style: TextStyle( - fontSize: 12, + fontSize: 14, fontWeight: FontWeight.w600, color: Colors.black, letterSpacing: -0.48, diff --git a/lib/pages/BookAppointment/book_reminder_page.dart b/lib/pages/BookAppointment/book_reminder_page.dart index 3007003a..fc5c96e8 100644 --- a/lib/pages/BookAppointment/book_reminder_page.dart +++ b/lib/pages/BookAppointment/book_reminder_page.dart @@ -14,29 +14,53 @@ import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; +import 'package:jiffy/jiffy.dart'; +import 'package:permission_handler/permission_handler.dart'; import 'BookSuccess.dart'; -class BookReminderPage extends StatelessWidget { +class BookReminderPage extends StatefulWidget { PatientShareResponse patientShareResponse; DoctorList docObject; - MyInAppBrowser browser; - final ChromeSafariBrowser chromeBrowser = new MyChromeSafariBrowser(new MyInAppBrowser()); - String selectedTime; String appoDateFormatted; String appoTimeFormatted; DateTime dateTime; - BookReminderPage({@required this.patientShareResponse, @required this.docObject, @required this.appoDateFormatted, @required this.appoTimeFormatted,this.dateTime}); + BookReminderPage({@required this.patientShareResponse, @required this.docObject, @required this.appoDateFormatted, @required this.appoTimeFormatted, this.dateTime}); + + @override + _BookReminderPageState createState() => _BookReminderPageState(); +} + +class _BookReminderPageState extends State { + MyInAppBrowser browser; + + final ChromeSafariBrowser chromeBrowser = new MyChromeSafariBrowser(new MyInAppBrowser()); + + String selectedTime; + bool isSuccessShow = true; + + @override + void initState() { + // TODO: implement initState + super.initState(); + Future.delayed(const Duration(seconds: 2), () { +// Here you can write your code + + setState(() { + isSuccessShow = false; + }); + }); + } @override Widget build(BuildContext context) { // print("selectedTime "+selectedTime??""); - print("appoDateFormatted "+appoDateFormatted??""); - print("appoTimeFormatted "+appoDateFormatted??""); + print("appoDateFormatted " + widget.appoDateFormatted ?? ""); + print("appoTimeFormatted " + widget.appoTimeFormatted ?? ""); return AppScaffold( - appBarTitle: docObject.doctorTitle + " " + docObject.name, + appBarTitle: widget.docObject.doctorTitle + " " + widget.docObject.name, isShowDecPage: false, isShowAppBar: true, showNewAppBarTitle: true, @@ -48,17 +72,17 @@ class BookReminderPage extends StatelessWidget { children: [ DoctorHeader( headerModel: HeaderModel( - docObject.name, - docObject.doctorImageURL, - docObject.speciality, + widget.docObject.name, + widget.docObject.doctorImageURL, + widget.docObject.speciality, "", - docObject.projectName, + widget.docObject.projectName, null, null, - docObject.nationalityFlagURL, - docObject.doctorRate, + widget.docObject.nationalityFlagURL, + widget.docObject.doctorRate, null, - docObject.noOfPatientsRate, + widget.docObject.noOfPatientsRate, "", ), isNeedToShowButton: false, @@ -78,7 +102,7 @@ class BookReminderPage extends StatelessWidget { size: 60, ), Text( - "Would you like to set a reminder for this appointment in your calendar?", + TranslationBase.of(context).appointmentCalendar, style: TextStyle( fontSize: 20, fontWeight: FontWeight.w600, @@ -86,40 +110,41 @@ class BookReminderPage extends StatelessWidget { ), ), mFlex(1), - Container( - width: double.infinity, - child: Card( - shape: cardRadius(12), - margin: EdgeInsets.all(10), - child: Padding( - padding: const EdgeInsets.all(16.0), - child: Row( - children: [ - circularAviator( - 30, - icon: Icons.done_rounded, - iconColor: Colors.white, - bcColor: CustomColors.green, - brColor: CustomColors.green, - ), - mWidth(10), - Expanded( - child: AutoSizeText( - "Appointment is successfully booked", - maxLines: 1, - minFontSize: 6, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - letterSpacing: -0.65, - ), + if (isSuccessShow) + Container( + width: double.infinity, + child: Card( + shape: cardRadius(12), + margin: EdgeInsets.all(10), + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Row( + children: [ + circularAviator( + 30, + icon: Icons.done_rounded, + iconColor: Colors.white, + bcColor: CustomColors.green, + brColor: CustomColors.green, ), - ) - ], + mWidth(10), + Expanded( + child: AutoSizeText( + TranslationBase.of(context).appointmentSuccess, + maxLines: 1, + minFontSize: 6, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + letterSpacing: -0.65, + ), + ), + ) + ], + ), ), ), ), - ), ], ), ), @@ -168,8 +193,16 @@ class BookReminderPage extends StatelessWidget { textColor: Colors.white, disabledTextColor: Colors.white, disabledColor: CustomColors.green, - onPressed: () { - _showReminderDialog(context); + onPressed: () async { + if (await Permission.contacts.request().isGranted) { + _showReminderDialog(context); + } else { + requestPermissions().then((results) { + if (results[Permission.calendar].isGranted) { + _showReminderDialog(context); + } + }); + } }, child: Text(TranslationBase.of(context).yes, style: TextStyle(fontSize: 16.0, letterSpacing: -0.48)), ), @@ -183,7 +216,11 @@ class BookReminderPage extends StatelessWidget { } Future navigateToBookSuccess(BuildContext context) async { - Navigator.push(context, FadePage(page: BookSuccess(docObject: docObject, patientShareResponse: patientShareResponse, appoDateFormatted: appoDateFormatted, appoTimeFormatted: appoTimeFormatted))); + Navigator.push( + context, + FadePage( + page: + BookSuccess(docObject: widget.docObject, patientShareResponse: widget.patientShareResponse, appoDateFormatted: widget.appoDateFormatted, appoTimeFormatted: widget.appoTimeFormatted))); } Future _showReminderDialog(BuildContext context) async { @@ -195,26 +232,42 @@ class BookReminderPage extends StatelessWidget { shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)), //this right here child: ReminderDialog( onClick: (int i) async { - CalendarUtils calendarUtils = await CalendarUtils.getInstance(); - calendarUtils.createOrUpdateEvent(title: "title",description: "descriptipn",scheduleDateTime:dateTime).then((value) { - AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess); - }); if (i == 0) { // Before 30 mints - + widget.dateTime = Jiffy(widget.dateTime).subtract(minutes: 30); + // dateTime.add(new Duration(minutes: -30)); } else if (i == 1) { // Before 1 hour - + // dateTime.add(new Duration(minutes: -60)); + widget.dateTime = Jiffy(widget.dateTime).subtract(hours: 1); } else if (i == 2) { // Before 1 hour and 30 mints - + // dateTime.add(new Duration(minutes: -90)); + widget.dateTime = Jiffy(widget.dateTime).subtract(hours: 1, minutes: 30); } else if (i == 3) { // Before 2 hours + // dateTime.add(new Duration(minutes: -120)); + widget.dateTime = Jiffy(widget.dateTime).subtract(hours: 2); } + CalendarUtils calendarUtils = await CalendarUtils.getInstance(); + calendarUtils + .createOrUpdateEvent( + title: TranslationBase.of(context).reminderTitle + " " + widget.docObject.name, + description: "At " + widget.appoDateFormatted + " " + widget.appoTimeFormatted, + scheduleDateTime: widget.dateTime) + .then((value) { + AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess); + navigateToBookSuccess(context); + }); }, ), ); }, ); } + + Future> requestPermissions() async { + var permissionResults = [Permission.calendar].request(); + return permissionResults; + } } diff --git a/lib/pages/BookAppointment/components/SearchByClinic.dart b/lib/pages/BookAppointment/components/SearchByClinic.dart index 8688532c..eef70269 100644 --- a/lib/pages/BookAppointment/components/SearchByClinic.dart +++ b/lib/pages/BookAppointment/components/SearchByClinic.dart @@ -1,6 +1,7 @@ import "dart:collection"; import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/models/Appointments/SearchInfoModel.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; @@ -19,6 +20,7 @@ import 'package:diplomaticquarterapp/widgets/card/rounded_container.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:provider/provider.dart'; import 'LiveCareBookAppointment.dart'; @@ -50,8 +52,9 @@ class _SearchByClinicState extends State { final GlobalKey clinicDropdownKey = GlobalKey(); final GlobalKey projectDropdownKey = GlobalKey(); + ProjectViewModel projectViewModel; - String radioValue = "Female"; + String radioValue = null; @override void initState() { @@ -61,6 +64,8 @@ class _SearchByClinicState extends State { @override Widget build(BuildContext context) { + projectViewModel = Provider.of(context); + if (radioValue == null) radioValue = TranslationBase.of(context).female; return Container( child: SingleChildScrollView( child: Column( @@ -73,7 +78,7 @@ class _SearchByClinicState extends State { top: 20, ), child: Text( - "Doctors will be filtered based on your gender and age", + TranslationBase.of(context).doctorFilter, style: TextStyle( fontSize: 16, fontWeight: FontWeight.w600, @@ -88,7 +93,7 @@ class _SearchByClinicState extends State { Padding( padding: const EdgeInsets.only(left: 20, right: 20), child: Text( - "Gender", + TranslationBase.of(context).gender, style: TextStyle( fontSize: 12, letterSpacing: -0.48, @@ -247,11 +252,13 @@ class _SearchByClinicState extends State { child: DropdownButtonHideUnderline( child: DropdownButton( key: clinicDropdownKey, - hint: new Text(TranslationBase.of(context).selectClinic), + hint: new Text( + TranslationBase.of(context).selectClinic, + ), value: dropdownValue, iconSize: 0, isExpanded: true, - style: TextStyle(fontSize: 14, letterSpacing: -0.56, color: Colors.black), + style: TextStyle(fontSize: 14, letterSpacing: -0.56, color: Colors.black, fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins'), items: clinicsList.map((item) { return new DropdownMenuItem( value: item.clinicID.toString() + diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index 5402e9b9..ee4822bb 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -74,6 +74,7 @@ class _LandingPageState extends State with WidgetsBindingObserver { ToDoCountProviderModel model; var notificationCount = ''; var themeNotifier; + DateTime currentBackPressTime; bool _showBottomNavigationBar = true; @@ -97,6 +98,16 @@ class _LandingPageState extends State with WidgetsBindingObserver { bool isPageNavigated = false; LocationUtils locationUtils; + Future onWillPop() { + DateTime now = DateTime.now(); + if (currentBackPressTime == null || now.difference(currentBackPressTime) > Duration(seconds: 2)) { + currentBackPressTime = now; + AppToast.showToast(message: TranslationBase.of(context).pressAgain); + return Future.value(false); + } + return Future.value(true); + } + changeCurrentTab(int tab) { if (!projectViewModel.isLogin) { if (tab == 3) { @@ -170,8 +181,7 @@ class _LandingPageState extends State with WidgetsBindingObserver { var route = ModalRoute.of(context); - if (route != null) { - } + if (route != null) {} //setState(() { AppGlobal.context = context; @@ -213,8 +223,7 @@ class _LandingPageState extends State with WidgetsBindingObserver { pageController = PageController(keepPage: true); _firebaseMessaging.setAutoInitEnabled(true); - locationUtils = - new LocationUtils(isShowConfirmDialog: false, context: context); + locationUtils = new LocationUtils(isShowConfirmDialog: false, context: context); WidgetsBinding.instance.addPostFrameCallback((_) { // locationUtils.getCurrentLocation(); if (projectViewModel.isLogin) { @@ -232,14 +241,14 @@ class _LandingPageState extends State with WidgetsBindingObserver { } requestPermissions().then((results) { - _firebaseMessaging.getToken().then((String token) { - sharedPref.setString(PUSH_TOKEN, token); - if (token != null && DEVICE_TOKEN == "") { - DEVICE_TOKEN = token; - checkUserStatus(token); - if (projectViewModel.isLogin) this.getNotificationCount(DEVICE_TOKEN); - } - }); + _firebaseMessaging.getToken().then((String token) { + sharedPref.setString(PUSH_TOKEN, token); + if (token != null && DEVICE_TOKEN == "") { + DEVICE_TOKEN = token; + checkUserStatus(token); + if (projectViewModel.isLogin) this.getNotificationCount(DEVICE_TOKEN); + } + }); if (results[Permission.location].isGranted) {} // if (results[Permission.storage].isGranted) ; // if (results[Permission.camera].isGranted) ; @@ -584,23 +593,26 @@ class _LandingPageState extends State with WidgetsBindingObserver { ), drawer: SafeArea(child: AppDrawer()), extendBody: true, - body: PageView( - physics: NeverScrollableScrollPhysics(), - controller: pageController, - children: [ - HomePage2( - goToMyProfile: () { - changeCurrentTab(1); - }, - onLoginClick: () { - login(); - }, - ), - MedicalProfilePageNew(), - Search(), - MyFamily(isAppbarVisible: false), - ToDo(isShowAppBar: false), - ], // Please do not remove the BookingOptions from this array + body: WillPopScope( + onWillPop: onWillPop, + child: PageView( + physics: NeverScrollableScrollPhysics(), + controller: pageController, + children: [ + HomePage2( + goToMyProfile: () { + changeCurrentTab(1); + }, + onLoginClick: () { + login(); + }, + ), + MedicalProfilePageNew(), + Search(), + MyFamily(isAppbarVisible: false), + ToDo(isShowAppBar: false), + ], // Please do not remove the BookingOptions from this array + ), ), bottomNavigationBar: BottomNavBar( changeIndex: changeCurrentTab, diff --git a/lib/pages/medical/prescriptions/prescriptions_page.dart b/lib/pages/medical/prescriptions/prescriptions_page.dart index 3986353e..1d5f92c5 100644 --- a/lib/pages/medical/prescriptions/prescriptions_page.dart +++ b/lib/pages/medical/prescriptions/prescriptions_page.dart @@ -74,6 +74,8 @@ class PrescriptionsPage extends StatelessWidget { subName: prescriptions.name, isInOutPatient: prescriptions.isInOutPatient, isLiveCareAppointment: prescriptions.isLiveCareAppointment, + appointmentTime: DateUtil.formatDateToTime(DateUtil.convertStringToDate(prescriptions + .appointmentDate)), date: DateUtil.convertStringToDate(prescriptions .appointmentDate) //projectViewModel.isArabic? DateUtil.getMonthDayYearDateFormattedAr( DateUtil.convertStringToDate(prescriptions.appointmentDate) ):DateUtil.getMonthDayYearDateFormatted(DateUtil.convertStringToDate(prescriptions.appointmentDate)), ); diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 347deb9c..46c59c60 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -95,12 +95,16 @@ class TranslationBase { String get neverWait => localizedValues['neverWait'][locale.languageCode]; String get patientShareWithTax => localizedValues['patientShareWithTax'][locale.languageCode]; + String get reminderTitle => localizedValues['reminderTitle'][locale.languageCode]; String get confirmAppo => localizedValues['confirmAppo'][locale.languageCode]; - String get confirm => localizedValues['confirm'][locale.languageCode]; + String get appointmentCalendar => localizedValues['appointmentCalendar'][locale.languageCode]; + String get appointmentSuccess => localizedValues['appointmentSuccess'][locale.languageCode]; + String get confirm => localizedValues['confirm'][locale.languageCode]; + String get pressAgain => localizedValues['pressAgain'][locale.languageCode]; String get confirmLiveCare => localizedValues['confirmLiveCare'][locale.languageCode]; - + String get doctorFilter => localizedValues['doctorFilter'][locale.languageCode]; String get waitingForDoctor => localizedValues['waitingForDoctor'][locale.languageCode]; String get confirmLater => localizedValues['confirmLater'][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 4fe33e4a..09ab030c 100644 --- a/lib/widgets/data_display/medical/time_line_new_widget.dart +++ b/lib/widgets/data_display/medical/time_line_new_widget.dart @@ -307,7 +307,7 @@ class TimelineNewWidget extends StatelessWidget { projectViewModel.isArabic ? "ar" : "en", ), style: TextStyle( - color: CustomColors.grey2, + color: Colors.grey[200], fontSize: 12, height: 1.2, ), @@ -346,7 +346,7 @@ class TimelineNewWidget extends StatelessWidget { appoitmentAllHistoryResul.clinicName, style: TextStyle( color: CustomColors.grey2, - fontSize: 8, + fontSize: 10, fontWeight: FontWeight.w600, letterSpacing: -0.36, ),