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