diff --git a/assets/icons/1gang.svg b/assets/icons/1gang.svg index 23dee22..647dc35 100644 --- a/assets/icons/1gang.svg +++ b/assets/icons/1gang.svg @@ -1,5 +1,5 @@ - - - + + + diff --git a/assets/icons/2gang.svg b/assets/icons/2gang.svg new file mode 100644 index 0000000..6cfe191 --- /dev/null +++ b/assets/icons/2gang.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/lib/features/devices/bloc/two_gang_bloc/two_gang_bloc.dart b/lib/features/devices/bloc/two_gang_bloc/two_gang_bloc.dart index 8e32ef7..b36d286 100644 --- a/lib/features/devices/bloc/two_gang_bloc/two_gang_bloc.dart +++ b/lib/features/devices/bloc/two_gang_bloc/two_gang_bloc.dart @@ -69,7 +69,8 @@ class TwoGangBloc extends Bloc { deviceName: devicesList[i].name ?? '', firstSwitch: deviceStatus.firstSwitch, secondSwitch: deviceStatus.secondSwitch, - )); + ) + ); } if (groupTwoGangList.isNotEmpty) { @@ -128,22 +129,8 @@ class TwoGangBloc extends Bloc { void _changeFirstSwitch(ChangeFirstSwitchStatusEvent event, Emitter emit) async { emit(LoadingNewSate(twoGangModel: deviceStatus)); try { - if (twoGangGroup) { - bool allSwitchesValue = true; - groupTwoGangList.forEach((element) { - if (element.deviceId == event.deviceId) { - element.firstSwitch = !event.value; - } - if (!element.firstSwitch || !element.secondSwitch ) { - allSwitchesValue = false; - } - }); - emit(UpdateGroupState(twoGangList: groupTwoGangList, allSwitches: allSwitchesValue)); - } else { - deviceStatus.firstSwitch = !event.value; - emit(UpdateState(twoGangModel: deviceStatus)); - } - + deviceStatus.firstSwitch = !event.value; + emit(UpdateState(twoGangModel: deviceStatus)); if (_timer != null) { _timer!.cancel(); } @@ -169,22 +156,8 @@ class TwoGangBloc extends Bloc { ChangeSecondSwitchStatusEvent event, Emitter emit) async { emit(LoadingNewSate(twoGangModel: deviceStatus)); try { - if (twoGangGroup) { - bool allSwitchesValue = true; - groupTwoGangList.forEach((element) { - if (element.deviceId == event.deviceId) { - element.secondSwitch = !event.value; - } - if (!element.firstSwitch || !element.secondSwitch ) { - allSwitchesValue = false; - } - }); - emit(UpdateGroupState(twoGangList: groupTwoGangList, allSwitches: allSwitchesValue)); - } else { - deviceStatus.secondSwitch = !event.value; - emit(UpdateState(twoGangModel: deviceStatus)); - } - + deviceStatus.secondSwitch = !event.value; + emit(UpdateState(twoGangModel: deviceStatus)); if (_timer != null) { _timer!.cancel(); } @@ -238,24 +211,23 @@ class TwoGangBloc extends Bloc { void _allOn(AllOnEvent event, Emitter emit) async { emit(LoadingNewSate(twoGangModel: deviceStatus)); - try { deviceStatus.firstSwitch = true; deviceStatus.secondSwitch = true; emit(UpdateState(twoGangModel: deviceStatus)); - final response = await Future.wait([ DevicesAPI.controlDevice( - DeviceControlModel( - deviceId: twoGangId, code: 'switch_1', value: deviceStatus.firstSwitch), + DeviceControlModel( + deviceId: twoGangId, code: 'switch_1', + value: deviceStatus.firstSwitch), twoGangId), DevicesAPI.controlDevice( - DeviceControlModel( - deviceId: twoGangId, code: 'switch_2', value: deviceStatus.secondSwitch), - twoGangId), - + DeviceControlModel( + deviceId: twoGangId, + code: 'switch_2', + value: deviceStatus.secondSwitch), + twoGangId), ]); - if (response.every((element) => !element['success'])) { await Future.delayed(const Duration(milliseconds: 500)); add(const InitialEvent(groupScreen: false)); diff --git a/lib/features/devices/model/device_model.dart b/lib/features/devices/model/device_model.dart index 82fac11..c5ba2ae 100644 --- a/lib/features/devices/model/device_model.dart +++ b/lib/features/devices/model/device_model.dart @@ -58,6 +58,10 @@ class DeviceModel { tempIcon = Assets.assetsIcons3GangSwitch; } else if (type == DeviceType.Gateway) { tempIcon = Assets.assetsIconsGateway; + } else if (type == DeviceType.OneGang) { + tempIcon = Assets.oneGang; + } else if (type == DeviceType.TwoGang) { + tempIcon = Assets.twoGang; } else { tempIcon = Assets.assetsIconsLogo; } diff --git a/lib/features/devices/view/widgets/devices_view_body.dart b/lib/features/devices/view/widgets/devices_view_body.dart index 9ee89a6..53fa8a3 100644 --- a/lib/features/devices/view/widgets/devices_view_body.dart +++ b/lib/features/devices/view/widgets/devices_view_body.dart @@ -79,8 +79,7 @@ class DevicesViewBody extends StatelessWidget { ), if (HomeCubit.getInstance().selectedSpace != null) if (HomeCubit.getInstance().selectedSpace!.rooms != null) - ...HomeCubit.getInstance().selectedSpace!.rooms!.map( - (room) { + ...HomeCubit.getInstance().selectedSpace!.rooms!.map((room) { return RoomPage( room: room, ); diff --git a/lib/features/devices/view/widgets/rooms_slider.dart b/lib/features/devices/view/widgets/rooms_slider.dart index 02d85f0..a53efb3 100644 --- a/lib/features/devices/view/widgets/rooms_slider.dart +++ b/lib/features/devices/view/widgets/rooms_slider.dart @@ -22,6 +22,7 @@ class RoomsSlider extends StatelessWidget { onPageChanged: (index) { HomeCubit.getInstance().roomSliderPageChanged(index); }, + children: [ Padding( padding: const EdgeInsets.symmetric(horizontal: 15), diff --git a/lib/generated/assets.dart b/lib/generated/assets.dart index e592f1e..80d9bf8 100644 --- a/lib/generated/assets.dart +++ b/lib/generated/assets.dart @@ -1030,9 +1030,9 @@ class Assets { static const String assetsPresenceState = "assets/icons/functions_icons/automation_functions/presence_state.svg"; - //assets/icons/functions_icons/automation_functions/presence_state.svg - static const String oneGang = - "assets/icons/1gang.svg"; + static const String oneGang = "assets/icons/1gang.svg"; + + static const String twoGang = "assets/icons/2gang.svg"; } diff --git a/lib/main.dart b/lib/main.dart index 05f1875..1738eac 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -14,7 +14,7 @@ void main() { //to catch all the errors in the app and send them to firebase runZonedGuarded(() async { //to load the environment variables - const environment = String.fromEnvironment('FLAVOR', defaultValue: 'production'); + const environment = String.fromEnvironment('FLAVOR', defaultValue: 'development'); await dotenv.load(fileName: '.env.$environment'); // //this is to make the app work with the self-signed certificate