More work with fire notifications
This commit is contained in:
parent
5fdaf239c0
commit
9dd8a7de97
24 changed files with 512 additions and 288 deletions
|
|
@ -1,16 +1,38 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'colors.dart';
|
||||
import 'sandbox.dart';
|
||||
import 'activeFires.dart';
|
||||
import 'globals.dart' as globals;
|
||||
import 'generated/i18n.dart';
|
||||
import 'package:badge/badge.dart';
|
||||
import 'package:comunes_flutter/comunes_flutter.dart';
|
||||
import 'privacyPage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
|
||||
import 'activeFires.dart';
|
||||
import 'colors.dart';
|
||||
import 'fireAlert.dart';
|
||||
import 'supportPage.dart';
|
||||
import 'fireNotificationList.dart';
|
||||
import 'package:community_material_icon/community_material_icon.dart';
|
||||
import 'generated/i18n.dart';
|
||||
import 'globals.dart' as globals;
|
||||
import 'models/appState.dart';
|
||||
import 'privacyPage.dart';
|
||||
import 'sandbox.dart';
|
||||
import 'supportPage.dart';
|
||||
|
||||
@immutable
|
||||
class _ViewModel {
|
||||
final int unreadCount;
|
||||
|
||||
_ViewModel({
|
||||
@required this.unreadCount,
|
||||
});
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
other is _ViewModel &&
|
||||
runtimeType == other.runtimeType &&
|
||||
unreadCount == other.unreadCount;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => unreadCount.hashCode;
|
||||
}
|
||||
|
||||
class MainDrawer extends Drawer {
|
||||
MainDrawer(BuildContext context, {key})
|
||||
|
|
@ -18,101 +40,115 @@ class MainDrawer extends Drawer {
|
|||
}
|
||||
|
||||
Widget mainDrawer(BuildContext context) {
|
||||
return new ListView(
|
||||
// Important: Remove any padding from the ListView.
|
||||
padding: EdgeInsets.zero,
|
||||
children: listWithoutNulls(<Widget>[
|
||||
new GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, '/');
|
||||
},
|
||||
child: new DrawerHeader(
|
||||
child: new Column(
|
||||
children: <Widget>[
|
||||
new Image.asset(
|
||||
'images/logo-200.png',
|
||||
fit: BoxFit.scaleDown,
|
||||
height: 80.0,
|
||||
return new StoreConnector<AppState, _ViewModel>(
|
||||
distinct: true,
|
||||
converter: (store) {
|
||||
return new _ViewModel(unreadCount: store.state.fireNotificationsUnread);
|
||||
},
|
||||
builder: (context, view) {
|
||||
return new ListView(
|
||||
// Important: Remove any padding from the ListView.
|
||||
padding: EdgeInsets.zero,
|
||||
children: listWithoutNulls(<Widget>[
|
||||
new GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, '/');
|
||||
},
|
||||
child: new DrawerHeader(
|
||||
child: new Column(
|
||||
children: <Widget>[
|
||||
new Image.asset(
|
||||
'images/logo-200.png',
|
||||
fit: BoxFit.scaleDown,
|
||||
height: 80.0,
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
new Text(S.of(context).appName,
|
||||
style: new TextStyle(
|
||||
fontSize: 24.0,
|
||||
color: Colors.white,
|
||||
)),
|
||||
],
|
||||
),
|
||||
decoration: new BoxDecoration(
|
||||
color: fires300,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
new Text(S.of(context).appName,
|
||||
style: new TextStyle(
|
||||
fontSize: 24.0,
|
||||
color: Colors.white,
|
||||
)),
|
||||
],
|
||||
),
|
||||
decoration: new BoxDecoration(
|
||||
color: fires300,
|
||||
),
|
||||
),
|
||||
),
|
||||
new ListTile(
|
||||
leading: const Icon(Icons.whatshot),
|
||||
title: new Text(S.of(context).activeFires),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, ActiveFiresPage.routeName);
|
||||
},
|
||||
),
|
||||
new ListTile(
|
||||
leading: const Icon(Icons.notifications_active),
|
||||
title: new Text(S.of(context).notifyAFire),
|
||||
onTap: () {
|
||||
// Then close the drawer
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, FireAlert.routeName);
|
||||
},
|
||||
),
|
||||
new ListTile(
|
||||
leading: const Icon(Icons.notifications),
|
||||
title: new Text(S.of(context).fireNotificationsTitleShort),
|
||||
onTap: () {
|
||||
// Then close the drawer
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, FireNotificationList.routeName);
|
||||
},
|
||||
),
|
||||
new Divider(),
|
||||
new ListTile(
|
||||
leading: const Icon(Icons.favorite),
|
||||
title: new Text(S.of(context).supportThisInitiative),
|
||||
onTap: () {
|
||||
// Then close the drawer
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, SupportPage.routeName);
|
||||
},
|
||||
),
|
||||
new ListTile(
|
||||
leading: const Icon(Icons.lock),
|
||||
title: new Text(S.of(context).privacyPolicy),
|
||||
onTap: () {
|
||||
// Then close the drawer
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, PrivacyPage.routeName);
|
||||
},
|
||||
),
|
||||
globals.isDevelopment ?
|
||||
new ListTile(
|
||||
leading: const Icon(Icons.bug_report),
|
||||
title: new Text('Sandbox'),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, Sandbox.routeName);
|
||||
},
|
||||
): null,
|
||||
new AboutListTile(
|
||||
icon: globals.appIcon,
|
||||
applicationName: S.of(context).appName,
|
||||
applicationVersion: globals.appVersion,
|
||||
applicationIcon: globals.appMediumIcon,
|
||||
applicationLegalese: S.of(context).appLicense(DateTime.now().year.toString()),
|
||||
aboutBoxChildren: <Widget> [
|
||||
// new Text('What?')
|
||||
]
|
||||
// FIXME
|
||||
)
|
||||
])
|
||||
);
|
||||
new ListTile(
|
||||
leading: const Icon(Icons.whatshot),
|
||||
title: new Text(S.of(context).activeFires),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, ActiveFiresPage.routeName);
|
||||
},
|
||||
),
|
||||
new ListTile(
|
||||
leading: const Icon(Icons.notifications_active),
|
||||
title: new Text(S.of(context).notifyAFire),
|
||||
onTap: () {
|
||||
// Then close the drawer
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, FireAlert.routeName);
|
||||
},
|
||||
),
|
||||
new ListTile(
|
||||
leading: const Icon(Icons.notifications),
|
||||
title: view.unreadCount > 0
|
||||
? Badge.after(
|
||||
spacing: 5.0,
|
||||
borderColor: Colors.red,
|
||||
child: Text(S.of(context).fireNotificationsTitleShort),
|
||||
value: ' ${view.unreadCount.toString()} ')
|
||||
: Text(S.of(context).fireNotificationsTitleShort),
|
||||
onTap: () {
|
||||
// Then close the drawer
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, FireNotificationList.routeName);
|
||||
},
|
||||
),
|
||||
new Divider(),
|
||||
new ListTile(
|
||||
leading: const Icon(Icons.favorite),
|
||||
title: new Text(S.of(context).supportThisInitiative),
|
||||
onTap: () {
|
||||
// Then close the drawer
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, SupportPage.routeName);
|
||||
},
|
||||
),
|
||||
new ListTile(
|
||||
leading: const Icon(Icons.lock),
|
||||
title: new Text(S.of(context).privacyPolicy),
|
||||
onTap: () {
|
||||
// Then close the drawer
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, PrivacyPage.routeName);
|
||||
},
|
||||
),
|
||||
globals.isDevelopment
|
||||
? new ListTile(
|
||||
leading: const Icon(Icons.bug_report),
|
||||
title: new Text('Sandbox'),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, Sandbox.routeName);
|
||||
},
|
||||
)
|
||||
: null,
|
||||
new AboutListTile(
|
||||
icon: globals.appIcon,
|
||||
applicationName: S.of(context).appName,
|
||||
applicationVersion: globals.appVersion,
|
||||
applicationIcon: globals.appMediumIcon,
|
||||
applicationLegalese:
|
||||
S.of(context).appLicense(DateTime.now().year.toString()),
|
||||
aboutBoxChildren: <Widget>[
|
||||
// new Text('What?')
|
||||
]
|
||||
// FIXME
|
||||
)
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue