diff --git a/lib/pages/BookAppointment/BookingOptions.dart b/lib/pages/BookAppointment/BookingOptions.dart index 83af454f..91d90da6 100644 --- a/lib/pages/BookAppointment/BookingOptions.dart +++ b/lib/pages/BookAppointment/BookingOptions.dart @@ -32,6 +32,8 @@ class _BookingOptionsState extends State { return AppScaffold( isShowAppBar: widget.isAppbar, isShowDecPage: false, + isShowBottomNavBar: false, + appBarTitle: TranslationBase.of(context).bookAppo, body: Container( margin: EdgeInsets.fromLTRB(10.0, 20.0, 10.0, 10.0), diff --git a/lib/pages/DrawerPages/family/my-family.dart b/lib/pages/DrawerPages/family/my-family.dart index 7493dfc1..5f326ba6 100644 --- a/lib/pages/DrawerPages/family/my-family.dart +++ b/lib/pages/DrawerPages/family/my-family.dart @@ -92,6 +92,8 @@ class _MyFamily extends State with TickerProviderStateMixin { isShowAppBar: widget.isAppbarVisible, imagesInfo: imagesInfo, description: TranslationBase.of(context).familyInfo, + isShowBottomNavBar: false, + body: Scaffold( extendBodyBehindAppBar: true, appBar: PreferredSize( diff --git a/lib/pages/ToDoList/ToDo.dart b/lib/pages/ToDoList/ToDo.dart index febbdf0f..6ef794c8 100644 --- a/lib/pages/ToDoList/ToDo.dart +++ b/lib/pages/ToDoList/ToDo.dart @@ -81,6 +81,8 @@ class _ToDoState extends State { isShowAppBar: widget.isShowAppBar, isShowDecPage: true, description: TranslationBase.of(context).infoTodo, + isShowBottomNavBar: false, + body: SingleChildScrollView( child: Column( children: [ diff --git a/lib/pages/landing/home_page.dart b/lib/pages/landing/home_page.dart index 8793452a..22adeec2 100644 --- a/lib/pages/landing/home_page.dart +++ b/lib/pages/landing/home_page.dart @@ -51,6 +51,7 @@ class _HomePageState extends State { builder: (_, model, wi) => AppScaffold( isShowDecPage: false, isHelp: true, + isShowBottomNavBar: false, body: Container( width: double.infinity, child: SingleChildScrollView( diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index df0af1f3..d17c557b 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -32,6 +32,7 @@ import 'package:diplomaticquarterapp/widgets/buttons/floatingActionButton.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:diplomaticquarterapp/widgets/drawer/app_drawer_widget.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:firebase_analytics/observer.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/cupertino.dart'; @@ -47,8 +48,11 @@ import 'home_page.dart'; class LandingPage extends StatefulWidget { static LandingPage shared; + int currentTab = 0; _LandingPageState state; - LandingPage() { + + LandingPage({currentTabLocal}) { + currentTab = currentTabLocal ?? 0; LandingPage.shared = this; } @@ -67,7 +71,6 @@ class LandingPage extends StatefulWidget { class _LandingPageState extends State with WidgetsBindingObserver { var authProvider = new AuthProvider(); - int currentTab = 0; PageController pageController; ProjectViewModel projectViewModel; var notificationCount = ''; @@ -99,7 +102,7 @@ class _LandingPageState extends State with WidgetsBindingObserver { changeCurrentTab(int tab) { setState(() { - if (currentTab > 0 && tab == 2) + if (widget.currentTab > 0 && tab == 2) pageController.jumpToPage(0); else if (tab != 0) pageController.jumpToPage(tab); @@ -107,7 +110,7 @@ class _LandingPageState extends State with WidgetsBindingObserver { IS_VOICE_COMMAND_CLOSED = false; pageController.jumpToPage(tab); } - currentTab = tab; + widget.currentTab = tab; }); } @@ -166,7 +169,8 @@ class _LandingPageState extends State with WidgetsBindingObserver { AppGlobal.context = context; _requestIOSPermissions(); - pageController = PageController(keepPage: true); + pageController = + PageController(keepPage: true, initialPage: widget.currentTab); _firebaseMessaging.setAutoInitEnabled(true); locationUtils = @@ -472,94 +476,84 @@ class _LandingPageState extends State with WidgetsBindingObserver { Widget build(BuildContext context) { projectViewModel = Provider.of(context); - return Scaffold( - appBar: AppBar( - elevation: 0, - textTheme: TextTheme( - headline6: TextStyle( - color: Theme.of(context).textTheme.headline1.color, - fontWeight: FontWeight.bold), - ), - title: Text( - getText(currentTab).toUpperCase(), - style: TextStyle( - fontWeight: FontWeight.bold, - color: Theme.of(context).textTheme.headline1.color, - fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans'), - // bold: true, - // color: Colors.white, - ), - leading: Builder( - builder: (BuildContext context) { - return new Stack( - children: [ - currentTab == 0 - ? IconButton( - icon: Icon(Icons.menu), - color: Theme.of(context).textTheme.headline1.color, - onPressed: () => Scaffold.of(context).openDrawer(), - ) - : IconButton( - icon: Icon(Icons.arrow_back), - color: Theme.of(context).textTheme.headline1.color, - onPressed: () { - setState(() { - currentTab = 0; - }); - - pageController.jumpToPage(0); - }, - ), - notificationCount != '' - ? new Positioned( - right: projectViewModel.isArabic ? 35 : 0, - top: 5, - child: new Container( - padding: EdgeInsets.all(4), - decoration: new BoxDecoration( - color: Colors.red, - borderRadius: BorderRadius.circular(20), - ), - constraints: BoxConstraints( - minWidth: 20, - minHeight: 20, - ), - child: new Text( - notificationCount, - style: new TextStyle( - color: Colors.white, - fontSize: projectViewModel.isArabic ? 8 : 9, - ), - textAlign: TextAlign.center, + return AppScaffold( + isShowAppBar: true, + showHomeAppBarIcon: false, + appBarTitle: getText(widget.currentTab).toUpperCase(), + leading: Builder( + builder: (BuildContext context) { + return new Stack( + children: [ + widget.currentTab == 0 + ? IconButton( + icon: Icon(Icons.menu), + color: Theme.of(context).textTheme.headline1.color, + onPressed: () => Scaffold.of(context).openDrawer(), + ) + : IconButton( + icon: Icon(Icons.arrow_back), + color: Theme.of(context).textTheme.headline1.color, + onPressed: () { + setState(() { + widget.currentTab = 0; + }); + + pageController.jumpToPage(0); + }, + ), + notificationCount != '' + ? new Positioned( + right: projectViewModel.isArabic ? 35 : 0, + top: 5, + child: new Container( + padding: EdgeInsets.all(4), + decoration: new BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(20), + ), + constraints: BoxConstraints( + minWidth: 20, + minHeight: 20, + ), + child: new Text( + notificationCount, + style: new TextStyle( + color: Colors.white, + fontSize: projectViewModel.isArabic ? 8 : 9, ), + textAlign: TextAlign.center, ), - ) - : SizedBox() - ], - ); - }, - ), - actions: [ - IconButton( - //iconSize: 70, - icon: Icon( - projectViewModel.isLogin ? Icons.settings : Icons.login, - color: Theme.of(context).textTheme.headline1.color, - ), - onPressed: () { - if (projectViewModel.isLogin) - Navigator.of(context).pushNamed( - SETTINGS, - ); - else - login(); - }, //do something, - ) - ], - centerTitle: true, + ), + ) + : SizedBox() + ], + ); + }, ), - drawer: SafeArea(child: AppDrawer()), - extendBody: true, + isShowDrawer: true, + appBarIcons: [ + IconButton( + //iconSize: 70, + icon: Icon( + projectViewModel.isLogin ? Icons.settings : Icons.login, + color: Theme.of(context).textTheme.headline1.color, + ), + onPressed: () { + if (projectViewModel.isLogin) + Navigator.of(context).pushNamed( + SETTINGS, + ); + else + login(); + }, //do something, + ) + ], + // drawer: SafeArea(child: AppDrawer()), + // extendBody: true, + isShowDecPage: false, + changeTab: changeCurrentTab, + isFromLandingPage: true, + currentTab: widget.currentTab, body: PageView( physics: NeverScrollableScrollPhysics(), controller: pageController, @@ -575,13 +569,9 @@ class _LandingPageState extends State with WidgetsBindingObserver { ToDo(isShowAppBar: false), ], // Please do not remove the BookingOptions from this array ), - bottomNavigationBar: BottomNavBar( - changeIndex: changeCurrentTab, - index: currentTab, - ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, floatingActionButton: - (projectViewModel.havePrivilege(34) && currentTab == 0) + (projectViewModel.havePrivilege(34) && widget.currentTab == 0) ? FloatingButton( elevation: true, onTap: () { diff --git a/lib/pages/medical/medical_profile_page.dart b/lib/pages/medical/medical_profile_page.dart index 8d49a89b..8ba7106f 100644 --- a/lib/pages/medical/medical_profile_page.dart +++ b/lib/pages/medical/medical_profile_page.dart @@ -72,6 +72,8 @@ class _MedicalProfilePageState extends State { isShowDecPage: false, baseViewModel: model, isHelp: true, + isShowBottomNavBar: false, + body: Container( child: SingleChildScrollView( child: Column( diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index 6a20ef3f..7f2a0f96 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -12,7 +12,9 @@ import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.da import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/bottom_navigation/bottom_nav_bar.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/drawer/app_drawer_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/bottom_bar.dart'; import 'package:diplomaticquarterapp/widgets/progress_indicator/app_loader_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; @@ -44,6 +46,7 @@ class AppScaffold extends StatelessWidget { final BaseViewModel baseViewModel; final bool isBottomBar; final Widget floatingActionButton; + final FloatingActionButtonLocation floatingActionButtonLocation; final bool isPharmacy; final bool isOfferPackages; final bool showPharmacyCart; @@ -58,10 +61,19 @@ class AppScaffold extends StatelessWidget { final List appBarIcons; final List imagesInfo; final bool isHelp; + + final int currentTab; + final bool isShowBottomNavBar; + final bool isFromLandingPage; + final bool isShowDrawer; + final Function(int tab) changeTab; + final Widget leading; + AuthenticatedUserObject authenticatedUserObject = locator(); AppBarWidget appBar; + AppScaffold( {@required this.body, this.appBarTitle = '', @@ -85,7 +97,14 @@ class AppScaffold extends StatelessWidget { this.infoList, this.isHelp = false, this.showHomeAppBarIcon = true, - this.imagesInfo}); + this.imagesInfo, + this.currentTab, + this.isShowBottomNavBar = true, + this.isFromLandingPage = false, + this.changeTab, + this.floatingActionButtonLocation, + this.leading, + this.isShowDrawer = false}); AppScaffold setOnAppBarCartClick(VoidCallback onClick) { _onCartClick = onClick; @@ -98,6 +117,7 @@ class AppScaffold extends StatelessWidget { return Scaffold( backgroundColor: backgroundColor ?? Theme.of(context).scaffoldBackgroundColor, + drawer: isShowDrawer ? SafeArea(child: AppDrawer()) : null, appBar: isShowAppBar ? appBar = AppBarWidget( appBarTitle: appBarTitle, @@ -108,9 +128,16 @@ class AppScaffold extends StatelessWidget { isOfferPackages: isOfferPackages, showOfferPackagesCart: showOfferPackagesCart, isShowDecPage: isShowDecPage, + leading: leading, ) : null, bottomSheet: bottomSheet, + bottomNavigationBar: isShowBottomNavBar + ? BottomNavBar( + changeIndex: changeCurrentTab, + index: currentTab, + ) + : null, body: SafeArea( top: true, bottom: true, @@ -131,6 +158,7 @@ class AppScaffold extends StatelessWidget { : buildBodyWidget(context), ), floatingActionButton: floatingActionButton, + floatingActionButtonLocation: floatingActionButtonLocation, ); } @@ -142,6 +170,20 @@ class AppScaffold extends StatelessWidget { return Stack( children: [body, isHelp == true ? RobotIcon() : Container()]); } + + void changeCurrentTab(int value) { + if (isFromLandingPage) { + changeTab(value); + // call the nav funcion + } else { + // navigate to langing page with index + Navigator.pushAndRemoveUntil( + AppGlobal.context, + MaterialPageRoute( + builder: (context) => LandingPage(currentTabLocal: value)), + (Route r) => false); + } + } } class AppBarWidget extends StatefulWidget with PreferredSizeWidget { @@ -159,6 +201,8 @@ class AppBarWidget extends StatefulWidget with PreferredSizeWidget { Function(String) badgeUpdater; + final Widget leading; + AppBarWidget( {this.appBarTitle, this.showHomeAppBarIcon, @@ -167,7 +211,8 @@ class AppBarWidget extends StatefulWidget with PreferredSizeWidget { this.showPharmacyCart = true, this.isOfferPackages = false, this.showOfferPackagesCart = false, - this.isShowDecPage = true}); + this.isShowDecPage = true, + this.leading}); @override State createState() => AppBarWidgetState(); @@ -178,6 +223,7 @@ class AppBarWidget extends StatefulWidget with PreferredSizeWidget { class AppBarWidgetState extends State { String badgeText = "0"; + @override Widget build(BuildContext context) { widget.badgeUpdater = badgeUpdateBlock; @@ -210,11 +256,12 @@ class AppBarWidgetState extends State { fontWeight: FontWeight.bold, color: Theme.of(context).textTheme.headline1.color, fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans')), - leading: Builder( - builder: (BuildContext context) { - return ArrowBack(); - }, - ), + leading: widget.leading ?? + Builder( + builder: (BuildContext context) { + return ArrowBack(); + }, + ), centerTitle: true, actions: [ (widget.isPharmacy && widget.showPharmacyCart) @@ -364,10 +411,10 @@ class _RobotIcon extends State { bottom: -15); } - // setAnimation() async { - // /// await sharedPref.getBool(IS_ROBOT_VISIBLE) || - // // var animation = - // // IS_TEXT_COMPLETED == ? true : false; +// setAnimation() async { +// /// await sharedPref.getBool(IS_ROBOT_VISIBLE) || +// // var animation = +// // IS_TEXT_COMPLETED == ? true : false; - // } +// } }