mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 18:16:21 +00:00
46 lines
1.4 KiB
Dart
46 lines
1.4 KiB
Dart
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
|
|
|
class OneTouchModel {
|
|
bool firstSwitch;
|
|
int firstCountDown;
|
|
status relay;
|
|
lightStatus light_mode;
|
|
status relay_status_1;
|
|
|
|
OneTouchModel(
|
|
{required this.firstSwitch,
|
|
required this.firstCountDown,
|
|
required this.light_mode,
|
|
required this.relay,
|
|
required this.relay_status_1});
|
|
|
|
factory OneTouchModel.fromJson(List<StatusModel> jsonList) {
|
|
bool _switch = false;
|
|
int _count = 0;
|
|
String _relay = '';
|
|
String _light_mode = '';
|
|
String relay_status_1 = '';
|
|
|
|
for (int i = 0; i < jsonList.length; i++) {
|
|
if (jsonList[i].code == 'switch_1') {
|
|
_switch = jsonList[i].value ?? false;
|
|
} else if (jsonList[i].code == 'countdown_1') {
|
|
_count = jsonList[i].value ?? 0;
|
|
} else if (jsonList[i].code == 'relay_status') {
|
|
_relay = jsonList[i].value ?? 0;
|
|
} else if (jsonList[i].code == 'light_mode') {
|
|
_light_mode = jsonList[i].value ?? 0;
|
|
} else if (jsonList[i].code == 'relay_status_1') {
|
|
relay_status_1 = jsonList[i].value ?? 0;
|
|
}
|
|
}
|
|
return OneTouchModel(
|
|
firstSwitch: _switch,
|
|
firstCountDown: _count,
|
|
light_mode: lightStatusExtension.fromString(_light_mode),
|
|
relay: StatusExtension.fromString(_relay),
|
|
relay_status_1: StatusExtension.fromString(relay_status_1));
|
|
}
|
|
}
|