mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-14 17:25:47 +00:00
fixes issues
This commit is contained in:
@ -7,14 +7,11 @@ import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_st
|
||||
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_report_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/group_devices_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_info_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/six_scene_question_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/six_scene_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/subspace_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scenes_model.dart';
|
||||
import 'package:syncrow_app/generated/assets.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/scene_api.dart';
|
||||
@ -27,29 +24,21 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
required this.sixSceneId,
|
||||
}) : super(const SixSceneState()) {
|
||||
on<SixSceneInitial>(_fetchDeviceStatus);
|
||||
on<ToggleNotificationEvent>(_toggleNotification);
|
||||
on<ChangeNameEvent>(_changeName);
|
||||
on<SearchFaqEvent>(_onSearchFaq);
|
||||
on<ChangeSwitchStatusEvent>(changeSwitchStatus);
|
||||
on<LoadScenes>(_onLoadScenes);
|
||||
on<SearchScenesEvent>(searchScene);
|
||||
on<SaveSelectionEvent>(_onSaveSelection);
|
||||
on<SelectOptionEvent>(_onOptionSelected);
|
||||
on<AddDeviceToGroup>(_addDeviceToGroup);
|
||||
on<RemoveDeviceFromGroup>(_removeDeviceFromGroup);
|
||||
on<SexSceneSwitchInitial>(_fetchFourSceneSwitches);
|
||||
on<AssignDeviceScene>(assignScene);
|
||||
on<GetSceneBySwitchName>(getSceneByName);
|
||||
on<SelectSceneEvent>(_selectScene);
|
||||
on<SixSceneInitialInfo>(fetchDeviceInfo);
|
||||
on<SaveNameEvent>(saveName);
|
||||
on<AssignRoomEvent>(_assignDevice);
|
||||
on<FetchRoomsEvent>(_fetchRoomsAndDevices);
|
||||
on<SixSceneInitialQuestion>(_onSixSceneInitial);
|
||||
on<DeleteDeviceEvent>(deleteDevice);
|
||||
on<ToggleEnableAlarmEvent>(_toggleLowBattery);
|
||||
on<ToggleUpdateEvent>(_toggleUpdate);
|
||||
on<ToggleHelpfulEvent>(_toggleHelpful);
|
||||
on<UnAssignSceneEvent>(_unAssignScene);
|
||||
}
|
||||
|
||||
final TextEditingController nameController =
|
||||
@ -156,6 +145,22 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _unAssignScene(
|
||||
UnAssignSceneEvent event, Emitter<SixSceneState> emit) async {
|
||||
try {
|
||||
emit(SixSceneLoadingState());
|
||||
if (_hasSelectionChanged) {
|
||||
var response = await DevicesAPI.unAssignScenesDevice(
|
||||
deviceUuid: event.switchSceneUuid);
|
||||
CustomSnackBar.displaySnackBar('Save Successfully');
|
||||
emit(SaveSelectionSuccessState());
|
||||
}
|
||||
} catch (e) {
|
||||
emit(SixSceneFailedState(errorMessage: e.toString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
deleteDevice(DeleteDeviceEvent event, Emitter<SixSceneState> emit) async {
|
||||
try {
|
||||
emit(SixSceneLoadingState());
|
||||
@ -226,9 +231,16 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
|
||||
String selectedSceneId = '';
|
||||
|
||||
|
||||
_selectScene(SelectSceneEvent event, Emitter<SixSceneState> emit) {
|
||||
emit(SixSceneLoadingState());
|
||||
selectedSceneId = event.unitId;
|
||||
if (event.isSelected == false) {
|
||||
selectedSceneId = '';
|
||||
selectedFormApiSceneId = '';
|
||||
emit(SceneSelectionUpdatedState(selectedSceneId: selectedSceneId));
|
||||
} else {
|
||||
selectedSceneId = event.selectedSceneId;
|
||||
}
|
||||
emit(SceneSelectionUpdatedState(selectedSceneId: selectedSceneId));
|
||||
}
|
||||
|
||||
@ -238,7 +250,8 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
SexSceneSwitchInitial event, Emitter<SixSceneState> emit) async {
|
||||
emit(SixSceneLoadingState());
|
||||
try {
|
||||
var response = await DevicesAPI.getFourSceneInfo(sixSceneId);
|
||||
var response = await DevicesAPI.getDeviceSceneInfo(sixSceneId);
|
||||
|
||||
Map<String, String> sceneTitles = {
|
||||
"scene_1": '',
|
||||
"scene_2": '',
|
||||
@ -272,11 +285,16 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
void assignScene(AssignDeviceScene event, Emitter<SixSceneState> emit) async {
|
||||
emit(SixSceneLoadingState());
|
||||
try {
|
||||
final response = await DevicesAPI.postFourSceneInfo(
|
||||
if (event.sceneUuid == '') {
|
||||
final response = await DevicesAPI.unAssignScenesDevice(
|
||||
deviceUuid: sixSceneId, switchName: event.switchName);
|
||||
} else {
|
||||
final response = await DevicesAPI.postDeviceSceneInfo(
|
||||
deviceId: sixSceneId,
|
||||
sceneUuid: event.sceneUuid,
|
||||
spaceUuid: event.unit!.id,
|
||||
switchName: event.switchName);
|
||||
}
|
||||
|
||||
emit(SaveSelectionSuccessState());
|
||||
CustomSnackBar.displaySnackBar('Save Successfully');
|
||||
@ -285,27 +303,6 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _onSearchFaq(SearchFaqEvent event, Emitter<SixSceneState> emit) {
|
||||
emit(SixSceneLoadingState());
|
||||
List<SixSceneQuestionModel> _faqQuestions = faqQuestions.where((question) {
|
||||
return question.question
|
||||
.toLowerCase()
|
||||
.contains(event.query.toLowerCase());
|
||||
}).toList();
|
||||
emit(FaqSearchState(filteredFaqQuestions: _faqQuestions));
|
||||
}
|
||||
|
||||
void _toggleNotification(
|
||||
ToggleNotificationEvent event, Emitter<SixSceneState> emit) async {
|
||||
emit(LoadingNewSate(device: deviceStatus));
|
||||
try {
|
||||
closingReminder = event.isClosingEnabled;
|
||||
emit(UpdateState(device: deviceStatus));
|
||||
} catch (e) {
|
||||
emit(SixSceneFailedState(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
DeviceReport recordGroups =
|
||||
DeviceReport(startTime: '0', endTime: '0', data: []);
|
||||
|
||||
@ -355,6 +352,7 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
} catch (e) {
|
||||
emit(const SixSceneFailedState(errorMessage: 'Something went wrong'));
|
||||
}
|
||||
|
||||
emit(SuccessState());
|
||||
}
|
||||
|
||||
@ -368,7 +366,7 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
filteredScenes = event.query.isEmpty
|
||||
? allScenes
|
||||
: allScenes.where((scene) {
|
||||
final sceneName = scene.name.toLowerCase() ?? '';
|
||||
final sceneName = scene.name.toLowerCase();
|
||||
return sceneName.contains(event.query.toLowerCase());
|
||||
}).toList();
|
||||
emit(SearchResultsState());
|
||||
@ -393,162 +391,4 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
emit(SaveSelectionSuccessState());
|
||||
}
|
||||
}
|
||||
|
||||
//============================= group settings =================================
|
||||
//addDevicesIcon
|
||||
List<GroupDevicesModel> groupDevices = [
|
||||
GroupDevicesModel(
|
||||
dec: 'Syncroom', icon: Assets.minusIcon, name: '6 Scene Switch')
|
||||
];
|
||||
|
||||
List<GroupDevicesModel> devices = [
|
||||
GroupDevicesModel(
|
||||
dec: 'Syncroom', icon: Assets.addDevicesIcon, name: '6 Scene Switch')
|
||||
];
|
||||
|
||||
// Handler for AddDeviceToGroup
|
||||
void _addDeviceToGroup(AddDeviceToGroup event, Emitter<SixSceneState> emit) {
|
||||
devices.remove(event.device);
|
||||
groupDevices.add(event.device);
|
||||
for (var device in groupDevices) {
|
||||
device.icon = event.icon;
|
||||
}
|
||||
emit(UpdateStateList(groupDevices: groupDevices, devices: devices));
|
||||
}
|
||||
|
||||
// Handler for RemoveDeviceFromGroup
|
||||
void _removeDeviceFromGroup(
|
||||
RemoveDeviceFromGroup event, Emitter<SixSceneState> emit) {
|
||||
groupDevices.remove(event.device);
|
||||
devices.add(event.device);
|
||||
for (var device in groupDevices) {
|
||||
device.icon = event.icon;
|
||||
}
|
||||
emit(UpdateStateList(groupDevices: groupDevices, devices: devices));
|
||||
}
|
||||
|
||||
//======================= update device functions ============================
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool enableUpdate = false;
|
||||
|
||||
void _toggleUpdate(
|
||||
ToggleUpdateEvent event, Emitter<SixSceneState> emit) async {
|
||||
try {
|
||||
emit(SixSceneLoadingState());
|
||||
enableUpdate = event.isUpdateEnabled!;
|
||||
emit(SaveState());
|
||||
} catch (e) {
|
||||
emit(const SixSceneFailedState(errorMessage: 'Something went wrong'));
|
||||
}
|
||||
}
|
||||
|
||||
//======================= q&a and questions ====================================
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool isHelpful = false;
|
||||
|
||||
void _toggleHelpful(
|
||||
ToggleHelpfulEvent event, Emitter<SixSceneState> emit) async {
|
||||
try {
|
||||
emit(SixSceneLoadingState());
|
||||
isHelpful = event.isHelpful!;
|
||||
emit(SaveState());
|
||||
} catch (e) {
|
||||
emit(const SixSceneFailedState(errorMessage: 'Something went wrong'));
|
||||
}
|
||||
}
|
||||
|
||||
final List<SixSceneQuestionModel> faqQuestions = [
|
||||
SixSceneQuestionModel(
|
||||
id: 1,
|
||||
question: 'How does an SOS emergency button work?',
|
||||
answer:
|
||||
'The SOS emergency button sends an alert to your contacts when pressed.',
|
||||
),
|
||||
SixSceneQuestionModel(
|
||||
id: 2,
|
||||
question: 'How long will an SOS alarm persist?',
|
||||
answer:
|
||||
'The SOS alarm will persist until it is manually turned off or after a set time.',
|
||||
),
|
||||
SixSceneQuestionModel(
|
||||
id: 3,
|
||||
question: 'What should I do if the SOS button is unresponsive?',
|
||||
answer: 'Try restarting the device. If it persists, contact support.',
|
||||
),
|
||||
SixSceneQuestionModel(
|
||||
id: 4,
|
||||
question: 'Can I use the SOS feature without a network connection?',
|
||||
answer:
|
||||
'No, a network connection is required to send the alert to your contacts.',
|
||||
),
|
||||
SixSceneQuestionModel(
|
||||
id: 5,
|
||||
question: 'How often should I check the SOS battery?',
|
||||
answer:
|
||||
'Check the SOS battery at least once a month to ensure it is operational.',
|
||||
),
|
||||
];
|
||||
|
||||
Future<void> _onSixSceneInitial(
|
||||
SixSceneInitialQuestion event, Emitter<SixSceneState> emit) async {
|
||||
emit(SixSceneLoadingState());
|
||||
emit(FaqLoadedState(filteredFaqQuestions: faqQuestions));
|
||||
}
|
||||
|
||||
//=========================== name setting ===================================
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void _changeName(ChangeNameEvent event, Emitter<SixSceneState> emit) {
|
||||
emit(SixSceneLoadingState());
|
||||
editName = event.value!;
|
||||
if (editName) {
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
focusNode.requestFocus();
|
||||
});
|
||||
} else {
|
||||
focusNode.unfocus();
|
||||
}
|
||||
emit(NameEditingState(editName: editName));
|
||||
}
|
||||
|
||||
Future<void> saveName(
|
||||
SaveNameEvent event, Emitter<SixSceneState> emit) async {
|
||||
if (_validateInputs()) return;
|
||||
try {
|
||||
add(const ChangeNameEvent(value: false));
|
||||
isSaving = true;
|
||||
emit(SixSceneLoadingState());
|
||||
var response = await DevicesAPI.putDeviceName(
|
||||
deviceId: sixSceneId, deviceName: nameController.text);
|
||||
add(const SixSceneInitialInfo());
|
||||
CustomSnackBar.displaySnackBar('Save Successfully');
|
||||
emit(SaveState());
|
||||
} catch (e) {
|
||||
emit(SixSceneFailedState(errorMessage: e.toString()));
|
||||
} finally {
|
||||
isSaving = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool _validateInputs() {
|
||||
final nameError = fullNameValidator(nameController.text);
|
||||
if (nameError != null) {
|
||||
CustomSnackBar.displaySnackBar(nameError);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
String? fullNameValidator(String? value) {
|
||||
if (value == null) return 'name is required';
|
||||
final withoutExtraSpaces = value.replaceAll(RegExp(r"\s+"), ' ').trim();
|
||||
if (withoutExtraSpaces.length < 2 || withoutExtraSpaces.length > 30) {
|
||||
return 'name must be between 2 and 30 characters long';
|
||||
}
|
||||
if (RegExp(r"/[^ a-zA-Z0-9-\']/").hasMatch(withoutExtraSpaces)) {
|
||||
return 'Only alphanumeric characters, space, dash and single quote are allowed';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,11 @@ class SaveNameEvent extends SixSceneEvent {
|
||||
const SaveNameEvent();
|
||||
}
|
||||
|
||||
class UnAssignSceneEvent extends SixSceneEvent {
|
||||
final String switchSceneUuid;
|
||||
const UnAssignSceneEvent({required this.switchSceneUuid});
|
||||
}
|
||||
|
||||
class SixSceneInitialInfo extends SixSceneEvent {
|
||||
const SixSceneInitialInfo();
|
||||
}
|
||||
@ -91,12 +96,17 @@ class LoadScenes extends SixSceneEvent {
|
||||
}
|
||||
|
||||
class SelectSceneEvent extends SixSceneEvent {
|
||||
final String unitId;
|
||||
final String selectedSceneId;
|
||||
final bool isSelected;
|
||||
// final String unitId;
|
||||
const SelectSceneEvent({
|
||||
required this.unitId,
|
||||
// required this.unitId,
|
||||
required this.selectedSceneId,
|
||||
required this.isSelected,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
class SearchScenesEvent extends SixSceneEvent {
|
||||
final String query;
|
||||
const SearchScenesEvent({
|
||||
|
@ -4,7 +4,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/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/model/device_control_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_report_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/four_scene_model.dart';
|
||||
@ -18,7 +17,6 @@ import 'package:syncrow_app/features/scene/model/scenes_model.dart';
|
||||
import 'package:syncrow_app/generated/assets.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/scene_api.dart';
|
||||
import 'package:syncrow_app/services/api/spaces_api.dart';
|
||||
import 'package:syncrow_app/utils/helpers/snack_bar.dart';
|
||||
|
||||
@ -34,23 +32,20 @@ class DeviceSettingBloc extends Bloc<DeviceSettingEvent, DeviceSettingState> {
|
||||
on<ChangeNameEvent>(_changeName);
|
||||
on<SearchFaqEvent>(_onSearchFaq);
|
||||
on<FetchRoomsEvent>(_fetchRoomsAndDevices);
|
||||
on<ChangeSwitchStatusEvent>(changeSwitchStatus);
|
||||
on<LoadSettings>(_onLoadSettings);
|
||||
on<SearchSettingsEvent>(searchSetting);
|
||||
on<AssignRoomEvent>(_assignDevice);
|
||||
on<SelectOptionEvent>(_onOptionSelected);
|
||||
on<AddDeviceToGroup>(_addDeviceToGroup);
|
||||
on<RemoveDeviceFromGroup>(_removeDeviceFromGroup);
|
||||
on<DeviceSettingInitialQuestion>(_onDeviceSettingInitial);
|
||||
on<FetchDeviceSetting>(_fetchDeviceSetting);
|
||||
on<DeviceSettingSwitchInitial>(_fetchDeviceSettingSwitches);
|
||||
on<AssignDeviceSetting>(assignSetting);
|
||||
on<GetSettingBySwitchName>(getSettingByName);
|
||||
on<SelectSettingEvent>(_selectSetting);
|
||||
on<DeleteDeviceEvent>(deleteDevice);
|
||||
on<ToggleEnableAlarmEvent>(_toggleLowBattery);
|
||||
on<ToggleUpdateEvent>(_toggleUpdate);
|
||||
on<ToggleHelpfulEvent>(_toggleHelpful);
|
||||
on<SelectOptionEvent>(_onOptionSelected);
|
||||
}
|
||||
|
||||
final TextEditingController nameController =
|
||||
@ -133,64 +128,6 @@ class DeviceSettingBloc extends Bloc<DeviceSettingEvent, DeviceSettingState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _onOptionSelected(
|
||||
SelectOptionEvent event, Emitter<DeviceSettingState> emit) {
|
||||
emit(DeviceSettingLoadingState());
|
||||
_selectedOption = event.selectedOption;
|
||||
_hasSelectionChanged = true;
|
||||
emit(OptionSelectedState(
|
||||
selectedOption: _selectedOption,
|
||||
hasSelectionChanged: _hasSelectionChanged));
|
||||
}
|
||||
|
||||
void _fetchDeviceSettingSwitches(DeviceSettingSwitchInitial event,
|
||||
Emitter<DeviceSettingState> emit) async {
|
||||
emit(DeviceSettingLoadingState());
|
||||
try {
|
||||
var response = await DevicesAPI.getFourSceneInfo(deviceId);
|
||||
Map<String, String> sceneTitles = {
|
||||
"scene_1": '',
|
||||
"scene_2": '',
|
||||
"scene_3": '',
|
||||
"scene_4": '',
|
||||
};
|
||||
for (var item in response) {
|
||||
if (item["switchName"] != null) {
|
||||
sceneTitles[item["switchName"]] = item["scene"]["name"] ?? '';
|
||||
}
|
||||
}
|
||||
FourSceneModelState deviceStatus = FourSceneModelState(
|
||||
scene_1: sceneTitles["scene_1"] ?? '',
|
||||
scene_2: sceneTitles["scene_2"] ?? '',
|
||||
scene_3: sceneTitles["scene_3"] ?? '',
|
||||
scene_4: sceneTitles["scene_4"] ?? '',
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '',
|
||||
);
|
||||
emit(UpdateState(device: deviceStatus));
|
||||
} catch (e) {
|
||||
emit(DeviceSettingFailedState(errorMessage: e.toString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void assignSetting(
|
||||
AssignDeviceSetting event, Emitter<DeviceSettingState> emit) async {
|
||||
emit(DeviceSettingLoadingState());
|
||||
try {
|
||||
final response = await DevicesAPI.postFourSceneInfo(
|
||||
deviceId: deviceId,
|
||||
sceneUuid: event.sceneUuid,
|
||||
spaceUuid: event.unit!.id,
|
||||
switchName: event.switchName);
|
||||
|
||||
emit(SaveSelectionSuccessState());
|
||||
CustomSnackBar.displaySnackBar('Save Successfully');
|
||||
} catch (e) {
|
||||
emit(DeviceSettingFailedState(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
void _fetchDeviceSetting(
|
||||
FetchDeviceSetting event, Emitter<DeviceSettingState> emit) async {
|
||||
emit(DeviceSettingLoadingState());
|
||||
@ -315,7 +252,7 @@ class DeviceSettingBloc extends Bloc<DeviceSettingEvent, DeviceSettingState> {
|
||||
),
|
||||
];
|
||||
|
||||
bool isHelpful = false;
|
||||
bool? isHelpful;
|
||||
|
||||
void _toggleHelpful(
|
||||
ToggleHelpfulEvent event, Emitter<DeviceSettingState> emit) async {
|
||||
@ -338,30 +275,6 @@ class DeviceSettingBloc extends Bloc<DeviceSettingEvent, DeviceSettingState> {
|
||||
List<DeviceModel> allDevices = [];
|
||||
List<SubSpaceModel> roomsList = [];
|
||||
bool switchStatus = true;
|
||||
Future<void> changeSwitchStatus(
|
||||
ChangeSwitchStatusEvent event, Emitter<DeviceSettingState> emit) async {
|
||||
try {
|
||||
emit(DeviceSettingLoadingState());
|
||||
switchStatus = deviceStatus.switch_backlight;
|
||||
switchStatus = !switchStatus;
|
||||
final response = await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: deviceId,
|
||||
code: 'switch_backlight',
|
||||
value: switchStatus),
|
||||
deviceId);
|
||||
deviceStatus.switch_backlight = switchStatus;
|
||||
Future.delayed(const Duration(milliseconds: 200), () {
|
||||
add(const DeviceSettingSwitchInitial());
|
||||
});
|
||||
Future.delayed(const Duration(milliseconds: 200), () {
|
||||
emit(ChangeSwitchState(isEnable: switchStatus));
|
||||
emit(UpdateState(device: deviceStatus));
|
||||
});
|
||||
} catch (_) {
|
||||
add(const DeviceSettingInitial());
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onLoadSettings(
|
||||
LoadSettings event, Emitter<DeviceSettingState> emit) async {
|
||||
@ -519,6 +432,7 @@ class DeviceSettingBloc extends Bloc<DeviceSettingEvent, DeviceSettingState> {
|
||||
var response = await DevicesAPI.putDeviceName(
|
||||
deviceId: deviceId, deviceName: nameController.text);
|
||||
add(const DeviceSettingInitialInfo());
|
||||
await HomeCubit.getInstance().fetchUnitsByUserId();
|
||||
CustomSnackBar.displaySnackBar('Save Successfully');
|
||||
emit(SaveState());
|
||||
} catch (e) {
|
||||
@ -556,4 +470,14 @@ class DeviceSettingBloc extends Bloc<DeviceSettingEvent, DeviceSettingState> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void _onOptionSelected(
|
||||
SelectOptionEvent event, Emitter<DeviceSettingState> emit) {
|
||||
emit(DeviceSettingLoadingState());
|
||||
_selectedOption = event.selectedOption;
|
||||
_hasSelectionChanged = true;
|
||||
emit(OptionSelectedState(
|
||||
selectedOption: _selectedOption,
|
||||
hasSelectionChanged: _hasSelectionChanged));
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ class DeviceSettingInitialQuestion extends DeviceSettingEvent {
|
||||
const DeviceSettingInitialQuestion();
|
||||
}
|
||||
|
||||
class ChangeSwitchStatusEvent extends DeviceSettingEvent {}
|
||||
// class ChangeSwitchStatusEvent extends DeviceSettingEvent {}
|
||||
|
||||
class FetchRoomsEvent extends DeviceSettingEvent {
|
||||
final SpaceModel unit;
|
||||
@ -139,9 +139,9 @@ class AssignRoomEvent extends DeviceSettingEvent {
|
||||
|
||||
class FetchDeviceSetting extends DeviceSettingEvent {}
|
||||
|
||||
class DeviceSettingSwitchInitial extends DeviceSettingEvent {
|
||||
const DeviceSettingSwitchInitial();
|
||||
}
|
||||
// class DeviceSettingSwitchInitial extends DeviceSettingEvent {
|
||||
// const DeviceSettingSwitchInitial();
|
||||
// }
|
||||
|
||||
class AssignDeviceSetting extends DeviceSettingEvent {
|
||||
final String? sceneUuid;
|
||||
|
@ -1,25 +1,19 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/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/model/device_control_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_report_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/four_scene_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/question_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/four_scene_switch_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/group_devices_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_info_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/subspace_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scenes_model.dart';
|
||||
import 'package:syncrow_app/generated/assets.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/scene_api.dart';
|
||||
import 'package:syncrow_app/services/api/spaces_api.dart';
|
||||
import 'package:syncrow_app/utils/helpers/snack_bar.dart';
|
||||
|
||||
class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
@ -29,28 +23,17 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
}) : super(const FourSceneState()) {
|
||||
on<FourSceneInitial>(_fetchDeviceStatus);
|
||||
on<FourSceneInitialInfo>(fetchDeviceInfo);
|
||||
on<SaveNameEvent>(saveName);
|
||||
on<ToggleNotificationEvent>(_toggleNotification);
|
||||
on<ChangeNameEvent>(_changeName);
|
||||
on<SearchFaqEvent>(_onSearchFaq);
|
||||
on<FetchRoomsEvent>(_fetchRoomsAndDevices);
|
||||
on<ChangeSwitchStatusEvent>(changeSwitchStatus);
|
||||
on<LoadScenes>(_onLoadScenes);
|
||||
on<SearchScenesEvent>(searchScene);
|
||||
on<AssignRoomEvent>(_assignDevice);
|
||||
on<SelectOptionEvent>(_onOptionSelected);
|
||||
on<AddDeviceToGroup>(_addDeviceToGroup);
|
||||
on<RemoveDeviceFromGroup>(_removeDeviceFromGroup);
|
||||
on<FourSceneInitialQuestion>(_onFourSceneInitial);
|
||||
on<FetchDeviceScene>(_fetchDeviceScene);
|
||||
on<FourSceneSwitchInitial>(_fetchFourSceneSwitches);
|
||||
on<AssignDeviceScene>(assignScene);
|
||||
on<GetSceneBySwitchName>(getSceneByName);
|
||||
on<SelectSceneEvent>(_selectScene);
|
||||
on<DeleteDeviceEvent>(deleteDevice);
|
||||
on<ToggleEnableAlarmEvent>(_toggleLowBattery);
|
||||
on<ToggleUpdateEvent>(_toggleUpdate);
|
||||
on<ToggleHelpfulEvent>(_toggleHelpful);
|
||||
}
|
||||
|
||||
final TextEditingController nameController =
|
||||
@ -116,7 +99,15 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
|
||||
_selectScene(SelectSceneEvent event, Emitter<FourSceneState> emit) {
|
||||
emit(FourSceneLoadingState());
|
||||
print('-------${event.selectedSceneId}------');
|
||||
print('-------${event.isSelected}------');
|
||||
if (event.isSelected == false) {
|
||||
selectedSceneId = '';
|
||||
selectedFormApiSceneId = '';
|
||||
emit(SceneSelectionUpdatedState(selectedSceneId: selectedSceneId));
|
||||
} else {
|
||||
selectedSceneId = event.selectedSceneId;
|
||||
}
|
||||
emit(SceneSelectionUpdatedState(selectedSceneId: selectedSceneId));
|
||||
}
|
||||
|
||||
@ -147,7 +138,7 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
FourSceneSwitchInitial event, Emitter<FourSceneState> emit) async {
|
||||
emit(FourSceneLoadingState());
|
||||
try {
|
||||
var response = await DevicesAPI.getFourSceneInfo(fourSceneId);
|
||||
var response = await DevicesAPI.getDeviceSceneInfo(fourSceneId);
|
||||
Map<String, String> sceneTitles = {
|
||||
"scene_1": '',
|
||||
"scene_2": '',
|
||||
@ -178,11 +169,16 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
AssignDeviceScene event, Emitter<FourSceneState> emit) async {
|
||||
emit(FourSceneLoadingState());
|
||||
try {
|
||||
final response = await DevicesAPI.postFourSceneInfo(
|
||||
if (event.sceneUuid == '') {
|
||||
final response = await DevicesAPI.unAssignScenesDevice(
|
||||
deviceUuid: fourSceneId, switchName: event.switchName);
|
||||
} else {
|
||||
final response = await DevicesAPI.postDeviceSceneInfo(
|
||||
deviceId: fourSceneId,
|
||||
sceneUuid: event.sceneUuid,
|
||||
spaceUuid: event.unit!.id,
|
||||
switchName: event.switchName);
|
||||
}
|
||||
|
||||
emit(SaveSelectionSuccessState());
|
||||
CustomSnackBar.displaySnackBar('Save Successfully');
|
||||
@ -191,6 +187,7 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void _fetchDeviceScene(
|
||||
FetchDeviceScene event, Emitter<FourSceneState> emit) async {
|
||||
emit(FourSceneLoadingState());
|
||||
@ -256,16 +253,6 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _onSearchFaq(SearchFaqEvent event, Emitter<FourSceneState> emit) {
|
||||
emit(FourSceneLoadingState());
|
||||
List<QuestionModel> _faqQuestions = faqQuestions.where((question) {
|
||||
return question.question
|
||||
.toLowerCase()
|
||||
.contains(event.query.toLowerCase());
|
||||
}).toList();
|
||||
emit(FaqSearchState(filteredFaqQuestions: _faqQuestions));
|
||||
}
|
||||
|
||||
//============================ assign Device ==================================
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -283,56 +270,6 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
DeviceReport recordGroups =
|
||||
DeviceReport(startTime: '0', endTime: '0', data: []);
|
||||
|
||||
//========================= Question and faq ================================
|
||||
|
||||
final List<QuestionModel> faqQuestions = [
|
||||
QuestionModel(
|
||||
id: 1,
|
||||
question:
|
||||
'How does an 4 Scene Switch work? How long will an 4 Scene Switch persist?',
|
||||
answer:
|
||||
'Yes. In scenes with high detection requirements, we recommend that you choose phone or message notification in Automation.',
|
||||
),
|
||||
QuestionModel(
|
||||
id: 2,
|
||||
question: 'Does the 4 Scene Switch support sending notifications?',
|
||||
answer:
|
||||
'The SOS alarm will persist until it is manually turned off or after a set time.',
|
||||
),
|
||||
QuestionModel(
|
||||
id: 3,
|
||||
question:
|
||||
'Why does the data statistics in the device panel not show the correct data?',
|
||||
answer: 'Try restarting the device. If it persists, contact support.',
|
||||
),
|
||||
QuestionModel(
|
||||
id: 4,
|
||||
question:
|
||||
'How long will the App show offline after a device (low-power devices and normal devices) is powered...',
|
||||
answer:
|
||||
'No, a network connection is required to send the alert to your contacts.',
|
||||
),
|
||||
];
|
||||
|
||||
bool isHelpful = false;
|
||||
|
||||
void _toggleHelpful(
|
||||
ToggleHelpfulEvent event, Emitter<FourSceneState> emit) async {
|
||||
try {
|
||||
emit(FourSceneLoadingState());
|
||||
isHelpful = event.isHelpful!;
|
||||
emit(SaveState());
|
||||
} catch (e) {
|
||||
emit(const FourSceneFailedState(errorMessage: 'Something went wrong'));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onFourSceneInitial(
|
||||
FourSceneInitialQuestion event, Emitter<FourSceneState> emit) async {
|
||||
emit(FourSceneLoadingState());
|
||||
emit(FaqLoadedState(filteredFaqQuestions: faqQuestions));
|
||||
}
|
||||
|
||||
List<DeviceModel> allDevices = [];
|
||||
List<SubSpaceModel> roomsList = [];
|
||||
bool switchStatus = true;
|
||||
@ -393,159 +330,4 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
}).toList();
|
||||
emit(SearchResultsState());
|
||||
}
|
||||
|
||||
List<GroupDevicesModel> groupDevices = [
|
||||
GroupDevicesModel(
|
||||
dec: 'Syncroom', icon: Assets.minusIcon, name: '6 Scene Switch')
|
||||
];
|
||||
|
||||
List<GroupDevicesModel> devices = [
|
||||
GroupDevicesModel(
|
||||
dec: 'Syncroom', icon: Assets.addDevicesIcon, name: '6 Scene Switch')
|
||||
];
|
||||
|
||||
// Handler for AddDeviceToGroup
|
||||
void _addDeviceToGroup(AddDeviceToGroup event, Emitter<FourSceneState> emit) {
|
||||
devices.remove(event.device);
|
||||
groupDevices.add(event.device);
|
||||
for (var device in groupDevices) {
|
||||
device.icon = event.icon;
|
||||
}
|
||||
emit(UpdateStateList(groupDevices: groupDevices, devices: devices));
|
||||
}
|
||||
|
||||
// Handler for RemoveDeviceFromGroup
|
||||
void _removeDeviceFromGroup(
|
||||
RemoveDeviceFromGroup event, Emitter<FourSceneState> emit) {
|
||||
groupDevices.remove(event.device);
|
||||
devices.add(event.device);
|
||||
for (var device in groupDevices) {
|
||||
device.icon = event.icon;
|
||||
}
|
||||
emit(UpdateStateList(groupDevices: groupDevices, devices: devices));
|
||||
}
|
||||
|
||||
//=========================== assign device to room ==========================
|
||||
|
||||
void _assignDevice(
|
||||
AssignRoomEvent event, Emitter<FourSceneState> emit) async {
|
||||
try {
|
||||
emit(FourSceneLoadingState());
|
||||
if (_hasSelectionChanged) {
|
||||
await HomeManagementAPI.assignDeviceToRoom(event.unit.community.uuid,
|
||||
event.unit.id, event.roomId, fourSceneId);
|
||||
final devicesList = await DevicesAPI.getDevicesByRoomId(
|
||||
communityUuid: event.unit.community.uuid,
|
||||
spaceUuid: event.unit.id,
|
||||
roomId: event.roomId);
|
||||
List<String> allDevicesIds = [];
|
||||
allDevices.forEach((element) {
|
||||
allDevicesIds.add(element.uuid!);
|
||||
});
|
||||
await HomeCubit.getInstance().fetchUnitsByUserId();
|
||||
CustomSnackBar.displaySnackBar('Save Successfully');
|
||||
|
||||
emit(SaveSelectionSuccessState());
|
||||
}
|
||||
} catch (e) {
|
||||
emit(const FourSceneFailedState(errorMessage: 'Something went wrong'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void _fetchRoomsAndDevices(
|
||||
FetchRoomsEvent event, Emitter<FourSceneState> emit) async {
|
||||
try {
|
||||
emit(FourSceneLoadingState());
|
||||
roomsList = await SpacesAPI.getSubSpaceBySpaceId(
|
||||
event.unit.community.uuid, event.unit.id);
|
||||
emit(FetchRoomsState(devicesList: allDevices, roomsList: roomsList));
|
||||
} catch (e) {
|
||||
emit(const FourSceneFailedState(errorMessage: 'Something went wrong'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//============================ setting name ==================================
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void _changeName(ChangeNameEvent event, Emitter<FourSceneState> emit) {
|
||||
emit(FourSceneLoadingState());
|
||||
editName = event.value!;
|
||||
if (editName) {
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
focusNode.requestFocus();
|
||||
});
|
||||
} else {
|
||||
focusNode.unfocus();
|
||||
}
|
||||
emit(NameEditingState(editName: editName));
|
||||
}
|
||||
|
||||
bool _validateInputs() {
|
||||
final nameError = fullNameValidator(nameController.text);
|
||||
if (nameError != null) {
|
||||
CustomSnackBar.displaySnackBar(nameError);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
String? fullNameValidator(String? value) {
|
||||
if (value == null) return 'name is required';
|
||||
final withoutExtraSpaces = value.replaceAll(RegExp(r"\s+"), ' ').trim();
|
||||
if (withoutExtraSpaces.length < 2 || withoutExtraSpaces.length > 30) {
|
||||
return 'name must be between 2 and 30 characters long';
|
||||
}
|
||||
if (RegExp(r"/[^ a-zA-Z0-9-\']/").hasMatch(withoutExtraSpaces)) {
|
||||
return 'Only alphanumeric characters, space, dash and single quote are allowed';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<void> saveName(
|
||||
SaveNameEvent event, Emitter<FourSceneState> emit) async {
|
||||
if (_validateInputs()) return;
|
||||
try {
|
||||
add(const ChangeNameEvent(value: false));
|
||||
isSaving = true;
|
||||
emit(FourSceneLoadingState());
|
||||
var response = await DevicesAPI.putDeviceName(
|
||||
deviceId: fourSceneId, deviceName: nameController.text);
|
||||
add(const FourSceneInitialInfo());
|
||||
CustomSnackBar.displaySnackBar('Save Successfully');
|
||||
emit(SaveState());
|
||||
} catch (e) {
|
||||
emit(FourSceneFailedState(errorMessage: e.toString()));
|
||||
} finally {
|
||||
isSaving = false;
|
||||
}
|
||||
}
|
||||
|
||||
//====================== update device ==============================
|
||||
|
||||
bool enableUpdate = false;
|
||||
|
||||
void _toggleUpdate(
|
||||
ToggleUpdateEvent event, Emitter<FourSceneState> emit) async {
|
||||
try {
|
||||
emit(FourSceneLoadingState());
|
||||
enableUpdate = event.isUpdateEnabled!;
|
||||
emit(SaveState());
|
||||
} catch (e) {
|
||||
emit(const FourSceneFailedState(errorMessage: 'Something went wrong'));
|
||||
}
|
||||
}
|
||||
|
||||
deleteDevice(DeleteDeviceEvent event, Emitter<FourSceneState> emit) async {
|
||||
try {
|
||||
emit(FourSceneLoadingState());
|
||||
var response = await DevicesAPI.resetDevise(devicesUuid: fourSceneId);
|
||||
CustomSnackBar.displaySnackBar('Reset Successfully');
|
||||
emit(UpdateState(device: deviceStatus));
|
||||
} catch (e) {
|
||||
emit(FourSceneFailedState(errorMessage: e.toString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,10 +84,12 @@ class LoadScenes extends FourSceneEvent {
|
||||
|
||||
class SelectSceneEvent extends FourSceneEvent {
|
||||
final String selectedSceneId;
|
||||
final bool isSelected;
|
||||
// final String unitId;
|
||||
const SelectSceneEvent({
|
||||
// required this.unitId,
|
||||
required this.selectedSceneId,
|
||||
required this.isSelected,
|
||||
});
|
||||
}
|
||||
|
||||
@ -143,6 +145,13 @@ class FourSceneSwitchInitial extends FourSceneEvent {
|
||||
const FourSceneSwitchInitial();
|
||||
}
|
||||
|
||||
class UnAssignSceneEvent extends FourSceneEvent {
|
||||
final String deviceUuid;
|
||||
final String switchName;
|
||||
const UnAssignSceneEvent(
|
||||
{required this.deviceUuid, required this.switchName});
|
||||
}
|
||||
|
||||
class AssignDeviceScene extends FourSceneEvent {
|
||||
final String? sceneUuid;
|
||||
final String? switchName;
|
||||
|
@ -1,200 +1,200 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_bloc.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/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
// import 'package:flutter_svg/svg.dart';
|
||||
// import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_bloc.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/model/device_model.dart';
|
||||
// import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
// import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
// import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||
// import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
// import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||
// import 'package:syncrow_app/generated/assets.dart';
|
||||
// import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class FourSceneCreateGroup extends StatelessWidget {
|
||||
final DeviceModel? device;
|
||||
// class FourSceneCreateGroup extends StatelessWidget {
|
||||
// final DeviceModel? device;
|
||||
|
||||
const FourSceneCreateGroup({super.key, this.device});
|
||||
// const FourSceneCreateGroup({super.key, this.device});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultScaffold(
|
||||
title: 'Create Group',
|
||||
child: BlocProvider(
|
||||
create: (context) => FourSceneBloc(fourSceneId: device?.uuid ?? '')
|
||||
..add(const FourSceneInitial()),
|
||||
child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<FourSceneBloc>(context);
|
||||
return state is LoadingNewSate
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
)
|
||||
: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(left: 25, right: 25),
|
||||
child: BodySmall(
|
||||
text:
|
||||
'Devices in the same group can be controlled together',
|
||||
fontColor: ColorsManager.primaryTextColor,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: ListView.builder(
|
||||
itemCount: sensor.groupDevices.length,
|
||||
itemBuilder: (context, index) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
BlocProvider.of<FourSceneBloc>(context).add(
|
||||
RemoveDeviceFromGroup(
|
||||
sensor.groupDevices[index],
|
||||
Assets.addDevicesIcon));
|
||||
},
|
||||
child: DefaultContainer(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(5.0),
|
||||
child: Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
sensor.groupDevices[index].icon!,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 15,
|
||||
),
|
||||
BodyMedium(
|
||||
text: sensor
|
||||
.groupDevices[index].name!,
|
||||
fontColor:
|
||||
ColorsManager.primaryTextColor,
|
||||
textAlign: TextAlign.center,
|
||||
fontSize: 15,
|
||||
),
|
||||
],
|
||||
),
|
||||
BodyMedium(
|
||||
text: sensor.groupDevices[index].dec!,
|
||||
fontColor: ColorsManager.grayColor,
|
||||
textAlign: TextAlign.center,
|
||||
fontSize: 15,
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const BodyLarge(
|
||||
text: 'Devices to be added',
|
||||
fontColor: ColorsManager.grayColor,
|
||||
textAlign: TextAlign.center,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
sensor.devices.isNotEmpty
|
||||
? Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: sensor.devices.length,
|
||||
itemBuilder: (context, index) {
|
||||
final device = sensor.devices[index];
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
BlocProvider.of<FourSceneBloc>(
|
||||
context)
|
||||
.add(AddDeviceToGroup(device,
|
||||
Assets.minusIcon));
|
||||
},
|
||||
child: DefaultContainer(
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.all(5.0),
|
||||
child: Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment
|
||||
.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
device.icon!,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 15,
|
||||
),
|
||||
BodyMedium(
|
||||
text: device.name!,
|
||||
fontColor: ColorsManager
|
||||
.primaryTextColor,
|
||||
textAlign:
|
||||
TextAlign.center,
|
||||
fontSize: 15,
|
||||
),
|
||||
],
|
||||
),
|
||||
BodyMedium(
|
||||
text: device.dec!,
|
||||
fontColor: ColorsManager
|
||||
.grayColor,
|
||||
textAlign:
|
||||
TextAlign.center,
|
||||
fontSize: 15,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
: const Column(
|
||||
children: [
|
||||
BodySmall(
|
||||
text:
|
||||
'Currently no devices available to create group',
|
||||
fontColor: ColorsManager.grayColor,
|
||||
textAlign: TextAlign.center,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Spacer()
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return DefaultScaffold(
|
||||
// title: 'Create Group',
|
||||
// child: BlocProvider(
|
||||
// create: (context) => FourSceneBloc(fourSceneId: device?.uuid ?? '')
|
||||
// ..add(const FourSceneInitial()),
|
||||
// child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
||||
// builder: (context, state) {
|
||||
// final sensor = BlocProvider.of<FourSceneBloc>(context);
|
||||
// return state is LoadingNewSate
|
||||
// ? const Center(
|
||||
// child: DefaultContainer(
|
||||
// width: 50,
|
||||
// height: 50,
|
||||
// child: CircularProgressIndicator()),
|
||||
// )
|
||||
// : Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: Column(
|
||||
// children: [
|
||||
// const Padding(
|
||||
// padding: EdgeInsets.only(left: 25, right: 25),
|
||||
// child: BodySmall(
|
||||
// text:
|
||||
// 'Devices in the same group can be controlled together',
|
||||
// fontColor: ColorsManager.primaryTextColor,
|
||||
// textAlign: TextAlign.center,
|
||||
// ),
|
||||
// ),
|
||||
// Flexible(
|
||||
// child: ListView.builder(
|
||||
// itemCount: sensor.groupDevices.length,
|
||||
// itemBuilder: (context, index) {
|
||||
// return InkWell(
|
||||
// onTap: () {
|
||||
// BlocProvider.of<FourSceneBloc>(context).add(
|
||||
// RemoveDeviceFromGroup(
|
||||
// sensor.groupDevices[index],
|
||||
// Assets.addDevicesIcon));
|
||||
// },
|
||||
// child: DefaultContainer(
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(5.0),
|
||||
// child: Row(
|
||||
// crossAxisAlignment:
|
||||
// CrossAxisAlignment.start,
|
||||
// mainAxisAlignment:
|
||||
// MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// Row(
|
||||
// children: [
|
||||
// SvgPicture.asset(
|
||||
// sensor.groupDevices[index].icon!,
|
||||
// fit: BoxFit.contain,
|
||||
// ),
|
||||
// const SizedBox(
|
||||
// width: 15,
|
||||
// ),
|
||||
// BodyMedium(
|
||||
// text: sensor
|
||||
// .groupDevices[index].name!,
|
||||
// fontColor:
|
||||
// ColorsManager.primaryTextColor,
|
||||
// textAlign: TextAlign.center,
|
||||
// fontSize: 15,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// BodyMedium(
|
||||
// text: sensor.groupDevices[index].dec!,
|
||||
// fontColor: ColorsManager.grayColor,
|
||||
// textAlign: TextAlign.center,
|
||||
// fontSize: 15,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// )),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// Flexible(
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// const BodyLarge(
|
||||
// text: 'Devices to be added',
|
||||
// fontColor: ColorsManager.grayColor,
|
||||
// textAlign: TextAlign.center,
|
||||
// fontSize: 12,
|
||||
// fontWeight: FontWeight.w700,
|
||||
// ),
|
||||
// const SizedBox(
|
||||
// height: 5,
|
||||
// ),
|
||||
// sensor.devices.isNotEmpty
|
||||
// ? Expanded(
|
||||
// child: ListView.builder(
|
||||
// itemCount: sensor.devices.length,
|
||||
// itemBuilder: (context, index) {
|
||||
// final device = sensor.devices[index];
|
||||
// return GestureDetector(
|
||||
// onTap: () {
|
||||
// BlocProvider.of<FourSceneBloc>(
|
||||
// context)
|
||||
// .add(AddDeviceToGroup(device,
|
||||
// Assets.minusIcon));
|
||||
// },
|
||||
// child: DefaultContainer(
|
||||
// child: Padding(
|
||||
// padding:
|
||||
// const EdgeInsets.all(5.0),
|
||||
// child: Row(
|
||||
// crossAxisAlignment:
|
||||
// CrossAxisAlignment.start,
|
||||
// mainAxisAlignment:
|
||||
// MainAxisAlignment
|
||||
// .spaceBetween,
|
||||
// children: [
|
||||
// Row(
|
||||
// children: [
|
||||
// SvgPicture.asset(
|
||||
// device.icon!,
|
||||
// fit: BoxFit.contain,
|
||||
// ),
|
||||
// const SizedBox(
|
||||
// width: 15,
|
||||
// ),
|
||||
// BodyMedium(
|
||||
// text: device.name!,
|
||||
// fontColor: ColorsManager
|
||||
// .primaryTextColor,
|
||||
// textAlign:
|
||||
// TextAlign.center,
|
||||
// fontSize: 15,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// BodyMedium(
|
||||
// text: device.dec!,
|
||||
// fontColor: ColorsManager
|
||||
// .grayColor,
|
||||
// textAlign:
|
||||
// TextAlign.center,
|
||||
// fontSize: 15,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// )
|
||||
// : const Column(
|
||||
// children: [
|
||||
// BodySmall(
|
||||
// text:
|
||||
// 'Currently no devices available to create group',
|
||||
// fontColor: ColorsManager.grayColor,
|
||||
// textAlign: TextAlign.center,
|
||||
// fontSize: 12,
|
||||
// fontWeight: FontWeight.w400,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// const Spacer()
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
@ -1,9 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_bloc.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/device_settings_bloc/device_scene_bloc.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/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/question_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/device_settings/question_page.dart';
|
||||
@ -24,19 +24,18 @@ class FaqSettingPage extends StatelessWidget {
|
||||
return DefaultScaffold(
|
||||
title: 'FAQ',
|
||||
child: BlocProvider(
|
||||
create: (context) => FourSceneBloc(fourSceneId: device?.uuid ?? '')
|
||||
..add(const FourSceneInitialQuestion()),
|
||||
child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
||||
create: (context) => DeviceSettingBloc(deviceId: device?.uuid ?? '')
|
||||
..add(const DeviceSettingInitialQuestion()),
|
||||
child: BlocBuilder<DeviceSettingBloc, DeviceSettingState>(
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<FourSceneBloc>(context);
|
||||
|
||||
final sensor = BlocProvider.of<DeviceSettingBloc>(context);
|
||||
List<QuestionModel> displayedQuestions = [];
|
||||
if (state is FaqSearchState) {
|
||||
displayedQuestions = state.filteredFaqQuestions;
|
||||
} else if (state is FaqLoadedState) {
|
||||
displayedQuestions = state.filteredFaqQuestions;
|
||||
}
|
||||
return state is FourSceneLoadingState
|
||||
return state is DeviceSettingLoadingState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
width: 50,
|
||||
|
@ -3,9 +3,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:percent_indicator/linear_percent_indicator.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_bloc.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/device_settings_bloc/device_scene_bloc.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/view/device_settings/update_note.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
@ -15,20 +15,22 @@ import 'package:syncrow_app/generated/assets.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class UpdatePageSetting extends StatelessWidget {
|
||||
const UpdatePageSetting({super.key});
|
||||
final String? deviceId;
|
||||
const UpdatePageSetting({super.key, this.deviceId});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultScaffold(
|
||||
title: 'Device Update',
|
||||
child: BlocProvider(
|
||||
create: (context) =>
|
||||
FourSceneBloc(fourSceneId: '')..add(const FourSceneInitial()),
|
||||
child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
||||
create: (context) => DeviceSettingBloc(deviceId: deviceId ?? '')
|
||||
..add(const DeviceSettingInitial())
|
||||
..add(const DeviceSettingInitialInfo()),
|
||||
child: BlocBuilder<DeviceSettingBloc, DeviceSettingState>(
|
||||
builder: (context, state) {
|
||||
final _bloc = BlocProvider.of<FourSceneBloc>(context);
|
||||
final _bloc = BlocProvider.of<DeviceSettingBloc>(context);
|
||||
|
||||
return state is FourSceneLoadingState
|
||||
return state is DeviceSettingLoadingState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
width: 50,
|
||||
|
@ -37,8 +37,10 @@ class SixSelectSceneFourPage extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
final sensorBloc = BlocProvider.of<SixSceneBloc>(context);
|
||||
if (state is SaveSelectionSuccessState) {
|
||||
Future.delayed(const Duration(milliseconds: 250), () {
|
||||
Navigator.of(context).pop(true);
|
||||
Navigator.of(context).pop(true);
|
||||
});
|
||||
}
|
||||
return DefaultScaffold(
|
||||
title: 'Select Scene',
|
||||
@ -163,7 +165,8 @@ class SixSelectSceneFourPage extends StatelessWidget {
|
||||
disablePlayButton: false,
|
||||
onChanged: (isSelected) {
|
||||
sensorBloc.add(SelectOptionEvent(selectedOption: scene.id));
|
||||
sensorBloc.add(SelectSceneEvent(unitId: scene.id));
|
||||
sensorBloc.add(SelectSceneEvent(
|
||||
selectedSceneId: scene.id, isSelected: isSelected));
|
||||
},
|
||||
icon: scene.iconInBytes,
|
||||
title: scene.name,
|
||||
|
@ -196,12 +196,14 @@ class SixSceneScreen extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (value == true) {
|
||||
_bloc.add(const SixSceneInitial());
|
||||
_bloc.add(
|
||||
const SixSceneInitialInfo());
|
||||
Future.delayed(
|
||||
const Duration(
|
||||
milliseconds: 250), () {
|
||||
_bloc.add(
|
||||
const SexSceneSwitchInitial());
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Column(
|
||||
|
@ -175,12 +175,14 @@ class FourSceneScreen extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (value == true) {
|
||||
_bloc.add(const FourSceneInitial());
|
||||
_bloc.add(
|
||||
const FourSceneInitialInfo());
|
||||
Future.delayed(
|
||||
const Duration(
|
||||
milliseconds: 250), () {
|
||||
_bloc.add(
|
||||
const FourSceneSwitchInitial());
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Column(
|
||||
|
@ -37,8 +37,10 @@ class FourSelectSceneFourPage extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
final sensorBloc = BlocProvider.of<FourSceneBloc>(context);
|
||||
if (state is SaveSelectionSuccessState) {
|
||||
Future.delayed(const Duration(milliseconds: 250), () {
|
||||
Navigator.of(context).pop(true);
|
||||
Navigator.of(context).pop(true);
|
||||
});
|
||||
}
|
||||
return DefaultScaffold(
|
||||
title: 'Select Scene',
|
||||
@ -153,55 +155,25 @@ class FourSelectSceneFourPage extends StatelessWidget {
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
final scene = scenes[index];
|
||||
|
||||
// Check if this scene is currently selected
|
||||
bool isSelected = scene.id ==
|
||||
(state is SceneSelectionUpdatedState
|
||||
? state.selectedSceneId
|
||||
: sensorBloc.selectedFormApiSceneId);
|
||||
|
||||
return SceneItem(
|
||||
id: scene.id,
|
||||
value: isSelected,
|
||||
value: isSelected, // Pass isSelected to the SceneItem
|
||||
disablePlayButton: false,
|
||||
onChanged: (isSelected) {
|
||||
onChanged: (newSelection) {
|
||||
// If selected, assign the scene
|
||||
sensorBloc.add(SelectOptionEvent(selectedOption: scene.id));
|
||||
|
||||
sensorBloc.add(SelectSceneEvent(selectedSceneId: scene.id));
|
||||
sensorBloc.add(SelectSceneEvent(selectedSceneId: scene.id,isSelected:newSelection));
|
||||
},
|
||||
icon: scene.iconInBytes,
|
||||
title: scene.name,
|
||||
);
|
||||
|
||||
// if (index == scenes.length) {
|
||||
// return InkWell(
|
||||
// onTap: () => Navigator.pushNamed(
|
||||
// NavigationService.navigatorKey.currentContext!,
|
||||
// Routes.sceneTasksRoute,
|
||||
// arguments: SceneSettingsRouteArguments(
|
||||
// sceneType: '',
|
||||
// sceneId: '',
|
||||
// sceneName: '',
|
||||
// ),
|
||||
// ),
|
||||
// child: CreateSceneItem(),
|
||||
// );
|
||||
// } else {
|
||||
// final scene = scenes[index];
|
||||
// bool isSelected = scene.id ==
|
||||
// (state is SceneSelectionUpdatedState
|
||||
// ? state.selectedSceneId
|
||||
// : sensorBloc.selectedFormApiSceneId);
|
||||
// return SceneItem(
|
||||
// id: scene.id,
|
||||
// value: isSelected,
|
||||
// disablePlayButton: false,
|
||||
// onChanged: (isSelected) {
|
||||
// sensorBloc.add(SelectOptionEvent(selectedOption: scene.id));
|
||||
|
||||
// sensorBloc.add(SelectSceneEvent(selectedSceneId: scene.id));
|
||||
// },
|
||||
// icon: scene.iconInBytes,
|
||||
// title: scene.name,
|
||||
// );
|
||||
// }
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -317,3 +289,37 @@ class CreateSceneItem extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if (index == scenes.length) {
|
||||
// return InkWell(
|
||||
// onTap: () => Navigator.pushNamed(
|
||||
// NavigationService.navigatorKey.currentContext!,
|
||||
// Routes.sceneTasksRoute,
|
||||
// arguments: SceneSettingsRouteArguments(
|
||||
// sceneType: '',
|
||||
// sceneId: '',
|
||||
// sceneName: '',
|
||||
// ),
|
||||
// ),
|
||||
// child: CreateSceneItem(),
|
||||
// );
|
||||
// } else {
|
||||
// final scene = scenes[index];
|
||||
// bool isSelected = scene.id ==
|
||||
// (state is SceneSelectionUpdatedState
|
||||
// ? state.selectedSceneId
|
||||
// : sensorBloc.selectedFormApiSceneId);
|
||||
// return SceneItem(
|
||||
// id: scene.id,
|
||||
// value: isSelected,
|
||||
// disablePlayButton: false,
|
||||
// onChanged: (isSelected) {
|
||||
// sensorBloc.add(SelectOptionEvent(selectedOption: scene.id));
|
||||
|
||||
// sensorBloc.add(SelectSceneEvent(selectedSceneId: scene.id));
|
||||
// },
|
||||
// icon: scene.iconInBytes,
|
||||
// title: scene.name,
|
||||
// );
|
||||
// }
|
@ -213,11 +213,12 @@ abstract class ApiEndpoints {
|
||||
'/device/report-logs/{deviceUuid}?code={code}&startTime={startTime}&endTime={endTime}';
|
||||
static const String controlBatch = '/device/control/batch';
|
||||
static const String statusBatch = '/device/status/batch';
|
||||
static const String fourScene = '/device/{deviceUuid}/scenes';
|
||||
static const String deviceScene = '/device/{deviceUuid}/scenes';
|
||||
|
||||
static const String fourSceneByName =
|
||||
'/device/{deviceUuid}/scenes?switchName={switchName}';
|
||||
|
||||
static const String resetDevice = '/factory/reset/{deviceUuid}';
|
||||
static const String unAssignScenesDevice = '/factory/reset/{deviceUuid}';
|
||||
static const String unAssignScenesDevice =
|
||||
'/device/{deviceUuid}/scenes?switchName={switchName}';
|
||||
}
|
||||
|
@ -91,7 +91,6 @@ class DevicesAPI {
|
||||
.replaceAll('{deviceUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
print('json==#$json');
|
||||
return json;
|
||||
},
|
||||
);
|
||||
@ -138,11 +137,12 @@ class DevicesAPI {
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future getFourSceneInfo(String deviceId) async {
|
||||
static Future getDeviceSceneInfo(String deviceId) async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.fourScene.replaceAll('{deviceUuid}', deviceId),
|
||||
path: ApiEndpoints.deviceScene.replaceAll('{deviceUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
print(json);
|
||||
return json;
|
||||
});
|
||||
return response;
|
||||
@ -161,14 +161,14 @@ class DevicesAPI {
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future postFourSceneInfo({
|
||||
static Future postDeviceSceneInfo({
|
||||
String? switchName,
|
||||
String? sceneUuid,
|
||||
String? deviceId,
|
||||
String? spaceUuid,
|
||||
}) async {
|
||||
final response = await _httpService.post(
|
||||
path: ApiEndpoints.fourScene.replaceAll('{deviceUuid}', deviceId!),
|
||||
path: ApiEndpoints.deviceScene.replaceAll('{deviceUuid}', deviceId!),
|
||||
body: jsonEncode(
|
||||
{
|
||||
"switchName": switchName,
|
||||
@ -178,7 +178,6 @@ class DevicesAPI {
|
||||
),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
print('postFourSceneInfo=$json');
|
||||
return json;
|
||||
});
|
||||
return response;
|
||||
@ -189,7 +188,7 @@ class DevicesAPI {
|
||||
path: ApiEndpoints.deviceByUuid.replaceAll('{deviceUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
print('json==$json');
|
||||
print('object-*-*-*${json}');
|
||||
return json;
|
||||
});
|
||||
return response;
|
||||
@ -529,4 +528,20 @@ class DevicesAPI {
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future unAssignScenesDevice({
|
||||
String? deviceUuid,
|
||||
String? switchName,
|
||||
}) async {
|
||||
final response = await _httpService.delete(
|
||||
path: ApiEndpoints.unAssignScenesDevice
|
||||
.replaceAll('{deviceUuid}', deviceUuid!)
|
||||
.replaceAll('{switchName}', switchName!),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
},
|
||||
);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user