mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
Updated OccupancyHeatMapModel
model with what the api returns, and only used the necessary fields that the api returns for this feature to work.
This commit is contained in:
@ -1,22 +1,28 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
class OccupancyHeatMapModel extends Equatable {
|
class OccupancyHeatMapModel extends Equatable {
|
||||||
final DateTime date;
|
final String uuid;
|
||||||
|
|
||||||
final int occupancy;
|
final DateTime eventDate;
|
||||||
|
|
||||||
|
final int countTotalPresenceDetected;
|
||||||
|
|
||||||
const OccupancyHeatMapModel({
|
const OccupancyHeatMapModel({
|
||||||
required this.date,
|
required this.uuid,
|
||||||
required this.occupancy,
|
required this.eventDate,
|
||||||
|
required this.countTotalPresenceDetected,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory OccupancyHeatMapModel.fromJson(Map<String, dynamic> json) {
|
factory OccupancyHeatMapModel.fromJson(Map<String, dynamic> json) {
|
||||||
return OccupancyHeatMapModel(
|
return OccupancyHeatMapModel(
|
||||||
date: DateTime.parse(json['date'] as String),
|
uuid: json['uuid'] as String? ?? '',
|
||||||
occupancy: json['occupancy'] as int,
|
eventDate: DateTime.parse(
|
||||||
|
json['event_date'] as String? ?? '${DateTime.now()}',
|
||||||
|
),
|
||||||
|
countTotalPresenceDetected: json['count_total_presence_detected'] as int? ?? 0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object?> get props => [date, occupancy];
|
List<Object?> get props => [uuid, eventDate, countTotalPresenceDetected];
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,10 @@ class OccupancyHeatMapBox extends StatelessWidget {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: OccupancyHeatMap(
|
child: OccupancyHeatMap(
|
||||||
heatMapData: state.heatMapData.asMap().map(
|
heatMapData: state.heatMapData.asMap().map(
|
||||||
(_, value) => MapEntry(value.date, value.occupancy),
|
(_, value) => MapEntry(
|
||||||
|
value.eventDate,
|
||||||
|
value.countTotalPresenceDetected,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user