mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
49 lines
1.1 KiB
Dart
49 lines
1.1 KiB
Dart
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
|
import 'package:syncrow_app/features/devices/model/function_model.dart';
|
|
|
|
class CurtainModel extends DeviceModel {
|
|
late int openPercentage;
|
|
|
|
CurtainModel({
|
|
required this.openPercentage,
|
|
required super.id,
|
|
required super.name,
|
|
required super.type,
|
|
required super.status,
|
|
required super.image,
|
|
required super.timer,
|
|
required super.functions,
|
|
});
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'openPercentage': openPercentage,
|
|
'timer': timer,
|
|
'id': id,
|
|
'name': name,
|
|
'status': status,
|
|
'type': type,
|
|
'image': image,
|
|
};
|
|
}
|
|
|
|
factory CurtainModel.fromJson(Map<String, dynamic> json) {
|
|
List<FunctionModel> func = [];
|
|
if (json['functions'] != null) {
|
|
json['functions'].forEach((v) {
|
|
func.add(FunctionModel.fromJson(v));
|
|
});
|
|
}
|
|
return CurtainModel(
|
|
id: json['id'],
|
|
name: json['name'],
|
|
status: json['status'],
|
|
openPercentage: json['openPercentage'],
|
|
timer: json['timer'],
|
|
type: json['type'],
|
|
image: json['image'],
|
|
functions: func,
|
|
);
|
|
}
|
|
}
|