From 65b8ecf6720a18fdcee23e32fc827fad42f69ee5 Mon Sep 17 00:00:00 2001 From: raf-dev1 Date: Tue, 24 Jun 2025 08:39:30 +0300 Subject: [PATCH] PR improvments --- .../bloc/smart_door_bloc/smart_door_bloc.dart | 5 - .../view/widgets/smart_door/door_button.dart | 99 +------------------ 2 files changed, 1 insertion(+), 103 deletions(-) diff --git a/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart b/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart index 54e4730..e8c0f46 100644 --- a/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart +++ b/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart @@ -253,15 +253,10 @@ class SmartDoorBloc extends Bloc { } void _updateLock(UpdateLockEvent event, Emitter emit) async { - // emit(LoadingNewSate(smartDoorModel: deviceStatus)); final oldValue = deviceStatus.normalOpenSwitch; deviceStatus = deviceStatus.copyWith(normalOpenSwitch: !oldValue); emit(UpdateState(smartDoorModel: deviceStatus)); try { - // final response = await DevicesAPI.controlDevice( - // DeviceControlModel(deviceId: deviceId, code: 'normal_open_switch', value: !event.value), - // deviceId); - final response = await DevicesAPI.openDoorLock(deviceId); if (!response) { diff --git a/lib/features/devices/view/widgets/smart_door/door_button.dart b/lib/features/devices/view/widgets/smart_door/door_button.dart index 6704a5c..1034b95 100644 --- a/lib/features/devices/view/widgets/smart_door/door_button.dart +++ b/lib/features/devices/view/widgets/smart_door/door_button.dart @@ -6,7 +6,6 @@ import 'package:syncrow_app/features/devices/bloc/smart_door_bloc/smart_door_eve import 'package:syncrow_app/features/devices/model/device_model.dart'; import 'package:syncrow_app/features/devices/model/smart_door_model.dart'; import 'package:syncrow_app/generated/assets.dart'; -import 'package:syncrow_app/utils/context_extension.dart'; import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; class DoorLockButton extends StatelessWidget { @@ -93,100 +92,4 @@ class DoorLockButton extends StatelessWidget { ), ); } -} - -/** - import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart'; -import 'package:syncrow_web/pages/device_managment/door_lock/bloc/door_lock_bloc.dart'; -import 'package:syncrow_web/pages/device_managment/door_lock/bloc/door_lock_event.dart'; -import 'package:syncrow_web/pages/device_managment/door_lock/models/door_lock_status_model.dart'; -import 'package:syncrow_web/utils/color_manager.dart'; -import 'package:syncrow_web/utils/constants/assets.dart'; - -class DoorLockButton extends StatelessWidget { - const DoorLockButton({ - super.key, - required this.doorLock, - required this.smartDoorModel, - }); - - final DeviceModel doorLock; - final SmartDoorModel smartDoorModel; - - double _calculateProgress() { - final value = smartDoorModel.unlockRequest; - if (value <= 0 || value > 30) return 0; - return value / 30.0; - } - - @override - Widget build(BuildContext context) { - final progress = _calculateProgress(); - final isEnabled = smartDoorModel.unlockRequest > 0; - - return SizedBox( - width: 255, - height: 255, - child: InkWell( - onTap: isEnabled - ? () { - BlocProvider.of(context).add( - UpdateLockEvent(value: !smartDoorModel.normalOpenSwitch), - ); - } - : null, - child: Container( - width: 255, - height: 255, - decoration: BoxDecoration( - color: const Color(0xFFEBECED), - shape: BoxShape.circle, - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - blurRadius: 18, - blurStyle: BlurStyle.outer, - ), - ], - ), - child: Stack( - alignment: Alignment.center, - children: [ - Container( - margin: const EdgeInsets.all(30), - decoration: const BoxDecoration( - color: Color(0xFFF9F9F9), - shape: BoxShape.circle, - ), - child: Center( - child: SvgPicture.asset( - smartDoorModel.normalOpenSwitch - ? Assets.doorUnlock - : Assets.lockIcon, - width: 60, - height: 60, - ), - ), - ), - if (progress > 0) - SizedBox.expand( - child: CircularProgressIndicator( - value: progress, - strokeWidth: 8, - backgroundColor: Colors.transparent, - valueColor: const AlwaysStoppedAnimation( - ColorsManager.primaryColor), - ), - ), - ], - ), - ), - ), - ); - } -} - - */ +} \ No newline at end of file