diff --git a/lib/features/devices/bloc/curtain_bloc/curtain_bloc.dart b/lib/features/devices/bloc/curtain_bloc/curtain_bloc.dart index 6de8d58..3cff103 100644 --- a/lib/features/devices/bloc/curtain_bloc/curtain_bloc.dart +++ b/lib/features/devices/bloc/curtain_bloc/curtain_bloc.dart @@ -161,15 +161,12 @@ class CurtainBloc extends Bloc { void _fetchStatus(InitCurtain event, Emitter emit) async { try { emit(CurtainLoadingState()); - // Fetch the status from the API var response = await DevicesAPI.getDeviceStatus(curtainId); List statusModelList = []; for (var status in response['status']) { statusModelList.add(StatusModel.fromJson(status)); } - // Get the open percentage from the response openPercentage = double.tryParse(statusModelList[1].value.toString())!; - // Calculate curtain width and blind height based on the open percentage curtainWidth = 270 - (openPercentage / 100) * curtainOpeningSpace; blindHeight = 310 - (openPercentage / 100) * blindOpeningSpace; @@ -216,7 +213,6 @@ class CurtainBloc extends Bloc { if (groupList.isNotEmpty) { groupList.firstWhere((element) { - print('object=====${element.percentControl}'); if (element.percentControl > 1) { allSwitchesOn = true; } @@ -285,7 +281,6 @@ class CurtainBloc extends Bloc { if (response2['failedResults'].toString() != '[]') { await Future.delayed(const Duration(milliseconds: 500)); - // Handle retry or error if needed. } } catch (_) { emit(FailedState()); @@ -297,7 +292,6 @@ class CurtainBloc extends Bloc { void _groupAllOff(GroupAllOffEvent event, Emitter emit) async { emit(LoadingNewSate(curtainModel: deviceStatus)); try { - // Set all devices to 'close' for (int i = 0; i < groupList.length; i++) { groupList[i].percentControl = 0; } @@ -315,12 +309,10 @@ class CurtainBloc extends Bloc { if (response2['failedResults'].toString() != '[]') { await Future.delayed(const Duration(milliseconds: 500)); - // Handle retry or error if needed. } } catch (_) { emit(FailedState()); await Future.delayed(const Duration(milliseconds: 500)); - // Optionally add an initial event if needed. } } } diff --git a/lib/features/devices/bloc/door_sensor_bloc/door_sensor_bloc.dart b/lib/features/devices/bloc/door_sensor_bloc/door_sensor_bloc.dart index 4747405..5d39f25 100644 --- a/lib/features/devices/bloc/door_sensor_bloc/door_sensor_bloc.dart +++ b/lib/features/devices/bloc/door_sensor_bloc/door_sensor_bloc.dart @@ -100,7 +100,6 @@ class DoorSensorBloc extends Bloc { doorAlarm = event.isDoorAlarmEnabled; emit(UpdateState(doorSensor: deviceStatus)); - // API call to update the state, if necessary await DevicesAPI.controlDevice( DeviceControlModel( deviceId: DSId, @@ -119,33 +118,26 @@ class DoorSensorBloc extends Bloc { Future fetchLogsForLastMonth( ReportLogsInitial event, Emitter emit) async { - // Get the current date and time DateTime now = DateTime.now(); - // Calculate the date one month ago DateTime lastMonth = DateTime(now.year, now.month - 1, now.day); - // Convert the date to milliseconds since epoch (Unix timestamp in milliseconds) int startTime = lastMonth.millisecondsSinceEpoch; int endTime = now.millisecondsSinceEpoch; try { emit(DoorSensorLoadingState()); var response = await DevicesAPI.getReportLogs( startTime: - startTime.toString(), // Convert to String if the API expects it - endTime: endTime.toString(), // Convert to String if the API expects it + startTime.toString(), + endTime: endTime.toString(), deviceUuid: DSId, code: 'doorcontact_state', ); - print('response======${response}'); recordGroups = response; - // Process response here emit(UpdateState(doorSensor: deviceStatus)); } on DioException catch (e) { final errorData = e.response!.data; String errorMessage = errorData['message']; - // Handle error - print('Error fetching logs: ${errorMessage}'); } } diff --git a/lib/features/devices/bloc/three_touch_bloc/three_touch_bloc.dart b/lib/features/devices/bloc/three_touch_bloc/three_touch_bloc.dart index 8a4ac56..ed369eb 100644 --- a/lib/features/devices/bloc/three_touch_bloc/three_touch_bloc.dart +++ b/lib/features/devices/bloc/three_touch_bloc/three_touch_bloc.dart @@ -724,7 +724,8 @@ class ThreeTouchBloc extends Bloc { threeTouchId, ); } else { - print('Invalid statusSelected or optionSelected'); + emit(const FailedState( + error: 'Invalid statusSelected or optionSelected')); } } on DioException catch (e) { final errorData = e.response!.data; diff --git a/lib/features/devices/bloc/two_touch_bloc/two_touch_bloc.dart b/lib/features/devices/bloc/two_touch_bloc/two_touch_bloc.dart index fedf978..8391191 100644 --- a/lib/features/devices/bloc/two_touch_bloc/two_touch_bloc.dart +++ b/lib/features/devices/bloc/two_touch_bloc/two_touch_bloc.dart @@ -670,7 +670,7 @@ class TwoTouchBloc extends Bloc { twoTouchId, ); } else { - print('Invalid statusSelected or optionSelected'); + emit( const FailedState(error: 'Invalid statusSelected or optionSelected')); } } on DioException catch (e) { final errorData = e.response!.data; diff --git a/lib/features/devices/view/widgets/garage_door/garage_door_screen.dart b/lib/features/devices/view/widgets/garage_door/garage_door_screen.dart index 62884f6..3d59c4a 100644 --- a/lib/features/devices/view/widgets/garage_door/garage_door_screen.dart +++ b/lib/features/devices/view/widgets/garage_door/garage_door_screen.dart @@ -138,9 +138,10 @@ class GarageDoorScreen extends StatelessWidget { Assets .garageSchedule), ), - const SizedBox( + const Flexible( + child: SizedBox( height: 15, - ), + )), const Flexible( child: FittedBox( child: BodySmall( @@ -187,9 +188,10 @@ class GarageDoorScreen extends StatelessWidget { Assets .garageCountdown), ), - const SizedBox( + const Flexible( + child: SizedBox( height: 15, - ), + )), const Flexible( child: FittedBox( child: BodySmall( @@ -238,9 +240,10 @@ class GarageDoorScreen extends StatelessWidget { Assets .doorRecordsIcon), ), - const SizedBox( + const Flexible( + child: SizedBox( height: 15, - ), + )), const Flexible( child: FittedBox( child: BodySmall( @@ -282,9 +285,10 @@ class GarageDoorScreen extends StatelessWidget { child: SvgPicture.asset(Assets .garagePreferencesIcon), ), - const SizedBox( + const Flexible( + child: SizedBox( height: 15, - ), + )), const Flexible( child: FittedBox( child: BodySmall( diff --git a/lib/features/devices/view/widgets/garage_door/garage_preferences_settings.dart b/lib/features/devices/view/widgets/garage_door/garage_preferences_settings.dart index 185d003..e5752b8 100644 --- a/lib/features/devices/view/widgets/garage_door/garage_preferences_settings.dart +++ b/lib/features/devices/view/widgets/garage_door/garage_preferences_settings.dart @@ -97,9 +97,12 @@ class PreferencesPage extends StatelessWidget { Transform.scale( scale: .8, child: CupertinoSwitch( - value: garageDoorBloc.deviceStatus.doorState1 != 'unclosed_time', + value: garageDoorBloc.deviceStatus + .doorState1 != + 'unclosed_time', onChanged: (value) { - context.read() + context + .read() .add( ToggleAlarmEvent( value @@ -156,36 +159,37 @@ class PreferencesPage extends StatelessWidget { }, ); }, - child: SizedBox( - child: ListTile( - contentPadding: EdgeInsets.zero, - leading: const BodyMedium( + child: Container( + padding: EdgeInsets.only(top: 12, bottom: 12), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + const BodyMedium( text: 'Opening and Closing Time', fontWeight: FontWeight.normal, ), - trailing: Container( - height: 90, - width: 120, - child: Row( - crossAxisAlignment: - CrossAxisAlignment.center, - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - BodyMedium( - fontColor: ColorsManager.textGray, - text: - '${garageDoorBloc.secondSelected.toString()} Seconds', - fontWeight: FontWeight.normal, - ), - const Icon( - Icons.arrow_forward_ios, - size: 15, - color: ColorsManager.textGray, - ) - ], - ), - )), + Row( + crossAxisAlignment: + CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + BodyMedium( + fontColor: ColorsManager.textGray, + text: + '${garageDoorBloc.secondSelected.toString()} Seconds', + fontWeight: FontWeight.normal, + fontSize: 13, + ), + const Icon( + Icons.arrow_forward_ios, + size: 15, + color: ColorsManager.textGray, + ) + ], + ), + ], + ), ), ), ) diff --git a/lib/features/devices/view/widgets/water_leak/water_leak_records_screen.dart b/lib/features/devices/view/widgets/water_leak/water_leak_records_screen.dart index 363a125..92ccf23 100644 --- a/lib/features/devices/view/widgets/water_leak/water_leak_records_screen.dart +++ b/lib/features/devices/view/widgets/water_leak/water_leak_records_screen.dart @@ -22,7 +22,7 @@ class WaterLeakRecordsScreen extends StatefulWidget { } class _WaterLeakRecordsScreenState extends State { - int _selectedIndex = 0; + int _selectedIndex = 0; @override Widget build(BuildContext context) { return DefaultScaffold( @@ -177,8 +177,8 @@ class _WaterLeakRecordsScreenState extends State { ), title: Text( record.value == 'true' - ? "Normal" - : "Leak Detected", + ? "Leak Detected" + : "Normal", style: const TextStyle( fontWeight: FontWeight.bold, @@ -207,6 +207,8 @@ class _WaterLeakRecordsScreenState extends State { Container( height: 10, width: 20, + child: + const Center(child: Text('No data available.')), ), ], ), diff --git a/lib/services/api/devices_api.dart b/lib/services/api/devices_api.dart index c2d7e34..8d096f7 100644 --- a/lib/services/api/devices_api.dart +++ b/lib/services/api/devices_api.dart @@ -39,7 +39,6 @@ class DevicesAPI { body: controlModel.toJson(), showServerMessage: true, expectedResponseModel: (json) { - print(json); return json; }, ); @@ -70,7 +69,6 @@ class DevicesAPI { } static Future> getDeviceStatus(String deviceId) async { - print(deviceId); final response = await _httpService.get( path: ApiEndpoints.deviceFunctionsStatus .replaceAll('{deviceUuid}', deviceId),