mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 17:47:28 +00:00
31 lines
690 B
Dart
31 lines
690 B
Dart
|
|
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
|
|
|
class OneGangModel {
|
|
bool firstSwitch;
|
|
int firstCountDown;
|
|
|
|
OneGangModel(
|
|
{required this.firstSwitch,
|
|
required this.firstCountDown,
|
|
});
|
|
|
|
factory OneGangModel.fromJson(List<StatusModel> jsonList) {
|
|
late bool _switch;
|
|
late int _count;
|
|
|
|
|
|
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;
|
|
}
|
|
}
|
|
return OneGangModel(
|
|
firstSwitch: _switch,
|
|
firstCountDown: _count,
|
|
);
|
|
}
|
|
}
|