mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
sos_device
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class SceneSwitch {
|
||||
class DeviceInfoModel {
|
||||
final int activeTime;
|
||||
final String category;
|
||||
final String categoryName;
|
||||
@ -27,7 +27,7 @@ class SceneSwitch {
|
||||
final String macAddress;
|
||||
final Subspace subspace;
|
||||
|
||||
SceneSwitch({
|
||||
DeviceInfoModel({
|
||||
required this.activeTime,
|
||||
required this.category,
|
||||
required this.categoryName,
|
||||
@ -55,8 +55,8 @@ class SceneSwitch {
|
||||
required this.subspace,
|
||||
});
|
||||
|
||||
factory SceneSwitch.fromJson(Map<String, dynamic> json) {
|
||||
return SceneSwitch(
|
||||
factory DeviceInfoModel.fromJson(Map<String, dynamic> json) {
|
||||
return DeviceInfoModel(
|
||||
activeTime: json['activeTime'],
|
||||
category: json['category'],
|
||||
categoryName: json['categoryName'],
|
@ -1,9 +1,9 @@
|
||||
class FourSceneQuestionModel {
|
||||
class QuestionModel {
|
||||
final int id;
|
||||
final String question;
|
||||
final String answer;
|
||||
|
||||
FourSceneQuestionModel({
|
||||
QuestionModel({
|
||||
required this.id,
|
||||
required this.question,
|
||||
required this.answer,
|
28
lib/features/devices/model/sos_model.dart
Normal file
28
lib/features/devices/model/sos_model.dart
Normal file
@ -0,0 +1,28 @@
|
||||
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
||||
|
||||
class SosModel {
|
||||
String sosContactState;
|
||||
int batteryPercentage;
|
||||
|
||||
SosModel({
|
||||
required this.sosContactState,
|
||||
required this.batteryPercentage,
|
||||
});
|
||||
|
||||
factory SosModel.fromJson(List<StatusModel> jsonList) {
|
||||
late String _sosContactState;
|
||||
late int _batteryPercentage;
|
||||
|
||||
for (int i = 0; i < jsonList.length; i++) {
|
||||
if (jsonList[i].code == 'sos') {
|
||||
_sosContactState = jsonList[i].value ?? '';
|
||||
} else if (jsonList[i].code == 'battery_percentage') {
|
||||
_batteryPercentage = jsonList[i].value ?? 0;
|
||||
}
|
||||
}
|
||||
return SosModel(
|
||||
sosContactState: _sosContactState,
|
||||
batteryPercentage: _batteryPercentage,
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user