Navigation improvements
This commit is contained in:
parent
ff854b2a06
commit
0b56a02a0b
9 changed files with 151 additions and 160 deletions
|
|
@ -2,7 +2,6 @@ import 'package:badge/badge.dart';
|
|||
import 'package:comunes_flutter/comunes_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:flutter_simple_dependency_injection/injector.dart';
|
||||
|
||||
import 'activeFires.dart';
|
||||
import 'colors.dart';
|
||||
|
|
@ -37,30 +36,19 @@ class _ViewModel {
|
|||
}
|
||||
|
||||
class MainDrawer extends Drawer {
|
||||
MainDrawer(BuildContext context, {key})
|
||||
: super(key: key, child: mainDrawer(context));
|
||||
|
||||
static getDrawer(BuildContext context) {
|
||||
Injector inj = Injector.getInjector();
|
||||
MainDrawer d;
|
||||
try {
|
||||
d = inj.get<MainDrawer>();
|
||||
} catch (e) {
|
||||
inj.map<MainDrawer>((i) => new MainDrawer(context), isSingleton: true);
|
||||
d = inj.get<MainDrawer>();
|
||||
}
|
||||
return d;
|
||||
}
|
||||
MainDrawer(BuildContext context, String currentRoute, {key})
|
||||
: super(key: key, child: mainDrawer(context, currentRoute));
|
||||
}
|
||||
|
||||
Widget mainDrawer(BuildContext context) {
|
||||
Widget mainDrawer(BuildContext context, String currentRoute) {
|
||||
return new StoreConnector<AppState, _ViewModel>(
|
||||
distinct: true,
|
||||
converter: (store) {
|
||||
return new _ViewModel(unreadCount: store.state.fireNotificationsUnread);
|
||||
},
|
||||
builder: (context, view) {
|
||||
final bottomTextStyle = new TextStyle(fontSize: 12.0, color: Colors.grey);
|
||||
final bottomTextStyle =
|
||||
new TextStyle(fontSize: 12.0, color: Colors.grey);
|
||||
return new ListView(
|
||||
// Important: Remove any padding from the ListView.
|
||||
padding: EdgeInsets.zero,
|
||||
|
|
@ -68,7 +56,7 @@ Widget mainDrawer(BuildContext context) {
|
|||
new GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, '/');
|
||||
Navigator.popAndPushNamed(context, '/');
|
||||
},
|
||||
child: new DrawerHeader(
|
||||
child: new Column(
|
||||
|
|
@ -94,22 +82,22 @@ Widget mainDrawer(BuildContext context) {
|
|||
new ListTile(
|
||||
leading: const Icon(Icons.whatshot),
|
||||
title: new Text(S.of(context).activeFires),
|
||||
selected: currentRoute == ActiveFiresPage.routeName,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, ActiveFiresPage.routeName);
|
||||
Navigator.popAndPushNamed(context, ActiveFiresPage.routeName);
|
||||
},
|
||||
),
|
||||
new ListTile(
|
||||
leading: const Icon(Icons.notifications_active),
|
||||
selected: currentRoute == FireAlert.routeName,
|
||||
title: new Text(S.of(context).notifyAFire),
|
||||
onTap: () {
|
||||
// Then close the drawer
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, FireAlert.routeName);
|
||||
Navigator.popAndPushNamed(context, FireAlert.routeName);
|
||||
},
|
||||
),
|
||||
new ListTile(
|
||||
leading: const Icon(Icons.notifications),
|
||||
selected: currentRoute == FireNotificationList.routeName,
|
||||
title: view.unreadCount > 0
|
||||
? Badge.after(
|
||||
spacing: 5.0,
|
||||
|
|
@ -118,47 +106,45 @@ Widget mainDrawer(BuildContext context) {
|
|||
value: ' ${view.unreadCount.toString()} ')
|
||||
: Text(S.of(context).fireNotificationsTitleShort),
|
||||
onTap: () {
|
||||
// Then close the drawer
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, FireNotificationList.routeName);
|
||||
Navigator.popAndPushNamed(context, FireNotificationList.routeName);
|
||||
},
|
||||
),
|
||||
globals.isDevelopment
|
||||
? new ListTile(
|
||||
leading: const Icon(Icons.map),
|
||||
title: new Text(S.of(context).monitoredAreasTitle),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, MonitoredAreasPage.routeName);
|
||||
},
|
||||
)
|
||||
: null,
|
||||
? new ListTile(
|
||||
leading: const Icon(Icons.map),
|
||||
selected: currentRoute == MonitoredAreasPage.routeName,
|
||||
title: new Text(S.of(context).monitoredAreasTitle),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.popAndPushNamed(
|
||||
context, MonitoredAreasPage.routeName);
|
||||
},
|
||||
)
|
||||
: null,
|
||||
new Divider(),
|
||||
new ListTile(
|
||||
leading: const Icon(Icons.favorite),
|
||||
selected: currentRoute == SupportPage.routeName,
|
||||
title: new Text(S.of(context).supportThisInitiative),
|
||||
onTap: () {
|
||||
// Then close the drawer
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, SupportPage.routeName);
|
||||
Navigator.popAndPushNamed(context, SupportPage.routeName);
|
||||
},
|
||||
),
|
||||
new ListTile(
|
||||
leading: const Icon(Icons.lock),
|
||||
selected: currentRoute == PrivacyPage.routeName,
|
||||
title: new Text(S.of(context).privacyPolicy),
|
||||
onTap: () {
|
||||
// Then close the drawer
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, PrivacyPage.routeName);
|
||||
Navigator.popAndPushNamed(context, PrivacyPage.routeName);
|
||||
},
|
||||
),
|
||||
globals.isDevelopment
|
||||
? new ListTile(
|
||||
leading: const Icon(Icons.bug_report),
|
||||
title: new Text('Sandbox'),
|
||||
selected: currentRoute == Sandbox.routeName,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, Sandbox.routeName);
|
||||
Navigator.popAndPushNamed(context, Sandbox.routeName);
|
||||
},
|
||||
)
|
||||
: null,
|
||||
|
|
@ -167,10 +153,12 @@ Widget mainDrawer(BuildContext context) {
|
|||
applicationName: S.of(context).appName,
|
||||
applicationVersion: globals.appVersion,
|
||||
applicationIcon: globals.appMediumIcon,
|
||||
applicationLegalese: S.of(context).appLicense(DateTime.now().year.toString()),
|
||||
applicationLegalese:
|
||||
S.of(context).appLicense(DateTime.now().year.toString()),
|
||||
aboutBoxChildren: <Widget>[
|
||||
new SizedBox(height: 10.0),
|
||||
new Text(S.of(context).appMoto), // , style: new TextStyle(fontStyle: FontStyle.italic)),
|
||||
new Text(S.of(context).appMoto),
|
||||
// , style: new TextStyle(fontStyle: FontStyle.italic)),
|
||||
new SizedBox(height: 10.0),
|
||||
new Text(S.of(context).NASAAck, style: bottomTextStyle),
|
||||
// More ?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue