From 2d54d52061a72a0087e3784bd908b9347f071b25 Mon Sep 17 00:00:00 2001 From: Abdullah Alassaf Date: Sun, 6 Oct 2024 22:30:28 +0300 Subject: [PATCH] Updated the curtain desgin and removed unused code --- ...ticalBlade.svg => left_vertical_blade.svg} | 0 .../curtainsIcon/right_vertical_blade.svg | 32 +++ .../bloc/curtain_bloc/curtain_bloc.dart | 25 +- .../garage_door_bloc/garage_door_bloc.dart | 70 ++--- .../bloc/one_touch_bloc/one_touch_bloc.dart | 137 ++++------ .../three_touch_bloc/three_touch_bloc.dart | 156 ++++------- .../view/widgets/curtains/curtain_view.dart | 115 +++++--- .../garage_door/garage_door_screen.dart | 143 ++++------ .../garage_preferences_settings.dart | 34 +-- .../garage_door/schedule_garage_screen.dart | 71 ++--- .../widgets/one_touch/one_touch_screen.dart | 86 +++--- .../three_touch/three_touch_setting.dart | 250 ++++++------------ .../view/widgets/water_heater/wh_wizard.dart | 43 +-- lib/features/menu/view/menu_view.dart | 4 +- lib/generated/assets.dart | 232 ++++++---------- lib/main.dart | 2 +- lib/main_dev.dart | 2 +- lib/services/locator.dart | 3 +- 18 files changed, 556 insertions(+), 849 deletions(-) rename assets/icons/curtainsIcon/{verticalBlade.svg => left_vertical_blade.svg} (100%) create mode 100644 assets/icons/curtainsIcon/right_vertical_blade.svg diff --git a/assets/icons/curtainsIcon/verticalBlade.svg b/assets/icons/curtainsIcon/left_vertical_blade.svg similarity index 100% rename from assets/icons/curtainsIcon/verticalBlade.svg rename to assets/icons/curtainsIcon/left_vertical_blade.svg diff --git a/assets/icons/curtainsIcon/right_vertical_blade.svg b/assets/icons/curtainsIcon/right_vertical_blade.svg new file mode 100644 index 0000000..d7675aa --- /dev/null +++ b/assets/icons/curtainsIcon/right_vertical_blade.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/features/devices/bloc/curtain_bloc/curtain_bloc.dart b/lib/features/devices/bloc/curtain_bloc/curtain_bloc.dart index 1dea664..7e0ac56 100644 --- a/lib/features/devices/bloc/curtain_bloc/curtain_bloc.dart +++ b/lib/features/devices/bloc/curtain_bloc/curtain_bloc.dart @@ -24,9 +24,7 @@ class CurtainBloc extends Bloc { on(_onPauseCurtain); } - Future _onOpenCurtain( - OpenCurtain event, - Emitter emit) async { + Future _onOpenCurtain(OpenCurtain event, Emitter emit) async { isMoving = true; while (openPercentage < 100.0) { if (state is CurtainsClosing) { @@ -48,7 +46,7 @@ class CurtainBloc extends Bloc { _pauseCurtain(emit); } }); - if (openPercentage >=100.0) { + if (openPercentage >= 100.0) { await DevicesAPI.controlDevice( DeviceControlModel( deviceId: curtainId, @@ -73,8 +71,7 @@ class CurtainBloc extends Bloc { } } - Future _onCloseCurtain( - CloseCurtain event, Emitter emit) async { + Future _onCloseCurtain(CloseCurtain event, Emitter emit) async { isMoving = true; while (openPercentage > 0.0) { if (state is CurtainsOpening) { @@ -121,8 +118,7 @@ class CurtainBloc extends Bloc { } } - Future _onPauseCurtain( - PauseCurtain event, Emitter emit) async { + Future _onPauseCurtain(PauseCurtain event, Emitter emit) async { _pauseCurtain(emit); await DevicesAPI.controlDevice( DeviceControlModel( @@ -132,7 +128,7 @@ class CurtainBloc extends Bloc { ), curtainId, ); - await DevicesAPI.controlDevice( + await DevicesAPI.controlDevice( DeviceControlModel( deviceId: curtainId, code: 'percent_control', @@ -151,9 +147,6 @@ class CurtainBloc extends Bloc { )); } - - - void _fetchStatus(InitCurtain event, Emitter emit) async { try { emit(CurtainLoadingState()); @@ -166,10 +159,9 @@ class CurtainBloc extends Bloc { // 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 - if (openPercentage != null) { - curtainWidth = 270 - (openPercentage / 100) * curtainOpeningSpace; - blindHeight = 310 - (openPercentage / 100) * blindOpeningSpace; - } + curtainWidth = 270 - (openPercentage / 100) * curtainOpeningSpace; + blindHeight = 310 - (openPercentage / 100) * blindOpeningSpace; + emit(CurtainsOpening( curtainWidth: curtainWidth, blindHeight: blindHeight, @@ -180,5 +172,4 @@ class CurtainBloc extends Bloc { return; } } - } diff --git a/lib/features/devices/bloc/garage_door_bloc/garage_door_bloc.dart b/lib/features/devices/bloc/garage_door_bloc/garage_door_bloc.dart index f6c3d4f..a8cb8a4 100644 --- a/lib/features/devices/bloc/garage_door_bloc/garage_door_bloc.dart +++ b/lib/features/devices/bloc/garage_door_bloc/garage_door_bloc.dart @@ -54,8 +54,7 @@ class GarageDoorBloc extends Bloc { batteryPercentage: 0, ); - void _fetchStatus( - GarageDoorInitial event, Emitter emit) async { + void _fetchStatus(GarageDoorInitial event, Emitter emit) async { emit(GarageDoorLoadingState()); try { var response = await DevicesAPI.getDeviceStatus(GDId); @@ -77,8 +76,8 @@ class GarageDoorBloc extends Bloc { } } - void _toggleClosingReminder(ToggleClosingReminderEvent event, - Emitter emit) async { + void _toggleClosingReminder( + ToggleClosingReminderEvent event, Emitter emit) async { emit(LoadingNewSate(doorSensor: deviceStatus)); try { closingReminder = event.isClosingReminderEnabled; @@ -96,8 +95,7 @@ class GarageDoorBloc extends Bloc { } } - void _toggleDoorAlarm( - ToggleDoorAlarmEvent event, Emitter emit) async { + void _toggleDoorAlarm(ToggleDoorAlarmEvent event, Emitter emit) async { emit(LoadingNewSate(doorSensor: deviceStatus)); try { doorAlarm = event.isDoorAlarmEnabled; @@ -115,8 +113,7 @@ class GarageDoorBloc extends Bloc { } } - DeviceReport recordGroups = - DeviceReport(startTime: '0', endTime: '0', data: []); + DeviceReport recordGroups = DeviceReport(startTime: '0', endTime: '0', data: []); Future fetchLogsForLastMonth( ReportLogsInitial event, Emitter emit) async { @@ -144,16 +141,14 @@ class GarageDoorBloc extends Bloc { _listenToChanges() { try { - DatabaseReference ref = - FirebaseDatabase.instance.ref('device-status/$GDId'); + DatabaseReference ref = FirebaseDatabase.instance.ref('device-status/$GDId'); Stream stream = ref.onValue; stream.listen((DatabaseEvent event) async { if (_timer != null) { await Future.delayed(const Duration(seconds: 2)); } - Map usersMap = - event.snapshot.value as Map; + Map usersMap = event.snapshot.value as Map; List statusList = []; usersMap['status'].forEach((element) { statusList.add(StatusModel(code: element['code'], value: true)); @@ -227,8 +222,7 @@ class GarageDoorBloc extends Bloc { deviceId: GDId, ); List jsonData = response; - listSchedule = - jsonData.map((item) => ScheduleModel.fromJson(item)).toList(); + listSchedule = jsonData.map((item) => ScheduleModel.fromJson(item)).toList(); } on DioException catch (e) { final errorData = e.response!.data; String errorMessage = errorData['message']; @@ -238,13 +232,12 @@ class GarageDoorBloc extends Bloc { int? getTimeStampWithoutSeconds(DateTime? dateTime) { if (dateTime == null) return null; - DateTime dateTimeWithoutSeconds = DateTime(dateTime.year, dateTime.month, - dateTime.day, dateTime.hour, dateTime.minute); + DateTime dateTimeWithoutSeconds = + DateTime(dateTime.year, dateTime.month, dateTime.day, dateTime.hour, dateTime.minute); return dateTimeWithoutSeconds.millisecondsSinceEpoch ~/ 1000; } - Future toggleChange( - ToggleScheduleEvent event, Emitter emit) async { + Future toggleChange(ToggleScheduleEvent event, Emitter emit) async { try { emit(GarageDoorLoadingState()); final response = await DevicesAPI.changeSchedule( @@ -262,8 +255,7 @@ class GarageDoorBloc extends Bloc { } } - Future deleteSchedule( - DeleteScheduleEvent event, Emitter emit) async { + Future deleteSchedule(DeleteScheduleEvent event, Emitter emit) async { try { emit(GarageDoorLoadingState()); final response = await DevicesAPI.deleteSchedule( @@ -282,15 +274,13 @@ class GarageDoorBloc extends Bloc { } } - void toggleSelectedIndex( - ToggleSelectedEvent event, Emitter emit) { + void toggleSelectedIndex(ToggleSelectedEvent event, Emitter emit) { emit(GarageDoorLoadingState()); selectedTabIndex = event.index; emit(ChangeSlidingSegmentState(value: selectedTabIndex)); } - void toggleCreateSchedule( - ToggleCreateScheduleEvent event, Emitter emit) { + void toggleCreateSchedule(ToggleCreateScheduleEvent event, Emitter emit) { emit(GarageDoorLoadingState()); createSchedule = !createSchedule; selectedDays.clear(); @@ -307,16 +297,13 @@ class GarageDoorBloc extends Bloc { int secondSelected = 0; bool toggleDoor = false; - Future selectSeconds( - SelectSecondsEvent event, Emitter emit) async { + Future selectSeconds(SelectSecondsEvent event, Emitter emit) async { try { emit(GarageDoorLoadingState()); secondSelected = event.seconds; - final response = await DevicesAPI.controlDevice( - DeviceControlModel( - deviceId: GDId, code: 'tr_timecon', value: secondSelected), - GDId); + await DevicesAPI.controlDevice( + DeviceControlModel(deviceId: GDId, code: 'tr_timecon', value: secondSelected), GDId); emit(UpdateState(garageSensor: deviceStatus)); } on DioException catch (e) { final errorData = e.response!.data; @@ -325,16 +312,13 @@ class GarageDoorBloc extends Bloc { } } - openCloseGarageDoor( - ToggleDoorEvent event, Emitter emit) async { + openCloseGarageDoor(ToggleDoorEvent event, Emitter emit) async { emit(GarageDoorLoadingState()); try { toggleDoor = !event.toggle; - final response = await DevicesAPI.controlDevice( - DeviceControlModel( - deviceId: GDId, code: 'switch_1', value: toggleDoor), - GDId); - add(GarageDoorInitial()); + await DevicesAPI.controlDevice( + DeviceControlModel(deviceId: GDId, code: 'switch_1', value: toggleDoor), GDId); + add(const GarageDoorInitial()); emit(UpdateState(garageSensor: deviceStatus)); } on DioException catch (e) { final errorData = e.response!.data; @@ -343,21 +327,18 @@ class GarageDoorBloc extends Bloc { } } - void _setCounterValue( - SetCounterValue event, Emitter emit) async { + void _setCounterValue(SetCounterValue event, Emitter emit) async { emit(LoadingNewSate(doorSensor: deviceStatus)); int seconds = 0; try { seconds = event.duration.inSeconds; final response = await DevicesAPI.controlDevice( - DeviceControlModel( - deviceId: GDId, code: 'countdown_1', value: seconds), - GDId); + DeviceControlModel(deviceId: GDId, code: 'countdown_1', value: seconds), GDId); if (response['success'] ?? false) { deviceStatus.countdown1 = seconds; } else { - emit(GarageDoorFailedState(errorMessage: 'Something went wrong')); + emit(const GarageDoorFailedState(errorMessage: 'Something went wrong')); return; } } catch (e) { @@ -372,8 +353,7 @@ class GarageDoorBloc extends Bloc { } } - void _getCounterValue( - GetCounterEvent event, Emitter emit) async { + void _getCounterValue(GetCounterEvent event, Emitter emit) async { emit(LoadingInitialState()); try { var response = await DevicesAPI.getDeviceStatus(GDId); diff --git a/lib/features/devices/bloc/one_touch_bloc/one_touch_bloc.dart b/lib/features/devices/bloc/one_touch_bloc/one_touch_bloc.dart index 3d6512f..4b64206 100644 --- a/lib/features/devices/bloc/one_touch_bloc/one_touch_bloc.dart +++ b/lib/features/devices/bloc/one_touch_bloc/one_touch_bloc.dart @@ -29,8 +29,7 @@ class OneTouchBloc extends Bloc { bool oneTouchGroup = false; List devicesList = []; - OneTouchBloc({required this.oneTouchId, required this.switchCode}) - : super(InitialState()) { + OneTouchBloc({required this.oneTouchId, required this.switchCode}) : super(InitialState()) { on(_fetchOneTouchStatus); on(_oneTouchUpdated); on(_changeFirstSwitch); @@ -53,8 +52,7 @@ class OneTouchBloc extends Bloc { on(_changeStatus); } - void _fetchOneTouchStatus( - InitialEvent event, Emitter emit) async { + void _fetchOneTouchStatus(InitialEvent event, Emitter emit) async { emit(LoadingInitialState()); try { var response = await DevicesAPI.getDeviceStatus(oneTouchId); @@ -73,21 +71,18 @@ class OneTouchBloc extends Bloc { _listenToChanges() { try { - DatabaseReference ref = - FirebaseDatabase.instance.ref('device-status/$oneTouchId'); + DatabaseReference ref = FirebaseDatabase.instance.ref('device-status/$oneTouchId'); Stream stream = ref.onValue; stream.listen((DatabaseEvent event) async { if (_timer != null) { await Future.delayed(const Duration(seconds: 2)); } - Map usersMap = - event.snapshot.value as Map; + Map usersMap = event.snapshot.value as Map; List statusList = []; usersMap['status'].forEach((element) { - statusList - .add(StatusModel(code: element['code'], value: element['value'])); + statusList.add(StatusModel(code: element['code'], value: element['value'])); }); deviceStatus = OneTouchModel.fromJson(statusList); @@ -102,8 +97,7 @@ class OneTouchBloc extends Bloc { emit(UpdateState(oneTouchModel: deviceStatus)); } - void _changeFirstSwitch( - ChangeFirstSwitchStatusEvent event, Emitter emit) async { + void _changeFirstSwitch(ChangeFirstSwitchStatusEvent event, Emitter emit) async { emit(LoadingNewSate(oneTouchModel: deviceStatus)); try { deviceStatus.firstSwitch = !event.value; @@ -128,20 +122,17 @@ class OneTouchBloc extends Bloc { } } - void _changeSliding( - ChangeSlidingSegment event, Emitter emit) async { + void _changeSliding(ChangeSlidingSegment event, Emitter emit) async { emit(ChangeSlidingSegmentState(value: event.value)); } - void _setCounterValue( - SetCounterValue event, Emitter emit) async { + void _setCounterValue(SetCounterValue event, Emitter emit) async { emit(LoadingNewSate(oneTouchModel: deviceStatus)); int seconds = 0; try { seconds = event.duration.inSeconds; final response = await DevicesAPI.controlDevice( - DeviceControlModel( - deviceId: oneTouchId, code: event.deviceCode, value: seconds), + DeviceControlModel(deviceId: oneTouchId, code: event.deviceCode, value: seconds), oneTouchId); if (response['success'] ?? false) { @@ -164,8 +155,7 @@ class OneTouchBloc extends Bloc { } } - void _getCounterValue( - GetCounterEvent event, Emitter emit) async { + void _getCounterValue(GetCounterEvent event, Emitter emit) async { emit(LoadingInitialState()); try { var response = await DevicesAPI.getDeviceStatus(oneTouchId); @@ -254,8 +244,7 @@ class OneTouchBloc extends Bloc { deviceId: oneTouchId, ); List jsonData = response; - listSchedule = - jsonData.map((item) => ScheduleModel.fromJson(item)).toList(); + listSchedule = jsonData.map((item) => ScheduleModel.fromJson(item)).toList(); emit(InitialState()); } on DioException catch (e) { final errorData = e.response!.data; @@ -266,13 +255,12 @@ class OneTouchBloc extends Bloc { int? getTimeStampWithoutSeconds(DateTime? dateTime) { if (dateTime == null) return null; - DateTime dateTimeWithoutSeconds = DateTime(dateTime.year, dateTime.month, - dateTime.day, dateTime.hour, dateTime.minute); + DateTime dateTimeWithoutSeconds = + DateTime(dateTime.year, dateTime.month, dateTime.day, dateTime.hour, dateTime.minute); return dateTimeWithoutSeconds.millisecondsSinceEpoch ~/ 1000; } - Future toggleChange( - ToggleScheduleEvent event, Emitter emit) async { + Future toggleChange(ToggleScheduleEvent event, Emitter emit) async { try { emit(LoadingInitialState()); final response = await DevicesAPI.changeSchedule( @@ -291,8 +279,7 @@ class OneTouchBloc extends Bloc { } } - Future deleteSchedule( - DeleteScheduleEvent event, Emitter emit) async { + Future deleteSchedule(DeleteScheduleEvent event, Emitter emit) async { try { emit(LoadingInitialState()); final response = await DevicesAPI.deleteSchedule( @@ -312,8 +299,7 @@ class OneTouchBloc extends Bloc { } } - void toggleCreateSchedule( - ToggleCreateScheduleEvent event, Emitter emit) { + void toggleCreateSchedule(ToggleCreateScheduleEvent event, Emitter emit) { emit(LoadingInitialState()); createSchedule = !createSchedule; selectedDays.clear(); @@ -342,8 +328,7 @@ class OneTouchBloc extends Bloc { int selectedTabIndex = 0; - void toggleSelectedIndex( - ToggleSelectedEvent event, Emitter emit) { + void toggleSelectedIndex(ToggleSelectedEvent event, Emitter emit) { emit(LoadingInitialState()); selectedTabIndex = event.index; emit(ChangeSlidingSegmentState(value: selectedTabIndex)); @@ -352,8 +337,7 @@ class OneTouchBloc extends Bloc { List groupOneTouchList = []; bool allSwitchesOn = true; - void _fetchOneTouchWizardStatus( - InitialWizardEvent event, Emitter emit) async { + void _fetchOneTouchWizardStatus(InitialWizardEvent event, Emitter emit) async { emit(LoadingInitialState()); try { devicesList = []; @@ -363,8 +347,7 @@ class OneTouchBloc extends Bloc { HomeCubit.getInstance().selectedSpace?.id ?? '', '1GT'); for (int i = 0; i < devicesList.length; i++) { - var response = - await DevicesAPI.getDeviceStatus(devicesList[i].uuid ?? ''); + var response = await DevicesAPI.getDeviceStatus(devicesList[i].uuid ?? ''); List statusModelList = []; for (var status in response['status']) { statusModelList.add(StatusModel.fromJson(status)); @@ -385,16 +368,15 @@ class OneTouchBloc extends Bloc { return true; }); } - emit(UpdateGroupState( - oneTouchList: groupOneTouchList, allSwitches: allSwitchesOn)); + emit(UpdateGroupState(oneTouchList: groupOneTouchList, allSwitches: allSwitchesOn)); } catch (e) { emit(FailedState(error: e.toString())); return; } } - void _changeFirstWizardSwitch(ChangeFirstWizardSwitchStatusEvent event, - Emitter emit) async { + void _changeFirstWizardSwitch( + ChangeFirstWizardSwitchStatusEvent event, Emitter emit) async { emit(LoadingNewSate(oneTouchModel: deviceStatus)); try { bool allSwitchesValue = true; @@ -412,8 +394,7 @@ class OneTouchBloc extends Bloc { value: !event.value, ); - emit(UpdateGroupState( - oneTouchList: groupOneTouchList, allSwitches: allSwitchesValue)); + emit(UpdateGroupState(oneTouchList: groupOneTouchList, allSwitches: allSwitchesValue)); if (!response['success']) { add(InitialEvent(groupScreen: oneTouchGroup)); } @@ -431,12 +412,10 @@ class OneTouchBloc extends Bloc { } // Emit the state with updated values - emit( - UpdateGroupState(oneTouchList: groupOneTouchList, allSwitches: true)); + emit(UpdateGroupState(oneTouchList: groupOneTouchList, allSwitches: true)); // Get a list of all device IDs - List allDeviceIds = - groupOneTouchList.map((device) => device.deviceId).toList(); + List allDeviceIds = groupOneTouchList.map((device) => device.deviceId).toList(); // First call for switch_1 final response1 = await DevicesAPI.deviceBatchController( @@ -473,12 +452,10 @@ class OneTouchBloc extends Bloc { } // Emit the state with updated values - emit(UpdateGroupState( - oneTouchList: groupOneTouchList, allSwitches: false)); + emit(UpdateGroupState(oneTouchList: groupOneTouchList, allSwitches: false)); // Get a list of all device IDs - List allDeviceIds = - groupOneTouchList.map((device) => device.deviceId).toList(); + List allDeviceIds = groupOneTouchList.map((device) => device.deviceId).toList(); // First call for switch_1 final response1 = await DevicesAPI.deviceBatchController( @@ -508,40 +485,38 @@ class OneTouchBloc extends Bloc { String statusSelected = ''; String optionSelected = ''; - Future _changeStatus( - ChangeStatusEvent event, Emitter emit) async { - try { + Future _changeStatus(ChangeStatusEvent event, Emitter emit) async { + try { emit(LoadingInitialState()); - final Map> controlMap = { - "relay_status": { - 'Power On': 'power_on', - 'Power Off': 'power_off', - 'Restart Memory': 'last', - }, - "light_mode": { - 'Off': 'none', - 'On/Off Status': 'relay', - 'Switch Position': 'pos', - }, - "relay_status_1": { - 'Power On': 'power_on', - 'Power Off': 'power_off', - 'Restart Memory': 'last', - }, - }; + final Map> controlMap = { + "relay_status": { + 'Power On': 'power_on', + 'Power Off': 'power_off', + 'Restart Memory': 'last', + }, + "light_mode": { + 'Off': 'none', + 'On/Off Status': 'relay', + 'Switch Position': 'pos', + }, + "relay_status_1": { + 'Power On': 'power_on', + 'Power Off': 'power_off', + 'Restart Memory': 'last', + }, + }; - final selectedControl = controlMap[optionSelected]?[statusSelected]; - if (selectedControl != null) { - await DevicesAPI.controlDevice( - DeviceControlModel( - deviceId: oneTouchId, code: optionSelected, value: selectedControl), - oneTouchId, - ); - } else { - print('Invalid statusSelected or optionSelected'); - } - } on DioException catch (e) { + final selectedControl = controlMap[optionSelected]?[statusSelected]; + if (selectedControl != null) { + await DevicesAPI.controlDevice( + DeviceControlModel(deviceId: oneTouchId, code: optionSelected, value: selectedControl), + oneTouchId, + ); + } else { + print('Invalid statusSelected or optionSelected'); + } + } on DioException catch (e) { final errorData = e.response!.data; String errorMessage = errorData['message']; emit(FailedState(error: errorMessage.toString())); 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 da8a97e..d4a59ea 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 @@ -1,7 +1,6 @@ import 'dart:async'; import 'package:dio/dio.dart'; import 'package:firebase_database/firebase_database.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart'; import 'package:syncrow_app/features/devices/bloc/three_touch_bloc/three_touch_event.dart'; @@ -39,8 +38,7 @@ class ThreeTouchBloc extends Bloc { List groupThreeTouchList = []; bool allSwitchesOn = true; - ThreeTouchBloc({required this.threeTouchId, required this.switchCode}) - : super(InitialState()) { + ThreeTouchBloc({required this.threeTouchId, required this.switchCode}) : super(InitialState()) { on(_fetchThreeTouchStatus); on(_threeTouchUpdated); on(_changeFirstSwitch); @@ -67,8 +65,7 @@ class ThreeTouchBloc extends Bloc { on(_changeStatus); } - void _fetchThreeTouchStatus( - InitialEvent event, Emitter emit) async { + void _fetchThreeTouchStatus(InitialEvent event, Emitter emit) async { emit(LoadingInitialState()); try { threeTouchGroup = event.groupScreen; @@ -80,8 +77,7 @@ class ThreeTouchBloc extends Bloc { HomeCubit.getInstance().selectedSpace?.id ?? '', '3GT'); for (int i = 0; i < devicesList.length; i++) { - var response = - await DevicesAPI.getDeviceStatus(devicesList[i].uuid ?? ''); + var response = await DevicesAPI.getDeviceStatus(devicesList[i].uuid ?? ''); List statusModelList = []; for (var status in response['status']) { statusModelList.add(StatusModel.fromJson(status)); @@ -98,16 +94,13 @@ class ThreeTouchBloc extends Bloc { if (groupThreeTouchList.isNotEmpty) { groupThreeTouchList.firstWhere((element) { - if (!element.firstSwitch || - !element.secondSwitch || - !element.thirdSwitch) { + if (!element.firstSwitch || !element.secondSwitch || !element.thirdSwitch) { allSwitchesOn = false; } return true; }); } - emit(UpdateGroupState( - threeTouchList: groupThreeTouchList, allSwitches: allSwitchesOn)); + emit(UpdateGroupState(threeTouchList: groupThreeTouchList, allSwitches: allSwitchesOn)); } else { var response = await DevicesAPI.getDeviceStatus(threeTouchId); List statusModelList = []; @@ -126,21 +119,18 @@ class ThreeTouchBloc extends Bloc { _listenToChanges() { try { - DatabaseReference ref = - FirebaseDatabase.instance.ref('device-status/$threeTouchId'); + DatabaseReference ref = FirebaseDatabase.instance.ref('device-status/$threeTouchId'); Stream stream = ref.onValue; stream.listen((DatabaseEvent event) async { if (_timer != null) { await Future.delayed(const Duration(seconds: 2)); } - Map usersMap = - event.snapshot.value as Map; + Map usersMap = event.snapshot.value as Map; List statusList = []; usersMap['status'].forEach((element) { - statusList - .add(StatusModel(code: element['code'], value: element['value'])); + statusList.add(StatusModel(code: element['code'], value: element['value'])); }); deviceStatus = ThreeTouchModel.fromJson(statusList); @@ -155,8 +145,7 @@ class ThreeTouchBloc extends Bloc { emit(UpdateState(threeTouchModel: deviceStatus)); } - void _changeFirstSwitch( - ChangeFirstSwitchStatusEvent event, Emitter emit) async { + void _changeFirstSwitch(ChangeFirstSwitchStatusEvent event, Emitter emit) async { emit(LoadingNewSate(threeTouchModel: deviceStatus)); try { if (threeTouchGroup) { @@ -165,15 +154,11 @@ class ThreeTouchBloc extends Bloc { if (element.deviceId == event.deviceId) { element.firstSwitch = !event.value; } - if (!element.firstSwitch || - !element.secondSwitch || - !element.thirdSwitch) { + if (!element.firstSwitch || !element.secondSwitch || !element.thirdSwitch) { allSwitchesValue = false; } }); - emit(UpdateGroupState( - threeTouchList: groupThreeTouchList, - allSwitches: allSwitchesValue)); + emit(UpdateGroupState(threeTouchList: groupThreeTouchList, allSwitches: allSwitchesValue)); } else { deviceStatus.firstSwitch = !event.value; emit(UpdateState(threeTouchModel: deviceStatus)); @@ -200,8 +185,8 @@ class ThreeTouchBloc extends Bloc { } } - void _changeSecondSwitch(ChangeSecondSwitchStatusEvent event, - Emitter emit) async { + void _changeSecondSwitch( + ChangeSecondSwitchStatusEvent event, Emitter emit) async { emit(LoadingNewSate(threeTouchModel: deviceStatus)); try { if (threeTouchGroup) { @@ -210,15 +195,11 @@ class ThreeTouchBloc extends Bloc { if (element.deviceId == event.deviceId) { element.secondSwitch = !event.value; } - if (!element.firstSwitch || - !element.secondSwitch || - !element.thirdSwitch) { + if (!element.firstSwitch || !element.secondSwitch || !element.thirdSwitch) { allSwitchesValue = false; } }); - emit(UpdateGroupState( - threeTouchList: groupThreeTouchList, - allSwitches: allSwitchesValue)); + emit(UpdateGroupState(threeTouchList: groupThreeTouchList, allSwitches: allSwitchesValue)); } else { deviceStatus.secondSwitch = !event.value; emit(UpdateState(threeTouchModel: deviceStatus)); @@ -244,8 +225,7 @@ class ThreeTouchBloc extends Bloc { } } - void _changeThirdSwitch( - ChangeThirdSwitchStatusEvent event, Emitter emit) async { + void _changeThirdSwitch(ChangeThirdSwitchStatusEvent event, Emitter emit) async { emit(LoadingNewSate(threeTouchModel: deviceStatus)); try { if (threeTouchGroup) { @@ -254,15 +234,11 @@ class ThreeTouchBloc extends Bloc { if (element.deviceId == event.deviceId) { element.thirdSwitch = !event.value; } - if (!element.firstSwitch || - !element.secondSwitch || - !element.thirdSwitch) { + if (!element.firstSwitch || !element.secondSwitch || !element.thirdSwitch) { allSwitchesValue = false; } }); - emit(UpdateGroupState( - threeTouchList: groupThreeTouchList, - allSwitches: allSwitchesValue)); + emit(UpdateGroupState(threeTouchList: groupThreeTouchList, allSwitches: allSwitchesValue)); } else { deviceStatus.thirdSwitch = !event.value; emit(UpdateState(threeTouchModel: deviceStatus)); @@ -301,21 +277,15 @@ class ThreeTouchBloc extends Bloc { final response = await Future.wait([ DevicesAPI.controlDevice( DeviceControlModel( - deviceId: threeTouchId, - code: 'switch_1', - value: deviceStatus.firstSwitch), + deviceId: threeTouchId, code: 'switch_1', value: deviceStatus.firstSwitch), threeTouchId), DevicesAPI.controlDevice( DeviceControlModel( - deviceId: threeTouchId, - code: 'switch_2', - value: deviceStatus.secondSwitch), + deviceId: threeTouchId, code: 'switch_2', value: deviceStatus.secondSwitch), threeTouchId), DevicesAPI.controlDevice( DeviceControlModel( - deviceId: threeTouchId, - code: 'switch_3', - value: deviceStatus.thirdSwitch), + deviceId: threeTouchId, code: 'switch_3', value: deviceStatus.thirdSwitch), threeTouchId), ]); @@ -341,21 +311,15 @@ class ThreeTouchBloc extends Bloc { final response = await Future.wait([ DevicesAPI.controlDevice( DeviceControlModel( - deviceId: threeTouchId, - code: 'switch_1', - value: deviceStatus.firstSwitch), + deviceId: threeTouchId, code: 'switch_1', value: deviceStatus.firstSwitch), threeTouchId), DevicesAPI.controlDevice( DeviceControlModel( - deviceId: threeTouchId, - code: 'switch_2', - value: deviceStatus.secondSwitch), + deviceId: threeTouchId, code: 'switch_2', value: deviceStatus.secondSwitch), threeTouchId), DevicesAPI.controlDevice( DeviceControlModel( - deviceId: threeTouchId, - code: 'switch_3', - value: deviceStatus.thirdSwitch), + deviceId: threeTouchId, code: 'switch_3', value: deviceStatus.thirdSwitch), threeTouchId), ]); @@ -377,28 +341,21 @@ class ThreeTouchBloc extends Bloc { groupThreeTouchList[i].secondSwitch = true; groupThreeTouchList[i].thirdSwitch = true; } - emit(UpdateGroupState( - threeTouchList: groupThreeTouchList, allSwitches: true)); + emit(UpdateGroupState(threeTouchList: groupThreeTouchList, allSwitches: true)); for (int i = 0; i < groupThreeTouchList.length; i++) { final response = await Future.wait([ DevicesAPI.controlDevice( DeviceControlModel( - deviceId: groupThreeTouchList[i].deviceId, - code: 'switch_1', - value: true), + deviceId: groupThreeTouchList[i].deviceId, code: 'switch_1', value: true), groupThreeTouchList[i].deviceId), DevicesAPI.controlDevice( DeviceControlModel( - deviceId: groupThreeTouchList[i].deviceId, - code: 'switch_2', - value: true), + deviceId: groupThreeTouchList[i].deviceId, code: 'switch_2', value: true), groupThreeTouchList[i].deviceId), DevicesAPI.controlDevice( DeviceControlModel( - deviceId: groupThreeTouchList[i].deviceId, - code: 'switch_3', - value: true), + deviceId: groupThreeTouchList[i].deviceId, code: 'switch_3', value: true), groupThreeTouchList[i].deviceId), ]); @@ -414,8 +371,7 @@ class ThreeTouchBloc extends Bloc { } } - void _groupAllOff( - GroupAllOffEvent event, Emitter emit) async { + void _groupAllOff(GroupAllOffEvent event, Emitter emit) async { emit(LoadingNewSate(threeTouchModel: deviceStatus)); try { for (int i = 0; i < groupThreeTouchList.length; i++) { @@ -423,28 +379,21 @@ class ThreeTouchBloc extends Bloc { groupThreeTouchList[i].secondSwitch = false; groupThreeTouchList[i].thirdSwitch = false; } - emit(UpdateGroupState( - threeTouchList: groupThreeTouchList, allSwitches: false)); + emit(UpdateGroupState(threeTouchList: groupThreeTouchList, allSwitches: false)); for (int i = 0; i < groupThreeTouchList.length; i++) { final response = await Future.wait([ DevicesAPI.controlDevice( DeviceControlModel( - deviceId: groupThreeTouchList[i].deviceId, - code: 'switch_1', - value: false), + deviceId: groupThreeTouchList[i].deviceId, code: 'switch_1', value: false), groupThreeTouchList[i].deviceId), DevicesAPI.controlDevice( DeviceControlModel( - deviceId: groupThreeTouchList[i].deviceId, - code: 'switch_2', - value: false), + deviceId: groupThreeTouchList[i].deviceId, code: 'switch_2', value: false), groupThreeTouchList[i].deviceId), DevicesAPI.controlDevice( DeviceControlModel( - deviceId: groupThreeTouchList[i].deviceId, - code: 'switch_3', - value: false), + deviceId: groupThreeTouchList[i].deviceId, code: 'switch_3', value: false), groupThreeTouchList[i].deviceId), ]); @@ -460,20 +409,17 @@ class ThreeTouchBloc extends Bloc { } } - void _changeSliding( - ChangeSlidingSegment event, Emitter emit) async { + void _changeSliding(ChangeSlidingSegment event, Emitter emit) async { emit(ChangeSlidingSegmentState(value: event.value)); } - void _setCounterValue( - SetCounterValue event, Emitter emit) async { + void _setCounterValue(SetCounterValue event, Emitter emit) async { emit(LoadingNewSate(threeTouchModel: deviceStatus)); int seconds = 0; try { seconds = event.duration.inSeconds; final response = await DevicesAPI.controlDevice( - DeviceControlModel( - deviceId: threeTouchId, code: event.deviceCode, value: seconds), + DeviceControlModel(deviceId: threeTouchId, code: event.deviceCode, value: seconds), threeTouchId); if (response['success'] ?? false) { @@ -500,8 +446,7 @@ class ThreeTouchBloc extends Bloc { } } - void _getCounterValue( - GetCounterEvent event, Emitter emit) async { + void _getCounterValue(GetCounterEvent event, Emitter emit) async { emit(LoadingInitialState()); try { var response = await DevicesAPI.getDeviceStatus(threeTouchId); @@ -611,8 +556,7 @@ class ThreeTouchBloc extends Bloc { deviceId: threeTouchId, ); List jsonData = response; - listSchedule = - jsonData.map((item) => ScheduleModel.fromJson(item)).toList(); + listSchedule = jsonData.map((item) => ScheduleModel.fromJson(item)).toList(); emit(InitialState()); } on DioException catch (e) { final errorData = e.response!.data; @@ -623,13 +567,12 @@ class ThreeTouchBloc extends Bloc { int? getTimeStampWithoutSeconds(DateTime? dateTime) { if (dateTime == null) return null; - DateTime dateTimeWithoutSeconds = DateTime(dateTime.year, dateTime.month, - dateTime.day, dateTime.hour, dateTime.minute); + DateTime dateTimeWithoutSeconds = + DateTime(dateTime.year, dateTime.month, dateTime.day, dateTime.hour, dateTime.minute); return dateTimeWithoutSeconds.millisecondsSinceEpoch ~/ 1000; } - Future toggleChange( - ToggleScheduleEvent event, Emitter emit) async { + Future toggleChange(ToggleScheduleEvent event, Emitter emit) async { try { emit(LoadingInitialState()); final response = await DevicesAPI.changeSchedule( @@ -648,8 +591,7 @@ class ThreeTouchBloc extends Bloc { } } - Future deleteSchedule( - DeleteScheduleEvent event, Emitter emit) async { + Future deleteSchedule(DeleteScheduleEvent event, Emitter emit) async { try { emit(LoadingInitialState()); final response = await DevicesAPI.deleteSchedule( @@ -669,15 +611,13 @@ class ThreeTouchBloc extends Bloc { } } - void toggleSelectedIndex( - ToggleSelectedEvent event, Emitter emit) { + void toggleSelectedIndex(ToggleSelectedEvent event, Emitter emit) { emit(LoadingInitialState()); selectedTabIndex = event.index; emit(ChangeSlidingSegmentState(value: selectedTabIndex)); } - void toggleCreateSchedule( - ToggleCreateScheduleEvent event, Emitter emit) { + void toggleCreateSchedule(ToggleCreateScheduleEvent event, Emitter emit) { emit(LoadingInitialState()); createSchedule = !createSchedule; selectedDays.clear(); @@ -695,8 +635,7 @@ class ThreeTouchBloc extends Bloc { String statusSelected = ''; String optionSelected = ''; - Future _changeStatus( - ChangeStatusEvent event, Emitter emit) async { + Future _changeStatus(ChangeStatusEvent event, Emitter emit) async { try { emit(LoadingInitialState()); final Map> controlMap = { @@ -730,10 +669,7 @@ class ThreeTouchBloc extends Bloc { final selectedControl = controlMap[optionSelected]?[statusSelected]; if (selectedControl != null) { await DevicesAPI.controlDevice( - DeviceControlModel( - deviceId: threeTouchId, - code: optionSelected, - value: selectedControl), + DeviceControlModel(deviceId: threeTouchId, code: optionSelected, value: selectedControl), threeTouchId, ); } else { diff --git a/lib/features/devices/view/widgets/curtains/curtain_view.dart b/lib/features/devices/view/widgets/curtains/curtain_view.dart index 9f89aa2..acfb141 100644 --- a/lib/features/devices/view/widgets/curtains/curtain_view.dart +++ b/lib/features/devices/view/widgets/curtains/curtain_view.dart @@ -36,11 +36,11 @@ class CurtainView extends StatelessWidget { child: Column( children: [ Stack( - alignment: Alignment.centerLeft, + alignment: Alignment.center, children: [ Container( - height: 340, - width: 365, + height: MediaQuery.sizeOf(context).height * 0.5, + width: MediaQuery.sizeOf(context).width, decoration: const BoxDecoration( image: DecorationImage( image: AssetImage( @@ -49,42 +49,85 @@ class CurtainView extends StatelessWidget { ), ), ), - Padding( - padding: const EdgeInsets.all(40), - child: AnimatedContainer( - duration: const Duration(milliseconds: 200), - curve: Curves.linear, - height: 310, - width: curtainWidth, - child: Stack( - children: List.generate( - 10, - (index) { - double spacing = curtainWidth / 9; - double leftMostPosition = index * spacing; - return AnimatedPositioned( - duration: const Duration(milliseconds: 200), - curve: Curves.linear, - left: leftMostPosition, - child: SizedBox( - height: 320, - width: 32, - child: SvgPicture.asset( - Assets.assetsIconsCurtainsIconVerticalBlade, - fit: BoxFit.fill, + Container( + padding: const EdgeInsets.only(top: 40), + child: Column( + children: [ + SvgPicture.asset( + Assets.assetsIconsCurtainsIconCurtainHolder, + width: MediaQuery.sizeOf(context).width * 0.8, + ), + SizedBox( + width: MediaQuery.sizeOf(context).width * 0.8, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + padding: const EdgeInsets.only(bottom: 40, left: 8), + child: AnimatedContainer( + duration: const Duration(milliseconds: 200), + curve: Curves.linear, + height: MediaQuery.sizeOf(context).height * 0.4, + width: curtainWidth / 2, + child: Stack( + children: List.generate( + 4, + (index) { + double spacing = curtainWidth / 8; + double leftMostPosition = index * spacing; + return AnimatedPositioned( + duration: const Duration(milliseconds: 200), + curve: Curves.linear, + left: leftMostPosition, + child: SizedBox( + height: MediaQuery.sizeOf(context).height * 0.37, + width: 32, + child: SvgPicture.asset( + Assets.assetsIconsCurtainsIconVerticalBlade, + fit: BoxFit.fill, + ), + ), + ); + }, + ), + ), ), ), - ); - }, + Container( + padding: const EdgeInsets.only(bottom: 40, right: 8), + child: AnimatedContainer( + duration: const Duration(milliseconds: 200), + curve: Curves.linear, + height: MediaQuery.sizeOf(context).height * 0.4, + width: curtainWidth / 2, + child: Stack( + children: List.generate( + 4, + (index) { + double spacing = curtainWidth / 8; + double rightMostPosition = index * spacing; + return AnimatedPositioned( + duration: const Duration(milliseconds: 200), + curve: Curves.linear, + right: rightMostPosition, + child: SizedBox( + height: MediaQuery.sizeOf(context).height * 0.37, + width: 32, + child: SvgPicture.asset( + Assets.rightVerticalBlade, + fit: BoxFit.fill, + ), + ), + ); + }, + ), + ), + ), + ), + ], + ), ), - ), - ), - ), - Positioned( - top: 27, - left: 43, - child: SvgPicture.asset( - Assets.assetsIconsCurtainsIconCurtainHolder, + ], ), ), ], 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 8fb6a9f..ae1fe0d 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 @@ -1,12 +1,10 @@ import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:syncrow_app/features/devices/bloc/garage_door_bloc/garage_door_bloc.dart'; import 'package:syncrow_app/features/devices/bloc/garage_door_bloc/garage_door_event.dart'; import 'package:syncrow_app/features/devices/bloc/garage_door_bloc/garage_door_state.dart'; import 'package:syncrow_app/features/devices/model/device_model.dart'; -import 'package:syncrow_app/features/devices/model/garage_door_model.dart'; import 'package:syncrow_app/features/devices/view/widgets/garage_door/garage_preferences_settings.dart'; import 'package:syncrow_app/features/devices/view/widgets/garage_door/garage_records_screen.dart'; import 'package:syncrow_app/features/devices/view/widgets/garage_door/schedule_garage_screen.dart'; @@ -26,34 +24,32 @@ class GarageDoorScreen extends StatelessWidget { return DefaultScaffold( title: 'Garage Door Opener', child: BlocProvider( - create: (context) => GarageDoorBloc(GDId: device?.uuid ?? '') - ..add(const GarageDoorInitial()), + create: (context) => + GarageDoorBloc(GDId: device?.uuid ?? '')..add(const GarageDoorInitial()), child: BlocBuilder( builder: (context, state) { final garageBloc = BlocProvider.of(context); - GarageDoorModel model = GarageDoorModel( - tr_timecon: 0, - countdown1: 0, - countdownAlarm: 0, - doorContactState: false, - doorControl1: '', - doorState1: '', - switch1: false, - voiceControl1: false, - batteryPercentage: 0, - ); + // GarageDoorModel model = GarageDoorModel( + // tr_timecon: 0, + // countdown1: 0, + // countdownAlarm: 0, + // doorContactState: false, + // doorControl1: '', + // doorState1: '', + // switch1: false, + // voiceControl1: false, + // batteryPercentage: 0, + // ); - if (state is LoadingNewSate) { - model = state.doorSensor; - } else if (state is UpdateState) { - model = state.garageSensor; - } + // if (state is LoadingNewSate) { + // model = state.doorSensor; + // } else if (state is UpdateState) { + // model = state.garageSensor; + // } return state is GarageDoorLoadingState ? const Center( - child: DefaultContainer( - width: 50, - height: 50, - child: CircularProgressIndicator()), + child: + DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()), ) : RefreshIndicator( onRefresh: () async { @@ -68,36 +64,30 @@ class GarageDoorScreen extends StatelessWidget { Expanded( flex: 4, child: InkWell( - overlayColor: WidgetStateProperty.all( - Colors.transparent), + overlayColor: WidgetStateProperty.all(Colors.transparent), onTap: () {}, child: Row( mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( decoration: BoxDecoration( - borderRadius: - BorderRadius.circular(890), + borderRadius: BorderRadius.circular(890), boxShadow: [ BoxShadow( - color: Colors.white - .withOpacity(0.1), + color: Colors.white.withOpacity(0.1), blurRadius: 24, offset: const Offset(-5, -5), blurStyle: BlurStyle.outer, ), BoxShadow( - color: Colors.black - .withOpacity(0.11), + color: Colors.black.withOpacity(0.11), blurRadius: 25, offset: const Offset(5, 5), blurStyle: BlurStyle.outer, ), BoxShadow( - color: Colors.black - .withOpacity(0.13), + color: Colors.black.withOpacity(0.13), blurRadius: 30, offset: const Offset(5, 5), blurStyle: BlurStyle.inner, @@ -106,14 +96,12 @@ class GarageDoorScreen extends StatelessWidget { ), child: InkWell( onTap: () { - garageBloc.add(ToggleDoorEvent( - toggle: - garageBloc.toggleDoor)); + garageBloc.add( + ToggleDoorEvent(toggle: garageBloc.toggleDoor)); }, child: GradientWidget( doorStatus: garageBloc.toggleDoor, - seconds: - garageBloc.secondSelected, + seconds: garageBloc.secondSelected, ), )), ], @@ -128,8 +116,7 @@ class GarageDoorScreen extends StatelessWidget { onTap: () { Navigator.of(context).push( MaterialPageRoute( - builder: (context) => - TimerScheduleScreen( + builder: (context) => TimerScheduleScreen( device: device!, switchCode: 'switch_1', deviceCode: 'countdown_1', @@ -137,16 +124,13 @@ class GarageDoorScreen extends StatelessWidget { ); }, child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - mainAxisAlignment: - MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ ConstrainedBox( - constraints: const BoxConstraints( - maxHeight: 46, maxWidth: 50), - child: SvgPicture.asset( - Assets.garageSchedule), + constraints: + const BoxConstraints(maxHeight: 46, maxWidth: 50), + child: SvgPicture.asset(Assets.garageSchedule), ), const SizedBox( height: 15, @@ -179,16 +163,13 @@ class GarageDoorScreen extends StatelessWidget { ); }, child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - mainAxisAlignment: - MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ ConstrainedBox( - constraints: const BoxConstraints( - maxHeight: 46, maxWidth: 50), - child: SvgPicture.asset( - Assets.garageCountdown), + constraints: + const BoxConstraints(maxHeight: 46, maxWidth: 50), + child: SvgPicture.asset(Assets.garageCountdown), ), const SizedBox( height: 15, @@ -220,21 +201,17 @@ class GarageDoorScreen extends StatelessWidget { Navigator.of(context).push( MaterialPageRoute( builder: (context) => - GarageRecordsScreen( - GDId: device!.uuid!)), + GarageRecordsScreen(GDId: device!.uuid!)), ); }, child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - mainAxisAlignment: - MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ ConstrainedBox( - constraints: const BoxConstraints( - maxHeight: 46, maxWidth: 50), - child: SvgPicture.asset( - Assets.doorRecordsIcon), + constraints: + const BoxConstraints(maxHeight: 46, maxWidth: 50), + child: SvgPicture.asset(Assets.doorRecordsIcon), ), const SizedBox( height: 15, @@ -260,21 +237,17 @@ class GarageDoorScreen extends StatelessWidget { Navigator.of(context).push( MaterialPageRoute( builder: (context) => - PreferencesPage( - GDId: device!.uuid!)), + PreferencesPage(GDId: device!.uuid!)), ); }, child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - mainAxisAlignment: - MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ ConstrainedBox( - constraints: const BoxConstraints( - maxHeight: 46, maxWidth: 50), - child: SvgPicture.asset( - Assets.garagePreferencesIcon), + constraints: + const BoxConstraints(maxHeight: 46, maxWidth: 50), + child: SvgPicture.asset(Assets.garagePreferencesIcon), ), const SizedBox( height: 15, @@ -316,8 +289,7 @@ class GradientWidget extends StatefulWidget { State createState() => _GradientWidgetState(); } -class _GradientWidgetState extends State - with SingleTickerProviderStateMixin { +class _GradientWidgetState extends State with SingleTickerProviderStateMixin { late ScrollController _scrollController; late AnimationController _animationController; late Animation _itemExtentAnimation; @@ -330,16 +302,15 @@ class _GradientWidgetState extends State vsync: this, duration: Duration(seconds: widget.seconds), ); - _itemExtentAnimation = Tween( - begin: widget.doorStatus ? 0 : 15, end: widget.doorStatus ? 15 : 0) - .animate( + _itemExtentAnimation = + Tween(begin: widget.doorStatus ? 0 : 15, end: widget.doorStatus ? 15 : 0).animate( CurvedAnimation( parent: _animationController, curve: Curves.easeInOut, ), )..addListener(() { - setState(() {}); - }); + setState(() {}); + }); WidgetsBinding.instance.addPostFrameCallback((_) { if (widget.doorStatus) { 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 b0bb6db..72ea127 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 @@ -18,8 +18,7 @@ class PreferencesPage extends StatelessWidget { return DefaultScaffold( title: 'Preferences', child: BlocProvider( - create: (context) => - GarageDoorBloc(GDId: GDId)..add(const GarageDoorInitial()), + create: (context) => GarageDoorBloc(GDId: GDId)..add(const GarageDoorInitial()), child: BlocBuilder( builder: (context, state) { final garageDoorBloc = BlocProvider.of(context); @@ -27,9 +26,7 @@ class PreferencesPage extends StatelessWidget { return state is GarageDoorLoadingState ? const Center( child: DefaultContainer( - width: 50, - height: 50, - child: CircularProgressIndicator()), + width: 50, height: 50, child: CircularProgressIndicator()), ) : Column( children: [ @@ -59,8 +56,7 @@ class PreferencesPage extends StatelessWidget { trailing: Container( width: 100, child: Row( - mainAxisAlignment: - MainAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.end, children: [ Container( height: 30, @@ -70,8 +66,7 @@ class PreferencesPage extends StatelessWidget { Transform.scale( scale: .8, child: CupertinoSwitch( - value: - garageDoorBloc.lowBattery, + value: garageDoorBloc.lowBattery, onChanged: (value) { // context // .read() @@ -108,15 +103,12 @@ class PreferencesPage extends StatelessWidget { builder: (context) { return SecondDialog( label2: 'Close', - initialSelectedLabel: garageDoorBloc - .secondSelected - .toString(), + initialSelectedLabel: garageDoorBloc.secondSelected.toString(), cancelTab: () { Navigator.of(context).pop(); }, confirmTab: (v) { - garageDoorBloc - .add(SelectSecondsEvent(seconds: v)); + garageDoorBloc.add(SelectSecondsEvent(seconds: v)); Navigator.of(context).pop(); }, title: 'Control', @@ -137,10 +129,8 @@ class PreferencesPage extends StatelessWidget { height: 90, width: 120, child: Row( - crossAxisAlignment: - CrossAxisAlignment.center, - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ BodyMedium( fontColor: ColorsManager.textGray, @@ -193,7 +183,7 @@ class SecondDialog extends StatefulWidget { } class _SecondDialogState extends State { - late String _selectedOption; + // late String _selectedOption; late int selectedSecond; @override @@ -201,7 +191,7 @@ class _SecondDialogState extends State { super.initState(); // Parse the initialSelectedLabel as an integer. Default to 10 if invalid or not provided. selectedSecond = int.tryParse(widget.initialSelectedLabel ?? '10') ?? 10; - _selectedOption = widget.initialSelectedLabel ?? ''; + // _selectedOption = widget.initialSelectedLabel ?? ''; } @override @@ -252,9 +242,7 @@ class _SecondDialogState extends State { child: BodyLarge( text: (index + 10).toString().padLeft(2, '0'), style: const TextStyle( - fontWeight: FontWeight.w400, - fontSize: 30, - color: Colors.blue), + fontWeight: FontWeight.w400, fontSize: 30, color: Colors.blue), ), ); }), diff --git a/lib/features/devices/view/widgets/garage_door/schedule_garage_screen.dart b/lib/features/devices/view/widgets/garage_door/schedule_garage_screen.dart index 19ce643..1a20804 100644 --- a/lib/features/devices/view/widgets/garage_door/schedule_garage_screen.dart +++ b/lib/features/devices/view/widgets/garage_door/schedule_garage_screen.dart @@ -18,10 +18,7 @@ class TimerScheduleScreen extends StatelessWidget { final String deviceCode; final String switchCode; const TimerScheduleScreen( - {required this.device, - required this.deviceCode, - required this.switchCode, - super.key}); + {required this.device, required this.deviceCode, required this.switchCode, super.key}); @override Widget build(BuildContext context) { @@ -31,22 +28,21 @@ class TimerScheduleScreen extends StatelessWidget { statusBarIconBrightness: Brightness.light, ), child: BlocProvider( - create: (context) => - GarageDoorBloc(GDId: device.uuid ?? '')..add(GetScheduleEvent()), + create: (context) => GarageDoorBloc(GDId: device.uuid ?? '')..add(GetScheduleEvent()), child: BlocBuilder( builder: (context, state) { final garageBloc = BlocProvider.of(context); - Duration duration = Duration.zero; - int countNum = 0; - if (state is UpdateTimerState) { - countNum = state.seconds; - } else if (state is TimerRunInProgress) { - countNum = state.remainingTime; - } else if (state is TimerRunComplete) { - countNum = 0; - } else if (state is LoadingNewSate) { - countNum = 0; - } + // Duration duration = Duration.zero; + // int countNum = 0; + // if (state is UpdateTimerState) { + // countNum = state.seconds; + // } else if (state is TimerRunInProgress) { + // countNum = state.remainingTime; + // } else if (state is TimerRunComplete) { + // countNum = 0; + // } else if (state is LoadingNewSate) { + // countNum = 0; + // } return PopScope( canPop: false, onPopInvoked: (didPop) { @@ -75,9 +71,7 @@ class TimerScheduleScreen extends StatelessWidget { child: const Text('Save')) : IconButton( onPressed: () { - garageBloc.add( - const ToggleCreateScheduleEvent( - index: 1)); + garageBloc.add(const ToggleCreateScheduleEvent(index: 1)); }, icon: const Icon(Icons.add), ) @@ -92,8 +86,7 @@ class TimerScheduleScreen extends StatelessWidget { decoration: const ShapeDecoration( color: ColorsManager.onPrimaryColor, shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.all(Radius.circular(30)), + borderRadius: BorderRadius.all(Radius.circular(30)), ), ), ), @@ -104,37 +97,25 @@ class TimerScheduleScreen extends StatelessWidget { onToggleChanged: (bool value) { garageBloc.toggleSchedule = value; }, - onDateTimeChanged: - (DateTime dateTime) { - garageBloc.selectedTime = - dateTime; + onDateTimeChanged: (DateTime dateTime) { + garageBloc.selectedTime = dateTime; }, days: garageBloc.days, - selectDays: - (List selectedDays) { - garageBloc.selectedDays = - selectedDays; + selectDays: (List selectedDays) { + garageBloc.selectedDays = selectedDays; }, ) : Padding( - padding: - const EdgeInsets.only(top: 10), + padding: const EdgeInsets.only(top: 10), child: ScheduleListView( - listSchedule: - garageBloc.listSchedule, + listSchedule: garageBloc.listSchedule, onDismissed: (scheduleId) { - garageBloc.listSchedule - .removeWhere((schedule) => - schedule.scheduleId == - scheduleId); - garageBloc.add( - DeleteScheduleEvent( - id: scheduleId)); + garageBloc.listSchedule.removeWhere((schedule) => + schedule.scheduleId == scheduleId); + garageBloc.add(DeleteScheduleEvent(id: scheduleId)); }, - onToggleSchedule: - (scheduleId, isEnabled) { - garageBloc - .add(ToggleScheduleEvent( + onToggleSchedule: (scheduleId, isEnabled) { + garageBloc.add(ToggleScheduleEvent( id: scheduleId, toggle: isEnabled, )); diff --git a/lib/features/devices/view/widgets/one_touch/one_touch_screen.dart b/lib/features/devices/view/widgets/one_touch/one_touch_screen.dart index 383e7d0..853469c 100644 --- a/lib/features/devices/view/widgets/one_touch/one_touch_screen.dart +++ b/lib/features/devices/view/widgets/one_touch/one_touch_screen.dart @@ -5,7 +5,6 @@ import 'package:syncrow_app/features/devices/bloc/one_touch_bloc/one_touch_bloc. import 'package:syncrow_app/features/devices/bloc/one_touch_bloc/one_touch_event.dart'; import 'package:syncrow_app/features/devices/bloc/one_touch_bloc/one_touch_state.dart'; import 'package:syncrow_app/features/devices/model/device_model.dart'; -import 'package:syncrow_app/features/devices/model/group_one_touch_model.dart'; import 'package:syncrow_app/features/devices/model/one_touch_model.dart'; import 'package:syncrow_app/features/devices/view/widgets/circular_button.dart'; import 'package:syncrow_app/features/devices/view/widgets/device_appbar.dart'; @@ -69,9 +68,9 @@ class OneTouchScreen extends StatelessWidget { bottom: Constants.bottomNavBarHeight, ), child: BlocProvider( - create: (context) => OneTouchBloc( - switchCode: 'switch_1', oneTouchId: device?.uuid ?? '') - ..add(const InitialEvent(groupScreen: false)), + create: (context) => + OneTouchBloc(switchCode: 'switch_1', oneTouchId: device?.uuid ?? '') + ..add(const InitialEvent(groupScreen: false)), child: BlocBuilder( builder: (context, state) { OneTouchModel oneTouchModel = OneTouchModel( @@ -81,30 +80,27 @@ class OneTouchScreen extends StatelessWidget { relay: status.off, relay_status_1: status.off); - List groupOneTouchModel = []; - bool allSwitchesOn = false; + // List groupOneTouchModel = []; + // bool allSwitchesOn = false; if (state is LoadingNewSate) { oneTouchModel = state.oneTouchModel; } else if (state is UpdateState) { oneTouchModel = state.oneTouchModel; - } else if (state is UpdateGroupState) { - groupOneTouchModel = state.oneTouchList; - allSwitchesOn = state.allSwitches; } + // else if (state is UpdateGroupState) { + // groupOneTouchModel = state.oneTouchList; + // allSwitchesOn = state.allSwitches; + // } return state is LoadingInitialState ? const Center( child: DefaultContainer( - width: 50, - height: 50, - child: CircularProgressIndicator()), + width: 50, height: 50, child: CircularProgressIndicator()), ) : RefreshIndicator( onRefresh: () async { - BlocProvider.of(context).add( - InitialEvent( - groupScreen: - device != null ? false : true)); + BlocProvider.of(context) + .add(InitialEvent(groupScreen: device != null ? false : true)); }, child: ListView( children: [ @@ -112,30 +108,23 @@ class OneTouchScreen extends StatelessWidget { height: MediaQuery.of(context).size.height, child: Column( mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.stretch, + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ const Expanded(child: SizedBox.shrink()), Expanded( child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceAround, - crossAxisAlignment: - CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.center, children: [ Column( children: [ GangSwitch( threeGangSwitch: device!, - value: - oneTouchModel.firstSwitch, + value: oneTouchModel.firstSwitch, action: () { - BlocProvider.of< - OneTouchBloc>( - context) - .add(ChangeFirstSwitchStatusEvent( - value: oneTouchModel - .firstSwitch)); + BlocProvider.of(context).add( + ChangeFirstSwitchStatusEvent( + value: oneTouchModel.firstSwitch)); }, ), const SizedBox(height: 20), @@ -143,8 +132,7 @@ class OneTouchScreen extends StatelessWidget { width: 70, child: BodySmall( text: " Entrance Light", - fontColor: ColorsManager - .textPrimaryColor, + fontColor: ColorsManager.textPrimaryColor, textAlign: TextAlign.center, ), ), @@ -155,10 +143,8 @@ class OneTouchScreen extends StatelessWidget { ), Center( child: Row( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, children: [ CircularButton( device: device, @@ -168,16 +154,13 @@ class OneTouchScreen extends StatelessWidget { Navigator.push( context, PageRouteBuilder( - pageBuilder: (context, - animation1, - animation2) => - TimerScheduleScreen( - switchCode: - 'switch_1', - device: device!, - deviceCode: - 'countdown_1', - ))); + pageBuilder: + (context, animation1, animation2) => + TimerScheduleScreen( + switchCode: 'switch_1', + device: device!, + deviceCode: 'countdown_1', + ))); }, ), const SizedBox( @@ -191,12 +174,11 @@ class OneTouchScreen extends StatelessWidget { Navigator.push( context, PageRouteBuilder( - pageBuilder: (context, - animation1, - animation2) => - OneTouchSetting( - device: device, - ))); + pageBuilder: + (context, animation1, animation2) => + OneTouchSetting( + device: device, + ))); }, ), ], diff --git a/lib/features/devices/view/widgets/three_touch/three_touch_setting.dart b/lib/features/devices/view/widgets/three_touch/three_touch_setting.dart index 21ef6b3..f61d0d9 100644 --- a/lib/features/devices/view/widgets/three_touch/three_touch_setting.dart +++ b/lib/features/devices/view/widgets/three_touch/three_touch_setting.dart @@ -4,7 +4,6 @@ import 'package:syncrow_app/features/devices/bloc/three_touch_bloc/three_touch_b import 'package:syncrow_app/features/devices/bloc/three_touch_bloc/three_touch_event.dart'; import 'package:syncrow_app/features/devices/bloc/three_touch_bloc/three_touch_state.dart'; import 'package:syncrow_app/features/devices/model/device_model.dart'; -import 'package:syncrow_app/features/devices/model/three_touch_model.dart'; import 'package:syncrow_app/features/devices/view/widgets/restart_status_dialog.dart'; import 'package:syncrow_app/features/shared_widgets/default_container.dart'; import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart'; @@ -23,41 +22,15 @@ class ThreeTouchSetting extends StatelessWidget { return DefaultScaffold( title: 'Setting', child: BlocProvider( - create: (context) => - ThreeTouchBloc(switchCode: '', threeTouchId: device?.uuid ?? '') - ..add(InitialEvent(groupScreen: false)), + create: (context) => ThreeTouchBloc(switchCode: '', threeTouchId: device?.uuid ?? '') + ..add(InitialEvent(groupScreen: false)), child: BlocBuilder( builder: (context, state) { final threeTouchBloc = BlocProvider.of(context); - ThreeTouchModel deviceStatus = ThreeTouchModel( - firstSwitch: false, - secondSwitch: false, - thirdSwitch: false, - firstCountDown: 0, - secondCountDown: 0, - thirdCountDown: 0, - light_mode: lightStatus.off, - relay: status.off, - relay_status_1: status.off, - relay_status_2: status.off, - relay_status_3: status.off, - ); - if (state is LoadingNewSate) { - deviceStatus = state.threeTouchModel; - } else if (state is UpdateState) { - deviceStatus = state.threeTouchModel; - } - // if (state is ChangeStateSetting) { - // // Navigator.of(context).pop(true); - // threeTouchBloc - // .add(InitialSettingDevises(id: device?.uuid ?? '')); - // } return state is LoadingInitialState ? const Center( child: DefaultContainer( - width: 50, - height: 50, - child: CircularProgressIndicator()), + width: 50, height: 50, child: CircularProgressIndicator()), ) : Column( children: [ @@ -70,22 +43,19 @@ class ThreeTouchSetting extends StatelessWidget { children: [ InkWell( onTap: () async { - threeTouchBloc.optionSelected = - 'relay_status'; + threeTouchBloc.optionSelected = 'relay_status'; final result = await showDialog( context: context, builder: (context) { return RestartStatusDialog( - initialSelectedLabel: threeTouchBloc - .deviceStatus.relay.value, + initialSelectedLabel: + threeTouchBloc.deviceStatus.relay.value, cancelTab: () { Navigator.of(context).pop(); }, confirmTab: () { - threeTouchBloc.add( - ChangeStatusEvent( - deviceId: device!.uuid!, - context: context)); + threeTouchBloc.add(ChangeStatusEvent( + deviceId: device!.uuid!, context: context)); Navigator.of(context).pop(true); }, title: 'Restart Status', @@ -93,34 +63,27 @@ class ThreeTouchSetting extends StatelessWidget { label2: 'Power On', label3: 'Restart Memory', onTapLabel1: (selected) { - threeTouchBloc.statusSelected = - selected; + threeTouchBloc.statusSelected = selected; }, onTapLabel2: (selected) { - threeTouchBloc.statusSelected = - selected; + threeTouchBloc.statusSelected = selected; }, onTapLabel3: (selected) { - threeTouchBloc.statusSelected = - selected; + threeTouchBloc.statusSelected = selected; }, ); }, ); if (result == true) { - Future.delayed(const Duration(seconds: 2), - () async { - threeTouchBloc.add( - InitialEvent(groupScreen: false)); + Future.delayed(const Duration(seconds: 2), () async { + threeTouchBloc.add(InitialEvent(groupScreen: false)); }); } }, child: Container( - padding: const EdgeInsets.only( - bottom: 10, top: 10), + padding: const EdgeInsets.only(bottom: 10, top: 10), child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const BodyLarge( fontSize: 15, @@ -131,10 +94,8 @@ class ThreeTouchSetting extends StatelessWidget { children: [ BodyMedium( fontSize: 13, - text: threeTouchBloc - .deviceStatus.relay.value, - fontColor: - ColorsManager.textGray, + text: threeTouchBloc.deviceStatus.relay.value, + fontColor: ColorsManager.textGray, ), const Icon( Icons.keyboard_arrow_right, @@ -149,26 +110,22 @@ class ThreeTouchSetting extends StatelessWidget { color: ColorsManager.graysColor, ), Padding( - padding: const EdgeInsets.only( - bottom: 10, top: 10), + padding: const EdgeInsets.only(bottom: 10, top: 10), child: InkWell( onTap: () async { - threeTouchBloc.optionSelected = - 'light_mode'; + threeTouchBloc.optionSelected = 'light_mode'; final result = await showDialog( context: context, builder: (context) { return RestartStatusDialog( - initialSelectedLabel: threeTouchBloc - .deviceStatus.light_mode.value, + initialSelectedLabel: + threeTouchBloc.deviceStatus.light_mode.value, cancelTab: () { Navigator.of(context).pop(); }, confirmTab: () { - threeTouchBloc.add( - ChangeStatusEvent( - deviceId: device!.uuid!, - context: context)); + threeTouchBloc.add(ChangeStatusEvent( + deviceId: device!.uuid!, context: context)); Navigator.of(context).pop(true); }, title: 'Indicator Status', @@ -176,33 +133,26 @@ class ThreeTouchSetting extends StatelessWidget { label2: 'On/Off Status', label3: 'Switch Position', onTapLabel1: (selected) { - threeTouchBloc.statusSelected = - selected; + threeTouchBloc.statusSelected = selected; }, onTapLabel2: (selected) { - threeTouchBloc.statusSelected = - selected; + threeTouchBloc.statusSelected = selected; }, onTapLabel3: (selected) { - threeTouchBloc.statusSelected = - selected; + threeTouchBloc.statusSelected = selected; }, ); }, ); if (result == true) { - Future.delayed( - const Duration(seconds: 2), - () async { - threeTouchBloc.add( - InitialEvent(groupScreen: false)); + Future.delayed(const Duration(seconds: 2), () async { + threeTouchBloc.add(InitialEvent(groupScreen: false)); }); } }, child: SizedBox( child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const BodyLarge( fontSize: 15, @@ -213,8 +163,7 @@ class ThreeTouchSetting extends StatelessWidget { children: [ BodyMedium( fontSize: 13, - text: threeTouchBloc.deviceStatus - .light_mode.value, + text: threeTouchBloc.deviceStatus.light_mode.value, fontColor: ColorsManager.textGray, ), const Icon( @@ -231,27 +180,22 @@ class ThreeTouchSetting extends StatelessWidget { color: ColorsManager.graysColor, ), Container( - padding: const EdgeInsets.only( - bottom: 10, top: 10), + padding: const EdgeInsets.only(bottom: 10, top: 10), child: InkWell( onTap: () async { - threeTouchBloc.optionSelected = - 'relay_status_1'; + threeTouchBloc.optionSelected = 'relay_status_1'; final result = await showDialog( context: context, builder: (context) { return RestartStatusDialog( initialSelectedLabel: - threeTouchBloc.deviceStatus - .relay_status_1.value, + threeTouchBloc.deviceStatus.relay_status_1.value, cancelTab: () { Navigator.of(context).pop(); }, confirmTab: () { - threeTouchBloc.add( - ChangeStatusEvent( - deviceId: device!.uuid!, - context: context)); + threeTouchBloc.add(ChangeStatusEvent( + deviceId: device!.uuid!, context: context)); Navigator.of(context).pop(true); }, title: 'Restart Status 1', @@ -259,33 +203,26 @@ class ThreeTouchSetting extends StatelessWidget { label2: 'Power On', label3: 'Restart Memory', onTapLabel1: (selected) { - threeTouchBloc.statusSelected = - selected; + threeTouchBloc.statusSelected = selected; }, onTapLabel2: (selected) { - threeTouchBloc.statusSelected = - selected; + threeTouchBloc.statusSelected = selected; }, onTapLabel3: (selected) { - threeTouchBloc.statusSelected = - selected; + threeTouchBloc.statusSelected = selected; }, ); }, ); if (result == true) { - Future.delayed( - const Duration(seconds: 2), - () async { - threeTouchBloc.add( - const InitialEvent( - groupScreen: false)); + Future.delayed(const Duration(seconds: 2), () async { + threeTouchBloc + .add(const InitialEvent(groupScreen: false)); }); } }, child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const BodyLarge( fontSize: 15, @@ -297,11 +234,8 @@ class ThreeTouchSetting extends StatelessWidget { BodyMedium( fontSize: 13, text: threeTouchBloc - .deviceStatus - .relay_status_1 - .value, - fontColor: - ColorsManager.textGray, + .deviceStatus.relay_status_1.value, + fontColor: ColorsManager.textGray, ), const Icon( Icons.keyboard_arrow_right, @@ -316,27 +250,22 @@ class ThreeTouchSetting extends StatelessWidget { color: ColorsManager.graysColor, ), Container( - padding: const EdgeInsets.only( - bottom: 10, top: 10), + padding: const EdgeInsets.only(bottom: 10, top: 10), child: InkWell( onTap: () async { - threeTouchBloc.optionSelected = - 'relay_status_2'; + threeTouchBloc.optionSelected = 'relay_status_2'; final result = await showDialog( context: context, builder: (context) { return RestartStatusDialog( initialSelectedLabel: - threeTouchBloc.deviceStatus - .relay_status_2.value, + threeTouchBloc.deviceStatus.relay_status_2.value, cancelTab: () { Navigator.of(context).pop(); }, confirmTab: () { - threeTouchBloc.add( - ChangeStatusEvent( - deviceId: device!.uuid!, - context: context)); + threeTouchBloc.add(ChangeStatusEvent( + deviceId: device!.uuid!, context: context)); Navigator.of(context).pop(true); }, title: 'Restart Status 2', @@ -344,36 +273,28 @@ class ThreeTouchSetting extends StatelessWidget { label2: 'Power On', label3: 'Restart Memory', onTapLabel1: (selected) { - threeTouchBloc.statusSelected = - selected; + threeTouchBloc.statusSelected = selected; }, onTapLabel2: (selected) { - threeTouchBloc.statusSelected = - selected; + threeTouchBloc.statusSelected = selected; }, onTapLabel3: (selected) { - threeTouchBloc.statusSelected = - selected; + threeTouchBloc.statusSelected = selected; }, ); }, ); if (result == true) { - Future.delayed( - const Duration(seconds: 2), - () async { - threeTouchBloc.add( - const InitialEvent( - groupScreen: false)); - threeTouchBloc.add( - const InitialEvent( - groupScreen: false)); + Future.delayed(const Duration(seconds: 2), () async { + threeTouchBloc + .add(const InitialEvent(groupScreen: false)); + threeTouchBloc + .add(const InitialEvent(groupScreen: false)); }); } }, child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const BodyLarge( fontSize: 15, @@ -385,11 +306,8 @@ class ThreeTouchSetting extends StatelessWidget { BodyMedium( fontSize: 13, text: threeTouchBloc - .deviceStatus - .relay_status_2 - .value, - fontColor: - ColorsManager.textGray, + .deviceStatus.relay_status_2.value, + fontColor: ColorsManager.textGray, ), const Icon( Icons.keyboard_arrow_right, @@ -404,27 +322,22 @@ class ThreeTouchSetting extends StatelessWidget { color: ColorsManager.graysColor, ), Container( - padding: const EdgeInsets.only( - bottom: 10, top: 10), + padding: const EdgeInsets.only(bottom: 10, top: 10), child: InkWell( onTap: () async { - threeTouchBloc.optionSelected = - 'relay_status_3'; + threeTouchBloc.optionSelected = 'relay_status_3'; final result = await showDialog( context: context, builder: (context) { return RestartStatusDialog( initialSelectedLabel: - threeTouchBloc.deviceStatus - .relay_status_3.value, + threeTouchBloc.deviceStatus.relay_status_3.value, cancelTab: () { Navigator.of(context).pop(); }, confirmTab: () { - threeTouchBloc.add( - ChangeStatusEvent( - deviceId: device!.uuid!, - context: context)); + threeTouchBloc.add(ChangeStatusEvent( + deviceId: device!.uuid!, context: context)); Navigator.of(context).pop(true); }, title: 'Restart Status 3', @@ -432,36 +345,28 @@ class ThreeTouchSetting extends StatelessWidget { label2: 'Power On', label3: 'Restart Memory', onTapLabel1: (selected) { - threeTouchBloc.statusSelected = - selected; + threeTouchBloc.statusSelected = selected; }, onTapLabel2: (selected) { - threeTouchBloc.statusSelected = - selected; + threeTouchBloc.statusSelected = selected; }, onTapLabel3: (selected) { - threeTouchBloc.statusSelected = - selected; + threeTouchBloc.statusSelected = selected; }, ); }, ); if (result == true) { - Future.delayed( - const Duration(seconds: 2), - () async { - threeTouchBloc.add( - const InitialEvent( - groupScreen: false)); - threeTouchBloc.add( - const InitialEvent( - groupScreen: false)); + Future.delayed(const Duration(seconds: 2), () async { + threeTouchBloc + .add(const InitialEvent(groupScreen: false)); + threeTouchBloc + .add(const InitialEvent(groupScreen: false)); }); } }, child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const BodyLarge( fontSize: 15, @@ -473,11 +378,8 @@ class ThreeTouchSetting extends StatelessWidget { BodyMedium( fontSize: 13, text: threeTouchBloc - .deviceStatus - .relay_status_3 - .value, - fontColor: - ColorsManager.textGray, + .deviceStatus.relay_status_3.value, + fontColor: ColorsManager.textGray, ), const Icon( Icons.keyboard_arrow_right, diff --git a/lib/features/devices/view/widgets/water_heater/wh_wizard.dart b/lib/features/devices/view/widgets/water_heater/wh_wizard.dart index c27fd55..c8ce572 100644 --- a/lib/features/devices/view/widgets/water_heater/wh_wizard.dart +++ b/lib/features/devices/view/widgets/water_heater/wh_wizard.dart @@ -19,28 +19,29 @@ class WHWizard extends StatelessWidget { List groupModel = []; return DefaultScaffold( + title: 'Water Heater', child: BlocProvider( - create: (context) => - WaterHeaterBloc(switchCode: '', whId: device?.uuid ?? '')..add(InitialWizardEvent()), - child: BlocBuilder( - builder: (context, state) { - bool allSwitchesOn = false; + create: (context) => + WaterHeaterBloc(switchCode: '', whId: device?.uuid ?? '')..add(InitialWizardEvent()), + child: BlocBuilder( + builder: (context, state) { + bool allSwitchesOn = false; - if (state is UpdateGroupState) { - groupModel = state.twoGangList; - allSwitchesOn = state.allSwitches; - } - return state is WHLoadingState - ? const Center( - child: - DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()), - ) - : WHList( - whList: groupModel, - allSwitches: allSwitchesOn, - ); - }, - ), - )); + if (state is UpdateGroupState) { + groupModel = state.twoGangList; + allSwitchesOn = state.allSwitches; + } + return state is WHLoadingState + ? const Center( + child: DefaultContainer( + width: 50, height: 50, child: CircularProgressIndicator()), + ) + : WHList( + whList: groupModel, + allSwitches: allSwitchesOn, + ); + }, + ), + )); } } diff --git a/lib/features/menu/view/menu_view.dart b/lib/features/menu/view/menu_view.dart index bba2896..aa1ae86 100644 --- a/lib/features/menu/view/menu_view.dart +++ b/lib/features/menu/view/menu_view.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart'; import 'package:syncrow_app/features/menu/bloc/menu_cubit.dart'; import 'package:syncrow_app/features/menu/view/widgets/menu_list.dart'; @@ -7,7 +8,6 @@ import 'package:syncrow_app/features/menu/view/widgets/profile/profile_tab.dart' import 'package:syncrow_app/features/shared_widgets/default_container.dart'; import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart'; import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart'; -import 'package:syncrow_app/services/locator.dart'; import 'package:syncrow_app/utils/context_extension.dart'; import 'package:syncrow_app/utils/resource_manager/constants.dart'; @@ -34,7 +34,7 @@ class MenuView extends StatelessWidget { const SizedBox( height: 15, ), - BodyMedium(text: serviceLocator.get()), + BodyMedium(text: dotenv.env['ENV_NAME'] ?? ''), const SizedBox( height: 15, ), diff --git a/lib/generated/assets.dart b/lib/generated/assets.dart index c94ff82..cb89189 100644 --- a/lib/generated/assets.dart +++ b/lib/generated/assets.dart @@ -3,8 +3,7 @@ class Assets { /// Assets for assetsFontsAftikaRegular /// assets/fonts/AftikaRegular.ttf - static const String assetsFontsAftikaRegular = - "assets/fonts/AftikaRegular.ttf"; + static const String assetsFontsAftikaRegular = "assets/fonts/AftikaRegular.ttf"; /// Assets for assetsIcons3GangSwitch /// assets/icons/3GangSwitch.svg @@ -20,98 +19,82 @@ class Assets { /// Assets for assetsIconsAutomatedClock /// assets/icons/automated_clock.svg - static const String assetsIconsAutomatedClock = - "assets/icons/automated_clock.svg"; + static const String assetsIconsAutomatedClock = "assets/icons/automated_clock.svg"; static const String acSwitchIcon = "assets/icons/ac_switch_ic.svg"; /// Assets for assetsIconsBatteryDmOffPerOffchargOfflowOffpmOffstChargeddmOff /// assets/icons/battery/dmOff/perOffchargOfflowOffpmOffstChargeddmOff.svg - static const String - assetsIconsBatteryDmOffPerOffchargOfflowOffpmOffstChargeddmOff = + static const String assetsIconsBatteryDmOffPerOffchargOfflowOffpmOffstChargeddmOff = "assets/icons/battery/dmOff/perOffchargOfflowOffpmOffstChargeddmOff.svg"; /// Assets for assetsIconsBatteryDmOffPerOffchargOfflowOffpmOffstDefaultdmOff /// assets/icons/battery/dmOff/perOffchargOfflowOffpmOffstDefaultdmOff.svg - static const String - assetsIconsBatteryDmOffPerOffchargOfflowOffpmOffstDefaultdmOff = + static const String assetsIconsBatteryDmOffPerOffchargOfflowOffpmOffstDefaultdmOff = "assets/icons/battery/dmOff/perOffchargOfflowOffpmOffstDefaultdmOff.svg"; /// Assets for assetsIconsBatteryDmOffPerOffchargOfflowOffpmOnstChargeddmOff /// assets/icons/battery/dmOff/perOffchargOfflowOffpmOnstChargeddmOff.svg - static const String - assetsIconsBatteryDmOffPerOffchargOfflowOffpmOnstChargeddmOff = + static const String assetsIconsBatteryDmOffPerOffchargOfflowOffpmOnstChargeddmOff = "assets/icons/battery/dmOff/perOffchargOfflowOffpmOnstChargeddmOff.svg"; /// Assets for assetsIconsBatteryDmOffPerOffchargOfflowOnpmOffstDefaultdmOff /// assets/icons/battery/dmOff/perOffchargOfflowOnpmOffstDefaultdmOff.svg - static const String - assetsIconsBatteryDmOffPerOffchargOfflowOnpmOffstDefaultdmOff = + static const String assetsIconsBatteryDmOffPerOffchargOfflowOnpmOffstDefaultdmOff = "assets/icons/battery/dmOff/perOffchargOfflowOnpmOffstDefaultdmOff.svg"; /// Assets for assetsIconsBatteryDmOffPerOffchargOfflowOnpmOnstDefaultdmOff /// assets/icons/battery/dmOff/perOffchargOfflowOnpmOnstDefaultdmOff.svg - static const String - assetsIconsBatteryDmOffPerOffchargOfflowOnpmOnstDefaultdmOff = + static const String assetsIconsBatteryDmOffPerOffchargOfflowOnpmOnstDefaultdmOff = "assets/icons/battery/dmOff/perOffchargOfflowOnpmOnstDefaultdmOff.svg"; /// Assets for assetsIconsBatteryDmOffPerOffchargOnlowOffpmOffstChargeddmOff /// assets/icons/battery/dmOff/perOffchargOnlowOffpmOffstChargeddmOff.svg - static const String - assetsIconsBatteryDmOffPerOffchargOnlowOffpmOffstChargeddmOff = + static const String assetsIconsBatteryDmOffPerOffchargOnlowOffpmOffstChargeddmOff = "assets/icons/battery/dmOff/perOffchargOnlowOffpmOffstChargeddmOff.svg"; /// Assets for assetsIconsBatteryDmOffPerOffchargOnlowOnpmOffstlowBatterydmOff /// assets/icons/battery/dmOff/perOffchargOnlowOnpmOffstlowBatterydmOff.svg - static const String - assetsIconsBatteryDmOffPerOffchargOnlowOnpmOffstlowBatterydmOff = + static const String assetsIconsBatteryDmOffPerOffchargOnlowOnpmOffstlowBatterydmOff = "assets/icons/battery/dmOff/perOffchargOnlowOnpmOffstlowBatterydmOff.svg"; /// Assets for assetsIconsBatteryDmOffPerOffchargOnlowOnpmOnstlowpmdmOff /// assets/icons/battery/dmOff/perOffchargOnlowOnpmOnstlowpmdmOff.svg - static const String - assetsIconsBatteryDmOffPerOffchargOnlowOnpmOnstlowpmdmOff = + static const String assetsIconsBatteryDmOffPerOffchargOnlowOnpmOnstlowpmdmOff = "assets/icons/battery/dmOff/perOffchargOnlowOnpmOnstlowpmdmOff.svg"; /// Assets for assetsIconsBatteryDmOffPerOnchargOfflowOffpmOffstChargeddmOff /// assets/icons/battery/dmOff/perOnchargOfflowOffpmOffstChargeddmOff.svg - static const String - assetsIconsBatteryDmOffPerOnchargOfflowOffpmOffstChargeddmOff = + static const String assetsIconsBatteryDmOffPerOnchargOfflowOffpmOffstChargeddmOff = "assets/icons/battery/dmOff/perOnchargOfflowOffpmOffstChargeddmOff.svg"; /// Assets for assetsIconsBatteryDmOffPerOnchargOfflowOffpmOffstDefaultdmOff /// assets/icons/battery/dmOff/perOnchargOfflowOffpmOffstDefaultdmOff.svg - static const String - assetsIconsBatteryDmOffPerOnchargOfflowOffpmOffstDefaultdmOff = + static const String assetsIconsBatteryDmOffPerOnchargOfflowOffpmOffstDefaultdmOff = "assets/icons/battery/dmOff/perOnchargOfflowOffpmOffstDefaultdmOff.svg"; /// Assets for assetsIconsBatteryDmOffPerOnchargOfflowOffpmOnstChargeddmOff /// assets/icons/battery/dmOff/perOnchargOfflowOffpmOnstChargeddmOff.svg - static const String - assetsIconsBatteryDmOffPerOnchargOfflowOffpmOnstChargeddmOff = + static const String assetsIconsBatteryDmOffPerOnchargOfflowOffpmOnstChargeddmOff = "assets/icons/battery/dmOff/perOnchargOfflowOffpmOnstChargeddmOff.svg"; /// Assets for assetsIconsBatteryDmOffPerOnchargOfflowOnpmOffstDefaultdmOff /// assets/icons/battery/dmOff/perOnchargOfflowOnpmOffstDefaultdmOff.svg - static const String - assetsIconsBatteryDmOffPerOnchargOfflowOnpmOffstDefaultdmOff = + static const String assetsIconsBatteryDmOffPerOnchargOfflowOnpmOffstDefaultdmOff = "assets/icons/battery/dmOff/perOnchargOfflowOnpmOffstDefaultdmOff.svg"; /// Assets for assetsIconsBatteryDmOffPerOnchargOfflowOnpmOnstDefaultdmOff /// assets/icons/battery/dmOff/perOnchargOfflowOnpmOnstDefaultdmOff.svg - static const String - assetsIconsBatteryDmOffPerOnchargOfflowOnpmOnstDefaultdmOff = + static const String assetsIconsBatteryDmOffPerOnchargOfflowOnpmOnstDefaultdmOff = "assets/icons/battery/dmOff/perOnchargOfflowOnpmOnstDefaultdmOff.svg"; /// Assets for assetsIconsBatteryDmOffPerOnchargOnlowOffpmOffstChargeddmOff /// assets/icons/battery/dmOff/perOnchargOnlowOffpmOffstChargeddmOff.svg - static const String - assetsIconsBatteryDmOffPerOnchargOnlowOffpmOffstChargeddmOff = + static const String assetsIconsBatteryDmOffPerOnchargOnlowOffpmOffstChargeddmOff = "assets/icons/battery/dmOff/perOnchargOnlowOffpmOffstChargeddmOff.svg"; /// Assets for assetsIconsBatteryDmOffPerOnchargOnlowOnpmOffstlowBatterydmOff /// assets/icons/battery/dmOff/perOnchargOnlowOnpmOffstlowBatterydmOff.svg - static const String - assetsIconsBatteryDmOffPerOnchargOnlowOnpmOffstlowBatterydmOff = + static const String assetsIconsBatteryDmOffPerOnchargOnlowOnpmOffstlowBatterydmOff = "assets/icons/battery/dmOff/perOnchargOnlowOnpmOffstlowBatterydmOff.svg"; /// Assets for assetsIconsBatteryDmOffPerOnchargOnlowOnpmOnstlowpmdmOff @@ -121,44 +104,37 @@ class Assets { /// Assets for assetsIconsBatteryDmOnPerOffchargOfflowOffpmOffstChargeddmOn /// assets/icons/battery/dmOn/perOffchargOfflowOffpmOffstChargeddmOn.svg - static const String - assetsIconsBatteryDmOnPerOffchargOfflowOffpmOffstChargeddmOn = + static const String assetsIconsBatteryDmOnPerOffchargOfflowOffpmOffstChargeddmOn = "assets/icons/battery/dmOn/perOffchargOfflowOffpmOffstChargeddmOn.svg"; /// Assets for assetsIconsBatteryDmOnPerOffchargOfflowOffpmOffstDefaultdmOn /// assets/icons/battery/dmOn/perOffchargOfflowOffpmOffstDefaultdmOn.svg - static const String - assetsIconsBatteryDmOnPerOffchargOfflowOffpmOffstDefaultdmOn = + static const String assetsIconsBatteryDmOnPerOffchargOfflowOffpmOffstDefaultdmOn = "assets/icons/battery/dmOn/perOffchargOfflowOffpmOffstDefaultdmOn.svg"; /// Assets for assetsIconsBatteryDmOnPerOffchargOfflowOffpmOnstChargeddmOn /// assets/icons/battery/dmOn/perOffchargOfflowOffpmOnstChargeddmOn.svg - static const String - assetsIconsBatteryDmOnPerOffchargOfflowOffpmOnstChargeddmOn = + static const String assetsIconsBatteryDmOnPerOffchargOfflowOffpmOnstChargeddmOn = "assets/icons/battery/dmOn/perOffchargOfflowOffpmOnstChargeddmOn.svg"; /// Assets for assetsIconsBatteryDmOnPerOffchargOfflowOnpmOffstDefaultdmOn /// assets/icons/battery/dmOn/perOffchargOfflowOnpmOffstDefaultdmOn.svg - static const String - assetsIconsBatteryDmOnPerOffchargOfflowOnpmOffstDefaultdmOn = + static const String assetsIconsBatteryDmOnPerOffchargOfflowOnpmOffstDefaultdmOn = "assets/icons/battery/dmOn/perOffchargOfflowOnpmOffstDefaultdmOn.svg"; /// Assets for assetsIconsBatteryDmOnPerOffchargOfflowOnpmOnstDefaultdmOn /// assets/icons/battery/dmOn/perOffchargOfflowOnpmOnstDefaultdmOn.svg - static const String - assetsIconsBatteryDmOnPerOffchargOfflowOnpmOnstDefaultdmOn = + static const String assetsIconsBatteryDmOnPerOffchargOfflowOnpmOnstDefaultdmOn = "assets/icons/battery/dmOn/perOffchargOfflowOnpmOnstDefaultdmOn.svg"; /// Assets for assetsIconsBatteryDmOnPerOffchargOnlowOffpmOffstChargeddmOn /// assets/icons/battery/dmOn/perOffchargOnlowOffpmOffstChargeddmOn.svg - static const String - assetsIconsBatteryDmOnPerOffchargOnlowOffpmOffstChargeddmOn = + static const String assetsIconsBatteryDmOnPerOffchargOnlowOffpmOffstChargeddmOn = "assets/icons/battery/dmOn/perOffchargOnlowOffpmOffstChargeddmOn.svg"; /// Assets for assetsIconsBatteryDmOnPerOffchargOnlowOnpmOffstlowBatterydmOn /// assets/icons/battery/dmOn/perOffchargOnlowOnpmOffstlowBatterydmOn.svg - static const String - assetsIconsBatteryDmOnPerOffchargOnlowOnpmOffstlowBatterydmOn = + static const String assetsIconsBatteryDmOnPerOffchargOnlowOnpmOffstlowBatterydmOn = "assets/icons/battery/dmOn/perOffchargOnlowOnpmOffstlowBatterydmOn.svg"; /// Assets for assetsIconsBatteryDmOnPerOffchargOnlowOnpmOnstlowpmdmOn @@ -168,44 +144,37 @@ class Assets { /// Assets for assetsIconsBatteryDmOnPerOnchargOfflowOffpmOffstChargeddmOn /// assets/icons/battery/dmOn/perOnchargOfflowOffpmOffstChargeddmOn.svg - static const String - assetsIconsBatteryDmOnPerOnchargOfflowOffpmOffstChargeddmOn = + static const String assetsIconsBatteryDmOnPerOnchargOfflowOffpmOffstChargeddmOn = "assets/icons/battery/dmOn/perOnchargOfflowOffpmOffstChargeddmOn.svg"; /// Assets for assetsIconsBatteryDmOnPerOnchargOfflowOffpmOffstDefaultdmOn /// assets/icons/battery/dmOn/perOnchargOfflowOffpmOffstDefaultdmOn.svg - static const String - assetsIconsBatteryDmOnPerOnchargOfflowOffpmOffstDefaultdmOn = + static const String assetsIconsBatteryDmOnPerOnchargOfflowOffpmOffstDefaultdmOn = "assets/icons/battery/dmOn/perOnchargOfflowOffpmOffstDefaultdmOn.svg"; /// Assets for assetsIconsBatteryDmOnPerOnchargOfflowOffpmOnstChargeddmOn /// assets/icons/battery/dmOn/perOnchargOfflowOffpmOnstChargeddmOn.svg - static const String - assetsIconsBatteryDmOnPerOnchargOfflowOffpmOnstChargeddmOn = + static const String assetsIconsBatteryDmOnPerOnchargOfflowOffpmOnstChargeddmOn = "assets/icons/battery/dmOn/perOnchargOfflowOffpmOnstChargeddmOn.svg"; /// Assets for assetsIconsBatteryDmOnPerOnchargOfflowOnpmOffstDefaultdmOn /// assets/icons/battery/dmOn/perOnchargOfflowOnpmOffstDefaultdmOn.svg - static const String - assetsIconsBatteryDmOnPerOnchargOfflowOnpmOffstDefaultdmOn = + static const String assetsIconsBatteryDmOnPerOnchargOfflowOnpmOffstDefaultdmOn = "assets/icons/battery/dmOn/perOnchargOfflowOnpmOffstDefaultdmOn.svg"; /// Assets for assetsIconsBatteryDmOnPerOnchargOfflowOnpmOnstDefaultdmOn /// assets/icons/battery/dmOn/perOnchargOfflowOnpmOnstDefaultdmOn.svg - static const String - assetsIconsBatteryDmOnPerOnchargOfflowOnpmOnstDefaultdmOn = + static const String assetsIconsBatteryDmOnPerOnchargOfflowOnpmOnstDefaultdmOn = "assets/icons/battery/dmOn/perOnchargOfflowOnpmOnstDefaultdmOn.svg"; /// Assets for assetsIconsBatteryDmOnPerOnchargOnlowOffpmOffstChargeddmOn /// assets/icons/battery/dmOn/perOnchargOnlowOffpmOffstChargeddmOn.svg - static const String - assetsIconsBatteryDmOnPerOnchargOnlowOffpmOffstChargeddmOn = + static const String assetsIconsBatteryDmOnPerOnchargOnlowOffpmOffstChargeddmOn = "assets/icons/battery/dmOn/perOnchargOnlowOffpmOffstChargeddmOn.svg"; /// Assets for assetsIconsBatteryDmOnPerOnchargOnlowOnpmOffstlowBatterydmOn /// assets/icons/battery/dmOn/perOnchargOnlowOnpmOffstlowBatterydmOn.svg - static const String - assetsIconsBatteryDmOnPerOnchargOnlowOnpmOffstlowBatterydmOn = + static const String assetsIconsBatteryDmOnPerOnchargOnlowOnpmOffstlowBatterydmOn = "assets/icons/battery/dmOn/perOnchargOnlowOnpmOffstlowBatterydmOn.svg"; /// Assets for assetsIconsBatteryDmOnPerOnchargOnlowOnpmOnstlowpmdmOn @@ -247,7 +216,9 @@ class Assets { /// Assets for assetsIconsCurtainsIconVerticalBlade /// assets/icons/curtainsIcon/verticalBlade.svg static const String assetsIconsCurtainsIconVerticalBlade = - "assets/icons/curtainsIcon/verticalBlade.svg"; + "assets/icons/curtainsIcon/left_vertical_blade.svg"; + + static const String rightVerticalBlade = "assets/icons/curtainsIcon/right_vertical_blade.svg"; /// Assets for assetsIconsDashboard /// assets/icons/dashboard.svg @@ -257,8 +228,7 @@ class Assets { /// Assets for assetsIconsDashboardFill /// assets/icons/dashboard-fill.svg - static const String assetsIconsDashboardFill = - "assets/icons/dashboard-fill.svg"; + static const String assetsIconsDashboardFill = "assets/icons/dashboard-fill.svg"; /// Assets for assetsIconsDevices /// assets/icons/Devices.svg @@ -274,8 +244,7 @@ class Assets { /// Assets for assetsIconsDoorLockLinkage /// assets/icons/DoorLockLinkage.svg - static const String assetsIconsDoorLockLinkage = - "assets/icons/DoorLockLinkage.svg"; + static const String assetsIconsDoorLockLinkage = "assets/icons/DoorLockLinkage.svg"; /// Assets for assetsIconsDoorLockLock /// assets/icons/DoorLockLock.svg @@ -283,18 +252,15 @@ class Assets { /// Assets for assetsIconsDoorLockMembers /// assets/icons/DoorLockMembers.svg - static const String assetsIconsDoorLockMembers = - "assets/icons/DoorLockMembers.svg"; + static const String assetsIconsDoorLockMembers = "assets/icons/DoorLockMembers.svg"; /// Assets for assetsIconsDoorLockPassword /// assets/icons/DoorLockPassword.svg - static const String assetsIconsDoorLockPassword = - "assets/icons/DoorLockPassword.svg"; + static const String assetsIconsDoorLockPassword = "assets/icons/DoorLockPassword.svg"; /// Assets for assetsIconsDoorLockRecords /// assets/icons/DoorLockRecords.svg - static const String assetsIconsDoorLockRecords = - "assets/icons/DoorLockRecords.svg"; + static const String assetsIconsDoorLockRecords = "assets/icons/DoorLockRecords.svg"; /// Assets for assetsIconsDoorlockAssetsBatteryIndicator /// assets/icons/doorlock-assets/BatteryIndicator.svg @@ -315,8 +281,7 @@ class Assets { /// assets/icons/doorlock-assets/lockIcon.svg static const String assetsIconsDoorlockAssetsLockIcon = "assets/icons/doorlock-assets/lockIcon.svg"; - static const String doorUnlockIcon = - "assets/icons/doorlock-assets/door_un_look_ic.svg"; + static const String doorUnlockIcon = "assets/icons/doorlock-assets/door_un_look_ic.svg"; /// Assets for assetsIconsDoorlockAssetsMembersManagement /// assets/icons/doorlock-assets/members-management.svg @@ -404,13 +369,11 @@ class Assets { /// Assets for assetsIconsLightSwitchOff /// assets/icons/lightSwitchOff.svg - static const String assetsIconsLightSwitchOff = - "assets/icons/lightSwitchOff.svg"; + static const String assetsIconsLightSwitchOff = "assets/icons/lightSwitchOff.svg"; /// Assets for assetsIconsLightSwitchOn /// assets/icons/lightSwitchOn.svg - static const String assetsIconsLightSwitchOn = - "assets/icons/lightSwitchOn.svg"; + static const String assetsIconsLightSwitchOn = "assets/icons/lightSwitchOn.svg"; /// Assets for assetsIconsLinkageIconsDoorLockAlarm /// assets/icons/linkageIcons/doorLockAlarm.svg @@ -419,8 +382,7 @@ class Assets { /// Assets for assetsIconsLinkTimeLimitedPasswordIcon /// assets/icons/timeLimitedPasswordIcon.svg - static const String timeLimitedPasswordIcon = - "assets/icons/timeLimitedPasswordIcon.svg"; + static const String timeLimitedPasswordIcon = "assets/icons/timeLimitedPasswordIcon.svg"; /// Assets for assetsIconsoneTimePassword /// assets/icons/oneTimePassword.svg @@ -428,8 +390,7 @@ class Assets { /// Assets for assetsIconsTimeLimitedPassword /// assets/icons/timeLimitedPassword.svg - static const String timeLimitedPassword = - "assets/icons/timeLimitedPassword.svg"; + static const String timeLimitedPassword = "assets/icons/timeLimitedPassword.svg"; /// Assets for assetsIconsNoValidPasswords /// assets/icons/noValidPasswords.svg @@ -598,13 +559,11 @@ class Assets { /// Assets for assetsIconsPresenceSensorAssetsParameterSettings /// assets/icons/presence-sensor-assets/space_type_icon.svg - static const String spaceTypeIcon = - "assets/icons/presence-sensor-assets/space_type_icon.svg"; + static const String spaceTypeIcon = "assets/icons/presence-sensor-assets/space_type_icon.svg"; /// Assets for assetsIconsPresenceSensorAssetsParameterSettings /// assets/icons/presence-sensor-assets/space_type_icon.svg - static const String sensitivityIcon = - "assets/icons/presence-sensor-assets/Sensitivity.svg"; + static const String sensitivityIcon = "assets/icons/presence-sensor-assets/Sensitivity.svg"; /// Assets for assetsIconsPresenceSensorAssetsParameterSettings /// assets/icons/presence-sensor-assets/maximum_distance.svg @@ -637,8 +596,7 @@ class Assets { /// Assets for assetsIconsRoutinesFill /// assets/icons/Routines-fill.svg - static const String assetsIconsRoutinesFill = - "assets/icons/Routines-fill.svg"; + static const String assetsIconsRoutinesFill = "assets/icons/Routines-fill.svg"; /// Assets for assetsIconsScan /// assets/icons/Scan.svg @@ -670,8 +628,7 @@ class Assets { /// Assets for assetsIconsSustainability /// assets/icons/sustainability.svg - static const String assetsIconsSustainability = - "assets/icons/sustainability.svg"; + static const String assetsIconsSustainability = "assets/icons/sustainability.svg"; /// Assets for assetsIconsUnlockingMethodsIconsFace /// assets/icons/unlockingMethodsIcons/face.svg @@ -767,8 +724,7 @@ class Assets { /// Assets for assetsImagesHorizintalBlade /// assets/images/HorizintalBlade.png - static const String assetsImagesHorizintalBlade = - "assets/images/HorizintalBlade.png"; + static const String assetsImagesHorizintalBlade = "assets/images/HorizintalBlade.png"; /// Assets for assetsImagesLogo /// assets/images/Logo.svg @@ -776,8 +732,7 @@ class Assets { /// Assets for assetsImagesLogoHorizontal /// assets/images/logo_horizontal.png - static const String assetsImagesLogoHorizontal = - "assets/images/logo_horizontal.png"; + static const String assetsImagesLogoHorizontal = "assets/images/logo_horizontal.png"; /// Assets for assetsImagesPause /// assets/images/Pause.png @@ -807,8 +762,7 @@ class Assets { /// assets/images/Window.png static const String assetsImagesWindow = "assets/images/Window.png"; - static const String assetsSensitivityFunction = - "assets/icons/functions_icons/sensitivity.svg"; + static const String assetsSensitivityFunction = "assets/icons/functions_icons/sensitivity.svg"; //assets/icons/functions_icons/sesitivity_operation_icon.svg static const String assetsSensitivityOperationIcon = @@ -816,73 +770,59 @@ class Assets { //assets/icons/functions_icons/ac_power.svg - static const String assetsAcPower = - "assets/icons/functions_icons/ac_power.svg"; + static const String assetsAcPower = "assets/icons/functions_icons/ac_power.svg"; //assets/icons/functions_icons/ac_power_off.svg - static const String assetsAcPowerOFF = - "assets/icons/functions_icons/ac_power_off.svg"; + static const String assetsAcPowerOFF = "assets/icons/functions_icons/ac_power_off.svg"; //assets/icons/functions_icons/child_lock.svg - static const String assetsChildLock = - "assets/icons/functions_icons/child_lock.svg"; + static const String assetsChildLock = "assets/icons/functions_icons/child_lock.svg"; //assets/icons/functions_icons/cooling.svg - static const String assetsFreezing = - "assets/icons/functions_icons/freezing.svg"; + static const String assetsFreezing = "assets/icons/functions_icons/freezing.svg"; //assets/icons/functions_icons/fan_speed.svg - static const String assetsFanSpeed = - "assets/icons/functions_icons/fan_speed.svg"; + static const String assetsFanSpeed = "assets/icons/functions_icons/fan_speed.svg"; //assets/icons/functions_icons/ac_cooling.svg - static const String assetsAcCooling = - "assets/icons/functions_icons/ac_cooling.svg"; + static const String assetsAcCooling = "assets/icons/functions_icons/ac_cooling.svg"; //assets/icons/functions_icons/ac_heating.svg - static const String assetsAcHeating = - "assets/icons/functions_icons/ac_heating.svg"; + static const String assetsAcHeating = "assets/icons/functions_icons/ac_heating.svg"; //assets/icons/functions_icons/celsius_degrees.svg - static const String assetsCelsiusDegrees = - "assets/icons/functions_icons/celsius_degrees.svg"; + static const String assetsCelsiusDegrees = "assets/icons/functions_icons/celsius_degrees.svg"; //assets/icons/functions_icons/tempreture.svg - static const String assetsTempreture = - "assets/icons/functions_icons/tempreture.svg"; + static const String assetsTempreture = "assets/icons/functions_icons/tempreture.svg"; //assets/icons/functions_icons/ac_fan_low.svg - static const String assetsAcFanLow = - "assets/icons/functions_icons/ac_fan_low.svg"; + static const String assetsAcFanLow = "assets/icons/functions_icons/ac_fan_low.svg"; //assets/icons/functions_icons/ac_fan_middle.svg - static const String assetsAcFanMiddle = - "assets/icons/functions_icons/ac_fan_middle.svg"; + static const String assetsAcFanMiddle = "assets/icons/functions_icons/ac_fan_middle.svg"; //assets/icons/functions_icons/ac_fan_high.svg - static const String assetsAcFanHigh = - "assets/icons/functions_icons/ac_fan_high.svg"; + static const String assetsAcFanHigh = "assets/icons/functions_icons/ac_fan_high.svg"; //assets/icons/functions_icons/ac_fan_auto.svg - static const String assetsAcFanAuto = - "assets/icons/functions_icons/ac_fan_auto.svg"; + static const String assetsAcFanAuto = "assets/icons/functions_icons/ac_fan_auto.svg"; //assets/icons/functions_icons/scene_child_lock.svg - static const String assetsSceneChildLock = - "assets/icons/functions_icons/scene_child_lock.svg"; + static const String assetsSceneChildLock = "assets/icons/functions_icons/scene_child_lock.svg"; //assets/icons/functions_icons/scene_child_unlock.svg @@ -891,18 +831,15 @@ class Assets { //assets/icons/functions_icons/scene_refresh.svg - static const String assetsSceneRefresh = - "assets/icons/functions_icons/scene_refresh.svg"; + static const String assetsSceneRefresh = "assets/icons/functions_icons/scene_refresh.svg"; //assets/icons/functions_icons/light_countdown.svg - static const String assetsLightCountdown = - "assets/icons/functions_icons/light_countdown.svg"; + static const String assetsLightCountdown = "assets/icons/functions_icons/light_countdown.svg"; //assets/icons/functions_icons/far_detection.svg - static const String assetsFarDetection = - "assets/icons/functions_icons/far_detection.svg"; + static const String assetsFarDetection = "assets/icons/functions_icons/far_detection.svg"; //assets/icons/functions_icons/far_detection_function.svg @@ -911,13 +848,11 @@ class Assets { //assets/icons/functions_icons/indicator.svg - static const String assetsIndicator = - "assets/icons/functions_icons/indicator.svg"; + static const String assetsIndicator = "assets/icons/functions_icons/indicator.svg"; //assets/icons/functions_icons/motion_detection.svg - static const String assetsMotionDetection = - "assets/icons/functions_icons/motion_detection.svg"; + static const String assetsMotionDetection = "assets/icons/functions_icons/motion_detection.svg"; //assets/icons/functions_icons/motionless_detection.svg @@ -926,18 +861,15 @@ class Assets { //assets/icons/functions_icons/nobody_time.svg - static const String assetsNobodyTime = - "assets/icons/functions_icons/nobody_time.svg"; + static const String assetsNobodyTime = "assets/icons/functions_icons/nobody_time.svg"; //assets/icons/functions_icons/factory_reset.svg - static const String assetsFactoryReset = - "assets/icons/functions_icons/factory_reset.svg"; + static const String assetsFactoryReset = "assets/icons/functions_icons/factory_reset.svg"; //assets/icons/functions_icons/master_state.svg - static const String assetsMasterState = - "assets/icons/functions_icons/master_state.svg"; + static const String assetsMasterState = "assets/icons/functions_icons/master_state.svg"; //assets/icons/functions_icons/switch_alarm_sound.svg @@ -946,8 +878,7 @@ class Assets { //assets/icons/functions_icons/reset_off.svg - static const String assetsResetOff = - "assets/icons/functions_icons/reset_off.svg"; + static const String assetsResetOff = "assets/icons/functions_icons/reset_off.svg"; //assets/icons/functions_icons/automation_functions/card_unlock.svg @@ -1021,8 +952,7 @@ class Assets { //assets/icons/functions_icons/automation_functions/motion.svg - static const String assetsMotion = - "assets/icons/functions_icons/automation_functions/motion.svg"; + static const String assetsMotion = "assets/icons/functions_icons/automation_functions/motion.svg"; //assets/icons/functions_icons/automation_functions/current_temp.svg @@ -1044,19 +974,15 @@ class Assets { static const String waterHeaterOn = "assets/icons/water_heater_on.svg"; static const String waterHeaterOff = "assets/icons/water_heater_off.svg"; - static const String scheduleCelenderIcon = - "assets/icons/schedule_celender_icon.svg"; - static const String scheduleCirculateIcon = - "assets/icons/schedule_circulate_icon.svg"; - static const String scheduleInchingIcon = - "assets/icons/schedule_Inching_icon.svg"; + static const String scheduleCelenderIcon = "assets/icons/schedule_celender_icon.svg"; + static const String scheduleCirculateIcon = "assets/icons/schedule_circulate_icon.svg"; + static const String scheduleInchingIcon = "assets/icons/schedule_Inching_icon.svg"; static const String scheduleTimeIcon = "assets/icons/schedule_time_icon.svg"; static const String waterHeaterIcon = "assets/icons/water_heater_icon.svg"; static const String doorOpen = "assets/icons/opened_door.svg"; static const String doorClose = "assets/icons/closed_door.svg"; - static const String doorNotificationSetting = - "assets/icons/door_notification_setting_icon.svg"; + static const String doorNotificationSetting = "assets/icons/door_notification_setting_icon.svg"; static const String doorRecordsIcon = "assets/icons/door_records_icon.svg"; static const String doorSensorIcon = "assets/icons/door_sensor_icon.svg"; static const String closedGarageIcon = "assets/icons/closed_garage_door.svg"; diff --git a/lib/main.dart b/lib/main.dart index 1a6c5a6..4f1f904 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -30,7 +30,7 @@ void main() { // }); //to initialize the locator - initialSetup(envName: 'prod'); + initialSetup(); await Firebase.initializeApp( options: DefaultFirebaseOptionsStaging.currentPlatform, diff --git a/lib/main_dev.dart b/lib/main_dev.dart index 9e53a7e..5f13c0a 100644 --- a/lib/main_dev.dart +++ b/lib/main_dev.dart @@ -30,7 +30,7 @@ void main() { // }); //to initialize the locator - initialSetup(envName: 'dev'); + initialSetup(); await Firebase.initializeApp( options: DefaultFirebaseOptionsDev.currentPlatform, diff --git a/lib/services/locator.dart b/lib/services/locator.dart index 97a9ae8..0fef6d7 100644 --- a/lib/services/locator.dart +++ b/lib/services/locator.dart @@ -5,9 +5,8 @@ import 'package:syncrow_app/services/api/http_service.dart'; final GetIt serviceLocator = GetIt.instance; // setupLocator() // to search for dependency injection in flutter -initialSetup({required String envName}) { +initialSetup() { serviceLocator.registerSingleton(HTTPInterceptor()); //Base classes serviceLocator.registerSingleton(HTTPService.setupDioClient()); - serviceLocator.registerSingleton(envName); }