diff --git a/assets/icons/door_un_look_ic.svg b/assets/icons/door_un_look_ic.svg
new file mode 100644
index 00000000..b647ec84
--- /dev/null
+++ b/assets/icons/door_un_look_ic.svg
@@ -0,0 +1,17 @@
+
diff --git a/assets/icons/lockIcon.svg b/assets/icons/lockIcon.svg
new file mode 100644
index 00000000..a78161ca
--- /dev/null
+++ b/assets/icons/lockIcon.svg
@@ -0,0 +1,17 @@
+
diff --git a/lib/pages/device_managment/all_devices/helper/route_controls_based_code.dart b/lib/pages/device_managment/all_devices/helper/route_controls_based_code.dart
index e4595870..fbe1f198 100644
--- a/lib/pages/device_managment/all_devices/helper/route_controls_based_code.dart
+++ b/lib/pages/device_managment/all_devices/helper/route_controls_based_code.dart
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/device_managment/ac/view/ac_device_control.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
import 'package:syncrow_web/pages/device_managment/ceiling_sensor/view/ceiling_sensor_controls.dart';
+import 'package:syncrow_web/pages/device_managment/door_lock/view/door_lock_status_view.dart';
import 'package:syncrow_web/pages/device_managment/gateway/view/gateway_view.dart';
import 'package:syncrow_web/pages/device_managment/living_room_switch/view/living_room_device_control.dart';
import 'package:syncrow_web/pages/device_managment/wall_sensor/view/wall_sensor_conrtols.dart';
@@ -19,7 +20,7 @@ mixin RouteControlsBasedCode {
gatewayId: device.uuid!,
);
case 'DL':
- return const SizedBox();
+ return DoorLockView(device: device);
case 'WPS':
return WallSensorControls(device: device);
case 'CPS':
diff --git a/lib/pages/device_managment/door_lock/bloc/door_lock_bloc.dart b/lib/pages/device_managment/door_lock/bloc/door_lock_bloc.dart
new file mode 100644
index 00000000..98af2b5a
--- /dev/null
+++ b/lib/pages/device_managment/door_lock/bloc/door_lock_bloc.dart
@@ -0,0 +1,131 @@
+// ignore_for_file: invalid_use_of_visible_for_testing_member
+
+import 'dart:async';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
+import 'package:syncrow_web/pages/device_managment/door_lock/bloc/door_lock_event.dart';
+import 'package:syncrow_web/pages/device_managment/door_lock/bloc/door_lock_state.dart';
+import 'package:syncrow_web/pages/device_managment/door_lock/models/door_lock_status_model.dart';
+import 'package:syncrow_web/services/devices_mang_api.dart';
+
+class DoorLockBloc extends Bloc {
+ late DoorLockStatusModel deviceStatus;
+ final String deviceId;
+ Timer? _timer;
+
+ DoorLockBloc({required this.deviceId}) : super(DoorLockInitial()) {
+ on(_onFetchDeviceStatus);
+ on(_onDoorLockControl);
+ on(_updateLock);
+ }
+
+ FutureOr _onFetchDeviceStatus(
+ DoorLockFetchStatus event, Emitter emit) async {
+ emit(DoorLockStatusLoading());
+ try {
+ final status =
+ await DevicesManagementApi().getDeviceStatus(event.deviceId);
+ deviceStatus =
+ DoorLockStatusModel.fromJson(event.deviceId, status.status);
+ emit(DoorLockStatusLoaded(deviceStatus));
+ } catch (e) {
+ emit(DoorLockControlError(e.toString()));
+ }
+ }
+
+ FutureOr _onDoorLockControl(
+ DoorLockControl event, Emitter emit) async {
+ final oldValue = _getValueByCode(event.code);
+ _updateLocalValue(event.code, event.value);
+ emit(DoorLockStatusLoaded(deviceStatus));
+
+ await _runDebounce(
+ deviceId: event.deviceId,
+ code: event.code,
+ value: event.value,
+ oldValue: oldValue,
+ emit: emit,
+ );
+ }
+
+ FutureOr _updateLock(
+ UpdateLockEvent event, Emitter emit) async {
+ final oldValue = deviceStatus.normalOpenSwitch;
+ deviceStatus = deviceStatus.copyWith(normalOpenSwitch: event.value);
+ emit(DoorLockStatusLoaded(deviceStatus));
+
+ try {
+ final response = await DevicesManagementApi.openDoorLock(deviceId);
+
+ if (!response) {
+ _revertValueAndEmit(deviceId, 'normal_open_switch', oldValue, emit);
+ }
+ } catch (e) {
+ _revertValueAndEmit(deviceId, 'normal_open_switch', oldValue, emit);
+ emit(DoorLockControlError('Error controlling the lock: $e'));
+ }
+ }
+
+ Future _runDebounce({
+ required String deviceId,
+ required String code,
+ required dynamic value,
+ required dynamic oldValue,
+ required Emitter emit,
+ }) async {
+ if (_timer != null) {
+ _timer!.cancel();
+ }
+ _timer = Timer(const Duration(seconds: 1), () async {
+ try {
+ final response = await DevicesManagementApi()
+ .deviceControl(deviceId, Status(code: code, value: value));
+ if (!response) {
+ _revertValueAndEmit(deviceId, code, oldValue, emit);
+ }
+ } catch (e) {
+ _revertValueAndEmit(deviceId, code, oldValue, emit);
+ }
+ });
+ }
+
+ void _revertValueAndEmit(
+ String deviceId,
+ String code,
+ dynamic oldValue,
+ Emitter emit,
+ ) {
+ _updateLocalValue(code, oldValue);
+ emit(DoorLockStatusLoaded(deviceStatus));
+ emit(const DoorLockControlError('Failed to control the device.'));
+ }
+
+ void _updateLocalValue(String code, dynamic value) {
+ switch (code) {
+ case 'reverse_lock':
+ if (value is bool) {
+ deviceStatus = deviceStatus.copyWith(reverseLock: value);
+ }
+ break;
+ case 'normal_open_switch':
+ if (value is bool) {
+ deviceStatus = deviceStatus.copyWith(normalOpenSwitch: value);
+ }
+ break;
+ default:
+ break;
+ }
+ emit(DoorLockStatusLoaded(deviceStatus));
+ }
+
+ dynamic _getValueByCode(String code) {
+ switch (code) {
+ case 'reverse_lock':
+ return deviceStatus.reverseLock;
+ case 'normal_open_switch':
+ return deviceStatus.normalOpenSwitch;
+ default:
+ return null;
+ }
+ }
+}
diff --git a/lib/pages/device_managment/door_lock/bloc/door_lock_event.dart b/lib/pages/device_managment/door_lock/bloc/door_lock_event.dart
new file mode 100644
index 00000000..8ee2e6aa
--- /dev/null
+++ b/lib/pages/device_managment/door_lock/bloc/door_lock_event.dart
@@ -0,0 +1,39 @@
+import 'package:equatable/equatable.dart';
+
+sealed class DoorLockEvent extends Equatable {
+ const DoorLockEvent();
+
+ @override
+ List