From 191719a74cbe7c7bb9b502a44df4dd15c8f78d6d Mon Sep 17 00:00:00 2001 From: themindstorm Date: Wed, 8 Apr 2020 01:05:25 +0800 Subject: [PATCH] fixed back button in mrt map page --- lib/components/core/buttons/back_button.dart | 50 ++++++++++--------- lib/components/core/page_template.dart | 21 +++++--- lib/main.dart | 3 +- lib/route_app.dart | 10 ++-- lib/tabbed_app.dart | 52 ++++++++++++++------ 5 files changed, 80 insertions(+), 56 deletions(-) diff --git a/lib/components/core/buttons/back_button.dart b/lib/components/core/buttons/back_button.dart index d80d95b..6dc5c5e 100644 --- a/lib/components/core/buttons/back_button.dart +++ b/lib/components/core/buttons/back_button.dart @@ -5,31 +5,35 @@ import 'package:nextbussg/styles/values.dart'; class AppBackButton extends StatelessWidget { @override Widget build(BuildContext context) { - return InkWell( - borderRadius: BorderRadius.circular(1000.0), - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 15.0, - vertical: 10.0, - ), - decoration: BoxDecoration( - color: Colors.grey.withOpacity(Values.containerOpacity), - borderRadius: BorderRadius.circular(1000.0) - ), - child: Wrap( - crossAxisAlignment: WrapCrossAlignment.center, - children: [ - Padding( - padding: EdgeInsets.only(right: 10.0), - child: Icon(FontAwesomeIcons.chevronLeft, size: 15) - ), - Text("back", style: Theme.of(context).textTheme.body1.copyWith( - fontSize: 19, - ),), - ], + return Material( + color: Colors.transparent, + child: InkWell( + borderRadius: BorderRadius.circular(1000.0), + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 15.0, + vertical: 10.0, + ), + decoration: BoxDecoration( + color: Colors.grey.withOpacity(Values.containerOpacity), + borderRadius: BorderRadius.circular(1000.0)), + child: Wrap( + crossAxisAlignment: WrapCrossAlignment.center, + children: [ + Padding( + padding: EdgeInsets.only(right: 10.0), + child: Icon(FontAwesomeIcons.chevronLeft, size: 15)), + Text( + "back", + style: Theme.of(context).textTheme.body1.copyWith( + fontSize: 19, + ), + ), + ], + ), ), + onTap: () => Navigator.of(context).pop(), ), - onTap: () => Navigator.of(context).pop(), ); } } diff --git a/lib/components/core/page_template.dart b/lib/components/core/page_template.dart index ce4595d..3f74f58 100644 --- a/lib/components/core/page_template.dart +++ b/lib/components/core/page_template.dart @@ -12,20 +12,25 @@ class PageTemplate extends StatelessWidget { @override Widget build(BuildContext context) { - return SafeArea( + return SafeArea(, bottom: false, child: Padding( padding: EdgeInsets.symmetric(horizontal: Values.pageHorizontalPadding), child: CustomScrollView( slivers: [ - // if (showBackButton) - if (showBackButton) ...[ - Spacing(height: Values.marginBelowTitle).sliver(), + if (showBackButton) + Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Spacing(height: Values.marginBelowTitle), + // Using wrap so it doesn't take 100% width + Wrap(children: [AppBackButton()]), - // Using wrap so it doesn't take 100% width - Wrap(children: [AppBackButton()],).sliverToBoxAdapter(), - Spacing(height: Values.marginBelowTitle).sliver() - ] else + Spacing(height: Values.marginBelowTitle), + ], + ).sliverToBoxAdapter() + else Spacing(height: 20).sliver(), ...children, diff --git a/lib/main.dart b/lib/main.dart index 47347cd..a49dc7a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -12,7 +12,7 @@ import 'package:provider/provider.dart'; void main() async { await Hive.initFlutter(); - await Hive.registerAdapter(ThemeEnumAdapter()); + Hive.registerAdapter(ThemeEnumAdapter()); await Hive.openBox('settings'); await Hive.openBox('favorites'); @@ -23,7 +23,6 @@ void main() async { class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - // return MainApp(); return MultiProvider( providers: [ ChangeNotifierProvider(create: (_) => FavoritesProvider()), diff --git a/lib/route_app.dart b/lib/route_app.dart index c804958..55b6e39 100644 --- a/lib/route_app.dart +++ b/lib/route_app.dart @@ -4,7 +4,7 @@ import 'package:hive/hive.dart'; import 'package:nextbussg/tabbed_app.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:nextbussg/utils/theme_enum.dart'; -import 'dart:io' show Platform; +import 'dart:io'; import 'package:nextbussg/styles/theme.dart'; import 'package:nextbussg/bounce_scroll.dart'; import 'package:nextbussg/components/onboarding/introduction_screen.dart'; @@ -25,12 +25,7 @@ class RouteApp extends StatelessWidget { bool firstLaunch = settingsBox.get('first_launch', defaultValue: true); // set firstLaunch to false so that the onboarding view does not show - Widget home; - if (firstLaunch) - home = new OnboardingView(); - else { - home = new TabbedApp(); - } + Widget home = firstLaunch ? OnboardingView() : TabbedApp(); // change status bar color accordingly, fix for android if (Platform.isAndroid) { @@ -60,6 +55,7 @@ class RouteApp extends StatelessWidget { child: MaterialApp( debugShowCheckedModeBanner: false, theme: theme == ThemeEnum.dark ? appDarkTheme : appLightTheme, + // nice IOS rubber band scrolling home: ScrollConfiguration( child: home, behavior: BounceScrollBehavior(), diff --git a/lib/tabbed_app.dart b/lib/tabbed_app.dart index 5569e59..93d542e 100644 --- a/lib/tabbed_app.dart +++ b/lib/tabbed_app.dart @@ -28,23 +28,43 @@ class TabbedAppState extends State { Widget build(BuildContext context) { // TODO: make nav bar a little transparent so it looks nice return Scaffold( - body: IndexedStack( - index: _selectedIndex, - children: _tabViews, - ), - bottomNavigationBar: Container( - child: BottomNavigationBar( - showSelectedLabels: false, - showUnselectedLabels: false, - backgroundColor: Theme.of(context).scaffoldBackgroundColor, - elevation: 0, - items: _tabs, - currentIndex: _selectedIndex, - onTap: _onItemTapped, - unselectedIconTheme: IconThemeData(size: 26), - selectedIconTheme: IconThemeData(size: 28), - ), + body: Stack( + children: [ + IndexedStack( + index: _selectedIndex, + children: _tabViews, + ), + Align( + alignment: Alignment.bottomCenter, + child: BottomNavigationBar( + showSelectedLabels: false, + showUnselectedLabels: false, + // backgroundColor: Theme.of(context).scaffoldBackgroundColor, + backgroundColor: Theme.of(context).scaffoldBackgroundColor.withOpacity(0.9), + elevation: 0.0, + items: _tabs, + currentIndex: _selectedIndex, + onTap: _onItemTapped, + unselectedIconTheme: IconThemeData(size: 26), + selectedIconTheme: IconThemeData(size: 28), + ), + ) + ], ), + // bottomNavigationBar: Container( + // child: BottomNavigationBar( + // showSelectedLabels: false, + // showUnselectedLabels: false, + // // backgroundColor: Theme.of(context).scaffoldBackgroundColor, + // backgroundColor: Colors.transparent, + // elevation: 0.0, + // items: _tabs, + // currentIndex: _selectedIndex, + // onTap: _onItemTapped, + // unselectedIconTheme: IconThemeData(size: 26), + // selectedIconTheme: IconThemeData(size: 28), + // ), + // ), ); } }