mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
finished bugs
This commit is contained in:
@ -3,8 +3,8 @@ import 'dart:convert';
|
||||
class ScenesModel {
|
||||
final String id;
|
||||
final String name;
|
||||
final Status status;
|
||||
final Type type;
|
||||
final String status;
|
||||
final String type;
|
||||
|
||||
ScenesModel({
|
||||
required this.id,
|
||||
@ -20,36 +20,15 @@ class ScenesModel {
|
||||
|
||||
factory ScenesModel.fromJson(Map<String, dynamic> json) => ScenesModel(
|
||||
id: json["id"],
|
||||
name: json["name"],
|
||||
status: statusValues.map[json["status"]]!,
|
||||
type: typeValues.map[json["type"]]!,
|
||||
name: json["name"] ?? '',
|
||||
status: json["status"] ?? '',
|
||||
type: json["type"] ?? '',
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"status": statusValues.reverse[status],
|
||||
"type": typeValues.reverse[type],
|
||||
"status": status,
|
||||
"type": type,
|
||||
};
|
||||
}
|
||||
|
||||
enum Status { ENABLE }
|
||||
|
||||
final statusValues = EnumValues({"enable": Status.ENABLE});
|
||||
|
||||
enum Type { TAP_TO_RUN, automation }
|
||||
|
||||
final typeValues =
|
||||
EnumValues({"tap_to_run": Type.TAP_TO_RUN, "automation": Type.automation});
|
||||
|
||||
class EnumValues<T> {
|
||||
Map<String, T> map;
|
||||
late Map<T, String> reverseMap;
|
||||
|
||||
EnumValues(this.map);
|
||||
|
||||
Map<T, String> get reverse {
|
||||
reverseMap = map.map((k, v) => MapEntry(v, k));
|
||||
return reverseMap;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user