- introPage.dart: Convert fireItems to proper static function closure - mainDrawer.dart: Convert unreadCount int to String for Text widget
43 lines
1.5 KiB
Dart
43 lines
1.5 KiB
Dart
import 'package:redux/redux.dart';
|
|
|
|
import '../models/yourLocation.dart';
|
|
import 'actions.dart';
|
|
|
|
final Reducer<List<YourLocation>> yourLocationsReducer = combineReducers<List<YourLocation>>(<Reducer<List<YourLocation>>>[
|
|
TypedReducer<List<YourLocation>, AddedYourLocationAction>(
|
|
_addedYourLocation),
|
|
TypedReducer<List<YourLocation>, DeletedYourLocationAction>(
|
|
_deletedYourLocation),
|
|
TypedReducer<List<YourLocation>, UpdatedYourLocationAction>(
|
|
_updatedYourLocation),
|
|
TypedReducer<List<YourLocation>, ToggledSubscriptionAction>(
|
|
_toggledSubscriptionAction)
|
|
]);
|
|
|
|
List<YourLocation> _addedYourLocation(
|
|
List<YourLocation> yourLocations, AddedYourLocationAction action) {
|
|
return List.from(yourLocations)..add(action.loc);
|
|
}
|
|
|
|
List<YourLocation> _deletedYourLocation(
|
|
List<YourLocation> yourLocations, DeletedYourLocationAction action) {
|
|
return yourLocations
|
|
.where((YourLocation yourLocation) => yourLocation.id != action.id)
|
|
.toList();
|
|
}
|
|
|
|
List<YourLocation> _updatedYourLocation(
|
|
List<YourLocation> yourLocations, UpdatedYourLocationAction action) {
|
|
return yourLocations
|
|
.map((YourLocation yourLocation) =>
|
|
yourLocation.id == action.loc.id ? action.loc : yourLocation)
|
|
.toList();
|
|
}
|
|
|
|
List<YourLocation> _toggledSubscriptionAction(
|
|
List<YourLocation> yourLocations, ToggledSubscriptionAction action) {
|
|
return yourLocations
|
|
.map((YourLocation yourLocation) =>
|
|
yourLocation.id == action.loc.id ? action.loc : yourLocation)
|
|
.toList();
|
|
}
|