Connectivity redux work
This commit is contained in:
parent
2f52801b12
commit
e67256c010
2 changed files with 15 additions and 6 deletions
|
|
@ -6,7 +6,7 @@ import 'package:fires_flutter/models/yourLocation.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:meta/meta.dart';
|
||||||
|
import 'package:connectivity/connectivity.dart';
|
||||||
import 'fireMapState.dart';
|
import 'fireMapState.dart';
|
||||||
import 'user.dart';
|
import 'user.dart';
|
||||||
|
|
||||||
|
|
@ -39,6 +39,8 @@ class AppState extends Object with _$AppStateSerializerMixin {
|
||||||
final int fireNotificationsUnread;
|
final int fireNotificationsUnread;
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
final FireMapState fireMapState;
|
final FireMapState fireMapState;
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
final ConnectivityResult connectivity;
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
factory AppState.fromJson(Map<String, dynamic> json) =>
|
factory AppState.fromJson(Map<String, dynamic> json) =>
|
||||||
|
|
@ -56,6 +58,7 @@ class AppState extends Object with _$AppStateSerializerMixin {
|
||||||
this.firesApiKey,
|
this.firesApiKey,
|
||||||
this.firesApiUrl,
|
this.firesApiUrl,
|
||||||
this.serverUrl,
|
this.serverUrl,
|
||||||
|
this.connectivity,
|
||||||
this.fireMapState: const FireMapState.initial()});
|
this.fireMapState: const FireMapState.initial()});
|
||||||
|
|
||||||
AppState copyWith(
|
AppState copyWith(
|
||||||
|
|
@ -70,7 +73,8 @@ class AppState extends Object with _$AppStateSerializerMixin {
|
||||||
List<YourLocation> yourLocations,
|
List<YourLocation> yourLocations,
|
||||||
List<FireNotification> fireNotifications,
|
List<FireNotification> fireNotifications,
|
||||||
int fireNotificationsUnread,
|
int fireNotificationsUnread,
|
||||||
FireMapState fireMapState}) {
|
FireMapState fireMapState,
|
||||||
|
ConnectivityResult connectivity}) {
|
||||||
return new AppState(
|
return new AppState(
|
||||||
isLoading: isLoading ?? this.isLoading,
|
isLoading: isLoading ?? this.isLoading,
|
||||||
isLoaded: isLoaded ?? this.isLoaded,
|
isLoaded: isLoaded ?? this.isLoaded,
|
||||||
|
|
@ -84,12 +88,13 @@ class AppState extends Object with _$AppStateSerializerMixin {
|
||||||
fireNotifications: fireNotifications ?? this.fireNotifications,
|
fireNotifications: fireNotifications ?? this.fireNotifications,
|
||||||
fireNotificationsUnread:
|
fireNotificationsUnread:
|
||||||
fireNotificationsUnread ?? this.fireNotificationsUnread,
|
fireNotificationsUnread ?? this.fireNotificationsUnread,
|
||||||
fireMapState: fireMapState ?? this.fireMapState);
|
fireMapState: fireMapState ?? this.fireMapState,
|
||||||
|
connectivity: connectivity ?? this.connectivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'AppState{\nuser: ${user}\nisLoading: $isLoading\nisLoaded: $isLoaded\napiKey: ${ellipse(
|
return 'AppState{\nuser: ${user}\nconnectivity: ${connectivity.toString()}\nisLoading: $isLoading\nisLoaded: $isLoaded\napiKey: ${ellipse(
|
||||||
firesApiKey,
|
firesApiKey,
|
||||||
8)}\napiUrl: ${firesApiUrl}\nserverUrl: ${serverUrl}\nfireMapState: $fireMapState\nyourLocations count: ${yourLocations
|
8)}\napiUrl: ${firesApiUrl}\nserverUrl: ${serverUrl}\nfireMapState: $fireMapState\nyourLocations count: ${yourLocations
|
||||||
.length}\nunread notif: ${fireNotificationsUnread}\nfireNotifications: ${fireNotifications}\nyourLocations: ${yourLocations}}';
|
.length}\nunread notif: ${fireNotificationsUnread}\nfireNotifications: ${fireNotifications}\nyourLocations: ${yourLocations}}';
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import 'package:fires_flutter/models/yourLocation.dart';
|
import 'package:fires_flutter/models/yourLocation.dart';
|
||||||
import 'package:fires_flutter/models/fireNotification.dart';
|
import 'package:fires_flutter/models/fireNotification.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'package:connectivity/connectivity.dart';
|
||||||
abstract class AppActions {}
|
abstract class AppActions {}
|
||||||
|
|
||||||
class FetchYourLocationsAction extends AppActions {
|
class FetchYourLocationsAction extends AppActions {
|
||||||
|
|
@ -51,4 +51,8 @@ class FetchFireNotificationsSucceededAction extends AppActions {
|
||||||
FetchFireNotificationsSucceededAction(this.fetchedFireNotifications, this.unreadCount);
|
FetchFireNotificationsSucceededAction(this.fetchedFireNotifications, this.unreadCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnConnect
|
class OnConnectivityChanged extends AppActions {
|
||||||
|
final ConnectivityResult connectivityResult;
|
||||||
|
|
||||||
|
OnConnectivityChanged(this.connectivityResult);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue