mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-26 19:34:54 +00:00
Added smart door bloc
This commit is contained in:
116
lib/features/devices/model/smart_door_model.dart
Normal file
116
lib/features/devices/model/smart_door_model.dart
Normal file
@ -0,0 +1,116 @@
|
||||
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
||||
|
||||
class SmartDoorModel {
|
||||
int unlockFingerprint;
|
||||
int unlockPassword;
|
||||
int unlockTemporary;
|
||||
int unlockCard;
|
||||
String unlockAlarm;
|
||||
int unlockRequest;
|
||||
int residualElectricity;
|
||||
bool reverseLock;
|
||||
int unlockApp;
|
||||
bool hijack;
|
||||
bool doorbell;
|
||||
String unlockOfflinePd;
|
||||
String unlockOfflineClear;
|
||||
String unlockDoubleKit;
|
||||
String remoteNoPdSetkey;
|
||||
String remoteNoDpKey;
|
||||
bool normalOpenSwitch;
|
||||
|
||||
SmartDoorModel(
|
||||
{required this.unlockFingerprint,
|
||||
required this.unlockPassword,
|
||||
required this.unlockTemporary,
|
||||
required this.unlockCard,
|
||||
required this.unlockAlarm,
|
||||
required this.unlockRequest,
|
||||
required this.residualElectricity,
|
||||
required this.reverseLock,
|
||||
required this.unlockApp,
|
||||
required this.hijack,
|
||||
required this.doorbell,
|
||||
required this.unlockOfflinePd,
|
||||
required this.unlockOfflineClear,
|
||||
required this.unlockDoubleKit,
|
||||
required this.remoteNoPdSetkey,
|
||||
required this.remoteNoDpKey,
|
||||
required this.normalOpenSwitch});
|
||||
|
||||
factory SmartDoorModel.fromJson(List<StatusModel> jsonList) {
|
||||
late int _unlockFingerprint;
|
||||
late int _unlockPassword;
|
||||
late int _unlockTemporary;
|
||||
late int _unlockCard;
|
||||
late String _unlockAlarm;
|
||||
late int _unlockRequest;
|
||||
late int _residualElectricity;
|
||||
late bool _reverseLock;
|
||||
late int _unlockApp;
|
||||
late bool _hijack;
|
||||
late bool _doorbell;
|
||||
late String _unlockOfflinePd;
|
||||
late String _unlockOfflineClear;
|
||||
late String _unlockDoubleKit;
|
||||
late String _remoteNoPdSetkey;
|
||||
late String _remoteNoDpKey;
|
||||
late bool _normalOpenSwitch;
|
||||
|
||||
for (int i = 0; i < jsonList.length; i++) {
|
||||
if (jsonList[i].code == 'unlock_fingerprint') {
|
||||
_unlockFingerprint = jsonList[i].value ?? 0;
|
||||
} else if (jsonList[i].code == 'unlock_password') {
|
||||
_unlockPassword = jsonList[i].value ?? 0;
|
||||
} else if (jsonList[i].code == 'unlock_temporary') {
|
||||
_unlockTemporary = jsonList[i].value ?? 0;
|
||||
} else if (jsonList[i].code == 'unlock_card') {
|
||||
_unlockCard = jsonList[i].value ?? 0;
|
||||
} else if (jsonList[i].code == 'alarm_lock') {
|
||||
_unlockAlarm = jsonList[i].value ?? '';
|
||||
} else if (jsonList[i].code == 'unlock_request') {
|
||||
_unlockRequest = jsonList[i].value ?? 0;
|
||||
} else if (jsonList[i].code == 'residual_electricity') {
|
||||
_residualElectricity = jsonList[i].value ?? 0;
|
||||
} else if (jsonList[i].code == 'reverse_lock') {
|
||||
_reverseLock = jsonList[i].value ?? false;
|
||||
} else if (jsonList[i].code == 'unlock_app') {
|
||||
_unlockApp = jsonList[i].value ?? 0;
|
||||
} else if (jsonList[i].code == 'hijack') {
|
||||
_hijack = jsonList[i].value ?? false;
|
||||
} else if (jsonList[i].code == 'doorbell') {
|
||||
_doorbell = jsonList[i].value ?? false;
|
||||
} else if (jsonList[i].code == 'unlock_offline_pd') {
|
||||
_unlockOfflinePd = jsonList[i].value ?? '';
|
||||
} else if (jsonList[i].code == 'unlock_offline_clear') {
|
||||
_unlockOfflineClear = jsonList[i].value ?? '';
|
||||
} else if (jsonList[i].code == 'unlock_double_kit') {
|
||||
_unlockDoubleKit = jsonList[i].value ?? '';
|
||||
} else if (jsonList[i].code == 'remote_no_pd_setkey') {
|
||||
_remoteNoPdSetkey = jsonList[i].value ?? '';
|
||||
} else if (jsonList[i].code == 'remote_no_dp_key') {
|
||||
_remoteNoDpKey = jsonList[i].value ?? '';
|
||||
} else if (jsonList[i].code == 'normal_open_switch') {
|
||||
_normalOpenSwitch = jsonList[i].value ?? false;
|
||||
}
|
||||
}
|
||||
return SmartDoorModel(
|
||||
unlockFingerprint: _unlockFingerprint,
|
||||
unlockPassword: _unlockPassword,
|
||||
unlockTemporary: _unlockTemporary,
|
||||
unlockCard: _unlockCard,
|
||||
unlockAlarm: _unlockAlarm,
|
||||
unlockRequest: _unlockRequest,
|
||||
residualElectricity: _residualElectricity,
|
||||
reverseLock: _reverseLock,
|
||||
unlockApp: _unlockApp,
|
||||
hijack: _hijack,
|
||||
doorbell: _doorbell,
|
||||
unlockOfflinePd: _unlockOfflinePd,
|
||||
unlockOfflineClear: _unlockOfflineClear,
|
||||
unlockDoubleKit: _unlockDoubleKit,
|
||||
remoteNoPdSetkey: _remoteNoPdSetkey,
|
||||
remoteNoDpKey: _remoteNoDpKey,
|
||||
normalOpenSwitch: _normalOpenSwitch);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user