refactor: continue lint cleanup - 96 more issues fixed
- Add @immutable to classes with ==/hashCode (homePage, basicLocation, fireNotification, yourLocation, monitoredAreas) - Fix camel_case_types (genericMap → GenericMap) - Fix avoid_dynamic_calls (firesApi - typed responses) - Fix use_build_context_synchronously (locationUtils) - Fix always_put_control_body_on_new_line (4 reducers) - Fix always_specify_types (placesAutocompleteUtils, reducers) - Fix eol_at_end_of_file (4 files) - Fix prefer_function_declarations_over_variables (introPage) - Fix flutter_style_todos (fireMapReducer) Build: APK generated, 0 errors, 0 warnings
This commit is contained in:
parent
862d423f6b
commit
68ad4adbcf
23 changed files with 118 additions and 95 deletions
|
|
@ -287,7 +287,7 @@ class _ActiveFiresPageState extends State<ActiveFiresPage> {
|
|||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute<void>(
|
||||
builder: (BuildContext context) => const genericMap()));
|
||||
builder: (BuildContext context) => const GenericMap()));
|
||||
}
|
||||
|
||||
void onAddYourLocation(AddYourLocationFunction onAdd) {
|
||||
|
|
|
|||
|
|
@ -4,4 +4,4 @@ enum FireMarkType {
|
|||
fire,
|
||||
industry,
|
||||
falsePos
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ class _FireNotificationListState extends State<FireNotificationList> {
|
|||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute<void>(
|
||||
builder: (BuildContext context) => const genericMap()));
|
||||
builder: (BuildContext context) => const GenericMap()));
|
||||
}
|
||||
|
||||
Future<void> _showConfirmDialog(_ViewModel view) {
|
||||
|
|
|
|||
|
|
@ -72,14 +72,14 @@ class _ViewModel {
|
|||
int get hashCode => serverUrl.hashCode ^ lang.hashCode ^ mapState.hashCode;
|
||||
}
|
||||
|
||||
class genericMap extends StatefulWidget {
|
||||
const genericMap({super.key});
|
||||
class GenericMap extends StatefulWidget {
|
||||
const GenericMap({super.key});
|
||||
|
||||
@override
|
||||
_genericMapState createState() => _genericMapState();
|
||||
GenericMapState createState() => GenericMapState();
|
||||
}
|
||||
|
||||
class _genericMapState extends State<genericMap> {
|
||||
class GenericMapState extends State<GenericMap> {
|
||||
// This needs to be stateful so when resizes don't get a new globalkey
|
||||
// https://github.com/flutter/flutter/issues/1632#issuecomment-180478202
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import 'package:firebase_messaging/firebase_messaging.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
|
||||
import 'activeFires.dart';
|
||||
|
|
@ -19,6 +20,7 @@ import 'models/fireNotification.dart';
|
|||
import 'objectIdUtils.dart';
|
||||
import 'redux/actions.dart';
|
||||
|
||||
@immutable
|
||||
class _ViewModel {
|
||||
_ViewModel({required this.isLoaded});
|
||||
final bool isLoaded;
|
||||
|
|
@ -217,8 +219,7 @@ class _HomePageState extends State<HomePage> {
|
|||
if (shouldNavigate ?? false) {
|
||||
_navigateToItemDetail(message);
|
||||
}
|
||||
}).catchError((Object e) {
|
||||
});
|
||||
}).catchError((Object e) {});
|
||||
}
|
||||
|
||||
Widget _buildDialog(BuildContext context, FireNotification item) {
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ class IntroPage extends AppIntroPage {
|
|||
items: _fireItems,
|
||||
onIntroFinish: (BuildContext context) =>
|
||||
Navigator.pushNamed(context, HomePage.routeName));
|
||||
static const String routeName = '/intro';
|
||||
static String routeName = '/intro';
|
||||
|
||||
static final _fireItems = (BuildContext context) => <AppIntroItem>[
|
||||
static List<AppIntroItem> _fireItems(BuildContext context) => <AppIntroItem>[
|
||||
AppIntroItem(
|
||||
icon: Icons.location_on, title: S.of(context).chooseAPlace),
|
||||
AppIntroItem(
|
||||
|
|
|
|||
|
|
@ -37,15 +37,19 @@ Future<YourLocation> getUserLocation(
|
|||
} on PlatformException catch (e) {
|
||||
final BuildContext? context = scaffoldKey.currentContext;
|
||||
if (context != null) {
|
||||
// ignore: use_build_context_synchronously
|
||||
final S strings = S.of(context);
|
||||
// ignore: use_build_context_synchronously
|
||||
final ScaffoldMessengerState messenger = ScaffoldMessenger.of(context);
|
||||
if (e.code == 'PERMISSION_DENIED') {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(S.of(context).notPermsUbication),
|
||||
messenger.showSnackBar(SnackBar(
|
||||
content: Text(strings.notPermsUbication),
|
||||
));
|
||||
} else if (e.code == 'PERMISSION_DENIED_NEVER_ASK') {
|
||||
// User selected "Don't ask again" - show settings prompt
|
||||
}
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(S.of(context).isYourUbicationEnabled),
|
||||
messenger.showSnackBar(SnackBar(
|
||||
content: Text(strings.isYourUbicationEnabled),
|
||||
));
|
||||
}
|
||||
return YourLocation.noLocation;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
class BasicLocation implements Comparable<BasicLocation> {
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
@immutable
|
||||
class BasicLocation implements Comparable<BasicLocation> {
|
||||
// static BasicLocation noLocation = new BasicLocation(lat: 0.0, lon: 0.0);
|
||||
|
||||
BasicLocation({required this.lat, required this.lon, this.description});
|
||||
|
|
@ -18,7 +20,8 @@ class BasicLocation implements Comparable<BasicLocation> {
|
|||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object o) => o is BasicLocation && o.lat == lat && o.lon == lon;
|
||||
bool operator ==(Object o) =>
|
||||
o is BasicLocation && o.lat == lat && o.lon == lon;
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
enum FalsePositiveType { industry, controled, falsealarm }
|
||||
enum FalsePositiveType { industry, controled, falsealarm }
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
import 'package:comunes_flutter/comunes_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:objectid/objectid.dart';
|
||||
|
||||
import '../objectIdUtils.dart';
|
||||
|
||||
part 'fireNotification.g.dart';
|
||||
|
||||
@JsonSerializable(nullable: false)
|
||||
@immutable
|
||||
@JsonSerializable()
|
||||
class FireNotification {
|
||||
|
||||
FireNotification(
|
||||
{required this.id,
|
||||
required this.lat,
|
||||
|
|
|
|||
|
|
@ -28,9 +28,11 @@ class FiresApi {
|
|||
};
|
||||
final String url = '${state.firesApiUrl}mobile/users';
|
||||
try {
|
||||
final Response<dynamic> response = await _dio.post(url, data: params);
|
||||
final Response<Map<String, dynamic>> response =
|
||||
await _dio.post<Map<String, dynamic>>(url, data: params);
|
||||
if (response.statusCode == 200) {
|
||||
return response.data['data']['userId'] as String;
|
||||
final Map<String, dynamic> data = response.data as Map<String, dynamic>;
|
||||
return data['data']['userId'] as String;
|
||||
} else {
|
||||
throw Exception('Unexpected error on create user');
|
||||
}
|
||||
|
|
@ -45,18 +47,25 @@ class FiresApi {
|
|||
final String url =
|
||||
'${state.firesApiUrl}mobile/subscriptions/all/$apiKey/$mobileToken';
|
||||
try {
|
||||
final Response<dynamic> response = await _dio.get(url);
|
||||
final Response<Map<String, dynamic>> response =
|
||||
await _dio.get<Map<String, dynamic>>(url);
|
||||
if (response.statusCode == 200) {
|
||||
final Map<String, dynamic> data = response.data as Map<String, dynamic>;
|
||||
final Map<String, dynamic> dataData =
|
||||
data['data'] as Map<String, dynamic>;
|
||||
final List<dynamic> dataSubscriptions =
|
||||
response.data['data']['subscriptions'] as List<dynamic>;
|
||||
dataData['subscriptions'] as List<dynamic>;
|
||||
final List<YourLocation> subscribed = <YourLocation>[];
|
||||
for (int i = 0; i < dataSubscriptions.length; i++) {
|
||||
final Map<String, dynamic> el =
|
||||
dataSubscriptions[i] as Map<String, dynamic>;
|
||||
final double lat = (el['location']['lat'] as num).toDouble();
|
||||
final double lon = (el['location']['lon'] as num).toDouble();
|
||||
final Map<String, dynamic> location =
|
||||
el['location'] as Map<String, dynamic>;
|
||||
final double lat = (location['lat'] as num).toDouble();
|
||||
final double lon = (location['lon'] as num).toDouble();
|
||||
final Map<String, dynamic> id = el['_id'] as Map<String, dynamic>;
|
||||
subscribed.add(YourLocation(
|
||||
id: objectIdFromJson(el['_id']['_str'] as String),
|
||||
id: objectIdFromJson(id['_str'] as String),
|
||||
lat: lat,
|
||||
lon: lon,
|
||||
subscribed: true,
|
||||
|
|
@ -82,9 +91,11 @@ class FiresApi {
|
|||
};
|
||||
final String url = '${state.firesApiUrl}mobile/subscriptions';
|
||||
try {
|
||||
final Response<dynamic> response = await _dio.post(url, data: params);
|
||||
final Response<Map<String, dynamic>> response =
|
||||
await _dio.post<Map<String, dynamic>>(url, data: params);
|
||||
if (response.statusCode == 200) {
|
||||
return response.data['data']['subsId'] as String;
|
||||
final Map<String, dynamic> data = response.data as Map<String, dynamic>;
|
||||
return data['data']['subsId'] as String;
|
||||
} else {
|
||||
throw Exception('Unexpected error on subscribe');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:objectid/objectid.dart';
|
||||
|
||||
import '../objectIdUtils.dart';
|
||||
|
||||
part 'yourLocation.g.dart';
|
||||
|
||||
@immutable
|
||||
@JsonSerializable()
|
||||
class YourLocation {
|
||||
YourLocation(
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:redux/src/store.dart';
|
||||
|
||||
import 'colors.dart';
|
||||
|
|
@ -11,8 +12,8 @@ import 'generated/i18n.dart';
|
|||
import 'mainDrawer.dart';
|
||||
import 'models/appState.dart';
|
||||
|
||||
@immutable
|
||||
class _ViewModel {
|
||||
|
||||
_ViewModel(this.monitoredAreas);
|
||||
List<Polyline> monitoredAreas;
|
||||
|
||||
|
|
@ -41,8 +42,7 @@ class MonitoredAreasPage extends StatelessWidget {
|
|||
},
|
||||
builder: (BuildContext context, _ViewModel view) {
|
||||
return Scaffold(
|
||||
appBar:
|
||||
AppBar(title: Text(S.of(context).monitoredAreasTitle)),
|
||||
appBar: AppBar(title: Text(S.of(context).monitoredAreasTitle)),
|
||||
drawer: MainDrawer(context, MonitoredAreasPage.routeName),
|
||||
bottomNavigationBar: CustomBottomAppBar(
|
||||
fabLocation: FloatingActionButtonLocation.centerDocked,
|
||||
|
|
@ -51,7 +51,8 @@ class MonitoredAreasPage extends StatelessWidget {
|
|||
actions: <Widget>[
|
||||
Flexible(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 10.0, right: 10.0),
|
||||
padding:
|
||||
const EdgeInsets.only(left: 10.0, right: 10.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
|
|
@ -62,37 +63,35 @@ class MonitoredAreasPage extends StatelessWidget {
|
|||
])))
|
||||
]),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Column(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
|
||||
child: Text(S.of(context).inGreenMonitoredAreas),
|
||||
),
|
||||
Flexible(
|
||||
child: FlutterMap(
|
||||
options: const MapOptions(
|
||||
initialCenter: LatLng(53.5775, 3.106111),
|
||||
initialZoom: 1.0,
|
||||
),
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 8.0, bottom: 8.0),
|
||||
child: Text(S.of(context).inGreenMonitoredAreas),
|
||||
),
|
||||
Flexible(
|
||||
child: FlutterMap(
|
||||
options: const MapOptions(
|
||||
initialCenter: LatLng(53.5775, 3.106111),
|
||||
initialZoom: 1.0,
|
||||
),
|
||||
children: <Widget>[
|
||||
TileLayer(
|
||||
urlTemplate:
|
||||
'https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png',
|
||||
subdomains: const <String>['a', 'b', 'c', 'd'],
|
||||
userAgentPackageName:
|
||||
'com.example.fires_flutter'),
|
||||
const CompassMapPluginWidget(),
|
||||
PolylineLayer(
|
||||
polylines: view.monitoredAreas,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
TileLayer(
|
||||
urlTemplate:
|
||||
'https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png',
|
||||
subdomains: const <String>['a', 'b', 'c', 'd'],
|
||||
userAgentPackageName: 'com.example.fires_flutter'),
|
||||
const CompassMapPluginWidget(),
|
||||
PolylineLayer(
|
||||
polylines: view.monitoredAreas,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class _PlaceSelectionDialog extends StatefulWidget {
|
|||
|
||||
class _PlaceSelectionDialogState extends State<_PlaceSelectionDialog> {
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
List<Location> _searchResults = [];
|
||||
List<Location> _searchResults = <Location>[];
|
||||
bool _isSearching = false;
|
||||
String? _errorMessage;
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ class _PlaceSelectionDialogState extends State<_PlaceSelectionDialog> {
|
|||
Future<void> _searchPlaces(String query) async {
|
||||
if (query.isEmpty) {
|
||||
setState(() {
|
||||
_searchResults = [];
|
||||
_searchResults = <Location>[];
|
||||
_errorMessage = null;
|
||||
});
|
||||
return;
|
||||
|
|
@ -66,7 +66,7 @@ class _PlaceSelectionDialogState extends State<_PlaceSelectionDialog> {
|
|||
} catch (e) {
|
||||
setState(() {
|
||||
_errorMessage = 'Search error: ${e.toString()}';
|
||||
_searchResults = [];
|
||||
_searchResults = <Location>[];
|
||||
});
|
||||
} finally {
|
||||
setState(() {
|
||||
|
|
@ -147,7 +147,7 @@ class _PlaceSelectionDialogState extends State<_PlaceSelectionDialog> {
|
|||
_searchPlaces(value);
|
||||
} else {
|
||||
setState(() {
|
||||
_searchResults = [];
|
||||
_searchResults = <Location>[];
|
||||
_errorMessage = null;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export 'appActions.dart';
|
||||
export 'fireMapActions.dart';
|
||||
export 'fireNotificationActions.dart';
|
||||
export 'yourLocationActions.dart';
|
||||
export 'yourLocationActions.dart';
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
String errorReducer(String error, action) {
|
||||
String errorReducer(String error, dynamic action) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ import '../models/fireMapState.dart';
|
|||
import '../models/yourLocation.dart';
|
||||
import 'actions.dart';
|
||||
|
||||
final Reducer<FireMapState> fireMapReducer = combineReducers<FireMapState>(<Reducer<FireMapState>>[
|
||||
TypedReducer<FireMapState, ShowYourLocationMapAction>(
|
||||
_showYourLocationMap),
|
||||
final Reducer<FireMapState> fireMapReducer =
|
||||
combineReducers<FireMapState>(<Reducer<FireMapState>>[
|
||||
TypedReducer<FireMapState, ShowYourLocationMapAction>(_showYourLocationMap),
|
||||
TypedReducer<FireMapState, ShowFireNotificationMapAction>(
|
||||
_showFireNotificationMap),
|
||||
TypedReducer<FireMapState, UpdateFireMapStatsAction>(
|
||||
|
|
@ -15,8 +15,7 @@ final Reducer<FireMapState> fireMapReducer = combineReducers<FireMapState>(<Redu
|
|||
TypedReducer<FireMapState, SubscribeAction>(_subscribeYourLocationMap),
|
||||
TypedReducer<FireMapState, SubscribeConfirmAction>(
|
||||
_subscribeConfirmYourLocationMap),
|
||||
TypedReducer<FireMapState, UnSubscribeAction>(
|
||||
_unsubscribeYourLocationMap),
|
||||
TypedReducer<FireMapState, UnSubscribeAction>(_unsubscribeYourLocationMap),
|
||||
TypedReducer<FireMapState, EditYourLocationAction>(_editYourLocationMap),
|
||||
TypedReducer<FireMapState, EditConfirmYourLocationAction>(
|
||||
_editConfirmYourLocationMap),
|
||||
|
|
@ -52,7 +51,7 @@ FireMapState _showYourLocationMap(
|
|||
|
||||
FireMapState _showFireNotificationMap(
|
||||
FireMapState state, ShowFireNotificationMapAction action) {
|
||||
// TODO: use here you real location?
|
||||
// TODO(developer): use here real location instead of notification location?
|
||||
final YourLocation pseudoLoc = YourLocation(
|
||||
id: ObjectId(),
|
||||
lat: action.notif.lat,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import '../models/fireNotification.dart';
|
|||
abstract class FireNotificationActions {}
|
||||
|
||||
class DeleteFireNotificationAction extends FireNotificationActions {
|
||||
|
||||
DeleteFireNotificationAction(this.notif);
|
||||
final FireNotification notif;
|
||||
}
|
||||
|
|
@ -14,13 +13,11 @@ class DeleteAllFireNotificationAction extends FireNotificationActions {
|
|||
}
|
||||
|
||||
class AddFireNotificationAction extends FireNotificationActions {
|
||||
|
||||
AddFireNotificationAction(this.notif);
|
||||
final FireNotification notif;
|
||||
}
|
||||
|
||||
class DeletedFireNotificationAction extends FireNotificationActions {
|
||||
|
||||
DeletedFireNotificationAction(this.notif);
|
||||
final FireNotification notif;
|
||||
}
|
||||
|
|
@ -30,32 +27,27 @@ class DeletedAllFireNotificationAction extends FireNotificationActions {
|
|||
}
|
||||
|
||||
class AddedFireNotificationAction extends FireNotificationActions {
|
||||
|
||||
AddedFireNotificationAction(this.notif);
|
||||
final FireNotification notif;
|
||||
}
|
||||
|
||||
class ReadFireNotificationAction extends FireNotificationActions {
|
||||
|
||||
ReadFireNotificationAction(this.notif);
|
||||
final FireNotification notif;
|
||||
}
|
||||
|
||||
class ReadedFireNotificationAction extends FireNotificationActions {
|
||||
|
||||
ReadedFireNotificationAction(this.notif);
|
||||
final FireNotification notif;
|
||||
}
|
||||
|
||||
class MarkFireAsFalsePositiveAction extends FireNotificationActions {
|
||||
|
||||
MarkFireAsFalsePositiveAction(this.notif, this.type);
|
||||
final FireNotification notif;
|
||||
final FalsePositiveType type;
|
||||
}
|
||||
|
||||
class UpdatedFireNotificationAction extends FireNotificationActions {
|
||||
|
||||
UpdatedFireNotificationAction(this.notif);
|
||||
final FireNotification notif;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ import 'package:redux/redux.dart';
|
|||
import '../models/fireNotification.dart';
|
||||
import 'actions.dart';
|
||||
|
||||
final Reducer<List<FireNotification>> fireNotificationReducer = combineReducers<List<FireNotification>>(<Reducer<List<FireNotification>>>[
|
||||
final Reducer<List<FireNotification>> fireNotificationReducer =
|
||||
combineReducers<List<FireNotification>>(<Reducer<List<FireNotification>>>[
|
||||
TypedReducer<List<FireNotification>, AddedFireNotificationAction>(
|
||||
_addedFireNotification),
|
||||
TypedReducer<List<FireNotification>, DeletedFireNotificationAction>(
|
||||
|
|
@ -18,20 +19,21 @@ final Reducer<List<FireNotification>> fireNotificationReducer = combineReducers<
|
|||
|
||||
List<FireNotification> _addedFireNotification(
|
||||
List<FireNotification> notifications, AddedFireNotificationAction action) {
|
||||
return List.from(notifications)..insert(0, action.notif);
|
||||
return List<FireNotification>.from(notifications)..insert(0, action.notif);
|
||||
}
|
||||
|
||||
List<FireNotification> _deletedFireNotification(
|
||||
List<FireNotification> notifications,
|
||||
DeletedFireNotificationAction action) {
|
||||
return List.from(notifications)..remove(action.notif);
|
||||
return List<FireNotification>.from(notifications)..remove(action.notif);
|
||||
}
|
||||
|
||||
List<FireNotification> _updatedFireNotification(
|
||||
List<FireNotification> notifications,
|
||||
UpdatedFireNotificationAction action) {
|
||||
return notifications
|
||||
.map((FireNotification notif) => notif.id == action.notif.id ? action.notif : notif)
|
||||
.map((FireNotification notif) =>
|
||||
notif.id == action.notif.id ? action.notif : notif)
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import 'actions.dart';
|
||||
|
||||
bool loadedReducer(bool isLoaded, dynamic action) {
|
||||
if (action is FetchYourLocationsSucceededAction) return true;
|
||||
if (action is FetchYourLocationsSucceededAction) {
|
||||
return true;
|
||||
}
|
||||
return isLoaded;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import 'actions.dart';
|
||||
|
||||
bool loadingReducer(bool isLoading, dynamic action) {
|
||||
if (action is FetchYourLocationsAction) return true;
|
||||
if (action is FetchYourLocationsAction) {
|
||||
return true;
|
||||
}
|
||||
return isLoading;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,14 @@ import '../models/user.dart';
|
|||
import 'actions.dart';
|
||||
|
||||
User userReducer(User user, dynamic action) {
|
||||
if (action is OnUserCreatedAction)
|
||||
if (action is OnUserCreatedAction) {
|
||||
return user.copyWith(userId: action.userId);
|
||||
if (action is OnUserTokenAction) return user.copyWith(token: action.token);
|
||||
if (action is OnUserLangAction) return user.copyWith(lang: action.lang);
|
||||
}
|
||||
if (action is OnUserTokenAction) {
|
||||
return user.copyWith(token: action.token);
|
||||
}
|
||||
if (action is OnUserLangAction) {
|
||||
return user.copyWith(lang: action.lang);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ 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),
|
||||
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>(
|
||||
|
|
@ -16,7 +16,7 @@ final Reducer<List<YourLocation>> yourLocationsReducer = combineReducers<List<Yo
|
|||
|
||||
List<YourLocation> _addedYourLocation(
|
||||
List<YourLocation> yourLocations, AddedYourLocationAction action) {
|
||||
return List.from(yourLocations)..add(action.loc);
|
||||
return List<YourLocation>.from(yourLocations)..add(action.loc);
|
||||
}
|
||||
|
||||
List<YourLocation> _deletedYourLocation(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue