updated project hardcoded values

This commit is contained in:
hannathkadher
2025-02-16 20:55:13 +04:00
parent 67209961b4
commit 3f7f7ce49f
16 changed files with 199 additions and 77 deletions

View File

@ -10,6 +10,7 @@ import 'package:share_plus/share_plus.dart';
import 'package:syncrow_app/features/app_layout/model/permission_model.dart'; import 'package:syncrow_app/features/app_layout/model/permission_model.dart';
import 'package:syncrow_app/features/app_layout/model/space_model.dart'; import 'package:syncrow_app/features/app_layout/model/space_model.dart';
import 'package:syncrow_app/features/app_layout/view/widgets/app_bar_home_dropdown.dart'; import 'package:syncrow_app/features/app_layout/view/widgets/app_bar_home_dropdown.dart';
import 'package:syncrow_app/features/auth/model/project_model.dart';
import 'package:syncrow_app/features/auth/model/user_model.dart'; import 'package:syncrow_app/features/auth/model/user_model.dart';
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart'; import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
import 'package:syncrow_app/features/devices/model/subspace_model.dart'; import 'package:syncrow_app/features/devices/model/subspace_model.dart';
@ -28,6 +29,7 @@ import 'package:syncrow_app/navigation/routing_constants.dart';
import 'package:syncrow_app/services/api/devices_api.dart'; import 'package:syncrow_app/services/api/devices_api.dart';
import 'package:syncrow_app/services/api/profile_api.dart'; import 'package:syncrow_app/services/api/profile_api.dart';
import 'package:syncrow_app/services/api/spaces_api.dart'; import 'package:syncrow_app/services/api/spaces_api.dart';
import 'package:syncrow_app/utils/constants/temp_const.dart';
import 'package:syncrow_app/utils/helpers/snack_bar.dart'; import 'package:syncrow_app/utils/helpers/snack_bar.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
part 'home_state.dart'; part 'home_state.dart';
@ -67,6 +69,8 @@ class HomeCubit extends Cubit<HomeState> {
var uuid = var uuid =
await const FlutterSecureStorage().read(key: UserModel.userUuidKey); await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
user = await ProfileApi().fetchUserInfo(uuid); user = await ProfileApi().fetchUserInfo(uuid);
project = user?.project;
emit(HomeUserInfoLoaded(user!)); emit(HomeUserInfoLoaded(user!));
} catch (e) { } catch (e) {
return; return;
@ -175,6 +179,8 @@ class HomeCubit extends Cubit<HomeState> {
SubSpaceModel? selectedRoom; SubSpaceModel? selectedRoom;
Project? project;
PageController devicesPageController = PageController(); PageController devicesPageController = PageController();
PageController roomsPageController = PageController(); PageController roomsPageController = PageController();
@ -324,8 +330,8 @@ class HomeCubit extends Cubit<HomeState> {
//////////////////////////////////////// API //////////////////////////////////////// //////////////////////////////////////// API ////////////////////////////////////////
generateInvitation(SpaceModel unit) async { generateInvitation(SpaceModel unit) async {
try { try {
final invitationCode = final invitationCode = await SpacesAPI.generateInvitationCode(unit.id,
await SpacesAPI.generateInvitationCode(unit.id, unit.community.uuid); unit.community.uuid, project?.uuid ?? TempConst.projectIdDev);
if (invitationCode.isNotEmpty) { if (invitationCode.isNotEmpty) {
Share.share('The invitation code is $invitationCode'); Share.share('The invitation code is $invitationCode');
CustomSnackBar.displaySnackBar( CustomSnackBar.displaySnackBar(
@ -380,8 +386,10 @@ class HomeCubit extends Cubit<HomeState> {
fetchRoomsByUnitId(SpaceModel space) async { fetchRoomsByUnitId(SpaceModel space) async {
emitSafe(GetSpaceRoomsLoading()); emitSafe(GetSpaceRoomsLoading());
try { try {
space.subspaces = space.subspaces = await SpacesAPI.getSubSpaceBySpaceId(
await SpacesAPI.getSubSpaceBySpaceId(space.community.uuid, space.id); space.community.uuid,
space.id,
project?.uuid ?? TempConst.projectIdDev);
} catch (failure) { } catch (failure) {
emitSafe(GetSpaceRoomsError(failure.toString())); emitSafe(GetSpaceRoomsError(failure.toString()));
return; return;
@ -414,7 +422,6 @@ class HomeCubit extends Cubit<HomeState> {
emitSafe(ActivationError(errMessage: errorMsg)); emitSafe(ActivationError(errMessage: errorMsg));
return false; return false;
} }
} }
/////////////////////////////////////// Nav /////////////////////////////////////// /////////////////////////////////////// Nav ///////////////////////////////////////

View File

@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart'; import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/auth/model/project_model.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_event.dart'; import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart'; import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart';
import 'package:syncrow_app/features/devices/model/device_control_model.dart'; import 'package:syncrow_app/features/devices/model/device_control_model.dart';
@ -16,6 +17,7 @@ import 'package:syncrow_app/services/api/devices_api.dart';
import 'package:syncrow_app/services/api/home_management_api.dart'; import 'package:syncrow_app/services/api/home_management_api.dart';
import 'package:syncrow_app/services/api/scene_api.dart'; import 'package:syncrow_app/services/api/scene_api.dart';
import 'package:syncrow_app/services/api/spaces_api.dart'; import 'package:syncrow_app/services/api/spaces_api.dart';
import 'package:syncrow_app/utils/constants/temp_const.dart';
import 'package:syncrow_app/utils/helpers/snack_bar.dart'; import 'package:syncrow_app/utils/helpers/snack_bar.dart';
class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> { class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
@ -112,8 +114,9 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
FetchRoomsEvent event, Emitter<SixSceneState> emit) async { FetchRoomsEvent event, Emitter<SixSceneState> emit) async {
try { try {
emit(SixSceneLoadingState()); emit(SixSceneLoadingState());
Project? project = HomeCubit.getInstance().project;
roomsList = await SpacesAPI.getSubSpaceBySpaceId( roomsList = await SpacesAPI.getSubSpaceBySpaceId(
event.unit.community.uuid, event.unit.id); event.unit.community.uuid, event.unit.id, project?.uuid ?? TempConst.projectIdDev);
emit(FetchRoomsState(devicesList: allDevices, roomsList: roomsList)); emit(FetchRoomsState(devicesList: allDevices, roomsList: roomsList));
} catch (e) { } catch (e) {
emit(SixSceneFailedState(errorMessage: e.toString())); emit(SixSceneFailedState(errorMessage: e.toString()));
@ -125,12 +128,14 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
try { try {
emit(SixSceneLoadingState()); emit(SixSceneLoadingState());
if (_hasSelectionChanged) { if (_hasSelectionChanged) {
Project? project = HomeCubit.getInstance().project;
await HomeManagementAPI.assignDeviceToRoom( await HomeManagementAPI.assignDeviceToRoom(
event.unit.community.uuid, event.unit.id, event.roomId, sixSceneId); event.unit.community.uuid, event.unit.id, event.roomId, sixSceneId, project?.uuid ?? TempConst.projectIdDev);
final devicesList = await DevicesAPI.getDevicesByRoomId( final devicesList = await DevicesAPI.getDevicesByRoomId(
communityUuid: event.unit.community.uuid, communityUuid: event.unit.community.uuid,
spaceUuid: event.unit.id, spaceUuid: event.unit.id,
roomId: event.roomId); roomId: event.roomId,
projectId: project?.uuid ?? TempConst.projectIdDev);
List<String> allDevicesIds = []; List<String> allDevicesIds = [];
allDevices.forEach((element) { allDevices.forEach((element) {
allDevicesIds.add(element.uuid!); allDevicesIds.add(element.uuid!);
@ -341,8 +346,10 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
emit(SixSceneLoadingState()); emit(SixSceneLoadingState());
try { try {
Project? project = HomeCubit.getInstance().project;
allScenes = await SceneApi.getScenesByUnitId( allScenes = await SceneApi.getScenesByUnitId(
event.unitId, event.unit.community.uuid, event.unitId, event.unit.community.uuid, project?.uuid ?? TempConst.projectIdDev,
showInDevice: event.showInDevice); showInDevice: event.showInDevice);
filteredScenes = allScenes; filteredScenes = allScenes;

View File

@ -2,6 +2,8 @@ import 'dart:async';
import 'package:bloc/bloc.dart'; import 'package:bloc/bloc.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/auth/model/project_model.dart';
import 'package:syncrow_app/features/devices/bloc/device_manager_bloc/device_manager_event.dart'; import 'package:syncrow_app/features/devices/bloc/device_manager_bloc/device_manager_event.dart';
import 'package:syncrow_app/features/devices/bloc/device_manager_bloc/device_manager_state.dart'; import 'package:syncrow_app/features/devices/bloc/device_manager_bloc/device_manager_state.dart';
@ -10,6 +12,7 @@ import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/services/api/devices_api.dart'; import 'package:syncrow_app/services/api/devices_api.dart';
import 'package:syncrow_app/services/api/home_management_api.dart'; import 'package:syncrow_app/services/api/home_management_api.dart';
import 'package:syncrow_app/utils/constants/temp_const.dart';
import 'package:syncrow_app/utils/resource_manager/constants.dart'; import 'package:syncrow_app/utils/resource_manager/constants.dart';
class DeviceManagerBloc extends Bloc<DeviceManagerEvent, DeviceManagerState> { class DeviceManagerBloc extends Bloc<DeviceManagerEvent, DeviceManagerState> {
@ -27,11 +30,16 @@ class DeviceManagerBloc extends Bloc<DeviceManagerEvent, DeviceManagerState> {
static List<DevicesCategoryModel>? allCategories; static List<DevicesCategoryModel>? allCategories;
Future<void> _onFetchAllDevices(FetchAllDevices event, Emitter<DeviceManagerState> emit) async { Future<void> _onFetchAllDevices(
FetchAllDevices event, Emitter<DeviceManagerState> emit) async {
emit(state.copyWith(loading: true)); emit(state.copyWith(loading: true));
try { try {
final allDevices = await HomeManagementAPI.fetchDevicesByUnitId(); Project? project = HomeCubit.getInstance().project;
emit(state.copyWith(devices: _getOnlyImplementedDevices(allDevices), loading: false));
final allDevices = await HomeManagementAPI.fetchDevicesByUnitId(
project?.uuid ?? TempConst.projectIdDev);
emit(state.copyWith(
devices: _getOnlyImplementedDevices(allDevices), loading: false));
} catch (e) { } catch (e) {
emit(state.copyWith(error: e.toString(), loading: false)); emit(state.copyWith(error: e.toString(), loading: false));
} }
@ -41,26 +49,31 @@ class DeviceManagerBloc extends Bloc<DeviceManagerEvent, DeviceManagerState> {
FetchDevicesByRoomId event, Emitter<DeviceManagerState> emit) async { FetchDevicesByRoomId event, Emitter<DeviceManagerState> emit) async {
emit(state.copyWith(loading: true)); emit(state.copyWith(loading: true));
try { try {
final devices = await DevicesAPI.getDevicesByRoomId( Project? project = HomeCubit.getInstance().project;
communityUuid: event.unit.community.uuid,
spaceUuid: event.unit.id,
roomId: event.roomId,
);
emit(state.copyWith(devices: _getOnlyImplementedDevices(devices), loading: false)); final devices = await DevicesAPI.getDevicesByRoomId(
communityUuid: event.unit.community.uuid,
spaceUuid: event.unit.id,
roomId: event.roomId,
projectId: project?.uuid ?? TempConst.projectIdDev);
emit(state.copyWith(
devices: _getOnlyImplementedDevices(devices), loading: false));
} catch (e) { } catch (e) {
emit(state.copyWith(error: e.toString(), loading: false)); emit(state.copyWith(error: e.toString(), loading: false));
} }
} }
void _onSelectCategory(SelectCategory event, Emitter<DeviceManagerState> emit) { void _onSelectCategory(
SelectCategory event, Emitter<DeviceManagerState> emit) {
for (var i = 0; i < allCategories!.length; i++) { for (var i = 0; i < allCategories!.length; i++) {
allCategories![i].isSelected = i == event.index; allCategories![i].isSelected = i == event.index;
} }
emit(state.copyWith(categoryChanged: true)); emit(state.copyWith(categoryChanged: true));
} }
void _onUnselectAllCategories(UnselectAllCategories event, Emitter<DeviceManagerState> emit) { void _onUnselectAllCategories(
UnselectAllCategories event, Emitter<DeviceManagerState> emit) {
for (var category in allCategories!) { for (var category in allCategories!) {
category.isSelected = false; category.isSelected = false;
} }
@ -104,7 +117,8 @@ class DeviceManagerBloc extends Bloc<DeviceManagerEvent, DeviceManagerState> {
_updateDevicesStatus(category, emit); _updateDevicesStatus(category, emit);
} }
void _onTurnOnOffDevice(TurnOnOffDevice event, Emitter<DeviceManagerState> emit) { void _onTurnOnOffDevice(
TurnOnOffDevice event, Emitter<DeviceManagerState> emit) {
var device = event.device; var device = event.device;
device.isOnline = !device.isOnline!; device.isOnline = !device.isOnline!;
DevicesCategoryModel category = allCategories!.firstWhere((category) { DevicesCategoryModel category = allCategories!.firstWhere((category) {
@ -127,7 +141,8 @@ class DeviceManagerBloc extends Bloc<DeviceManagerEvent, DeviceManagerState> {
emit(state.copyWith(categoryChanged: true)); // Set category changed state emit(state.copyWith(categoryChanged: true)); // Set category changed state
} }
void _updateDevicesStatus(DevicesCategoryModel category, Emitter<DeviceManagerState> emit) { void _updateDevicesStatus(
DevicesCategoryModel category, Emitter<DeviceManagerState> emit) {
if (category.devices != null && category.devices!.isNotEmpty) { if (category.devices != null && category.devices!.isNotEmpty) {
bool? tempStatus = category.devices![0].isOnline; bool? tempStatus = category.devices![0].isOnline;
for (var device in category.devices!) { for (var device in category.devices!) {
@ -147,7 +162,8 @@ class DeviceManagerBloc extends Bloc<DeviceManagerEvent, DeviceManagerState> {
try { try {
final deviceFunctions = await DevicesAPI.deviceFunctions(event.deviceId); final deviceFunctions = await DevicesAPI.deviceFunctions(event.deviceId);
emit(state.copyWith(functionsLoading: false, deviceFunctions: deviceFunctions)); emit(state.copyWith(
functionsLoading: false, deviceFunctions: deviceFunctions));
} catch (e) { } catch (e) {
emit(state.copyWith(functionsLoading: false, error: e.toString())); emit(state.copyWith(functionsLoading: false, error: e.toString()));
} }

View File

@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart'; import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/auth/model/project_model.dart';
import 'package:syncrow_app/features/devices/bloc/device_settings_bloc/device_scene_event.dart'; import 'package:syncrow_app/features/devices/bloc/device_settings_bloc/device_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/device_settings_bloc/device_scene_state.dart'; import 'package:syncrow_app/features/devices/bloc/device_settings_bloc/device_scene_state.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart'; import 'package:syncrow_app/features/devices/model/device_model.dart';
@ -18,6 +19,7 @@ import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/services/api/devices_api.dart'; import 'package:syncrow_app/services/api/devices_api.dart';
import 'package:syncrow_app/services/api/home_management_api.dart'; import 'package:syncrow_app/services/api/home_management_api.dart';
import 'package:syncrow_app/services/api/spaces_api.dart'; import 'package:syncrow_app/services/api/spaces_api.dart';
import 'package:syncrow_app/utils/constants/temp_const.dart';
import 'package:syncrow_app/utils/helpers/snack_bar.dart'; import 'package:syncrow_app/utils/helpers/snack_bar.dart';
class DeviceSettingBloc extends Bloc<DeviceSettingEvent, DeviceSettingState> { class DeviceSettingBloc extends Bloc<DeviceSettingEvent, DeviceSettingState> {
@ -349,13 +351,20 @@ class DeviceSettingBloc extends Bloc<DeviceSettingEvent, DeviceSettingState> {
AssignRoomEvent event, Emitter<DeviceSettingState> emit) async { AssignRoomEvent event, Emitter<DeviceSettingState> emit) async {
try { try {
emit(DeviceSettingLoadingState()); emit(DeviceSettingLoadingState());
Project? project = HomeCubit.getInstance().project;
if (_hasSelectionChanged) { if (_hasSelectionChanged) {
await HomeManagementAPI.assignDeviceToRoom( await HomeManagementAPI.assignDeviceToRoom(
event.unit.community.uuid, event.unit.id, event.roomId, deviceId); event.unit.community.uuid,
event.unit.id,
event.roomId,
deviceId,
project?.uuid ?? TempConst.projectIdDev);
final devicesList = await DevicesAPI.getDevicesByRoomId( final devicesList = await DevicesAPI.getDevicesByRoomId(
communityUuid: event.unit.community.uuid, communityUuid: event.unit.community.uuid,
spaceUuid: event.unit.id, spaceUuid: event.unit.id,
roomId: event.roomId); roomId: event.roomId,
projectId: project?.uuid ?? TempConst.projectIdDev);
List<String> allDevicesIds = []; List<String> allDevicesIds = [];
allDevices.forEach((element) { allDevices.forEach((element) {
allDevicesIds.add(element.uuid!); allDevicesIds.add(element.uuid!);
@ -375,8 +384,12 @@ class DeviceSettingBloc extends Bloc<DeviceSettingEvent, DeviceSettingState> {
FetchRoomsEvent event, Emitter<DeviceSettingState> emit) async { FetchRoomsEvent event, Emitter<DeviceSettingState> emit) async {
try { try {
emit(DeviceSettingLoadingState()); emit(DeviceSettingLoadingState());
Project? project = HomeCubit.getInstance().project;
roomsList = await SpacesAPI.getSubSpaceBySpaceId( roomsList = await SpacesAPI.getSubSpaceBySpaceId(
event.unit.community.uuid, event.unit.id); event.unit.community.uuid,
event.unit.id,
project?.uuid ?? TempConst.projectIdDev);
emit(FetchRoomsState(devicesList: allDevices, roomsList: roomsList)); emit(FetchRoomsState(devicesList: allDevices, roomsList: roomsList));
} catch (e) { } catch (e) {
emit( emit(

View File

@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart'; import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/app_layout/model/space_model.dart'; import 'package:syncrow_app/features/app_layout/model/space_model.dart';
import 'package:syncrow_app/features/auth/model/project_model.dart';
import 'package:syncrow_app/features/devices/model/device_category_model.dart'; import 'package:syncrow_app/features/devices/model/device_category_model.dart';
import 'package:syncrow_app/features/devices/model/device_control_model.dart'; import 'package:syncrow_app/features/devices/model/device_control_model.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart'; import 'package:syncrow_app/features/devices/model/device_model.dart';
@ -19,6 +20,7 @@ import 'package:syncrow_app/services/api/devices_api.dart';
import 'package:syncrow_app/services/api/home_management_api.dart'; import 'package:syncrow_app/services/api/home_management_api.dart';
import 'package:syncrow_app/services/api/network_exception.dart'; import 'package:syncrow_app/services/api/network_exception.dart';
import 'package:syncrow_app/services/api/spaces_api.dart'; import 'package:syncrow_app/services/api/spaces_api.dart';
import 'package:syncrow_app/utils/constants/temp_const.dart';
import 'package:syncrow_app/utils/resource_manager/constants.dart'; import 'package:syncrow_app/utils/resource_manager/constants.dart';
part 'devices_state.dart'; part 'devices_state.dart';
@ -309,11 +311,14 @@ class DevicesCubit extends Cubit<DevicesState> {
.subspaces .subspaces
.indexWhere((element) => element.id == roomId); .indexWhere((element) => element.id == roomId);
try { try {
Project? project = HomeCubit.getInstance().project;
HomeCubit.getInstance().selectedSpace!.subspaces[roomIndex].devices = HomeCubit.getInstance().selectedSpace!.subspaces[roomIndex].devices =
await DevicesAPI.getDevicesByRoomId( await DevicesAPI.getDevicesByRoomId(
communityUuid: unit!.community.uuid, communityUuid: unit!.community.uuid,
spaceUuid: unit.id, spaceUuid: unit.id,
roomId: roomId); roomId: roomId,
projectId: project?.uuid ?? TempConst.projectIdDev);
} catch (e) { } catch (e) {
emitSafe(GetDevicesError(e.toString())); emitSafe(GetDevicesError(e.toString()));
return; return;
@ -410,10 +415,12 @@ class DevicesCubit extends Cubit<DevicesState> {
Future<void> fetchAllDevices(SpaceModel? unit) async { Future<void> fetchAllDevices(SpaceModel? unit) async {
emitSafe(GetDevicesLoading()); emitSafe(GetDevicesLoading());
try { try {
Project? project = HomeCubit.getInstance().project;
final devices = await DevicesAPI.getAllDevices( final devices = await DevicesAPI.getAllDevices(
communityUuid: unit!.community.uuid, communityUuid: unit!.community.uuid,
spaceUuid: unit.id, spaceUuid: unit.id,
); projectId: project?.uuid ?? TempConst.projectIdDev);
allDevices = devices; allDevices = devices;
emitSafe(GetDevicesSuccess(allDevices)); emitSafe(GetDevicesSuccess(allDevices));
} catch (e) { } catch (e) {

View File

@ -1,6 +1,8 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/auth/model/project_model.dart';
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_event.dart'; import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_state.dart'; import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_state.dart';
import 'package:syncrow_app/features/devices/model/device_control_model.dart'; import 'package:syncrow_app/features/devices/model/device_control_model.dart';
@ -14,6 +16,7 @@ import 'package:syncrow_app/features/devices/model/subspace_model.dart';
import 'package:syncrow_app/features/scene/model/scenes_model.dart'; import 'package:syncrow_app/features/scene/model/scenes_model.dart';
import 'package:syncrow_app/services/api/devices_api.dart'; import 'package:syncrow_app/services/api/devices_api.dart';
import 'package:syncrow_app/services/api/scene_api.dart'; import 'package:syncrow_app/services/api/scene_api.dart';
import 'package:syncrow_app/utils/constants/temp_const.dart';
import 'package:syncrow_app/utils/helpers/snack_bar.dart'; import 'package:syncrow_app/utils/helpers/snack_bar.dart';
class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> { class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
@ -299,9 +302,11 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
LoadScenes event, Emitter<FourSceneState> emit) async { LoadScenes event, Emitter<FourSceneState> emit) async {
emit(FourSceneLoadingState()); emit(FourSceneLoadingState());
try { try {
Project? project = HomeCubit.getInstance().project;
if (event.unitId.isNotEmpty) { if (event.unitId.isNotEmpty) {
allScenes = await SceneApi.getScenesByUnitId( allScenes = await SceneApi.getScenesByUnitId(
event.unitId, event.unit.community.uuid, event.unitId, event.unit.community.uuid, project?.uuid ?? TempConst.projectIdDev,
showInDevice: event.showInDevice); showInDevice: event.showInDevice);
filteredScenes = allScenes; filteredScenes = allScenes;

View File

@ -5,6 +5,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart'; import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/app_layout/model/community_model.dart'; import 'package:syncrow_app/features/app_layout/model/community_model.dart';
import 'package:syncrow_app/features/app_layout/model/space_model.dart'; import 'package:syncrow_app/features/app_layout/model/space_model.dart';
import 'package:syncrow_app/features/auth/model/project_model.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_event.dart'; import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_event.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_state.dart'; import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_state.dart';
import 'package:syncrow_app/features/devices/model/device_control_model.dart'; import 'package:syncrow_app/features/devices/model/device_control_model.dart';
@ -19,6 +20,7 @@ import 'package:syncrow_app/navigation/routing_constants.dart';
import 'package:syncrow_app/services/api/devices_api.dart'; import 'package:syncrow_app/services/api/devices_api.dart';
import 'package:syncrow_app/services/api/home_management_api.dart'; import 'package:syncrow_app/services/api/home_management_api.dart';
import 'package:syncrow_app/services/api/spaces_api.dart'; import 'package:syncrow_app/services/api/spaces_api.dart';
import 'package:syncrow_app/utils/constants/temp_const.dart';
import 'package:syncrow_app/utils/helpers/snack_bar.dart'; import 'package:syncrow_app/utils/helpers/snack_bar.dart';
class SosBloc extends Bloc<SosEvent, SosState> { class SosBloc extends Bloc<SosEvent, SosState> {
@ -184,8 +186,12 @@ class SosBloc extends Bloc<SosEvent, SosState> {
FetchRoomsEvent event, Emitter<SosState> emit) async { FetchRoomsEvent event, Emitter<SosState> emit) async {
try { try {
emit(SosLoadingState()); emit(SosLoadingState());
Project? project = HomeCubit.getInstance().project;
roomsList = await SpacesAPI.getSubSpaceBySpaceId( roomsList = await SpacesAPI.getSubSpaceBySpaceId(
event.unit.community.uuid, event.unit.id); event.unit.community.uuid,
event.unit.id,
project?.uuid ?? TempConst.projectIdDev);
emit(FetchRoomsState(devicesList: allDevices, roomsList: roomsList)); emit(FetchRoomsState(devicesList: allDevices, roomsList: roomsList));
} catch (e) { } catch (e) {
emit(const SosFailedState(errorMessage: 'Something went wrong')); emit(const SosFailedState(errorMessage: 'Something went wrong'));
@ -223,13 +229,19 @@ class SosBloc extends Bloc<SosEvent, SosState> {
void _assignDevice(AssignRoomEvent event, Emitter<SosState> emit) async { void _assignDevice(AssignRoomEvent event, Emitter<SosState> emit) async {
try { try {
emit(SosLoadingState()); emit(SosLoadingState());
Project? project = HomeCubit.getInstance().project;
await HomeManagementAPI.assignDeviceToRoom( await HomeManagementAPI.assignDeviceToRoom(
event.unit.community.uuid, event.unit.id, event.roomId, sosId); event.unit.community.uuid,
event.unit.id,
event.roomId,
sosId,
project?.uuid ?? TempConst.projectIdDev);
final devicesList = await DevicesAPI.getDevicesByRoomId( final devicesList = await DevicesAPI.getDevicesByRoomId(
communityUuid: event.unit.community.uuid, communityUuid: event.unit.community.uuid,
spaceUuid: event.unit.id, spaceUuid: event.unit.id,
roomId: event.roomId); roomId: event.roomId,
projectId: project?.uuid ?? TempConst.projectIdDev);
List<String> allDevicesIds = []; List<String> allDevicesIds = [];
@ -249,13 +261,16 @@ class SosBloc extends Bloc<SosEvent, SosState> {
void _unassignDevice(UnassignRoomEvent event, Emitter<SosState> emit) async { void _unassignDevice(UnassignRoomEvent event, Emitter<SosState> emit) async {
try { try {
Map<String, bool> roomDevicesId = {}; Map<String, bool> roomDevicesId = {};
Project? project = HomeCubit.getInstance().project;
emit(SosLoadingState()); emit(SosLoadingState());
await HomeManagementAPI.unAssignDeviceToRoom( await HomeManagementAPI.unAssignDeviceToRoom(
event.unit.community.uuid, event.unit.id, event.roomId, sosId); event.unit.community.uuid, event.unit.id, event.roomId, sosId, project?.uuid ?? TempConst.projectIdDev);
final devicesList = await DevicesAPI.getDevicesByRoomId( final devicesList = await DevicesAPI.getDevicesByRoomId(
communityUuid: event.unit.community.uuid, communityUuid: event.unit.community.uuid,
spaceUuid: event.unit.id, spaceUuid: event.unit.id,
roomId: event.roomId); roomId: event.roomId,
projectId: project?.uuid ?? TempConst.projectIdDev);
List<String> allDevicesIds = []; List<String> allDevicesIds = [];

View File

@ -1,10 +1,12 @@
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart'; import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/auth/model/project_model.dart';
import 'package:syncrow_app/features/auth/model/user_model.dart'; import 'package:syncrow_app/features/auth/model/user_model.dart';
import 'package:syncrow_app/features/menu/bloc/create_unit_bloc/create_unit_event.dart'; import 'package:syncrow_app/features/menu/bloc/create_unit_bloc/create_unit_event.dart';
import 'package:syncrow_app/features/menu/bloc/create_unit_bloc/create_unit_state.dart'; import 'package:syncrow_app/features/menu/bloc/create_unit_bloc/create_unit_state.dart';
import 'package:syncrow_app/services/api/home_creation_api.dart'; import 'package:syncrow_app/services/api/home_creation_api.dart';
import 'package:syncrow_app/utils/constants/temp_const.dart';
import 'package:syncrow_app/utils/helpers/snack_bar.dart'; import 'package:syncrow_app/utils/helpers/snack_bar.dart';
class CreateUnitBloc extends Bloc<CreateUnitEvent, CreateUnitState> { class CreateUnitBloc extends Bloc<CreateUnitEvent, CreateUnitState> {
@ -239,8 +241,13 @@ Future<String> _createNewRoom(
required String communityId}) async { required String communityId}) async {
try { try {
Map<String, String> body = {'subspaceName': roomName}; Map<String, String> body = {'subspaceName': roomName};
Project? project = HomeCubit.getInstance().project;
final response = await HomeCreation.createRoom( final response = await HomeCreation.createRoom(
communityId: communityId, spaceId: unitId, body: body); communityId: communityId,
spaceId: unitId,
body: body,
projectId: project?.uuid ?? TempConst.projectIdDev);
// if (response['data']['uuid'] != '') { // if (response['data']['uuid'] != '') {
// final result = await _assignToRoom(roomId: response['data']['uuid'], userId: userId); // final result = await _assignToRoom(roomId: response['data']['uuid'], userId: userId);

View File

@ -1,5 +1,6 @@
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart'; import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/auth/model/project_model.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart'; import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/menu/bloc/manage_unit_bloc/manage_unit_event.dart'; import 'package:syncrow_app/features/menu/bloc/manage_unit_bloc/manage_unit_event.dart';
import 'package:syncrow_app/features/menu/bloc/manage_unit_bloc/manage_unit_state.dart'; import 'package:syncrow_app/features/menu/bloc/manage_unit_bloc/manage_unit_state.dart';
@ -7,6 +8,7 @@ import 'package:syncrow_app/services/api/devices_api.dart';
import 'package:syncrow_app/services/api/home_creation_api.dart'; import 'package:syncrow_app/services/api/home_creation_api.dart';
import 'package:syncrow_app/services/api/home_management_api.dart'; import 'package:syncrow_app/services/api/home_management_api.dart';
import 'package:syncrow_app/services/api/spaces_api.dart'; import 'package:syncrow_app/services/api/spaces_api.dart';
import 'package:syncrow_app/utils/constants/temp_const.dart';
class ManageUnitBloc extends Bloc<ManageUnitEvent, ManageUnitState> { class ManageUnitBloc extends Bloc<ManageUnitEvent, ManageUnitState> {
List<DeviceModel> allDevices = []; List<DeviceModel> allDevices = [];
@ -24,8 +26,12 @@ class ManageUnitBloc extends Bloc<ManageUnitEvent, ManageUnitState> {
FetchRoomsEvent event, Emitter<ManageUnitState> emit) async { FetchRoomsEvent event, Emitter<ManageUnitState> emit) async {
try { try {
emit(LoadingState()); emit(LoadingState());
Project? project = HomeCubit.getInstance().project;
final roomsList = await SpacesAPI.getSubSpaceBySpaceId( final roomsList = await SpacesAPI.getSubSpaceBySpaceId(
event.unit.community.uuid, event.unit.id); event.unit.community.uuid,
event.unit.id,
project?.uuid ?? TempConst.projectIdDev);
emit(FetchRoomsState(devicesList: allDevices, roomsList: roomsList)); emit(FetchRoomsState(devicesList: allDevices, roomsList: roomsList));
} catch (e) { } catch (e) {
emit(const ErrorState(message: 'Something went wrong')); emit(const ErrorState(message: 'Something went wrong'));
@ -37,11 +43,14 @@ class ManageUnitBloc extends Bloc<ManageUnitEvent, ManageUnitState> {
FetchDevicesByRoomIdEvent event, Emitter<ManageUnitState> emit) async { FetchDevicesByRoomIdEvent event, Emitter<ManageUnitState> emit) async {
try { try {
Map<String, bool> roomDevicesId = {}; Map<String, bool> roomDevicesId = {};
Project? project = HomeCubit.getInstance().project;
emit(LoadingState()); emit(LoadingState());
final devicesList = await DevicesAPI.getDevicesByRoomId( final devicesList = await DevicesAPI.getDevicesByRoomId(
communityUuid: event.unit.community.uuid, communityUuid: event.unit.community.uuid,
spaceUuid: event.unit.id, spaceUuid: event.unit.id,
roomId: event.roomId); roomId: event.roomId,
projectId: project?.uuid ?? TempConst.projectIdDev);
allDevices = await HomeManagementAPI.fetchDevicesByUserId(); allDevices = await HomeManagementAPI.fetchDevicesByUserId();
List<String> allDevicesIds = []; List<String> allDevicesIds = [];
@ -72,14 +81,21 @@ class ManageUnitBloc extends Bloc<ManageUnitEvent, ManageUnitState> {
AssignRoomEvent event, Emitter<ManageUnitState> emit) async { AssignRoomEvent event, Emitter<ManageUnitState> emit) async {
try { try {
Map<String, bool> roomDevicesId = {}; Map<String, bool> roomDevicesId = {};
Project? project = HomeCubit.getInstance().project;
emit(LoadingState()); emit(LoadingState());
await HomeManagementAPI.assignDeviceToRoom( await HomeManagementAPI.assignDeviceToRoom(
event.unit.community.uuid, event.unit.id, event.roomId, event.deviceId); event.unit.community.uuid,
event.unit.id,
event.roomId,
event.deviceId,
project?.uuid ?? TempConst.projectIdDev);
final devicesList = await DevicesAPI.getDevicesByRoomId( final devicesList = await DevicesAPI.getDevicesByRoomId(
communityUuid: event.unit.community.uuid, communityUuid: event.unit.community.uuid,
spaceUuid: event.unit.id, spaceUuid: event.unit.id,
roomId: event.roomId); roomId: event.roomId,
projectId: project?.uuid ?? TempConst.projectIdDev);
List<String> allDevicesIds = []; List<String> allDevicesIds = [];
@ -105,19 +121,25 @@ class ManageUnitBloc extends Bloc<ManageUnitEvent, ManageUnitState> {
} }
} }
void _unassignDevice( void _unassignDevice(
UnassignRoomEvent event, Emitter<ManageUnitState> emit) async { UnassignRoomEvent event, Emitter<ManageUnitState> emit) async {
try { try {
Map<String, bool> roomDevicesId = {}; Map<String, bool> roomDevicesId = {};
Project? project = HomeCubit.getInstance().project;
emit(LoadingState()); emit(LoadingState());
await HomeManagementAPI.unAssignDeviceToRoom( await HomeManagementAPI.unAssignDeviceToRoom(
event.unit.community.uuid, event.unit.id, event.roomId, event.deviceId); event.unit.community.uuid,
event.unit.id,
event.roomId,
event.deviceId,
project?.uuid ?? TempConst.projectIdDev);
final devicesList = await DevicesAPI.getDevicesByRoomId( final devicesList = await DevicesAPI.getDevicesByRoomId(
communityUuid: event.unit.community.uuid, communityUuid: event.unit.community.uuid,
spaceUuid: event.unit.id, spaceUuid: event.unit.id,
roomId: event.roomId); roomId: event.roomId,
projectId: project?.uuid ?? TempConst.projectIdDev);
List<String> allDevicesIds = []; List<String> allDevicesIds = [];
@ -143,18 +165,22 @@ class ManageUnitBloc extends Bloc<ManageUnitEvent, ManageUnitState> {
} }
} }
_addNewRoom(AddNewRoom event, Emitter<ManageUnitState> emit) async { _addNewRoom(AddNewRoom event, Emitter<ManageUnitState> emit) async {
Map<String, String> body = {'subspaceName': event.roomName}; Map<String, String> body = {'subspaceName': event.roomName};
try { try {
emit(LoadingState()); emit(LoadingState());
Project? project = HomeCubit.getInstance().project;
final response = await HomeCreation.createRoom( final response = await HomeCreation.createRoom(
communityId: event.unit.community.uuid, communityId: event.unit.community.uuid,
spaceId: event.unit.id, spaceId: event.unit.id,
body: body); body: body,
projectId: project?.uuid ?? TempConst.projectIdDev);
if (response['data']['uuid'] != '') { if (response['data']['uuid'] != '') {
final roomsList = await SpacesAPI.getSubSpaceBySpaceId( final roomsList = await SpacesAPI.getSubSpaceBySpaceId(
event.unit.community.uuid, event.unit.id); event.unit.community.uuid,
event.unit.id,
project?.uuid ?? TempConst.projectIdDev);
allDevices = await HomeManagementAPI.fetchDevicesByUserId(); allDevices = await HomeManagementAPI.fetchDevicesByUserId();
emit(FetchRoomsState(devicesList: allDevices, roomsList: roomsList)); emit(FetchRoomsState(devicesList: allDevices, roomsList: roomsList));
await HomeCubit.getInstance().fetchUnitsByUserId(); await HomeCubit.getInstance().fetchUnitsByUserId();

View File

@ -23,8 +23,8 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
String timeZoneSelected = ''; String timeZoneSelected = '';
String regionSelected = ''; String regionSelected = '';
final TextEditingController searchController = TextEditingController(); final TextEditingController searchController = TextEditingController();
final TextEditingController nameController = final TextEditingController nameController = TextEditingController(
TextEditingController(text: '${HomeCubit.user!.firstName} ${HomeCubit.user!.lastName}'); text: '${HomeCubit.user!.firstName} ${HomeCubit.user!.lastName}');
List<RegionModel> allRegions = []; List<RegionModel> allRegions = [];
List<TimeZone> allTimeZone = []; List<TimeZone> allTimeZone = [];
@ -77,10 +77,13 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
emit(NameEditingState(editName: editName)); emit(NameEditingState(editName: editName));
} }
void _fetchUserInfo(InitialProfileEvent event, Emitter<ProfileState> emit) async { void _fetchUserInfo(
InitialProfileEvent event, Emitter<ProfileState> emit) async {
try { try {
emit(LoadingInitialState()); emit(LoadingInitialState());
HomeCubit.user = await ProfileApi().fetchUserInfo(HomeCubit.user!.uuid); HomeCubit.user = await ProfileApi().fetchUserInfo(HomeCubit.user!.uuid);
HomeCubit.getInstance().project = HomeCubit.user?.project;
emit(SaveState()); emit(SaveState());
} catch (e) { } catch (e) {
emit(FailedState(errorMessage: e.toString())); emit(FailedState(errorMessage: e.toString()));
@ -88,7 +91,8 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
} }
} }
Future _fetchTimeZone(TimeZoneInitialEvent event, Emitter<ProfileState> emit) async { Future _fetchTimeZone(
TimeZoneInitialEvent event, Emitter<ProfileState> emit) async {
emit(LoadingInitialState()); emit(LoadingInitialState());
try { try {
allTimeZone = await ProfileApi.fetchTimeZone(); allTimeZone = await ProfileApi.fetchTimeZone();
@ -100,7 +104,8 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
} }
} }
Future selectTimeZone(SelectTimeZoneEvent event, Emitter<ProfileState> emit) async { Future selectTimeZone(
SelectTimeZoneEvent event, Emitter<ProfileState> emit) async {
try { try {
emit(LoadingInitialState()); emit(LoadingInitialState());
timeZoneSelected = event.val; timeZoneSelected = event.val;
@ -112,7 +117,8 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
} }
} }
Future selectRegion(SelectRegionEvent event, Emitter<ProfileState> emit) async { Future selectRegion(
SelectRegionEvent event, Emitter<ProfileState> emit) async {
try { try {
emit(LoadingInitialState()); emit(LoadingInitialState());
await ProfileApi.saveRegion(regionUuid: event.val); await ProfileApi.saveRegion(regionUuid: event.val);
@ -124,7 +130,8 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
} }
} }
Future<void> searchRegion(SearchRegionEvent event, Emitter<ProfileState> emit) async { Future<void> searchRegion(
SearchRegionEvent event, Emitter<ProfileState> emit) async {
emit(LoadingInitialState()); emit(LoadingInitialState());
final query = event.query.toLowerCase(); final query = event.query.toLowerCase();
if (allRegions.isEmpty) { if (allRegions.isEmpty) {
@ -140,7 +147,8 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
} }
} }
Future<void> searchTimeZone(SearchTimeZoneEvent event, Emitter<ProfileState> emit) async { Future<void> searchTimeZone(
SearchTimeZoneEvent event, Emitter<ProfileState> emit) async {
emit(LoadingInitialState()); emit(LoadingInitialState());
final query = event.query.toLowerCase(); final query = event.query.toLowerCase();
if (allTimeZone.isEmpty) { if (allTimeZone.isEmpty) {
@ -156,7 +164,8 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
} }
} }
void _fetchRegion(RegionInitialEvent event, Emitter<ProfileState> emit) async { void _fetchRegion(
RegionInitialEvent event, Emitter<ProfileState> emit) async {
try { try {
emit(LoadingInitialState()); emit(LoadingInitialState());
allRegions = await ProfileApi.fetchRegion(); allRegions = await ProfileApi.fetchRegion();
@ -166,7 +175,8 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
} }
} }
Future<void> _selectImage(SelectImageEvent event, Emitter<ProfileState> emit) async { Future<void> _selectImage(
SelectImageEvent event, Emitter<ProfileState> emit) async {
try { try {
if (await _requestPermission()) { if (await _requestPermission()) {
emit(ChangeImageState()); emit(ChangeImageState());
@ -283,7 +293,8 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
} }
return false; return false;
} else { } else {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); SharedPreferences sharedPreferences =
await SharedPreferences.getInstance();
bool firstClick = sharedPreferences.getBool('firstPermission') ?? true; bool firstClick = sharedPreferences.getBool('firstPermission') ?? true;
await sharedPreferences.setBool('firstPermission', false); await sharedPreferences.setBool('firstPermission', false);
if (firstClick == false) { if (firstClick == false) {

View File

@ -2,9 +2,12 @@ import 'dart:async';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/auth/model/project_model.dart';
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.dart'; import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.dart';
import 'package:syncrow_app/features/scene/model/scenes_model.dart'; import 'package:syncrow_app/features/scene/model/scenes_model.dart';
import 'package:syncrow_app/services/api/scene_api.dart'; import 'package:syncrow_app/services/api/scene_api.dart';
import 'package:syncrow_app/utils/constants/temp_const.dart';
part 'scene_state.dart'; part 'scene_state.dart';
@ -23,9 +26,11 @@ class SceneBloc extends Bloc<SceneEvent, SceneState> {
emit(SceneLoading()); emit(SceneLoading());
try { try {
Project? project = HomeCubit.getInstance().project;
if (event.unitId.isNotEmpty) { if (event.unitId.isNotEmpty) {
scenes = await SceneApi.getScenesByUnitId( scenes = await SceneApi.getScenesByUnitId(event.unitId,
event.unitId, event.unit.community.uuid, event.unit.community.uuid, project?.uuid ?? TempConst.projectIdDev,
showInDevice: event.showInDevice); showInDevice: event.showInDevice);
emit(SceneLoaded(scenes, automationList)); emit(SceneLoaded(scenes, automationList));
} else { } else {

View File

@ -219,13 +219,14 @@ class DevicesAPI {
required String communityUuid, required String communityUuid,
required String spaceUuid, required String spaceUuid,
required String roomId, required String roomId,
required String projectId,
}) async { }) async {
try { try {
final String path = ApiEndpoints.deviceByRoom final String path = ApiEndpoints.deviceByRoom
.replaceAll('{communityUuid}', communityUuid) .replaceAll('{communityUuid}', communityUuid)
.replaceAll('{spaceUuid}', spaceUuid) .replaceAll('{spaceUuid}', spaceUuid)
.replaceAll('{subSpaceUuid}', roomId) .replaceAll('{subSpaceUuid}', roomId)
.replaceAll('{projectUuid}', TempConst.projectIdDev); .replaceAll('{projectUuid}', projectId);
final response = await _httpService.get( final response = await _httpService.get(
path: path, path: path,
@ -564,12 +565,13 @@ class DevicesAPI {
static Future<List<DeviceModel>> getAllDevices({ static Future<List<DeviceModel>> getAllDevices({
required String communityUuid, required String communityUuid,
required String spaceUuid, required String spaceUuid,
required String projectId,
}) async { }) async {
try { try {
final String path = ApiEndpoints.getAllDevices final String path = ApiEndpoints.getAllDevices
.replaceAll('{communityUuid}', communityUuid) .replaceAll('{communityUuid}', communityUuid)
.replaceAll('{spaceUuid}', spaceUuid) .replaceAll('{spaceUuid}', spaceUuid)
.replaceAll('{projectUuid}', TempConst.projectIdDev); .replaceAll('{projectUuid}', projectId);
final response = await _httpService.get( final response = await _httpService.get(
path: path, path: path,

View File

@ -145,12 +145,13 @@ class HomeCreation {
required String communityId, required String communityId,
required String spaceId, required String spaceId,
required Map<String, String> body, required Map<String, String> body,
required String projectId
}) async { }) async {
try { try {
final fullPath = ApiEndpoints.addSubSpace final fullPath = ApiEndpoints.addSubSpace
.replaceAll('{communityUuid}', communityId) .replaceAll('{communityUuid}', communityId)
.replaceAll('{spaceUuid}', spaceId) .replaceAll('{spaceUuid}', spaceId)
.replaceAll('{projectUuid}', TempConst.projectIdDev); .replaceAll('{projectUuid}', projectId);
final response = await _httpService.post( final response = await _httpService.post(
path: fullPath, path: fullPath,
body: body, body: body,

View File

@ -27,7 +27,7 @@ class HomeManagementAPI {
return list; return list;
} }
static Future<List<DeviceModel>> fetchDevicesByUnitId() async { static Future<List<DeviceModel>> fetchDevicesByUnitId(String projectUuid) async {
List<DeviceModel> list = []; List<DeviceModel> list = [];
try { try {
@ -40,7 +40,7 @@ class HomeManagementAPI {
final path = ApiEndpoints.spaceDevices final path = ApiEndpoints.spaceDevices
.replaceAll('{communityUuid}', communityUuid) .replaceAll('{communityUuid}', communityUuid)
.replaceAll('{spaceUuid}', spaceUuid) .replaceAll('{spaceUuid}', spaceUuid)
.replaceAll('{projectUuid}', TempConst.projectIdDev); .replaceAll('{projectUuid}', projectUuid);
await _httpService.get( await _httpService.get(
path: path, path: path,
@ -63,11 +63,11 @@ class HomeManagementAPI {
} }
static Future<Map<String, dynamic>> assignDeviceToRoom(String communityId, static Future<Map<String, dynamic>> assignDeviceToRoom(String communityId,
String spaceId, String subSpaceId, String deviceId) async { String spaceId, String subSpaceId, String deviceId, String projectId) async {
try { try {
final response = await _httpService.post( final response = await _httpService.post(
path: ApiEndpoints.assignDeviceToRoom path: ApiEndpoints.assignDeviceToRoom
.replaceAll('{projectUuid}', TempConst.projectIdDev) .replaceAll('{projectUuid}', projectId)
.replaceAll('{communityUuid}', communityId) .replaceAll('{communityUuid}', communityId)
.replaceAll('{spaceUuid}', spaceId) .replaceAll('{spaceUuid}', spaceId)
.replaceAll('{subSpaceUuid}', subSpaceId) .replaceAll('{subSpaceUuid}', subSpaceId)
@ -83,7 +83,7 @@ class HomeManagementAPI {
} }
static Future<Map<String, dynamic>> unAssignDeviceToRoom(String communityId, static Future<Map<String, dynamic>> unAssignDeviceToRoom(String communityId,
String spaceId, String subSpaceId, String deviceId) async { String spaceId, String subSpaceId, String deviceId, String projectId) async {
try { try {
final response = await _httpService.delete( final response = await _httpService.delete(
path: ApiEndpoints.assignDeviceToRoom path: ApiEndpoints.assignDeviceToRoom
@ -91,7 +91,7 @@ class HomeManagementAPI {
.replaceAll('{spaceUuid}', spaceId) .replaceAll('{spaceUuid}', spaceId)
.replaceAll('{subSpaceUuid}', subSpaceId) .replaceAll('{subSpaceUuid}', subSpaceId)
.replaceAll('{deviceUuid}', deviceId) .replaceAll('{deviceUuid}', deviceId)
.replaceAll('{projectUuid}', TempConst.projectIdDev), .replaceAll('{projectUuid}', projectId),
expectedResponseModel: (json) { expectedResponseModel: (json) {
return json; return json;
}, },

View File

@ -50,14 +50,14 @@ class SceneApi {
//get scene by unit id //get scene by unit id
static Future<List<ScenesModel>> getScenesByUnitId( static Future<List<ScenesModel>> getScenesByUnitId(
String unitId, String communityId, String unitId, String communityId, String projectId,
{showInDevice = false}) async { {showInDevice = false}) async {
try { try {
final response = await _httpService.get( final response = await _httpService.get(
path: ApiEndpoints.getUnitScenes path: ApiEndpoints.getUnitScenes
.replaceAll('{spaceUuid}', unitId) .replaceAll('{spaceUuid}', unitId)
.replaceAll('{communityUuid}', communityId) .replaceAll('{communityUuid}', communityId)
.replaceAll('{projectUuid}', TempConst.projectIdDev), .replaceAll('{projectUuid}', projectId),
queryParameters: {'showInHomePage': showInDevice}, queryParameters: {'showInHomePage': showInDevice},
showServerMessage: false, showServerMessage: false,
expectedResponseModel: (json) { expectedResponseModel: (json) {

View File

@ -32,13 +32,13 @@ class SpacesAPI {
} }
static Future<List<SubSpaceModel>> getSubSpaceBySpaceId( static Future<List<SubSpaceModel>> getSubSpaceBySpaceId(
String communityId, String spaceId) async { String communityId, String spaceId, String projectId) async {
try { try {
// Construct the API path // Construct the API path
final path = ApiEndpoints.listSubspace final path = ApiEndpoints.listSubspace
.replaceFirst('{communityUuid}', communityId) .replaceFirst('{communityUuid}', communityId)
.replaceFirst('{spaceUuid}', spaceId) .replaceFirst('{spaceUuid}', spaceId)
.replaceAll('{projectUuid}', TempConst.projectIdDev); .replaceAll('{projectUuid}', projectId);
final response = await _httpService.get( final response = await _httpService.get(
path: path, path: path,
@ -66,12 +66,12 @@ class SpacesAPI {
//factory/reset/{deviceUuid} //factory/reset/{deviceUuid}
static Future<String> generateInvitationCode( static Future<String> generateInvitationCode(
String unitId, String communityId) async { String unitId, String communityId, String projectId) async {
final response = await _httpService.post( final response = await _httpService.post(
path: ApiEndpoints.invitationCode path: ApiEndpoints.invitationCode
.replaceAll('{unitUuid}', unitId) .replaceAll('{unitUuid}', unitId)
.replaceAll('{communityUuid}', communityId) .replaceAll('{communityUuid}', communityId)
.replaceAll('{projectUuid}', TempConst.projectIdDev), .replaceAll('{projectUuid}', projectId),
showServerMessage: false, showServerMessage: false,
expectedResponseModel: (json) { expectedResponseModel: (json) {
if (json != null && json['data'] != null) { if (json != null && json['data'] != null) {