diff --git a/lib/pages/BookAppointment/Search.dart b/lib/pages/BookAppointment/Search.dart index 44cf46c3..6264c7a8 100644 --- a/lib/pages/BookAppointment/Search.dart +++ b/lib/pages/BookAppointment/Search.dart @@ -1,10 +1,11 @@ import 'package:diplomaticquarterapp/config/config.dart'; -import 'package:diplomaticquarterapp/pages/BookAppointment/components/SearchByClinic.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/components/SearchByDoctor.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/others/arrow_back.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; +import 'components/SearchByClinic.dart'; + class Search extends StatefulWidget { final int type; final List clnicIds; @@ -29,34 +30,70 @@ class _SearchState extends State with TickerProviderStateMixin { @override Widget build(BuildContext context) { AppGlobal.context = context; - return Scaffold( - appBar: AppBar( - bottom: TabBar( - tabs: [ - Tab(text: TranslationBase.of(context).clinicName), - Tab( - text: TranslationBase.of(context).doctorName, - ) - ], - controller: _tabController, - ), - title: Text(TranslationBase.of(context).bookAppo, - style: TextStyle(color: Colors.white)), - leading: Builder( - builder: (BuildContext context) { - return ArrowBack(); - }, - ), - ), - body: TabBarView( - physics: NeverScrollableScrollPhysics(), - children: [ - SearchByClinic( - clnicIds: widget.clnicIds, - ), - SearchByDoctor() - ], - controller: _tabController), - ); + return AppScaffold( + isShowAppBar: true, + isShowDecPage: false, + appBarTitle: TranslationBase.of(context).bookAppo, + body: Container( + child: Column( + children: [ + TabBar( + tabs: [ + Tab(text: TranslationBase.of(context).clinicName), + Tab( + text: TranslationBase.of(context).doctorName, + ) + ], + controller: _tabController, + ), + Divider( + color: Colors.grey[600], + thickness: 0.5, + ), + Expanded( + child: new TabBarView( + physics: NeverScrollableScrollPhysics(), + children: [ + SearchByClinic( + clnicIds: widget.clnicIds, + ), + SearchByDoctor() + ], + controller: _tabController, + ), + ) + ], + ), + )); + // Scaffold( + // appBar: AppBar( + // bottom: TabBar( + // labelColor: Colors.white, + // tabs: [ + // Tab(text: TranslationBase.of(context).clinicName), + // Tab( + // text: TranslationBase.of(context).doctorName, + // ) + // ], + // controller: _tabController, + // ), + // title: Text(TranslationBase.of(context).bookAppo, + // style: TextStyle(color: Colors.white)), + // leading: Builder( + // builder: (BuildContext context) { + // return ArrowBack(); + // }, + // ), + // ), + // body: TabBarView( + // physics: NeverScrollableScrollPhysics(), + // children: [ + // SearchByClinic( + // clnicIds: widget.clnicIds, + // ), + // SearchByDoctor() + // ], + // controller: _tabController), + // ); } } diff --git a/lib/pages/BookAppointment/components/DocInfo.dart b/lib/pages/BookAppointment/components/DocInfo.dart index 1d91f7de..89b9e4d0 100644 --- a/lib/pages/BookAppointment/components/DocInfo.dart +++ b/lib/pages/BookAppointment/components/DocInfo.dart @@ -17,6 +17,7 @@ class DoctorInformation extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ AppExpandableNotifier( + isExpand: true, headerWidget: Container( margin: EdgeInsets.all(10.0), child: Row( @@ -78,6 +79,7 @@ class DoctorInformation extends StatelessWidget { ), // ), AppExpandableNotifier( + isExpand: true, headerWidget: Container( margin: EdgeInsets.all(10.0), child: Row( diff --git a/lib/pages/MyAppointments/widgets/AppointmentCardView.dart b/lib/pages/MyAppointments/widgets/AppointmentCardView.dart index 2f3d941f..b3839834 100644 --- a/lib/pages/MyAppointments/widgets/AppointmentCardView.dart +++ b/lib/pages/MyAppointments/widgets/AppointmentCardView.dart @@ -24,14 +24,15 @@ class AppointmentCard extends StatefulWidget { } class _ApointmentCardState extends State { - CountdownTimerController controller; @override void initState() { super.initState(); int endTime = DateTime.now().millisecondsSinceEpoch + 1000 * 30; - controller = CountdownTimerController(endTime: endTime,); + controller = CountdownTimerController( + endTime: endTime, + ); } @override @@ -137,15 +138,22 @@ class _ApointmentCardState extends State { AppointmentType.CONFIRMED) ? Container( child: CountdownTimer( - controller: controller, + controller: new CountdownTimerController( + endTime: + DateTime.now().millisecondsSinceEpoch + + (widget.appo.remaniningHoursTocanPay * + 1000) * + 60), widgetBuilder: (_, CurrentRemainingTime time) { - return Text( - '${time.days}:${time.hours}:${time.min}:${time.sec} ' + - TranslationBase.of(context) - .upcomingTimeLeft, - style: TextStyle( - fontSize: 12.0, - color: Color(0xff40ACC9))); + return time != null + ? Text( + '${time.days}:${time.hours}:${time.min}:${time.sec} ' + + TranslationBase.of(context) + .upcomingTimeLeft, + style: TextStyle( + fontSize: 12.0, + color: Color(0xff40ACC9))) + : Container(); }, ), ) diff --git a/lib/pages/ToDoList/ToDo.dart b/lib/pages/ToDoList/ToDo.dart index e64b2906..b635bc52 100644 --- a/lib/pages/ToDoList/ToDo.dart +++ b/lib/pages/ToDoList/ToDo.dart @@ -11,8 +11,8 @@ import 'package:diplomaticquarterapp/pages/BookAppointment/QRCode.dart'; import 'package:diplomaticquarterapp/pages/MyAppointments/AppointmentDetails.dart'; import 'package:diplomaticquarterapp/pages/ToDoList/payment_method_select.dart'; import 'package:diplomaticquarterapp/pages/ToDoList/widgets/paymentDialog.dart'; +import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart'; -import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; @@ -68,7 +68,7 @@ class _ToDoState extends State { imageAr: 'https://hmgwebservices.com/Images/MobileApp/images-info-home/todo/ar/0.png')); int endTime = DateTime.now().millisecondsSinceEpoch + 1000 * 30; - controller = CountdownTimerController(endTime: endTime,); + controller = CountdownTimerController(endTime: endTime); } @override @@ -118,11 +118,15 @@ class _ToDoState extends State { EdgeInsets.only(left: 10.0, right: 10.0), child: Text( DateUtil.getWeekDayMonthDayYearDateFormatted( - DateUtil.convertStringToDate(widget - .appoList[index].appointmentDate), - projectViewModel.isArabic - ? "ar" - : "en") + " " + widget.appoList[index].startTime.substring(0, 5), + DateUtil.convertStringToDate( + widget.appoList[index] + .appointmentDate), + projectViewModel.isArabic + ? "ar" + : "en") + + " " + + widget.appoList[index].startTime + .substring(0, 5), style: TextStyle(fontSize: 10.0)), ), widget.appoList[index].isLiveCareAppointment @@ -233,18 +237,26 @@ class _ToDoState extends State { ), Container( child: CountdownTimer( - controller: controller, + controller: new CountdownTimerController( + endTime: DateTime.now() + .millisecondsSinceEpoch + + (widget.appoList[index] + .remaniningHoursTocanPay * + 1000) * + 60), widgetBuilder: (_, CurrentRemainingTime time) { - return Text( - '${time.days}:${time.hours}:${time.min}:${time.sec} ' + - TranslationBase.of( - context) - .upcomingTimeLeft, - style: TextStyle( - fontSize: 12.0, - color: - Color(0xff40ACC9))); + return time != null + ? Text( + '${time.days}:${time.hours}:${time.min}:${time.sec} ' + + TranslationBase.of( + context) + .upcomingTimeLeft, + style: TextStyle( + fontSize: 12.0, + color: Color( + 0xff40ACC9))) + : Container(); }, ), ), @@ -525,23 +537,11 @@ class _ToDoState extends State { }); } - getToDoCount() { - toDoProvider.setState(0, true); - ClinicListService service = new ClinicListService(); - service.getActiveAppointmentNo(context).then((res) { - print(res['AppointmentActiveNumber']); - if (res['MessageStatus'] == 1) { - toDoProvider.setState(res['AppointmentActiveNumber'], true); - } else {} - }).catchError((err) { - print(err); - }); - } - getPatientAppointmentHistory() { GifLoaderDialogUtils.showMyDialog(context); DoctorsListService service = new DoctorsListService(); service.getPatientAppointmentHistory(true, context).then((res) { + widget.appoList.clear(); GifLoaderDialogUtils.hideDialog(context); if (res['MessageStatus'] == 1) { setState(() { @@ -551,9 +551,10 @@ class _ToDoState extends State { widget.appoList .add(new AppoitmentAllHistoryResultList.fromJson(v)); }); - } else {} + } else { + Navigator.of(context).popAndPushNamed(HOME); + } }); - getToDoCount(); } else { AppToast.showErrorToast(message: res['ErrorEndUserMessage']); } diff --git a/lib/pages/paymentService/payment_service.dart b/lib/pages/paymentService/payment_service.dart index 126c3cdc..2bcca630 100644 --- a/lib/pages/paymentService/payment_service.dart +++ b/lib/pages/paymentService/payment_service.dart @@ -1,7 +1,9 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; import 'package:diplomaticquarterapp/pages/ToDoList/ToDo.dart'; import 'package:diplomaticquarterapp/pages/medical/balance/advance_payment_page.dart'; import 'package:diplomaticquarterapp/pages/medical/balance/my_balance_page.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; @@ -12,9 +14,13 @@ import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; class PaymentService extends StatelessWidget { + ToDoCountProviderModel model; + ProjectViewModel projectViewModel; + @override Widget build(BuildContext context) { - ProjectViewModel projectViewModel = Provider.of(context); + projectViewModel = Provider.of(context); + model = Provider.of(context); return AppScaffold( isShowAppBar: true, isShowDecPage: false, @@ -70,8 +76,7 @@ class PaymentService extends StatelessWidget { ), Expanded( child: InkWell( - onTap: () => - Navigator.push(context, FadePage(page: ToDo(isShowAppBar: true))), + onTap: () => navigateToToDoPage(context), child: Container( margin: EdgeInsets.all(5.0), padding: EdgeInsets.all(9), @@ -166,4 +171,17 @@ class PaymentService extends StatelessWidget { ), ); } + + navigateToToDoPage(BuildContext context) { + if (projectViewModel.isLogin) { + if (model.count != 0) { + Navigator.push(context, FadePage(page: ToDo(isShowAppBar: true))); + } else { + AppToast.showErrorToast( + message: TranslationBase.of(context).upcomingEmpty); + } + } else { + Navigator.push(context, FadePage(page: ToDo(isShowAppBar: true))); + } + } } diff --git a/lib/widgets/bottom_navigation/bottom_nav_bar.dart b/lib/widgets/bottom_navigation/bottom_nav_bar.dart index 2632ec4a..7acd0340 100644 --- a/lib/widgets/bottom_navigation/bottom_nav_bar.dart +++ b/lib/widgets/bottom_navigation/bottom_nav_bar.dart @@ -1,9 +1,14 @@ +import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; +import 'package:diplomaticquarterapp/locator.dart'; +import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/BookingOptions.dart'; import 'package:diplomaticquarterapp/pages/ToDoList/ToDo.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import '../../d_q_icons_icons.dart'; import 'bottom_navigation_item.dart'; @@ -21,12 +26,30 @@ class BottomNavBar extends StatefulWidget { class _BottomNavBarState extends State { int _index = 0; + ToDoCountProviderModel model; + AuthenticatedUserObject authenticatedUserObject = + locator(); + _changeIndex(int index) { - widget.changeIndex(index); + if (index != 4) + widget.changeIndex(index); + else { + if (authenticatedUserObject.isLogin) { + if (model.count != 0) { + widget.changeIndex(index); + } else { + AppToast.showErrorToast( + message: TranslationBase.of(context).upcomingEmpty); + } + } else { + widget.changeIndex(index); + } + } } @override Widget build(BuildContext context) { + model = Provider.of(context); return BottomAppBar( elevation: 4, shape: CircularNotchedRectangle(), @@ -103,6 +126,7 @@ class _BottomNavBarState extends State { } Future navigateToToDoList(context) async { - Navigator.push(context, MaterialPageRoute(builder: (context) => ToDo(isShowAppBar: false))); + Navigator.push(context, + MaterialPageRoute(builder: (context) => ToDo(isShowAppBar: false))); } }