mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 04:57:56 +00:00
sos_device
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
class QuestionModel {
|
||||
final int id;
|
||||
final String question;
|
||||
final String answer;
|
||||
|
||||
QuestionModel({
|
||||
required this.id,
|
||||
required this.question,
|
||||
required this.answer,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
||||
|
||||
class SosModel {
|
||||
String waterContactState;
|
||||
int batteryPercentage;
|
||||
|
||||
SosModel({
|
||||
required this.waterContactState,
|
||||
required this.batteryPercentage,
|
||||
});
|
||||
|
||||
factory SosModel.fromJson(List<StatusModel> jsonList) {
|
||||
late String _waterContactState;
|
||||
late int _batteryPercentage;
|
||||
|
||||
for (int i = 0; i < jsonList.length; i++) {
|
||||
if (jsonList[i].code == 'sossensor_state') {
|
||||
_waterContactState = jsonList[i].value ?? false;
|
||||
} else if (jsonList[i].code == 'battery_percentage') {
|
||||
_batteryPercentage = jsonList[i].value ?? 0;
|
||||
}
|
||||
}
|
||||
return SosModel(
|
||||
waterContactState: _waterContactState,
|
||||
batteryPercentage: _batteryPercentage,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user