diff --git a/lib/domain/device/i_device_repository.dart b/lib/domain/device/i_device_repository.dart index bd967f29..7ec84589 100644 --- a/lib/domain/device/i_device_repository.dart +++ b/lib/domain/device/i_device_repository.dart @@ -5,8 +5,8 @@ import 'dart:io'; import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/devices/device_helper/device_helper.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_dto_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_dto_base.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_blinds_entity/generic_blinds_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_blinds_entity/generic_blinds_value_objects.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_boiler_entity/generic_boiler_entity.dart'; @@ -49,42 +49,39 @@ abstract interface class IDeviceRepository { return _instance ??= _DeviceRepository(); } - void addOrUpdateDevice(DeviceEntityAbstract deviceEntity); + void addOrUpdateDevice(DeviceEntityBase deviceEntity); - void addOrUpdateDeviceAndStateToWaiting(DeviceEntityAbstract deviceEntity); + void addOrUpdateDeviceAndStateToWaiting(DeviceEntityBase deviceEntity); Future initiateHubConnection(); - Future>> getAllDevices(); + Future>> getAllDevices(); Stream>> watchAll(); - Stream>> - watchAllDevices(); + Stream>> watchAllDevices(); - Stream>> watchLights(); + Stream>> watchLights(); - Stream>> watchBlinds(); + Stream>> watchBlinds(); - Stream>> watchBoilers(); + Stream>> watchBoilers(); - Stream>> watchSmartTv(); + Stream>> watchSmartTv(); - Stream>> watchSwitches(); + Stream>> watchSwitches(); - Stream>> - watchSmartPlugs(); + Stream>> watchSmartPlugs(); - Stream>> + Stream>> watchSmartComputers(); - Stream>> watchPrinters(); + Stream>> watchPrinters(); - Stream>> - watchUncompleted(); + Stream>> watchUncompleted(); Future> create( - DeviceEntityAbstract deviceEntity, + DeviceEntityBase deviceEntity, ); /// Update document in the database in the following fields @@ -94,7 +91,7 @@ abstract interface class IDeviceRepository { }); Future> updateWithDeviceEntity({ - required DeviceEntityAbstract deviceEntity, + required DeviceEntityBase deviceEntity, }); Future> turnOnDevices({ @@ -174,7 +171,7 @@ abstract interface class IDeviceRepository { }); Future> delete( - DeviceEntityAbstract deviceEntity, + DeviceEntityBase deviceEntity, ); BehaviorSubject> allResponseFromTheHubStreamController = @@ -183,7 +180,7 @@ abstract interface class IDeviceRepository { BehaviorSubject> roomsResponseFromTheHubStreamController = BehaviorSubject>(); - BehaviorSubject> + BehaviorSubject> devicesResponseFromTheHubStreamController = - BehaviorSubject>(); + BehaviorSubject>(); } diff --git a/lib/domain/i_phone_as_hub.dart b/lib/domain/i_phone_as_hub.dart index a3268bb9..ffcf5c91 100644 --- a/lib/domain/i_phone_as_hub.dart +++ b/lib/domain/i_phone_as_hub.dart @@ -3,7 +3,7 @@ import 'dart:collection'; import 'package:cbj_integrations_controller/infrastructure/devices_service.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; import 'package:cbj_integrations_controller/infrastructure/search_devices.dart'; @@ -25,7 +25,7 @@ abstract interface class IPhoneAsHub { dynamic value, }); - Future> get getAllEntities; + Future> get getAllEntities; void startListen(); diff --git a/lib/infrastructure/device_repository.dart b/lib/infrastructure/device_repository.dart index 6d1c1bc9..55bb95eb 100644 --- a/lib/infrastructure/device_repository.dart +++ b/lib/infrastructure/device_repository.dart @@ -3,14 +3,14 @@ part of 'package:cybear_jinni/domain/device/i_device_repository.dart'; class _DeviceRepository implements IDeviceRepository { // final DeviceRemoteService _deviceRemoteService; // final DeviceLocalService _deviceLocalService; - HashMap allDevices = - HashMap(); + HashMap allDevices = + HashMap(); // @override // void addOrUpdateFromApp(dynamic entity) { // if (entity is RoomEntity) { // _addOrUpdateRoom(entity); - // } else if (entity is DeviceEntityAbstract) { + // } else if (entity is DeviceEntityBase) { // _addOrUpdateDevice(entity); // } else { // logger.w('Entity type to update ${entity.runtimeType} is not supported'); @@ -20,14 +20,14 @@ class _DeviceRepository implements IDeviceRepository { // } @override - void addOrUpdateDevice(DeviceEntityAbstract deviceEntity) { + void addOrUpdateDevice(DeviceEntityBase deviceEntity) { allDevices[deviceEntity.cbjDeviceVendor.getOrCrash()] = deviceEntity; devicesResponseFromTheHubStreamController.sink .add(allDevices.values.toImmutableList()); } @override - void addOrUpdateDeviceAndStateToWaiting(DeviceEntityAbstract deviceEntity) { + void addOrUpdateDeviceAndStateToWaiting(DeviceEntityBase deviceEntity) { addOrUpdateDevice( deviceEntity.copyWithDeviceState( EntityStateGRPC.waitingInComp, @@ -43,7 +43,7 @@ class _DeviceRepository implements IDeviceRepository { } @override - Future>> + Future>> getAllDevices() async { try { return right(allDevices.values.toImmutableList()); @@ -65,14 +65,14 @@ class _DeviceRepository implements IDeviceRepository { } @override - Stream>> + Stream>> watchAllDevices() async* { yield* devicesResponseFromTheHubStreamController.stream .map((event) => right(event)); } @override - Stream>> + Stream>> watchLights() async* { // Using watchAll devices from server function and filtering out only the // Light device type @@ -93,7 +93,7 @@ class _DeviceRepository implements IDeviceRepository { } @override - Stream>> + Stream>> watchSwitches() async* { // Using watchAll devices from server function and filtering out only the // Switches device type @@ -110,7 +110,7 @@ class _DeviceRepository implements IDeviceRepository { } @override - Stream>> + Stream>> watchSmartPlugs() async* { // Using watchAll devices from server function and filtering out only the // Smart Plugs device type @@ -127,7 +127,7 @@ class _DeviceRepository implements IDeviceRepository { } @override - Stream>> + Stream>> watchSmartComputers() async* { // Using watchAll devices from server function and filtering out only the // Smart Computers device type @@ -144,7 +144,7 @@ class _DeviceRepository implements IDeviceRepository { } @override - Stream>> + Stream>> watchBlinds() async* { // Using watchAll devices from server function and filtering out only the // Blinds device type @@ -161,7 +161,7 @@ class _DeviceRepository implements IDeviceRepository { } @override - Stream>> + Stream>> watchBoilers() async* { // Using watchAll devices from server function and filtering out only the // Boilers device type @@ -178,7 +178,7 @@ class _DeviceRepository implements IDeviceRepository { } @override - Stream>> + Stream>> watchSmartTv() async* { yield* watchAllDevices().map( (event) => event.fold((l) => left(l), (r) { @@ -193,7 +193,7 @@ class _DeviceRepository implements IDeviceRepository { } @override - Stream>> + Stream>> watchPrinters() async* { yield* watchAllDevices().map( (event) => event.fold((l) => left(l), (r) { @@ -208,15 +208,14 @@ class _DeviceRepository implements IDeviceRepository { } @override - Stream>> - watchUncompleted() { + Stream>> watchUncompleted() { // TODO: implement watchUncompleted throw UnimplementedError(); } @override Future> create( - DeviceEntityAbstract deviceEntity, + DeviceEntityBase deviceEntity, ) async { try { String deviceModelString = 'No Model found'; @@ -239,7 +238,7 @@ class _DeviceRepository implements IDeviceRepository { .copyWithDeviceSenderDeviceModel(deviceModelString) .copyWithSenderId(currentUserId); - DeviceEntityDtoAbstract.fromDomain(); + DeviceEntityDtoBase.fromDomain(); return right(unit); } on PlatformException catch (e) { @@ -273,7 +272,7 @@ class _DeviceRepository implements IDeviceRepository { @override Future> updateWithDeviceEntity({ - required DeviceEntityAbstract deviceEntity, + required DeviceEntityBase deviceEntity, }) async { const String updateLocation = 'L'; @@ -297,12 +296,11 @@ class _DeviceRepository implements IDeviceRepository { List? devicesId, String? forceUpdateLocation, }) async { - final List deviceEntityListToUpdate = + final List deviceEntityListToUpdate = await getDeviceEntityListFromId(devicesId!); try { - for (final DeviceEntityAbstract? deviceEntity - in deviceEntityListToUpdate) { + for (final DeviceEntityBase? deviceEntity in deviceEntityListToUpdate) { if (deviceEntity == null) { continue; } @@ -352,12 +350,11 @@ class _DeviceRepository implements IDeviceRepository { List? devicesId, String? forceUpdateLocation, }) async { - final List deviceEntityListToUpdate = + final List deviceEntityListToUpdate = await getDeviceEntityListFromId(devicesId!); try { - for (final DeviceEntityAbstract? deviceEntity - in deviceEntityListToUpdate) { + for (final DeviceEntityBase? deviceEntity in deviceEntityListToUpdate) { if (deviceEntity == null) { continue; } @@ -407,12 +404,11 @@ class _DeviceRepository implements IDeviceRepository { required List? devicesId, required int colorTemperatureToChange, }) async { - final List deviceEntityListToUpdate = + final List deviceEntityListToUpdate = await getDeviceEntityListFromId(devicesId!); try { - for (final DeviceEntityAbstract? deviceEntity - in deviceEntityListToUpdate) { + for (final DeviceEntityBase? deviceEntity in deviceEntityListToUpdate) { if (deviceEntity == null) { continue; } @@ -474,12 +470,11 @@ class _DeviceRepository implements IDeviceRepository { required List? devicesId, required HSVColor hsvColorToChange, }) async { - final List deviceEntityListToUpdate = + final List deviceEntityListToUpdate = await getDeviceEntityListFromId(devicesId!); try { - for (final DeviceEntityAbstract? deviceEntity - in deviceEntityListToUpdate) { + for (final DeviceEntityBase? deviceEntity in deviceEntityListToUpdate) { if (deviceEntity == null) { continue; } @@ -546,15 +541,14 @@ class _DeviceRepository implements IDeviceRepository { required List? devicesId, required int brightnessToChange, }) async { - final List deviceEntityListToUpdate = + final List deviceEntityListToUpdate = await getDeviceEntityListFromId(devicesId!); Either totalActionResult = right(unit); try { Either actionResult; - for (final DeviceEntityAbstract? deviceEntity - in deviceEntityListToUpdate) { + for (final DeviceEntityBase? deviceEntity in deviceEntityListToUpdate) { if (deviceEntity == null) { continue; } else if (deviceEntity is GenericDimmableLightDE) { @@ -654,12 +648,11 @@ class _DeviceRepository implements IDeviceRepository { List? devicesId, String? forceUpdateLocation, }) async { - final List deviceEntityListToUpdate = + final List deviceEntityListToUpdate = await getDeviceEntityListFromId(devicesId!); try { - for (final DeviceEntityAbstract? deviceEntity - in deviceEntityListToUpdate) { + for (final DeviceEntityBase? deviceEntity in deviceEntityListToUpdate) { if (deviceEntity == null) { continue; } @@ -694,12 +687,11 @@ class _DeviceRepository implements IDeviceRepository { List? devicesId, String? forceUpdateLocation, }) async { - final List deviceEntityListToUpdate = + final List deviceEntityListToUpdate = await getDeviceEntityListFromId(devicesId!); try { - for (final DeviceEntityAbstract? deviceEntity - in deviceEntityListToUpdate) { + for (final DeviceEntityBase? deviceEntity in deviceEntityListToUpdate) { if (deviceEntity == null) { continue; } @@ -738,12 +730,11 @@ class _DeviceRepository implements IDeviceRepository { List? devicesId, String? forceUpdateLocation, }) async { - final List deviceEntityListToUpdate = + final List deviceEntityListToUpdate = await getDeviceEntityListFromId(devicesId!); try { - for (final DeviceEntityAbstract? deviceEntity - in deviceEntityListToUpdate) { + for (final DeviceEntityBase? deviceEntity in deviceEntityListToUpdate) { if (deviceEntity == null) { continue; } @@ -777,12 +768,11 @@ class _DeviceRepository implements IDeviceRepository { Future> suspendDevices({ required List? devicesId, }) async { - final List deviceEntityListToUpdate = + final List deviceEntityListToUpdate = await getDeviceEntityListFromId(devicesId!); try { - for (final DeviceEntityAbstract? deviceEntity - in deviceEntityListToUpdate) { + for (final DeviceEntityBase? deviceEntity in deviceEntityListToUpdate) { if (deviceEntity == null) { continue; } @@ -818,12 +808,11 @@ class _DeviceRepository implements IDeviceRepository { Future> shutdownDevices({ required List? devicesId, }) async { - final List deviceEntityListToUpdate = + final List deviceEntityListToUpdate = await getDeviceEntityListFromId(devicesId!); try { - for (final DeviceEntityAbstract? deviceEntity - in deviceEntityListToUpdate) { + for (final DeviceEntityBase? deviceEntity in deviceEntityListToUpdate) { if (deviceEntity == null) { continue; } @@ -868,12 +857,11 @@ class _DeviceRepository implements IDeviceRepository { required List? devicesId, required String url, }) async { - final List deviceEntityListToUpdate = + final List deviceEntityListToUpdate = await getDeviceEntityListFromId(devicesId!); try { - for (final DeviceEntityAbstract? deviceEntity - in deviceEntityListToUpdate) { + for (final DeviceEntityBase? deviceEntity in deviceEntityListToUpdate) { if (deviceEntity == null) { continue; } @@ -907,12 +895,11 @@ class _DeviceRepository implements IDeviceRepository { List? devicesId, String? forceUpdateLocation, }) async { - final List deviceEntityListToUpdate = + final List deviceEntityListToUpdate = await getDeviceEntityListFromId(devicesId!); try { - for (final DeviceEntityAbstract? deviceEntity - in deviceEntityListToUpdate) { + for (final DeviceEntityBase? deviceEntity in deviceEntityListToUpdate) { if (deviceEntity == null) { continue; } @@ -946,12 +933,11 @@ class _DeviceRepository implements IDeviceRepository { Future> pauseStateDevices({ required List? devicesId, }) async { - final List deviceEntityListToUpdate = + final List deviceEntityListToUpdate = await getDeviceEntityListFromId(devicesId!); try { - for (final DeviceEntityAbstract? deviceEntity - in deviceEntityListToUpdate) { + for (final DeviceEntityBase? deviceEntity in deviceEntityListToUpdate) { if (deviceEntity == null) { continue; } @@ -986,12 +972,11 @@ class _DeviceRepository implements IDeviceRepository { Future> playStateDevices({ required List? devicesId, }) async { - final List deviceEntityListToUpdate = + final List deviceEntityListToUpdate = await getDeviceEntityListFromId(devicesId!); try { - for (final DeviceEntityAbstract? deviceEntity - in deviceEntityListToUpdate) { + for (final DeviceEntityBase? deviceEntity in deviceEntityListToUpdate) { if (deviceEntity == null) { continue; } @@ -1026,12 +1011,11 @@ class _DeviceRepository implements IDeviceRepository { Future> queuePrevStateDevices({ required List? devicesId, }) async { - final List deviceEntityListToUpdate = + final List deviceEntityListToUpdate = await getDeviceEntityListFromId(devicesId!); try { - for (final DeviceEntityAbstract? deviceEntity - in deviceEntityListToUpdate) { + for (final DeviceEntityBase? deviceEntity in deviceEntityListToUpdate) { if (deviceEntity == null) { continue; } @@ -1066,12 +1050,11 @@ class _DeviceRepository implements IDeviceRepository { Future> queueNextStateDevices({ required List? devicesId, }) async { - final List deviceEntityListToUpdate = + final List deviceEntityListToUpdate = await getDeviceEntityListFromId(devicesId!); try { - for (final DeviceEntityAbstract? deviceEntity - in deviceEntityListToUpdate) { + for (final DeviceEntityBase? deviceEntity in deviceEntityListToUpdate) { if (deviceEntity == null) { continue; } @@ -1112,19 +1095,19 @@ class _DeviceRepository implements IDeviceRepository { @override Future> delete( - DeviceEntityAbstract deviceEntity, + DeviceEntityBase deviceEntity, ) async { return left(const DevicesFailure.unexpected()); } Future> updateRemoteDB( - DeviceEntityAbstract deviceEntity, + DeviceEntityBase deviceEntity, ) async { return left(const DevicesFailure.unexpected()); } Future> updateComputer( - DeviceEntityAbstract deviceEntity, + DeviceEntityBase deviceEntity, ) async { try { addOrUpdateDeviceAndStateToWaiting(deviceEntity); @@ -1161,17 +1144,17 @@ class _DeviceRepository implements IDeviceRepository { } } - Future> getDeviceEntityListFromId( + Future> getDeviceEntityListFromId( List deviceIdList, ) async { - final List deviceEntityList = []; + final List deviceEntityList = []; if (allDevices.isEmpty) { return []; } for (final deviceId in deviceIdList) { - final DeviceEntityAbstract? device = allDevices[deviceId]; + final DeviceEntityBase? device = allDevices[deviceId]; if (device == null) { continue; } @@ -1259,9 +1242,9 @@ class _DeviceRepository implements IDeviceRepository { BehaviorSubject(); @override - BehaviorSubject> + BehaviorSubject> devicesResponseFromTheHubStreamController = - BehaviorSubject>(); + BehaviorSubject>(); @override BehaviorSubject> roomsResponseFromTheHubStreamController = diff --git a/lib/infrastructure/hub_client/hub_requests_routing.dart b/lib/infrastructure/hub_client/hub_requests_routing.dart index c4325652..2c65bbdd 100644 --- a/lib/infrastructure/hub_client/hub_requests_routing.dart +++ b/lib/infrastructure/hub_client/hub_requests_routing.dart @@ -5,7 +5,7 @@ import 'package:cbj_integrations_controller/domain/room/i_room_repository.dart'; import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/domain/scene/i_scene_cbj_repository.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_blinds_entity/generic_blinds_device_dtos.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_boiler_entity/generic_boiler_device_dtos.dart'; @@ -160,7 +160,7 @@ class HubRequestRouting { return; } - late DeviceEntityAbstract deviceEntity; + late DeviceEntityBase deviceEntity; switch (deviceType) { case EntityTypes.light: diff --git a/lib/infrastructure/mqtt.dart b/lib/infrastructure/mqtt.dart index b66bd080..a4e22150 100644 --- a/lib/infrastructure/mqtt.dart +++ b/lib/infrastructure/mqtt.dart @@ -5,8 +5,8 @@ import 'package:cbj_integrations_controller/domain/i_saved_devices_repo.dart'; import 'package:cbj_integrations_controller/domain/i_saved_rooms_repo.dart'; import 'package:cbj_integrations_controller/infrastructure/devices/device_helper/device_helper.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_dto_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_dto_base.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/value_objects_core.dart'; import 'package:cbj_integrations_controller/infrastructure/hub_client/hub_client.dart'; import 'package:cbj_integrations_controller/infrastructure/room/room_entity_dtos.dart'; @@ -55,7 +55,7 @@ class MqttServerRepository extends IMqttServerRepository { @override Future postSmartDeviceToAppMqtt({ - required DeviceEntityAbstract entityFromTheHub, + required DeviceEntityBase entityFromTheHub, }) async { HubRequestsToApp.streamRequestsToApp.sink.add( RequestsAndStatusFromHub( @@ -68,7 +68,7 @@ class MqttServerRepository extends IMqttServerRepository { @override Future postToAppMqtt({ - required DeviceEntityAbstract entityFromTheHub, + required DeviceEntityBase entityFromTheHub, }) async {} @override @@ -76,17 +76,16 @@ class MqttServerRepository extends IMqttServerRepository { required dynamic entityFromTheApp, bool? gotFromApp, }) async { - if (entityFromTheApp is DeviceEntityDtoAbstract) { - final DeviceEntityAbstract deviceEntityAbstract = - entityFromTheApp.toDomain(); - deviceEntityAbstract.entityStateGRPC = + if (entityFromTheApp is DeviceEntityDtoBase) { + final DeviceEntityBase deviceEntityBase = entityFromTheApp.toDomain(); + deviceEntityBase.entityStateGRPC = EntityState.state(EntityStateGRPC.waitingInComp); /// Sends directly to device connector conjecture - ISavedDevicesRepo.instance.addOrUpdateFromMqtt(deviceEntityAbstract); + ISavedDevicesRepo.instance.addOrUpdateFromMqtt(deviceEntityBase); return; - } else if (entityFromTheApp is DeviceEntityAbstract) { + } else if (entityFromTheApp is DeviceEntityBase) { entityFromTheApp.entityStateGRPC = EntityState.state(EntityStateGRPC.waitingInComp); @@ -110,7 +109,7 @@ class MqttServerRepository extends IMqttServerRepository { @override Future publishDeviceEntity( - DeviceEntityAbstract deviceEntityDtoAbstract, + DeviceEntityBase deviceEntityDtoAbstract, ) async {} @override diff --git a/lib/infrastructure/phone_as_hub.dart b/lib/infrastructure/phone_as_hub.dart index d3958eed..58ce835b 100644 --- a/lib/infrastructure/phone_as_hub.dart +++ b/lib/infrastructure/phone_as_hub.dart @@ -9,7 +9,7 @@ class _PhoneAsHubRepository implements IPhoneAsHub { } @override - Future> get getAllEntities async { + Future> get getAllEntities async { return DevicesService().getEntities(); } diff --git a/lib/presentation/molecules/device_by_type_molecule.dart b/lib/presentation/molecules/device_by_type_molecule.dart index 253099bb..b324f599 100644 --- a/lib/presentation/molecules/device_by_type_molecule.dart +++ b/lib/presentation/molecules/device_by_type_molecule.dart @@ -1,5 +1,5 @@ import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbenum.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_blinds_entity/generic_blinds_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_boiler_entity/generic_boiler_entity.dart'; @@ -18,7 +18,7 @@ import 'package:flutter/material.dart'; class DeviceByTypeMolecule extends StatelessWidget { const DeviceByTypeMolecule(this.entity); - final DeviceEntityAbstract entity; + final DeviceEntityBase entity; @override Widget build(BuildContext context) { diff --git a/lib/presentation/organisms/open_room_organism.dart b/lib/presentation/organisms/open_room_organism.dart index d1a82143..84a34220 100644 --- a/lib/presentation/organisms/open_room_organism.dart +++ b/lib/presentation/organisms/open_room_organism.dart @@ -1,6 +1,6 @@ import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cybear_jinni/domain/i_phone_as_hub.dart'; import 'package:cybear_jinni/presentation/atoms/atoms.dart'; import 'package:cybear_jinni/presentation/molecules/molecules.dart'; @@ -24,7 +24,7 @@ class OpenRoomOrganism extends StatefulWidget { } class _OpenRoomOrganismState extends State { - List? devices; + List? devices; @override void initState() { @@ -33,14 +33,14 @@ class _OpenRoomOrganismState extends State { } Future initialzeDevices() async { - final Map devicesMap = + final Map devicesMap = await IPhoneAsHub.instance.getAllEntities; final Set deviceIdsInRoom = widget.roomEntity.roomDevicesId.getOrCrash().toSet(); final String? entityTypeName = widget.entityTypes?.name; - final List tempDevices = devicesMap.values + final List tempDevices = devicesMap.values .where( (element) => deviceIdsInRoom @@ -74,7 +74,7 @@ class _OpenRoomOrganismState extends State { reverse: true, padding: EdgeInsets.zero, itemBuilder: (context, index) { - final DeviceEntityAbstract device = devices![index]; + final DeviceEntityBase device = devices![index]; return Column( children: [ diff --git a/lib/presentation/pages/add_new_automation_process/add_action/add_action_page.dart b/lib/presentation/pages/add_new_automation_process/add_action/add_action_page.dart index d2388f4e..bca48b4c 100644 --- a/lib/presentation/pages/add_new_automation_process/add_action/add_action_page.dart +++ b/lib/presentation/pages/add_new_automation_process/add_action/add_action_page.dart @@ -1,5 +1,5 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cybear_jinni/presentation/molecules/molecules.dart'; import 'package:cybear_jinni/presentation/pages/add_new_automation_process/add_action/widgets/action_choose_information.dart'; import 'package:flutter/material.dart'; @@ -7,7 +7,7 @@ import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:hexcolor/hexcolor.dart'; -@RoutePage>>>() +@RoutePage>>>() class AddActionPage extends StatelessWidget { void backButtonFunction(BuildContext context) {} diff --git a/lib/presentation/pages/add_new_automation_process/add_action/widgets/action_choose_information.dart b/lib/presentation/pages/add_new_automation_process/add_action/widgets/action_choose_information.dart index aefd84bb..168d65ae 100644 --- a/lib/presentation/pages/add_new_automation_process/add_action/widgets/action_choose_information.dart +++ b/lib/presentation/pages/add_new_automation_process/add_action/widgets/action_choose_information.dart @@ -1,7 +1,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/domain/room/i_room_repository.dart'; import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cybear_jinni/domain/device/i_device_repository.dart'; import 'package:cybear_jinni/presentation/atoms/atoms.dart'; import 'package:cybear_jinni/presentation/core/snack_bar_service.dart'; @@ -16,13 +16,13 @@ class ActionChooseInformation extends StatefulWidget { class _ActionChooseInformationState extends State { List _allRooms = []; - List _allDevices = []; + List _allDevices = []; String actionsName = ''; String propertyName = ''; /// Will contain (in that order) device to change his property to change and the new value of this property - List>> + List>> allDevicesWithNewAction = []; List> allEntityActions = []; bool isSubmitting = false; @@ -40,9 +40,9 @@ class _ActionChooseInformationState extends State { }); allRoomsTemp.removeWhere((element) => element == null); - List allDevicesTemp = []; + List allDevicesTemp = []; (await IDeviceRepository.instance.getAllDevices()).fold((l) => null, (r) { - allDevicesTemp = List.from(r.iter); + allDevicesTemp = List.from(r.iter); }); allDevicesTemp.removeWhere((element) => element == null); setState(() { @@ -52,7 +52,7 @@ class _ActionChooseInformationState extends State { } Future _changeActionDevices(String actionForProperty) async { - for (final DeviceEntityAbstract? device in _allDevices) { + for (final DeviceEntityBase? device in _allDevices) { if (device != null && actionForProperty == device.uniqueId.getOrCrash()) { setState(() { allDevicesWithNewAction = [ @@ -66,7 +66,7 @@ class _ActionChooseInformationState extends State { Future _actionsNameChange(String value) async { if (allDevicesWithNewAction.isNotEmpty) { - final List>> + final List>> tempAllDevicesWithNewActionList = List.from(allDevicesWithNewAction); final MapEntry propertyWithAction = MapEntry( @@ -86,7 +86,7 @@ class _ActionChooseInformationState extends State { Future _changePropertyForDevices(String propertyOfDevice) async { if (allDevicesWithNewAction.isNotEmpty) { - final List>> + final List>> tempAllDevicesWithNewActionList = List.from(allDevicesWithNewAction); final MapEntry propertyWithAction = MapEntry( @@ -238,7 +238,7 @@ class _ActionChooseInformationState extends State { context.router.pop< List< - MapEntry>>>( allDevicesWithNewAction, ); diff --git a/lib/presentation/pages/add_new_automation_process/add_bindings/widgets/add_binding_widget.dart b/lib/presentation/pages/add_new_automation_process/add_bindings/widgets/add_binding_widget.dart index 60706e69..6d6c01af 100644 --- a/lib/presentation/pages/add_new_automation_process/add_bindings/widgets/add_binding_widget.dart +++ b/lib/presentation/pages/add_new_automation_process/add_bindings/widgets/add_binding_widget.dart @@ -3,7 +3,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/domain/binding/i_binding_cbj_repository.dart'; import 'package:cbj_integrations_controller/domain/vendors/login_abstract/core_login_failures.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cybear_jinni/domain/device/i_device_repository.dart'; import 'package:cybear_jinni/presentation/atoms/atoms.dart'; import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; @@ -19,12 +19,12 @@ class AddBindingWidget extends StatefulWidget { } class _AddBindingWidgetState extends State { - List _allDevices = []; + List _allDevices = []; String bindingName = ''; /// List of devices with entities, will be treated as actions - List>> + List>> allDevicesWithNewAction = []; List> allEntityActions = []; bool showErrorMessages = false; @@ -39,9 +39,9 @@ class _AddBindingWidgetState extends State { } Future _initialized() async { - List value = []; + List value = []; (await IDeviceRepository.instance.getAllDevices()).fold((l) => null, (r) { - value = List.from(r.iter); + value = List.from(r.iter); }); value.removeWhere((element) => element == null); @@ -59,7 +59,7 @@ class _AddBindingWidgetState extends State { } Future _addDevicesWithNewActions( - List>> value, + List>> value, ) async { setState(() { allDevicesWithNewAction.addAll(value); @@ -94,13 +94,13 @@ class _AddBindingWidgetState extends State { child: ListView.builder( itemCount: allDevicesWithNewAction.length, itemBuilder: (BuildContext context, int index) { - final MapEntry> + final MapEntry> currentDevice = allDevicesWithNewAction[index]; return Container( margin: const EdgeInsets.symmetric(vertical: 1), child: BindingActionWidget( - deviceEntityAbstract: currentDevice.key, + deviceEntityBase: currentDevice.key, propertyToChange: currentDevice.value.key ?? 'Missing property', actionToChange: currentDevice.value.value ?? @@ -132,11 +132,11 @@ class _AddBindingWidgetState extends State { ), onPressed: (_) async { final List< - MapEntry>>? actionList = await context.router.push< List< - MapEntry>>>( const AddActionRoute(), ); diff --git a/lib/presentation/pages/add_new_automation_process/add_bindings/widgets/binding_action_widget.dart b/lib/presentation/pages/add_new_automation_process/add_bindings/widgets/binding_action_widget.dart index c8253b7d..3e0ee4bb 100644 --- a/lib/presentation/pages/add_new_automation_process/add_bindings/widgets/binding_action_widget.dart +++ b/lib/presentation/pages/add_new_automation_process/add_bindings/widgets/binding_action_widget.dart @@ -1,5 +1,5 @@ import 'package:auto_size_text/auto_size_text.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -8,13 +8,13 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; class BindingActionWidget extends StatelessWidget { /// Get all and store all info about the action const BindingActionWidget({ - required this.deviceEntityAbstract, + required this.deviceEntityBase, required this.propertyToChange, required this.actionToChange, }); /// Cbj unique id of a device - final DeviceEntityAbstract deviceEntityAbstract; + final DeviceEntityBase deviceEntityBase; /// The action for the device final String propertyToChange; @@ -32,7 +32,7 @@ class BindingActionWidget extends StatelessWidget { color: Colors.yellow, ), title: AutoSizeText( - '${deviceEntityAbstract.cbjEntityName.getOrCrash()!} - $propertyToChange', + '${deviceEntityBase.cbjEntityName.getOrCrash()!} - $propertyToChange', maxLines: 2, ), trailing: AutoSizeText( diff --git a/lib/presentation/pages/add_new_automation_process/add_routine/widgets/add_routine_widget.dart b/lib/presentation/pages/add_new_automation_process/add_routine/widgets/add_routine_widget.dart index 1fe4a08a..71617cf7 100644 --- a/lib/presentation/pages/add_new_automation_process/add_routine/widgets/add_routine_widget.dart +++ b/lib/presentation/pages/add_new_automation_process/add_routine/widgets/add_routine_widget.dart @@ -4,7 +4,7 @@ import 'package:cbj_integrations_controller/domain/routine/i_routine_cbj_reposit import 'package:cbj_integrations_controller/domain/routine/value_objects_routine_cbj.dart'; import 'package:cbj_integrations_controller/domain/vendors/login_abstract/core_login_failures.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cybear_jinni/domain/device/i_device_repository.dart'; import 'package:cybear_jinni/presentation/atoms/atoms.dart'; import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; @@ -20,7 +20,7 @@ class AddRoutineWidget extends StatefulWidget { } class _AddRoutineWidgetState extends State { - List _allDevices = []; + List _allDevices = []; String? routineName; @@ -29,7 +29,7 @@ class _AddRoutineWidgetState extends State { RoutineCbjRepeatDateMinute? minutesToRepeat; /// List of devices with entities, will be treated as actions - List>> + List>> allDevicesWithNewAction = []; List> allEntityActions = []; bool showErrorMessages = false; @@ -45,9 +45,9 @@ class _AddRoutineWidgetState extends State { } Future _initialized() async { - List temp = []; + List temp = []; (await IDeviceRepository.instance.getAllDevices()).fold((l) => null, (r) { - temp = List.from(r.iter); + temp = List.from(r.iter); }); temp.removeWhere((element) => element == null); @@ -78,7 +78,7 @@ class _AddRoutineWidgetState extends State { } Future _addDevicesWithNewActions( - Iterable>> value, + Iterable>> value, ) async { setState(() { allDevicesWithNewAction.addAll(value); @@ -111,13 +111,13 @@ class _AddRoutineWidgetState extends State { child: ListView.builder( itemCount: allDevicesWithNewAction.length, itemBuilder: (BuildContext context, int index) { - final MapEntry> + final MapEntry> currentDevice = allDevicesWithNewAction[index]; return Container( margin: const EdgeInsets.symmetric(vertical: 1), child: RoutineActionWidget( - deviceEntityAbstract: currentDevice.key, + deviceEntityBase: currentDevice.key, propertyToChange: currentDevice.value.key ?? 'Missing property', actionToChange: currentDevice.value.value ?? @@ -149,11 +149,11 @@ class _AddRoutineWidgetState extends State { ), onPressed: (_) async { final List< - MapEntry>>? actionList = await context.router.push< List< - MapEntry>>>( const AddActionRoute(), ); diff --git a/lib/presentation/pages/add_new_automation_process/add_routine/widgets/routine_action_widget.dart b/lib/presentation/pages/add_new_automation_process/add_routine/widgets/routine_action_widget.dart index 73c3aa5c..c5fd6c2c 100644 --- a/lib/presentation/pages/add_new_automation_process/add_routine/widgets/routine_action_widget.dart +++ b/lib/presentation/pages/add_new_automation_process/add_routine/widgets/routine_action_widget.dart @@ -1,5 +1,5 @@ import 'package:auto_size_text/auto_size_text.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -8,13 +8,13 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; class RoutineActionWidget extends StatelessWidget { /// Get all and store all info about the action const RoutineActionWidget({ - required this.deviceEntityAbstract, + required this.deviceEntityBase, required this.propertyToChange, required this.actionToChange, }); /// Cbj unique id of a device - final DeviceEntityAbstract deviceEntityAbstract; + final DeviceEntityBase deviceEntityBase; /// The action for the device final String propertyToChange; @@ -32,7 +32,7 @@ class RoutineActionWidget extends StatelessWidget { color: Colors.yellow, ), title: AutoSizeText( - '${deviceEntityAbstract.cbjEntityName.getOrCrash()!} - $propertyToChange', + '${deviceEntityBase.cbjEntityName.getOrCrash()!} - $propertyToChange', maxLines: 2, ), trailing: AutoSizeText( diff --git a/lib/presentation/pages/add_new_automation_process/add_scene/widgets/add_scene_widget.dart b/lib/presentation/pages/add_new_automation_process/add_scene/widgets/add_scene_widget.dart index ca5ee5db..36851c11 100644 --- a/lib/presentation/pages/add_new_automation_process/add_scene/widgets/add_scene_widget.dart +++ b/lib/presentation/pages/add_new_automation_process/add_scene/widgets/add_scene_widget.dart @@ -3,7 +3,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/domain/scene/i_scene_cbj_repository.dart'; import 'package:cbj_integrations_controller/domain/vendors/login_abstract/core_login_failures.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cybear_jinni/domain/device/i_device_repository.dart'; import 'package:cybear_jinni/presentation/atoms/atoms.dart'; import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; @@ -20,10 +20,10 @@ class AddSceneWidget extends StatefulWidget { class _AddSceneWidgetState extends State { String sceneName = ''; - List allDevices = []; + List allDevices = []; /// List of devices with entities, will be treated as actions - List>> + List>> allDevicesWithNewAction = []; List> allEntityActions = []; bool showErrorMessages = false; @@ -38,9 +38,9 @@ class _AddSceneWidgetState extends State { } Future _initialized() async { - List allDevicesTemp = []; + List allDevicesTemp = []; (await IDeviceRepository.instance.getAllDevices()).fold((l) => null, (r) { - allDevicesTemp = List.from(r.iter); + allDevicesTemp = List.from(r.iter); }); allDevicesTemp.removeWhere((element) => element == null); @@ -64,18 +64,18 @@ class _AddSceneWidgetState extends State { } Future _addDevicesWithNewActions( - List>> value, + List>> value, ) async { setState(() { allDevicesWithNewAction.addAll(value); }); } - // List>> + // List>> // smartDevicesWithActionToAdd, // required String actionsName, - // required List allDevices, - // required List>> + // required List allDevices, + // required List>> // allDevicesWithNewAction, // required List> allEntityActions, // required bool showErrorMessages, @@ -109,13 +109,13 @@ class _AddSceneWidgetState extends State { child: ListView.builder( itemCount: allDevicesWithNewAction.length, itemBuilder: (BuildContext context, int index) { - final MapEntry> + final MapEntry> currentDevice = allDevicesWithNewAction[index]; return Container( margin: const EdgeInsets.symmetric(vertical: 1), child: SceneActionWidget( - deviceEntityAbstract: currentDevice.key, + deviceEntityBase: currentDevice.key, propertyToChange: currentDevice.value.key ?? 'Missing property', actionToChange: currentDevice.value.value ?? @@ -147,11 +147,11 @@ class _AddSceneWidgetState extends State { ), onPressed: (_) async { final List< - MapEntry>>? actionList = await context.router.push< List< - MapEntry>>>( const AddActionRoute(), ); diff --git a/lib/presentation/pages/add_new_automation_process/add_scene/widgets/scene_action_widget.dart b/lib/presentation/pages/add_new_automation_process/add_scene/widgets/scene_action_widget.dart index 66531073..9fe0dcf3 100644 --- a/lib/presentation/pages/add_new_automation_process/add_scene/widgets/scene_action_widget.dart +++ b/lib/presentation/pages/add_new_automation_process/add_scene/widgets/scene_action_widget.dart @@ -1,5 +1,5 @@ import 'package:auto_size_text/auto_size_text.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -8,13 +8,13 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; class SceneActionWidget extends StatelessWidget { /// Get all and store all info about the action const SceneActionWidget({ - required this.deviceEntityAbstract, + required this.deviceEntityBase, required this.propertyToChange, required this.actionToChange, }); /// Cbj unique id of a device - final DeviceEntityAbstract deviceEntityAbstract; + final DeviceEntityBase deviceEntityBase; /// The action for the device final String propertyToChange; @@ -32,7 +32,7 @@ class SceneActionWidget extends StatelessWidget { color: Colors.yellow, ), title: AutoSizeText( - '${deviceEntityAbstract.cbjEntityName.getOrCrash()!} - $propertyToChange', + '${deviceEntityBase.cbjEntityName.getOrCrash()!} - $propertyToChange', maxLines: 2, ), trailing: AutoSizeText( diff --git a/lib/presentation/pages/add_new_room/widgets/add_new_room_form.dart b/lib/presentation/pages/add_new_room/widgets/add_new_room_form.dart index eec4e921..7a226040 100644 --- a/lib/presentation/pages/add_new_room/widgets/add_new_room_form.dart +++ b/lib/presentation/pages/add_new_room/widgets/add_new_room_form.dart @@ -4,7 +4,7 @@ import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/domain/room/room_failures.dart'; import 'package:cbj_integrations_controller/domain/room/value_objects_room.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cybear_jinni/domain/device/i_device_repository.dart'; import 'package:cybear_jinni/presentation/atoms/atoms.dart'; import 'package:cybear_jinni/presentation/core/snack_bar_service.dart'; @@ -21,7 +21,7 @@ class AddNewRoomForm extends StatefulWidget { class _AddNewRoomFormState extends State { List _allRooms = []; - List _allDevices = []; + List _allDevices = []; RoomUniqueId roomUniqueId = RoomUniqueId(); RoomDefaultName cbjEntityName = RoomDefaultName(''); RoomBackground background = RoomBackground( @@ -50,13 +50,13 @@ class _AddNewRoomFormState extends State { }); (await IDeviceRepository.instance.getAllDevices()).fold((l) => null, (r) { - _allDevices = List.from(r.iter); + _allDevices = List.from(r.iter); }); _allRooms.removeWhere((element) => element == null); _allDevices.removeWhere((element) => element == null); setState(() { _allRooms = _allRooms as List; - _allDevices = _allDevices as List; + _allDevices = _allDevices as List; }); } diff --git a/lib/presentation/pages/change_room_for_devices/widgets/change_room_for_devices_widget.dart b/lib/presentation/pages/change_room_for_devices/widgets/change_room_for_devices_widget.dart index afe571e1..52df2d04 100644 --- a/lib/presentation/pages/change_room_for_devices/widgets/change_room_for_devices_widget.dart +++ b/lib/presentation/pages/change_room_for_devices/widgets/change_room_for_devices_widget.dart @@ -2,7 +2,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/domain/room/i_room_repository.dart'; import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/domain/room/value_objects_room.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cybear_jinni/domain/device/i_device_repository.dart'; import 'package:cybear_jinni/presentation/atoms/atoms.dart'; import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; @@ -21,7 +21,7 @@ class ChangeRoomForDevicesWidget extends StatefulWidget { class _ChangeRoomForDevicesWidgetState extends State { List _allRooms = []; - List _allDevices = []; + List _allDevices = []; RoomUniqueId roomUniqueId = RoomUniqueId(); RoomDefaultName cbjEntityName = RoomDefaultName(''); RoomBackground background = RoomBackground( @@ -50,13 +50,13 @@ class _ChangeRoomForDevicesWidgetState }); (await IDeviceRepository.instance.getAllDevices()).fold((l) => null, (r) { - _allDevices = List.from(r.iter); + _allDevices = List.from(r.iter); }); _allRooms.removeWhere((element) => element == null); _allDevices.removeWhere((element) => element == null); setState(() { _allRooms = _allRooms as List; - _allDevices = _allDevices as List; + _allDevices = _allDevices as List; }); } diff --git a/lib/presentation/pages/connect_to_hub/widgets/cbj_hub_in_network_widget.dart b/lib/presentation/pages/connect_to_hub/widgets/cbj_hub_in_network_widget.dart index d670188a..9677c87e 100644 --- a/lib/presentation/pages/connect_to_hub/widgets/cbj_hub_in_network_widget.dart +++ b/lib/presentation/pages/connect_to_hub/widgets/cbj_hub_in_network_widget.dart @@ -1,6 +1,6 @@ import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/domain/hub/hub_failures.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cybear_jinni/domain/i_hub_connection_repository.dart'; import 'package:cybear_jinni/domain/i_phone_as_hub.dart'; import 'package:cybear_jinni/presentation/atoms/atoms.dart'; @@ -43,7 +43,7 @@ class _CbjHubInNetworkWidgetState extends State { eitherHub.fold((l) async { await IHubConnectionRepository.instance.closeConnection(); - final Map devices = + final Map devices = await IPhoneAsHub.instance.getAllEntities; if (!mounted) { diff --git a/lib/presentation/pages/connect_to_hub_more/widgets/connect_to_hub_more_widget.dart b/lib/presentation/pages/connect_to_hub_more/widgets/connect_to_hub_more_widget.dart index e9a53e7a..9b68c0e5 100644 --- a/lib/presentation/pages/connect_to_hub_more/widgets/connect_to_hub_more_widget.dart +++ b/lib/presentation/pages/connect_to_hub_more/widgets/connect_to_hub_more_widget.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'package:auto_route/auto_route.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cybear_jinni/domain/device/devices_failures.dart'; import 'package:cybear_jinni/domain/i_hub_connection_repository.dart'; import 'package:cybear_jinni/presentation/atoms/atoms.dart'; @@ -18,8 +18,7 @@ class ConnectToHubMoreWidget extends StatefulWidget { } class _ConnectToHubMoreWidgetState extends State { - StreamSubscription< - dartz.Either>>? + StreamSubscription>>? _deviceStreamSubscription; bool isLoading = false; diff --git a/lib/presentation/pages/devices_in_network_page.dart b/lib/presentation/pages/devices_in_network_page.dart index d5237281..c094b8e8 100644 --- a/lib/presentation/pages/devices_in_network_page.dart +++ b/lib/presentation/pages/devices_in_network_page.dart @@ -1,5 +1,5 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cybear_jinni/domain/i_phone_as_hub.dart'; import 'package:cybear_jinni/presentation/atoms/atoms.dart'; import 'package:cybear_jinni/presentation/core/theme_data.dart'; @@ -13,7 +13,7 @@ class DevicesInNetworkPage extends StatefulWidget { } class _DevicesInNetworkPageState extends State { - List? allDevices; + List? allDevices; @override void initState() { @@ -22,7 +22,7 @@ class _DevicesInNetworkPageState extends State { } Future initializeAllDevices() async { - final Map devices = + final Map devices = await IPhoneAsHub.instance.getAllEntities; setState(() { allDevices = devices.values.toList(); @@ -63,7 +63,7 @@ class _DevicesInNetworkPageState extends State { child: ListViewSeparatedMolecule( itemCount: allDevices!.length, itemBuilder: (context, index) { - final DeviceEntityAbstract device = allDevices!.elementAt(index); + final DeviceEntityBase device = allDevices!.elementAt(index); final String? deviceLastKnownIp = device.deviceLastKnownIp.getOrCrash(); diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/blinds_in_the_room.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/blinds_in_the_room.dart index a279dcfb..db255999 100644 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/blinds_in_the_room.dart +++ b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/blinds_in_the_room.dart @@ -5,7 +5,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:auto_size_text/auto_size_text.dart'; import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_blinds_entity/generic_blinds_entity.dart'; import 'package:cybear_jinni/domain/i_phone_as_hub.dart'; @@ -25,7 +25,7 @@ class BlindsInTheRoom extends StatefulWidget { factory BlindsInTheRoom.withAbstractDevice({ required RoomEntity roomEntity, - required List tempDeviceInRoom, + required List tempDeviceInRoom, required ListOfColors tempRoomColorGradiant, }) { final List tempLightsInRoom = []; diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/boilers_in_the_room.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/boilers_in_the_room.dart index a3842a4b..4d6d7c9f 100644 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/boilers_in_the_room.dart +++ b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/boilers_in_the_room.dart @@ -2,7 +2,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:auto_size_text/auto_size_text.dart'; import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_boiler_entity/generic_boiler_entity.dart'; import 'package:cybear_jinni/presentation/atoms/atoms.dart'; import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; @@ -20,7 +20,7 @@ class BoilersInTheRoom extends StatelessWidget { factory BoilersInTheRoom.withAbstractDevice({ required RoomEntity roomEntity, - required List tempDeviceInRoom, + required List tempDeviceInRoom, required ListOfColors tempRoomColorGradiant, }) { final List tempLightsInRoom = []; diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/lights_in_the_room_block.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/lights_in_the_room_block.dart index 2caa6880..fa0b9543 100644 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/lights_in_the_room_block.dart +++ b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/lights_in_the_room_block.dart @@ -5,7 +5,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:auto_size_text/auto_size_text.dart'; import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_dimmable_light_entity/generic_dimmable_light_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_light_entity/generic_light_entity.dart'; @@ -31,7 +31,7 @@ class LightsInTheRoomBlock extends StatefulWidget { factory LightsInTheRoomBlock.withAbstractDevice({ required RoomEntity roomEntity, - required List entities, + required List entities, required ListOfColors tempRoomColorGradiant, }) { final List tempLightsInRoom = []; @@ -67,7 +67,7 @@ class LightsInTheRoomBlock extends StatefulWidget { final List dimmableLightsInRoom; final List rgbwLightsInRoom; final ListOfColors roomColorGradiant; - final List entities; + final List entities; @override State createState() => _LightsInTheRoomBlockState(); @@ -115,7 +115,7 @@ class _LightsInTheRoomBlockState extends State { final HashMap> uniqueIdByVendor = HashMap(); - for (final DeviceEntityAbstract? element in widget.entities) { + for (final DeviceEntityBase? element in widget.entities) { final VendorsAndServices? vendor = element?.cbjDeviceVendor.vendorsAndServices; diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/printers_in_the_room_block.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/printers_in_the_room_block.dart index 558d08bf..84e80fdd 100644 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/printers_in_the_room_block.dart +++ b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/printers_in_the_room_block.dart @@ -2,7 +2,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:auto_size_text/auto_size_text.dart'; import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_printer_entity/generic_printer_entity.dart'; import 'package:cybear_jinni/presentation/atoms/atoms.dart'; import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; @@ -20,7 +20,7 @@ class PrintersInTheRoomBlock extends StatelessWidget { factory PrintersInTheRoomBlock.withAbstractDevice({ required RoomEntity roomEntityTemp, - required List tempDeviceInRoom, + required List tempDeviceInRoom, required ListOfColors tempRoomColorGradiant, }) { final List tempPrintersInRoom = []; diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/security_cameras_in_the_room_block.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/security_cameras_in_the_room_block.dart index 0a74086a..e7ac3e11 100644 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/security_cameras_in_the_room_block.dart +++ b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/security_cameras_in_the_room_block.dart @@ -1,7 +1,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:auto_size_text/auto_size_text.dart'; import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_security_camera_entity/generic_security_camera_entity.dart'; import 'package:cybear_jinni/presentation/atoms/atoms.dart'; import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; @@ -19,7 +19,7 @@ class SecurityCamerasInTheRoomBlock extends StatelessWidget { factory SecurityCamerasInTheRoomBlock.withAbstractDevice({ required RoomEntity roomEntityTemp, - required List tempDeviceInRoom, + required List tempDeviceInRoom, required ListOfColors tempRoomColorGradiant, }) { final List tempSecurityCamerasInRoom = []; diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_computers_in_the_room_block.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_computers_in_the_room_block.dart index 33c631ee..fe114741 100644 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_computers_in_the_room_block.dart +++ b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_computers_in_the_room_block.dart @@ -2,7 +2,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:auto_size_text/auto_size_text.dart'; import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_smart_computer_entity/generic_smart_computer_entity.dart'; import 'package:cybear_jinni/presentation/atoms/atoms.dart'; import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; @@ -20,7 +20,7 @@ class SmartComputersInTheRoomBlock extends StatelessWidget { factory SmartComputersInTheRoomBlock.withAbstractDevice({ required RoomEntity roomEntityTemp, - required List tempDeviceInRoom, + required List tempDeviceInRoom, required ListOfColors tempRoomColorGradiant, }) { final List tempSmartComputersInRoom = []; diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_plug_in_the_room_block.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_plug_in_the_room_block.dart index 221b7332..9d3bee1a 100644 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_plug_in_the_room_block.dart +++ b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_plug_in_the_room_block.dart @@ -5,7 +5,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:auto_size_text/auto_size_text.dart'; import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_smart_plug_entity/generic_smart_plug_entity.dart'; import 'package:cybear_jinni/domain/i_phone_as_hub.dart'; @@ -26,7 +26,7 @@ class SmartPlugsInTheRoomBlock extends StatefulWidget { factory SmartPlugsInTheRoomBlock.withAbstractDevice({ required RoomEntity roomEntityTemp, - required List entities, + required List entities, required ListOfColors tempRoomColorGradiant, }) { final List tempSmartPlugsInRoom = []; @@ -46,7 +46,7 @@ class SmartPlugsInTheRoomBlock extends StatefulWidget { final RoomEntity roomEntity; final List smartPlugsInRoom; final ListOfColors roomColorGradiant; - final List entities; + final List entities; @override State createState() => @@ -95,7 +95,7 @@ class _SmartPlugsInTheRoomBlockState extends State { final HashMap> uniqueIdByVendor = HashMap(); - for (final DeviceEntityAbstract? element in widget.entities) { + for (final DeviceEntityBase? element in widget.entities) { final VendorsAndServices? vendor = element?.cbjDeviceVendor.vendorsAndServices; diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_tv_in_the_room.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_tv_in_the_room.dart index 0aac857c..ed37dafc 100644 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_tv_in_the_room.dart +++ b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_tv_in_the_room.dart @@ -2,7 +2,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:auto_size_text/auto_size_text.dart'; import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_smart_tv_entity/generic_smart_tv_entity.dart'; import 'package:cybear_jinni/presentation/atoms/atoms.dart'; import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; @@ -20,7 +20,7 @@ class SmartTvInTheRoom extends StatelessWidget { factory SmartTvInTheRoom.withAbstractDevice({ required RoomEntity roomEntity, - required List tempDeviceInRoom, + required List tempDeviceInRoom, required ListOfColors tempRoomColorGradiant, }) { final List tempLightsInRoom = []; diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/switches_in_the_room_block.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/switches_in_the_room_block.dart index bae962a9..4bbf3cba 100644 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/switches_in_the_room_block.dart +++ b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/switches_in_the_room_block.dart @@ -5,7 +5,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:auto_size_text/auto_size_text.dart'; import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_switch_entity/generic_switch_entity.dart'; import 'package:cybear_jinni/domain/i_phone_as_hub.dart'; @@ -26,7 +26,7 @@ class SwitchesInTheRoomBlock extends StatefulWidget { factory SwitchesInTheRoomBlock.withAbstractDevice({ required RoomEntity roomEntityTemp, - required List entities, + required List entities, required ListOfColors tempRoomColorGradiant, }) { final List tempSwitchesInRoom = []; @@ -46,7 +46,7 @@ class SwitchesInTheRoomBlock extends StatefulWidget { final RoomEntity roomEntity; final List switchesInRoom; final ListOfColors roomColorGradiant; - final List entities; + final List entities; @override State createState() => _SwitchesInTheRoomBlockState(); @@ -100,7 +100,7 @@ class _SwitchesInTheRoomBlockState extends State { final HashMap> uniqueIdByVendor = HashMap(); - for (final DeviceEntityAbstract? element in widget.entities) { + for (final DeviceEntityBase? element in widget.entities) { final VendorsAndServices? vendor = element?.cbjDeviceVendor.vendorsAndServices; diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/rooms_widgets/rom_widget.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/rooms_widgets/rom_widget.dart index 8e4bd3ce..74a75272 100644 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/rooms_widgets/rom_widget.dart +++ b/lib/presentation/pages/home_page/tabs/smart_devices_tab/rooms_widgets/rom_widget.dart @@ -1,7 +1,7 @@ import 'package:another_flushbar/flushbar_helper.dart'; import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cybear_jinni/infrastructure/core/logger.dart'; import 'package:cybear_jinni/presentation/atoms/atoms.dart'; import 'package:cybear_jinni/presentation/core/theme_data.dart'; @@ -37,7 +37,7 @@ class RoomWidget extends StatefulWidget { final double borderRadius; final ListOfColors roomColorGradiant; final List roomsList; - final Map>> + final Map>> tempDevicesByRoomsByType; final String roomId; final int numberOfDevicesInTheRoom; @@ -156,7 +156,7 @@ class _RoomWidgetState extends State { .tempDevicesByRoomsByType[widget.roomId]!.keys .elementAt(secondIndex); - List devicesInTheRoom = widget + List devicesInTheRoom = widget .tempDevicesByRoomsByType[widget.roomId]![deviceType]!; if (deviceType == EntityTypes.light.toString() || @@ -169,20 +169,19 @@ class _RoomWidgetState extends State { devicesInTheRoom = []; - final List? - tempLightDevicesInTheRoom = + final List? tempLightDevicesInTheRoom = widget.tempDevicesByRoomsByType[widget.roomId] ?[EntityTypes.light.toString()]; devicesInTheRoom.addAll(tempLightDevicesInTheRoom ?? []); - final List? + final List? tempDimmableLightDevicesInTheRoom = widget.tempDevicesByRoomsByType[widget.roomId] ?[EntityTypes.dimmableLight.toString()]; devicesInTheRoom .addAll(tempDimmableLightDevicesInTheRoom ?? []); - final List? + final List? tempRgbwLightDevicesInTheRoom = widget.tempDevicesByRoomsByType[widget.roomId] ?[EntityTypes.rgbwLights.toString()]; diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/rooms_widgets/rooms_list_view_widget.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/rooms_widgets/rooms_list_view_widget.dart index 862fd214..d30cfd68 100644 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/rooms_widgets/rooms_list_view_widget.dart +++ b/lib/presentation/pages/home_page/tabs/smart_devices_tab/rooms_widgets/rooms_list_view_widget.dart @@ -3,7 +3,7 @@ import 'dart:io'; import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/domain/room/value_objects_room.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_blinds_entity/generic_blinds_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_boiler_entity/generic_boiler_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_dimmable_light_entity/generic_dimmable_light_entity.dart'; @@ -33,8 +33,8 @@ class RoomsListViewWidget extends StatefulWidget { required this.roomsList, }); - final Map> tempDevicesByRooms; - final List devicesList; + final Map> tempDevicesByRooms; + final List devicesList; final List roomsList; @override @@ -75,13 +75,13 @@ class _RoomsListViewWidgetState extends State { /// RoomId than TypeName than list of devices of this type in /// this room - Map>> + Map>> mapOfRoomsIdWithListOfDevices({ - required Map> tempDevicesByRooms, + required Map> tempDevicesByRooms, }) { - final Map>> + final Map>> tempDevicesByRoomsByType = - >>{}; + >>{}; tempDevicesByRooms.forEach((k, v) { tempDevicesByRoomsByType[k!] = {}; @@ -100,7 +100,7 @@ class _RoomsListViewWidgetState extends State { return tempDevicesByRoomsByType; } - bool isDeviceShouldBeSownInSummaryRoom(DeviceEntityAbstract deviceEntity) { + bool isDeviceShouldBeSownInSummaryRoom(DeviceEntityBase deviceEntity) { final String onAction = EntityActions.on.toString(); if (deviceEntity is GenericBlindsDE) { @@ -134,14 +134,14 @@ class _RoomsListViewWidgetState extends State { return false; } - Map> listOfDevicesInDiscoveredRoom({ + Map> listOfDevicesInDiscoveredRoom({ required List rooms, - required List devicesList, + required List devicesList, }) { - final List devicesListTemp = List.from(devicesList); + final List devicesListTemp = List.from(devicesList); - final Map> tempDevicesByRooms = - >{}; + final Map> tempDevicesByRooms = + >{}; /// Adding discovered room first so it will be the last in /// the list @@ -156,7 +156,7 @@ class _RoomsListViewWidgetState extends State { for (final String deviceId in room.roomDevicesId.getOrCrash()) { /// Check if app already received the device, it could also /// be on the way - for (final DeviceEntityAbstract? device in devicesListTemp) { + for (final DeviceEntityBase? device in devicesListTemp) { if (device != null && device.deviceCbjUniqueId.getOrCrash() == deviceId) { tempDevicesByRooms[roomId]!.add(device); @@ -176,14 +176,14 @@ class _RoomsListViewWidgetState extends State { return tempDevicesByRooms; } - Map> listOfDevicesInRooms({ + Map> listOfDevicesInRooms({ required List rooms, - required List devicesList, + required List devicesList, }) { - final List devicesListTemp = List.from(devicesList); + final List devicesListTemp = List.from(devicesList); - final Map> tempDevicesByRooms = - >{}; + final Map> tempDevicesByRooms = + >{}; /// Loops on the rooms for (final RoomEntity? room in rooms) { @@ -197,7 +197,7 @@ class _RoomsListViewWidgetState extends State { for (final String deviceId in room.roomDevicesId.getOrCrash()) { /// Check if app already received the device, it could also /// be on the way - for (final DeviceEntityAbstract? device in devicesListTemp) { + for (final DeviceEntityBase? device in devicesListTemp) { if (device != null && device.deviceCbjUniqueId.getOrCrash() == deviceId) { tempDevicesByRooms[roomId]!.add(device); @@ -216,12 +216,12 @@ class _RoomsListViewWidgetState extends State { return tempDevicesByRooms; } - Map> listOfDevicesInSummaryArea({ + Map> listOfDevicesInSummaryArea({ required List rooms, - required List devicesList, + required List devicesList, }) { - final Map> tempDevicesByRooms = - >{}; + final Map> tempDevicesByRooms = + >{}; // /// All Devices area // final RoomEntity allDevicesRoom = RoomEntity.empty().copyWith( // cbjEntityName: RoomDefaultName('All_Devices'.tr()), @@ -229,7 +229,7 @@ class _RoomsListViewWidgetState extends State { // final String allDevicesRoomId = allDevicesRoom.uniqueId.getOrCrash(); // tempDevicesByRooms[allDevicesRoomId] = []; // - // for (final DeviceEntityAbstract? device in devicesList) { + // for (final DeviceEntityBase? device in devicesList) { // if (device != null) { // allDevicesRoom.addDeviceId(device.uniqueId.getOrCrash()); // tempDevicesByRooms[allDevicesRoomId]!.add(device); @@ -245,7 +245,7 @@ class _RoomsListViewWidgetState extends State { final String summaryRoomId = summaryDevicesRoom.uniqueId.getOrCrash(); tempDevicesByRooms[summaryRoomId] = []; - for (final DeviceEntityAbstract? device in devicesList) { + for (final DeviceEntityBase? device in devicesList) { if (device != null && isDeviceShouldBeSownInSummaryRoom(device)) { summaryDevicesRoom.addDeviceId(device.deviceCbjUniqueId.getOrCrash()); tempDevicesByRooms[summaryRoomId]!.add(device); @@ -258,13 +258,12 @@ class _RoomsListViewWidgetState extends State { @override Widget build(BuildContext context) { - final Map> tempDevicesByRooms = - Map>.from( + final Map> tempDevicesByRooms = + Map>.from( widget.tempDevicesByRooms, ); - final List devicesList = - List.from(widget.devicesList); + final List devicesList = List.from(widget.devicesList); final List roomsList = List.from(widget.roomsList); tempDevicesByRooms.addAll( @@ -290,9 +289,9 @@ class _RoomsListViewWidgetState extends State { ); } - final Map>> + final Map>> tempDevicesByRoomsByType = - >>{}; + >>{}; tempDevicesByRoomsByType.addAll( mapOfRoomsIdWithListOfDevices( @@ -303,9 +302,8 @@ class _RoomsListViewWidgetState extends State { List objectList = []; tempDevicesByRoomsByType.forEach((key, value) { - final MapEntry>> - tempEntry = - MapEntry>>(key, value); + final MapEntry>> tempEntry = + MapEntry>>(key, value); objectList.add(tempEntry); }); @@ -365,8 +363,7 @@ class _RoomsListViewWidgetState extends State { ), ); } - if (adOrRoom - is MapEntry>>) { + if (adOrRoom is MapEntry>>) { gradientColorCounter++; // Don't make the last room pain blue as this will look the same with // Summary room blue diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/smart_devices_by_rooms.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/smart_devices_by_rooms.dart index 997ecbf9..85ca006d 100644 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/smart_devices_by_rooms.dart +++ b/lib/presentation/pages/home_page/tabs/smart_devices_tab/smart_devices_by_rooms.dart @@ -4,7 +4,7 @@ import 'package:cbj_integrations_controller/domain/room/i_room_repository.dart'; import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/domain/room/room_failures.dart'; import 'package:cbj_integrations_controller/domain/room/value_objects_room.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cybear_jinni/domain/device/devices_failures.dart'; import 'package:cybear_jinni/domain/i_phone_as_hub.dart'; import 'package:cybear_jinni/presentation/atoms/atoms.dart'; @@ -22,16 +22,14 @@ class SmartDevicesByRooms extends StatefulWidget { class _SmartDevicesByRoomsState extends State { KtList rooms = const KtList.empty(); - KtList devices = - const KtList.empty(); - KtList listOfDevices = [null].toImmutableList(); + KtList devices = const KtList.empty(); + KtList listOfDevices = [null].toImmutableList(); KtList listOfRooms = [null].toImmutableList(); StreamSubscription>>? _roomStreamSubscription; - StreamSubscription< - dartz.Either>>? + StreamSubscription>>? _deviceStreamSubscription; late RoomEntity discoveredRoom; @@ -48,11 +46,11 @@ class _SmartDevicesByRoomsState extends State { } Future _devicesReceived( - dartz.Either, KtList> + dartz.Either, KtList> failureOrDevices, ) async { - final KtList devicesTemp = failureOrDevices.fold( - (f) => const KtList.empty(), + final KtList devicesTemp = failureOrDevices.fold( + (f) => const KtList.empty(), (d) => d, ); setState(() { @@ -83,7 +81,7 @@ class _SmartDevicesByRoomsState extends State { ), ); - final Map allDevice = + final Map allDevice = await IPhoneAsHub.instance.getAllEntities; for (final String deviceId in allDevice.keys) { @@ -124,10 +122,10 @@ class _SmartDevicesByRoomsState extends State { child: EmptyOpenRoomOrganism(), ); } - final Map> tempDevicesByRooms = - >{}; + final Map> tempDevicesByRooms = + >{}; - final List devicesList = devices.iter.toList(); + final List devicesList = devices.iter.toList(); return SingleChildScrollView( reverse: true,