Skip to content

Commit

Permalink
fixed back button in mrt map page
Browse files Browse the repository at this point in the history
  • Loading branch information
ninest committed Apr 7, 2020
1 parent 69dec5c commit 191719a
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 56 deletions.
50 changes: 27 additions & 23 deletions lib/components/core/buttons/back_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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: <Widget>[
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: <Widget>[
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(),
);
}
}
21 changes: 13 additions & 8 deletions lib/components/core/page_template.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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: <Widget>[
// 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: <Widget>[AppBackButton()]),

// Using wrap so it doesn't take 100% width
Wrap(children: <Widget>[AppBackButton()],).sliverToBoxAdapter(),
Spacing(height: Values.marginBelowTitle).sliver()
] else
Spacing(height: Values.marginBelowTitle),
],
).sliverToBoxAdapter()
else
Spacing(height: 20).sliver(),

...children,
Expand Down
3 changes: 1 addition & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -23,7 +23,6 @@ void main() async {
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// return MainApp();
return MultiProvider(
providers: [
ChangeNotifierProvider<FavoritesProvider>(create: (_) => FavoritesProvider()),
Expand Down
10 changes: 3 additions & 7 deletions lib/route_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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) {
Expand Down Expand Up @@ -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(),
Expand Down
52 changes: 36 additions & 16 deletions lib/tabbed_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,43 @@ class TabbedAppState extends State<TabbedApp> {
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: <Widget>[
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),
// ),
// ),
);
}
}

0 comments on commit 191719a

Please sign in to comment.