From c4c8609f3ab2cd93033e83c9901f5e763fdcd43d Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Wed, 29 Apr 2020 18:22:01 +0300 Subject: [PATCH] fix bottom bar by Elham && mohammad --- lib/routes.dart | 14 +++- lib/screens/dashboard_screen.dart | 1 + lib/screens/doctor/message_screen.dart | 15 ++++ .../{ => doctor}/my_schedule_screen.dart | 6 +- lib/screens/doctor/services_screen.dart | 15 ++++ .../patients/patient_search_screen.dart | 1 + lib/widgets/shared/app_drawer_widget.dart | 7 +- lib/widgets/shared/app_scaffold_widget.dart | 81 +++++++++++++++---- 8 files changed, 114 insertions(+), 26 deletions(-) create mode 100644 lib/screens/doctor/message_screen.dart rename lib/screens/{ => doctor}/my_schedule_screen.dart (96%) create mode 100644 lib/screens/doctor/services_screen.dart diff --git a/lib/routes.dart b/lib/routes.dart index e887c62e..ebba02ed 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -1,3 +1,7 @@ +import 'package:doctor_app_flutter/screens/doctor/message_screen.dart'; +import 'package:doctor_app_flutter/screens/doctor/services_screen.dart'; + +import './screens/doctor/my_schedule_screen.dart'; import './screens/QR_reader_screen.dart'; import './screens/auth/change_password_screen.dart'; @@ -8,7 +12,6 @@ import './screens/blood_bank_screen.dart'; import './screens/dashboard_screen.dart'; import 'screens/doctor/doctor_reply_screen.dart'; import './screens/medicine/medicine_search_screen.dart'; -import './screens/my_schedule_screen.dart'; import './screens/patients/profile/patient_profile_screen.dart'; import './screens/patients/patient_search_screen.dart'; import './screens/patients/patients_screen.dart'; @@ -16,7 +19,7 @@ import './screens/patients/profile/vital_sign/vital_sign_screen.dart'; import './screens/profile_screen.dart'; import './screens/settings/settings_screen.dart'; -const String INIT_ROUTE = LOGIN; //PATIENT_SEARCH; +const String INIT_ROUTE = LOGIN; const String HOME = '/'; const String LOGIN = 'login'; const String PROFILE = 'profile'; @@ -30,6 +33,9 @@ const String PATIENTS = 'patients/patients'; const String PATIENTS_PROFILE = 'patients/patients-profile'; const String BLOOD_BANK = 'blood-bank'; const String DOCTOR_REPLY = 'doctor-reply'; +const String MESSAGES = 'messages'; +const String SERVICES = 'services'; + const String MEDICINE_SEARCH = 'medicine-search'; const String SETTINGS = 'settings'; const String VITAL_SIGN = 'vital-sign'; @@ -50,5 +56,7 @@ var routes = { VERIFY_ACCOUNT: (_) => VerifyAccountScreen(), VERIFICATION_METHODS: (_) => VerificationMethodsScreen(), PATIENTS_PROFILE: (_) => PatientProfileScreen(), - VITAL_SIGN: (_) => VitalSignScreen() + VITAL_SIGN: (_) => VitalSignScreen(), + MESSAGES: (_) => MessagesScreen(), + SERVICES: (_) => ServicesScreen() }; diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index 0148af61..79ef6878 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -27,6 +27,7 @@ class _DashboardScreenState extends State { Widget build(BuildContext context) { return AppScaffold( appBarTitle: 'Home', + current: 0, body: Container( child: Column( children: [ diff --git a/lib/screens/doctor/message_screen.dart b/lib/screens/doctor/message_screen.dart new file mode 100644 index 00000000..92eb61f3 --- /dev/null +++ b/lib/screens/doctor/message_screen.dart @@ -0,0 +1,15 @@ +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:flutter/material.dart'; + +class MessagesScreen extends StatelessWidget { + @override + Widget build(BuildContext context) { + return AppScaffold( + current: 1, + appBarTitle: 'Messages', + body: Center( + child: Text('Messages heeer'), + ), + ); + } +} diff --git a/lib/screens/my_schedule_screen.dart b/lib/screens/doctor/my_schedule_screen.dart similarity index 96% rename from lib/screens/my_schedule_screen.dart rename to lib/screens/doctor/my_schedule_screen.dart index c4b82e23..f4627d6c 100644 --- a/lib/screens/my_schedule_screen.dart +++ b/lib/screens/doctor/my_schedule_screen.dart @@ -4,9 +4,9 @@ import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indei import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import '../config/size_config.dart'; -import '../widgets/shared/app_scaffold_widget.dart'; -import '../widgets/shared/card_with_bg_widget.dart'; +import '../../config/size_config.dart'; +import '../../widgets/shared/app_scaffold_widget.dart'; +import '../../widgets/shared/card_with_bg_widget.dart'; class MyScheduleScreen extends StatelessWidget { ScheduleProvider scheduleProvider; diff --git a/lib/screens/doctor/services_screen.dart b/lib/screens/doctor/services_screen.dart new file mode 100644 index 00000000..fd599ecc --- /dev/null +++ b/lib/screens/doctor/services_screen.dart @@ -0,0 +1,15 @@ +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:flutter/material.dart'; + +class ServicesScreen extends StatelessWidget { + @override + Widget build(BuildContext context) { + return AppScaffold( + current: 2, + appBarTitle: 'Services', + body: Center( + child: Text('Services heeer'), + ), + ); + } +} \ No newline at end of file diff --git a/lib/screens/patients/patient_search_screen.dart b/lib/screens/patients/patient_search_screen.dart index c900a2ff..591d3059 100644 --- a/lib/screens/patients/patient_search_screen.dart +++ b/lib/screens/patients/patient_search_screen.dart @@ -85,6 +85,7 @@ class _PatientSearchScreenState extends State { Widget build(BuildContext context) { return AppScaffold( appBarTitle: "SEARCH FOR PATIENT", + current: 1, body: ListView( children: [ RoundedContainer( diff --git a/lib/widgets/shared/app_drawer_widget.dart b/lib/widgets/shared/app_drawer_widget.dart index 038af349..430387bc 100644 --- a/lib/widgets/shared/app_drawer_widget.dart +++ b/lib/widgets/shared/app_drawer_widget.dart @@ -1,11 +1,10 @@ -import 'package:doctor_app_flutter/providers/schedule_provider.dart'; -import 'package:doctor_app_flutter/routes.dart'; -import 'package:doctor_app_flutter/screens/my_schedule_screen.dart'; -import 'package:doctor_app_flutter/screens/profile_screen.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../config/size_config.dart'; +import '../../providers/schedule_provider.dart'; +import '../../routes.dart'; +import '../../screens/doctor/my_schedule_screen.dart'; import '../../widgets/shared/drawer_item_widget.dart'; import '../../widgets/shared/rounded_container_widget.dart'; import 'app_texts_widget.dart'; diff --git a/lib/widgets/shared/app_scaffold_widget.dart b/lib/widgets/shared/app_scaffold_widget.dart index 897e0ba1..ccc4d42a 100644 --- a/lib/widgets/shared/app_scaffold_widget.dart +++ b/lib/widgets/shared/app_scaffold_widget.dart @@ -1,3 +1,4 @@ +import 'package:doctor_app_flutter/routes.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; @@ -18,6 +19,7 @@ class AppScaffold extends StatelessWidget { String appBarTitle = ''; Widget body; bool isloading = false; + int current; AppScaffold( {this.pageOnly, @@ -28,7 +30,8 @@ class AppScaffold extends StatelessWidget { this.body, this.showbg, this.showCurve, - this.isloading = false}); + this.isloading = false, + this.current}); @override Widget build(BuildContext context) { @@ -46,9 +49,13 @@ class AppScaffold extends StatelessWidget { title: Text(appBarTitle.toUpperCase()), leading: Builder(builder: (BuildContext context) { return IconButton( - icon: showAppDrawer ? Icon(Icons.menu) : Icon(Icons.arrow_back_ios) , + icon: showAppDrawer + ? Icon(Icons.menu) + : Icon(Icons.arrow_back_ios), color: Colors.black, - onPressed: () => showAppDrawer? Scaffold.of(context).openDrawer() : Navigator.pop(context), + onPressed: () => showAppDrawer + ? Scaffold.of(context).openDrawer() + : Navigator.pop(context), ); }), centerTitle: true, @@ -67,19 +74,43 @@ class AppScaffold extends StatelessWidget { // , bottomNavigationBar: (pageOnly == true || showBottomBar == false) ? null - : BottomNavigationBar(items: [ - BottomNavigationBarItem( - icon: Icon(DoctorApp.home_icon), - title: Text('Home'), - backgroundColor: Colors.red, - activeIcon: Icon(Icons.home)), - BottomNavigationBarItem( - icon: new Icon(Icons.mail), - title: new Text('Messages'), - ), - BottomNavigationBarItem( - icon: Icon(Icons.apps), title: Text('Menu')) - ]), + : BottomNavigationBar( + items: [ + BottomNavigationBarItem( + icon: Icon( + Icons.home, + color: current == 0 ? Colors.red : Colors.grey, + ), + title: Text( + 'Home', + style: TextStyle( + color: current == 0 ? Colors.red : Colors.grey), + ), + backgroundColor: Colors.green, + // activeIcon: Icon(DoctorApp.home_icon) + ), + BottomNavigationBarItem( + icon: new Icon( + Icons.mail, + color: current == 1 ? Colors.red : Colors.grey, + ), + title: new Text('Messages', + style: TextStyle( + color: current == 1 ? Colors.red : Colors.grey)), + // backgroundColor: current == 1?Colors.red:Colors.grey, + ), + BottomNavigationBarItem( + icon: Icon( + Icons.apps, + color: current == 2 ? Colors.red : Colors.grey, + ), + title: Text('Menu', + style: TextStyle( + color: current == 2 ? Colors.red : Colors.grey)), + ) + ], + onTap: (index) => navigatot(index, context), + ), body: (pageOnly == true || showCurve == false) ? Stack(children: [body, buildAppLoaderWidget(isloading)]) : Stack( @@ -102,4 +133,22 @@ class AppScaffold extends StatelessWidget { Widget buildAppLoaderWidget(bool isloading) { return isloading ? AppLoaderWidget() : Container(); } + + navigatot(index, context) { + print('index :${index} current : ${current}'); + if (index != current) { + switch (index) { + case 0: + Navigator.of(context).pushReplacementNamed(HOME); + break; + case 1: + Navigator.of(context).pushReplacementNamed(MESSAGES); + break; + case 2: + Navigator.of(context).pushReplacementNamed(SERVICES); + break; + default: + } + } + } }