Added Monitorized Areas
This commit is contained in:
parent
864ee28584
commit
e50ff5179b
16 changed files with 223 additions and 19 deletions
|
|
@ -2,6 +2,8 @@ import 'package:fires_flutter/models/yourLocation.dart';
|
|||
import 'package:fires_flutter/models/fireNotification.dart';
|
||||
import 'dart:async';
|
||||
import 'package:connectivity/connectivity.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
|
||||
abstract class AppActions {}
|
||||
|
||||
class FetchYourLocationsAction extends AppActions {
|
||||
|
|
@ -20,6 +22,8 @@ class FetchYourLocationsSucceededAction extends AppActions {
|
|||
|
||||
class FetchFireNotificationsAction extends AppActions {}
|
||||
|
||||
class FetchMonitoredAreasAction extends AppActions {}
|
||||
|
||||
class FetchYourLocationsFailedAction extends AppActions {
|
||||
final Exception error;
|
||||
|
||||
|
|
@ -55,4 +59,10 @@ class OnConnectivityChanged extends AppActions {
|
|||
final ConnectivityResult connectivityResult;
|
||||
|
||||
OnConnectivityChanged(this.connectivityResult);
|
||||
}
|
||||
}
|
||||
|
||||
class FetchMonitoredAreasSucceededAction extends AppActions {
|
||||
final List<Polyline> monitoredAreas;
|
||||
|
||||
FetchMonitoredAreasSucceededAction(this.monitoredAreas);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ AppState appReducer(AppState state, action) {
|
|||
return state.copyWith(fireNotifications: action.fetchedFireNotifications,
|
||||
fireNotificationsUnread: action.unreadCount);
|
||||
}
|
||||
if (action is FetchMonitoredAreasSucceededAction) {
|
||||
return state.copyWith(monitoredAreas: action.monitoredAreas);
|
||||
}
|
||||
if (action is AddedFireNotificationAction)
|
||||
return state.copyWith(
|
||||
fireNotificationsUnread: state.fireNotificationsUnread + 1);
|
||||
|
|
|
|||
|
|
@ -214,6 +214,13 @@ void fetchDataMiddleware(Store<AppState> store, action, NextDispatcher next) {
|
|||
});
|
||||
}
|
||||
|
||||
if (action is FetchMonitoredAreasAction) {
|
||||
api.getMonitoredAreas(state: store.state).then((result) { // store.dispatch()
|
||||
store.dispatch(
|
||||
new FetchMonitoredAreasSucceededAction(result));
|
||||
});
|
||||
}
|
||||
|
||||
// Make sure our actions continue on to the reducer.
|
||||
next(action);
|
||||
}
|
||||
|
|
@ -243,5 +250,6 @@ void createUser(store, lang, token) {
|
|||
store.dispatch(new OnUserCreatedAction(userId));
|
||||
store.dispatch(new FetchYourLocationsAction());
|
||||
store.dispatch(new FetchFireNotificationsAction());
|
||||
store.dispatch(new FetchMonitoredAreasAction());
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ AppState appStateReducer(AppState prevState, action) {
|
|||
isLoaded: loadedReducer(state.isLoaded, action),
|
||||
error: errorReducer(state.error, action),
|
||||
fireMapState: fireMapReducer(state.fireMapState, action),
|
||||
monitoredAreas: state.monitoredAreas,
|
||||
firesApiKey: state.firesApiKey,
|
||||
firesApiUrl: state.firesApiUrl,
|
||||
serverUrl: state.serverUrl,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue