From cb568d74c046099416a056dc525aefa6a22f22b7 Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Thu, 15 Apr 2021 18:08:04 +0300 Subject: [PATCH] add fun back press on relay page --- lib/core/service/PatientMuseService.dart | 4 +- lib/landing_page.dart | 7 +- lib/screens/doctor/doctor_reply_screen.dart | 85 ++++++++++++--------- lib/widgets/shared/bottom_nav_bar.dart | 12 +-- 4 files changed, 64 insertions(+), 44 deletions(-) diff --git a/lib/core/service/PatientMuseService.dart b/lib/core/service/PatientMuseService.dart index 39c4192c..35e5fe7b 100644 --- a/lib/core/service/PatientMuseService.dart +++ b/lib/core/service/PatientMuseService.dart @@ -7,7 +7,7 @@ class PatientMuseService extends BaseService { getECGPatient({int patientType, int patientOutSA,int patientID}) async { Map body = Map(); - body['PatientType'] = patientType; + body['PatientType'] = patientType==7 ? 1: patientType; body['PatientOutSA'] = patientOutSA; body['PatientID'] = patientID; hasError = false; @@ -23,7 +23,7 @@ class PatientMuseService extends BaseService { hasError = true; super.error = error; }, - body: body,isAllowAny: true + body: body ); } } diff --git a/lib/landing_page.dart b/lib/landing_page.dart index a997675a..303b4413 100644 --- a/lib/landing_page.dart +++ b/lib/landing_page.dart @@ -70,10 +70,13 @@ class _LandingPageState extends State { ), MyScheduleScreen(), QrReaderScreen(), - DoctorReplyScreen(), + DoctorReplyScreen(changeCurrentTab:(){ + _changeCurrentTab(0); + + },), ], ), - bottomNavigationBar: BottomNavBar(changeIndex: _changeCurrentTab), + bottomNavigationBar: BottomNavBar(changeIndex: _changeCurrentTab,index: currentTab,), ); } diff --git a/lib/screens/doctor/doctor_reply_screen.dart b/lib/screens/doctor/doctor_reply_screen.dart index 51bc2652..283ce7cd 100644 --- a/lib/screens/doctor/doctor_reply_screen.dart +++ b/lib/screens/doctor/doctor_reply_screen.dart @@ -16,43 +16,60 @@ import 'package:flutter/material.dart'; *@desc: Doctor Reply Screen display data from GtMyPatientsQuestions service */ class DoctorReplyScreen extends StatelessWidget { + + final Function changeCurrentTab; + + const DoctorReplyScreen({Key key, this.changeCurrentTab}) : super(key: key); + @override Widget build(BuildContext context) { return BaseView( - onModelReady: (model) { - model.getDoctorReply(); + onModelReady: (model) { + model.getDoctorReply(); + }, + builder: (_, model, w) => WillPopScope( + onWillPop: ()async{ + changeCurrentTab(); + return false; }, - builder: (_, model, w) => AppScaffold( - baseViewModel: model, - appBarTitle: TranslationBase.of(context).replay2, - isShowAppBar: false, - body: model.listDoctorWorkingHoursTable.isEmpty - ? DrAppEmbeddedError( - error: TranslationBase.of(context).noItem) - : Container( - padding: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0), - child: ListView( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: - model.listDoctorWorkingHoursTable.map((reply) { - return InkWell( - onTap: reply.status != 2?null:() { - Navigator.push( - context, - MaterialPageRoute( - builder: (BuildContext context) => - DoctorReplayChat(reply: reply, previousModel: model,))); - }, - child: DoctorReplyWidget(reply: reply), - ); - }).toList(), - ) - ], - ), - ), - )); + child: AppScaffold( + baseViewModel: model, + appBarTitle: TranslationBase.of(context).replay2, + isShowAppBar: false, + body: model.listDoctorWorkingHoursTable.isEmpty + ? DrAppEmbeddedError(error: TranslationBase.of(context).noItem) + : Container( + padding: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0), + child: ListView( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: + model.listDoctorWorkingHoursTable.map((reply) { + return InkWell( + onTap: reply.status != 2 + ? null + : () { + Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => + DoctorReplayChat( + reply: reply, + previousModel: model, + ))); + }, + child: DoctorReplyWidget(reply: reply), + ); + }).toList(), + ) + ], + ), + ), + ), + ), + ); + } } diff --git a/lib/widgets/shared/bottom_nav_bar.dart b/lib/widgets/shared/bottom_nav_bar.dart index d3b07254..c603fdbe 100644 --- a/lib/widgets/shared/bottom_nav_bar.dart +++ b/lib/widgets/shared/bottom_nav_bar.dart @@ -7,8 +7,8 @@ import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; class BottomNavBar extends StatefulWidget { final ValueChanged changeIndex; - - BottomNavBar({Key key, this.changeIndex}) : super(key: key); + final int index; + BottomNavBar({Key key, this.changeIndex, this.index}) : super(key: key); @override _BottomNavBarState createState() => _BottomNavBarState(); @@ -40,7 +40,7 @@ class _BottomNavBarState extends State { icon: DoctorApp.home_1, activeIcon: DoctorApp.home_active_1, changeIndex: _changeIndex, - index: _index, + index: widget.index, currentIndex: 0, name: TranslationBase.of(context).home, ), @@ -48,7 +48,7 @@ class _BottomNavBarState extends State { icon: DoctorApp.schedule_1, activeIcon: DoctorApp.schedule_active_1, changeIndex: _changeIndex, - index: _index, + index: widget.index, currentIndex: 1, name: TranslationBase.of(context).mySchedule, ), @@ -56,7 +56,7 @@ class _BottomNavBarState extends State { icon: DoctorApp.qr_reader, activeIcon: DoctorApp.qr_reader_active_1, changeIndex: _changeIndex, - index: _index, + index: widget.index, currentIndex: 2, name: TranslationBase.of(context).qr, ), @@ -64,7 +64,7 @@ class _BottomNavBarState extends State { icon: DoctorApp.dr_reply_1, activeIcon: DoctorApp.dr_reply_active_1, changeIndex: _changeIndex, - index: _index, + index: widget.index, currentIndex: 3, name: TranslationBase.of(context).replay2, ),