Fire notification read

This commit is contained in:
Vicente J. Ruiz Jurado 2018-07-26 20:30:24 +02:00
parent 04171cdc12
commit b7468de0d1
10 changed files with 66 additions and 22 deletions

View file

@ -20,20 +20,20 @@ class FireNotification extends Object with _$FireNotificationSerializerMixin {
final double lon;
final String description;
final DateTime when;
final bool read;
factory FireNotification.fromJson(Map<String, dynamic> json) => _$FireNotificationFromJson(json);
// static FireNotification noLocation = new FireNotification(lat: 0.0, lon: 0.0, description: '', when: new DateTime(0));
FireNotification({this.id, @required this.lat, @required this.lon, @required this.description, @required this.when}) {
FireNotification({this.id, @required this.lat, @required this.lon, @required this.description, @required this.when, @required this.read}) {
if (this.id == null) this.id = new ObjectId();
}
FireNotification copyWith({id, lat, lon, description, when}) {
FireNotification copyWith({id, lat, lon, description, read, when}) {
return new FireNotification(
id: id ?? this.id,
lat: lat ?? this.lat,
lon: lon ?? this.lon,
lon: lon ?? this.lon,
read: read ?? this.read,
description: description ?? this.description,
when: when ?? this.when);
}
@ -45,15 +45,16 @@ class FireNotification extends Object with _$FireNotificationSerializerMixin {
runtimeType == other.runtimeType &&
id == other.id &&
lat == other.lat &&
lon == other.lon &&
lon == other.lon &&
read == other.read &&
description == other.description &&
when == other.when;
@override
int get hashCode => id.hashCode ^ lat.hashCode ^ lon.hashCode ^ description.hashCode ^ when.hashCode;
int get hashCode => id.hashCode ^ lat.hashCode ^ lon.hashCode ^ description.hashCode ^ when.hashCode ^ read.hashCode;
@override
String toString() {
return 'FireNotification {id: $id, lat: $lat, lon: $lon, description: $description, when: $when}';
return 'FireNotification {id: $id, lat: $lat, lon: $lon, description: $description, when: $when, read: $read}';
}
}

View file

@ -14,7 +14,8 @@ FireNotification _$FireNotificationFromJson(Map<String, dynamic> json) =>
lat: (json['lat'] as num).toDouble(),
lon: (json['lon'] as num).toDouble(),
description: json['description'] as String,
when: DateTime.parse(json['when'] as String));
when: DateTime.parse(json['when'] as String),
read: json['read'] as bool);
abstract class _$FireNotificationSerializerMixin {
ObjectId get id;
@ -22,6 +23,7 @@ abstract class _$FireNotificationSerializerMixin {
double get lon;
String get description;
DateTime get when;
bool get read;
Map<String, dynamic> toJson() => new _$FireNotificationJsonMapWrapper(this);
}
@ -31,7 +33,7 @@ class _$FireNotificationJsonMapWrapper extends $JsonMapWrapper {
@override
Iterable<String> get keys =>
const ['id', 'lat', 'lon', 'description', 'when'];
const ['id', 'lat', 'lon', 'description', 'when', 'read'];
@override
dynamic operator [](Object key) {
@ -47,6 +49,8 @@ class _$FireNotificationJsonMapWrapper extends $JsonMapWrapper {
return _v.description;
case 'when':
return _v.when.toIso8601String();
case 'read':
return _v.read;
}
}
return null;