More work with fire notifications
This commit is contained in:
parent
5fdaf239c0
commit
9dd8a7de97
24 changed files with 512 additions and 288 deletions
|
|
@ -1,40 +1,53 @@
|
|||
import 'package:bson_objectid/bson_objectid.dart';
|
||||
import 'package:comunes_flutter/comunes_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:redux/src/store.dart';
|
||||
|
||||
import '../genericMap.dart';
|
||||
import '../objectIdUtils.dart';
|
||||
import '../redux/actions.dart';
|
||||
|
||||
part 'fireNotification.g.dart';
|
||||
|
||||
_objectIdFromJson(String json) {
|
||||
return new ObjectId.fromHexString(json);
|
||||
}
|
||||
|
||||
_objectIdToJson(ObjectId o) {
|
||||
return o.toString();
|
||||
}
|
||||
|
||||
@JsonSerializable(nullable: false)
|
||||
class FireNotification extends Object with _$FireNotificationSerializerMixin {
|
||||
@JsonKey(toJson: _objectIdToJson, fromJson: _objectIdFromJson)
|
||||
@JsonKey(toJson: objectIdToJson, fromJson: objectIdFromJson)
|
||||
ObjectId id;
|
||||
final double lat;
|
||||
final double lon;
|
||||
final String description;
|
||||
final DateTime when;
|
||||
final String sealed;
|
||||
@JsonKey(toJson: objectIdToJson, fromJson: objectIdFromJson)
|
||||
final ObjectId subsId;
|
||||
final bool read;
|
||||
|
||||
factory FireNotification.fromJson(Map<String, dynamic> json) => _$FireNotificationFromJson(json);
|
||||
factory FireNotification.fromJson(Map<String, dynamic> json) =>
|
||||
_$FireNotificationFromJson(json);
|
||||
|
||||
FireNotification({this.id, @required this.lat, @required this.lon, @required this.description, @required this.when, @required this.read}) {
|
||||
FireNotification(
|
||||
{this.id,
|
||||
@required this.lat,
|
||||
@required this.lon,
|
||||
@required this.description,
|
||||
@required this.when,
|
||||
@required this.read,
|
||||
@required this.sealed,
|
||||
@required this.subsId}) {
|
||||
if (this.id == null) this.id = new ObjectId();
|
||||
}
|
||||
|
||||
FireNotification copyWith({id, lat, lon, description, read, when}) {
|
||||
FireNotification copyWith(
|
||||
{id, lat, lon, description, read, when, sealed, subsId}) {
|
||||
return new FireNotification(
|
||||
id: id ?? this.id,
|
||||
lat: lat ?? this.lat,
|
||||
lon: lon ?? this.lon,
|
||||
read: read ?? this.read,
|
||||
lon: lon ?? this.lon,
|
||||
read: read ?? this.read,
|
||||
description: description ?? this.description,
|
||||
sealed: sealed ?? this.sealed,
|
||||
subsId: subsId ?? this.subsId,
|
||||
when: when ?? this.when);
|
||||
}
|
||||
|
||||
|
|
@ -45,16 +58,46 @@ class FireNotification extends Object with _$FireNotificationSerializerMixin {
|
|||
runtimeType == other.runtimeType &&
|
||||
id == other.id &&
|
||||
lat == other.lat &&
|
||||
lon == other.lon &&
|
||||
read == other.read &&
|
||||
lon == other.lon &&
|
||||
read == other.read &&
|
||||
description == other.description &&
|
||||
sealed == other.sealed &&
|
||||
subsId == other.subsId &&
|
||||
when == other.when;
|
||||
|
||||
@override
|
||||
int get hashCode => id.hashCode ^ lat.hashCode ^ lon.hashCode ^ description.hashCode ^ when.hashCode ^ read.hashCode;
|
||||
int get hashCode =>
|
||||
id.hashCode ^
|
||||
lat.hashCode ^
|
||||
lon.hashCode ^
|
||||
description.hashCode ^
|
||||
when.hashCode ^
|
||||
read.hashCode ^
|
||||
sealed.hashCode ^
|
||||
subsId.hashCode;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'FireNotification {id: $id, lat: $lat, lon: $lon, description: $description, when: $when, read: $read}';
|
||||
return 'FireNotification {id: $id, lat: $lat, lon: $lon, when: $when, read: $read, subsId: $subsId, sealed ${ellipse(
|
||||
sealed)}';
|
||||
}
|
||||
|
||||
static final Map<String, Route<Null>> routes = <String, Route<Null>>{};
|
||||
|
||||
Route<Null> getRoute(Store store) {
|
||||
final String routeName = '/fire/${id}';
|
||||
return routes.putIfAbsent(
|
||||
routeName,
|
||||
() => new MaterialPageRoute<Null>(
|
||||
settings: new RouteSettings(name: routeName),
|
||||
builder: (BuildContext context) {
|
||||
store.dispatch(new ShowFireNotificationMapAction(this));
|
||||
Navigator.push(
|
||||
context,
|
||||
new MaterialPageRoute(
|
||||
builder: (context) => new genericMap()));
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue