From 4c7db58489c4b6b3729f4f21c1abb259b460a28e Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Tue, 1 Mar 2022 10:05:28 +0200 Subject: [PATCH] replace the TabBar in refer-patient-screen-in-patient with our custom TabBar in tab_utils --- .../refer-patient-screen-in-patient.dart | 169 +++++++++++++----- lib/utils/tab_utils.dart | 2 - 2 files changed, 125 insertions(+), 46 deletions(-) diff --git a/lib/screens/patients/profile/referral/refer-patient-screen-in-patient.dart b/lib/screens/patients/profile/referral/refer-patient-screen-in-patient.dart index 42bfab5f..a8bcbc5b 100644 --- a/lib/screens/patients/profile/referral/refer-patient-screen-in-patient.dart +++ b/lib/screens/patients/profile/referral/refer-patient-screen-in-patient.dart @@ -3,11 +3,13 @@ import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/provider/robot_provider.dart'; import 'package:doctor_app_flutter/core/viewModel/patient-referral-viewmodel.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_dialog_button.dart'; import 'package:doctor_app_flutter/utils/dr_app_toast_msg.dart'; +import 'package:doctor_app_flutter/utils/tab_utils.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-profile-app-bar.dart'; import 'package:doctor_app_flutter/widgets/patients/patient_service_title.dart'; @@ -22,6 +24,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:intl/intl.dart'; import 'package:permission_handler/permission_handler.dart'; +import 'package:provider/provider.dart'; import 'package:speech_to_text/speech_recognition_error.dart'; import 'package:speech_to_text/speech_to_text.dart' as stt; @@ -31,8 +34,9 @@ class PatientMakeInPatientReferralScreen extends StatefulWidget { _PatientMakeInPatientReferralScreenState(); } -class _PatientMakeInPatientReferralScreenState - extends State { +class _PatientMakeInPatientReferralScreenState extends State with SingleTickerProviderStateMixin{ + TabController _tabController; + int index = 0; PatiantInformtion patient; List referToList; dynamic _referTo; @@ -54,6 +58,20 @@ class _PatientMakeInPatientReferralScreenState var recognizedWord; var event = RobotProvider(); + + + _handleTabSelection() { + setState(() { + index = _tabController.index; + }); + } + + @override + void dispose() { + super.dispose(); + _tabController.dispose(); + } + @override void initState() { requestPermissions(); @@ -65,6 +83,8 @@ class _PatientMakeInPatientReferralScreenState } }); super.initState(); + _tabController = TabController(length: 3, vsync: this); + _tabController.addListener(_handleTabSelection); } onVoiceText() async { @@ -489,6 +509,9 @@ class _PatientMakeInPatientReferralScreenState ), ], ), + SizedBox( + height: 100, + ) ], ), ) @@ -587,52 +610,110 @@ class _PatientMakeInPatientReferralScreenState } Widget priorityBar(BuildContext _context, Size screenSize) { - List _priorities = [ - TranslationBase.of(context).veryUrgent.toUpperCase(), - TranslationBase.of(context).urgent.toUpperCase(), - TranslationBase.of(context).routine.toUpperCase(), - ]; - return Container( - height: screenSize.height * 0.070, - width: screenSize.width * 0.95, - decoration: - containerBorderDecoration(Color(0Xffffffff), Color(0xFFCCCCCC)), - child: Row( - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.center, - children: _priorities.map((item) { - bool _isActive = _priorities[_activePriority] == item ? true : false; - return Expanded( - child: InkWell( - child: Center( + ProjectViewModel projectsProvider = Provider.of(context); + return Center( + child: Container( + width: SizeConfig.widthMultiplier * 120, + height: TabHelper.getTabHeight(context), + color: TabHelper.getBgTabColor(), + child: Center( + child: TabBar( + isScrollable: false, + controller: _tabController, + indicatorColor: Colors.transparent, + indicatorWeight: 1.0, + indicatorSize: TabBarIndicatorSize.tab, + labelColor: Theme.of(context).primaryColor, + labelPadding: + EdgeInsets.only(top: 0, left: 0, right: 0, bottom: 0), + unselectedLabelColor: Colors.grey[800], + tabs: [ + Container( + decoration: TabHelper.getBoxTabsBoxDecoration( + isActive: index == 0, + isFirst: true, + projectViewModel: projectsProvider), + child: Center( + child: TabHelper.getTabText( + title: TranslationBase.of(context).veryUrgent.toUpperCase(), + isActive: index == 0)), + ), + Center( child: Container( - height: screenSize.height * 0.070, - decoration: containerBorderDecoration( - _isActive ? Color(0XFFB8382B) : Colors.white, - _isActive ? Color(0XFFB8382B) : Colors.white), - child: Center( - child: Text( - item, - style: TextStyle( - fontSize: 12, - color: _isActive ? Colors.white : Colors.black, - //Colors.black, - fontWeight: FontWeight.bold, - ), - ), - )), + decoration: TabHelper.getBoxTabsBoxDecoration( + isActive: index == 1, + isMiddle: true, + projectViewModel: projectsProvider), + child: Center( + child: TabHelper.getTabText( + title: TranslationBase.of(context).urgent.toUpperCase(), + isActive: index == 1)), + ), ), - onTap: () { - print(_priorities.indexOf(item)); - setState(() { - _activePriority = _priorities.indexOf(item); - }); - }, - ), - ); - }).toList(), + Center( + child: Container( + decoration: TabHelper.getBoxTabsBoxDecoration( + isActive: index == 2, + isLast: true, + projectViewModel: projectsProvider), + child: Center( + child: TabHelper.getTabText( + title: TranslationBase.of(context).routine.toUpperCase(), + isActive: index == 2), + ), + ), + ), + ], + ), + ), ), ); + // List _priorities = [ + // TranslationBase.of(context).veryUrgent.toUpperCase(), + // TranslationBase.of(context).urgent.toUpperCase(), + // TranslationBase.of(context).routine.toUpperCase(), + // ]; + // return Container( + // height: screenSize.height * 0.070, + // width: screenSize.width * 0.95, + // decoration: + // containerBorderDecoration(Color(0Xffffffff), Color(0xFFCCCCCC)), + // child: Row( + // mainAxisSize: MainAxisSize.max, + // crossAxisAlignment: CrossAxisAlignment.center, + // children: _priorities.map((item) { + // bool _isActive = _priorities[_activePriority] == item ? true : false; + // return Expanded( + // child: InkWell( + // child: Center( + // child: Container( + // height: screenSize.height * 0.070, + // decoration: containerBorderDecoration( + // _isActive ? Color(0XFFB8382B) : Colors.white, + // _isActive ? Color(0XFFB8382B) : Colors.white), + // child: Center( + // child: Text( + // item, + // style: TextStyle( + // fontSize: 12, + // color: _isActive ? Colors.white : Colors.black, + // //Colors.black, + // fontWeight: FontWeight.bold, + // ), + // ), + // )), + // ), + // onTap: () { + // print(_priorities.indexOf(item)); + // setState(() { + // _activePriority = _priorities.indexOf(item); + // }); + // }, + // ), + // ); + // }).toList(), + // ), + // ); } String getPriority() { diff --git a/lib/utils/tab_utils.dart b/lib/utils/tab_utils.dart index c4a023d4..b5981450 100644 --- a/lib/utils/tab_utils.dart +++ b/lib/utils/tab_utils.dart @@ -1,7 +1,5 @@ - import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; - import '../config/config.dart'; import '../config/size_config.dart'; import '../core/viewModel/project_view_model.dart';