mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 18:16:21 +00:00
four_scene&6scene
This commit is contained in:
@ -4,9 +4,11 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.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/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/scene_switch_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/sex_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';
|
||||
@ -15,40 +17,100 @@ import 'package:syncrow_app/generated/assets.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/spaces_api.dart';
|
||||
import 'package:syncrow_app/utils/helpers/snack_bar.dart';
|
||||
|
||||
class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
final String sixSceneId;
|
||||
SixSceneBloc({
|
||||
required this.sixSceneId,
|
||||
}) : super(const SixSceneState()) {
|
||||
on<SixSceneInitial>(_fetchStatus);
|
||||
on<ReportLogsInitial>(fetchLogsForLastMonth);
|
||||
on<SixSceneInitial>(_fetchDeviceStatus);
|
||||
on<ToggleNotificationEvent>(_toggleNotification);
|
||||
on<ChangeNameEvent>(_changeName);
|
||||
on<SearchFaqEvent>(_onSearchFaq);
|
||||
on<FetchRoomsEvent>(_fetchRoomsAndDevices);
|
||||
on<ChangeSwitchStatusEvent>(changeSwitchStatus);
|
||||
on<LoadScenes>(_onLoadScenes);
|
||||
on<SelectSceneEvent>(_selectScene);
|
||||
on<SearchScenesEvent>(searchScene);
|
||||
on<SaveSelectionEvent>(_onSaveSelection);
|
||||
on<SelectOptionEvent>(_onOptionSelected);
|
||||
on<AddDeviceToGroup>(_addDeviceToGroup); // Register handler here
|
||||
on<RemoveDeviceFromGroup>(_removeDeviceFromGroup);
|
||||
on<SexSceneSwitchInitial>(_fetchFourSceneSwitches);
|
||||
on<AssignDeviceScene>(assignScene);
|
||||
on<GetSceneBySwitchName>(getSceneByName);
|
||||
on<SelectSceneEvent>(_selectScene);
|
||||
on<SixSceneInitialInfo>(fetchDeviceInfo);
|
||||
on<ControlDeviceScene>(_controlDevice);
|
||||
}
|
||||
|
||||
final TextEditingController nameController =
|
||||
TextEditingController(text: '${'firstName'}');
|
||||
TextEditingController(text: deviceName);
|
||||
bool isSaving = false;
|
||||
bool editName = false;
|
||||
final FocusNode focusNode = FocusNode();
|
||||
bool closingReminder = false;
|
||||
bool waterAlarm = false;
|
||||
static String deviceName = '';
|
||||
|
||||
SixSceneModel deviceStatus =
|
||||
SixSceneModel(waterContactState: 'normal', batteryPercentage: 0);
|
||||
SixSceneModel deviceStatus = SixSceneModel(
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
scene_4: '',
|
||||
scene_5: '',
|
||||
scene_6: '',
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: false);
|
||||
|
||||
void _fetchStatus(SixSceneInitial event, Emitter<SixSceneState> emit) async {
|
||||
SceneSwitch deviceInfo = SceneSwitch(
|
||||
activeTime: 0,
|
||||
category: "",
|
||||
categoryName: "",
|
||||
createTime: 0,
|
||||
gatewayId: "",
|
||||
icon: "",
|
||||
ip: "",
|
||||
lat: "",
|
||||
localKey: "",
|
||||
lon: "",
|
||||
model: "",
|
||||
name: "",
|
||||
nodeId: "",
|
||||
online: false,
|
||||
ownerId: "",
|
||||
productName: "",
|
||||
sub: false,
|
||||
timeZone: "",
|
||||
updateTime: 0,
|
||||
uuid: "",
|
||||
productUuid: "",
|
||||
productType: "",
|
||||
permissionType: "",
|
||||
macAddress: "",
|
||||
subspace: Subspace(
|
||||
uuid: "",
|
||||
createdAt: "",
|
||||
updatedAt: "",
|
||||
subspaceName: "",
|
||||
),
|
||||
);
|
||||
|
||||
Future fetchDeviceInfo(
|
||||
SixSceneInitialInfo event, Emitter<SixSceneState> emit) async {
|
||||
try {
|
||||
emit(SixSceneLoadingState());
|
||||
var response = await DevicesAPI.getDeviceInfo(sixSceneId);
|
||||
deviceInfo = SceneSwitch.fromJson(response);
|
||||
deviceName = deviceInfo.name;
|
||||
emit(LoadingDeviceInfo(deviceInfo: deviceInfo));
|
||||
} catch (e) {
|
||||
emit(SixSceneFailedState(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
void _fetchDeviceStatus(
|
||||
SixSceneInitial event, Emitter<SixSceneState> emit) async {
|
||||
emit(SixSceneLoadingState());
|
||||
try {
|
||||
var response = await DevicesAPI.getDeviceStatus(sixSceneId);
|
||||
@ -59,16 +121,90 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
deviceStatus = SixSceneModel.fromJson(
|
||||
statusModelList,
|
||||
);
|
||||
add(const SexSceneSwitchInitial());
|
||||
emit(UpdateState(sensor: deviceStatus));
|
||||
|
||||
Future.delayed(const Duration(milliseconds: 500));
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(SixSceneFailedState(errorMessage: e.toString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
String selectedFormApiSceneId = '';
|
||||
|
||||
void getSceneByName(
|
||||
GetSceneBySwitchName event, Emitter<SixSceneState> emit) async {
|
||||
emit(SixSceneLoadingState());
|
||||
try {
|
||||
final response = await DevicesAPI.getSceneBySwitchName(
|
||||
deviceId: sixSceneId, switchName: event.switchName);
|
||||
selectedFormApiSceneId = response['scene']['uuid'];
|
||||
emit(UpdateState(sensor: deviceStatus));
|
||||
} catch (e) {
|
||||
emit(SixSceneFailedState(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
String selectedSceneId = '';
|
||||
|
||||
_selectScene(SelectSceneEvent event, Emitter<SixSceneState> emit) {
|
||||
emit(SixSceneLoadingState());
|
||||
selectedSceneId = event.unitId;
|
||||
emit(SceneSelectionUpdatedState(selectedSceneId: selectedSceneId));
|
||||
}
|
||||
|
||||
List<SixSceneModel> fourScene = [];
|
||||
|
||||
void _fetchFourSceneSwitches(
|
||||
SexSceneSwitchInitial event, Emitter<SixSceneState> emit) async {
|
||||
emit(SixSceneLoadingState());
|
||||
try {
|
||||
var response = await DevicesAPI.getFourSceneInfo(sixSceneId);
|
||||
Map<String, String> sceneTitles = {
|
||||
"scene_1": '',
|
||||
"scene_2": '',
|
||||
"scene_3": '',
|
||||
"scene_4": '',
|
||||
"scene_5": '',
|
||||
"scene_6": '',
|
||||
};
|
||||
for (var item in response) {
|
||||
if (item["switchName"] != null) {
|
||||
sceneTitles[item["switchName"]] = item["scene"]["name"] ?? '';
|
||||
}
|
||||
}
|
||||
SixSceneModel deviceStatus = SixSceneModel(
|
||||
scene_1: sceneTitles["scene_1"] ?? '',
|
||||
scene_2: sceneTitles["scene_2"] ?? '',
|
||||
scene_3: sceneTitles["scene_3"] ?? '',
|
||||
scene_4: sceneTitles["scene_4"] ?? '',
|
||||
scene_5: sceneTitles["scene_5"] ?? '',
|
||||
scene_6: sceneTitles["scene_6"] ?? '',
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '',
|
||||
);
|
||||
emit(UpdateState(sensor: deviceStatus));
|
||||
} catch (e) {
|
||||
emit(SixSceneFailedState(errorMessage: e.toString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void assignScene(AssignDeviceScene event, Emitter<SixSceneState> emit) async {
|
||||
emit(SixSceneLoadingState());
|
||||
try {
|
||||
final response = await DevicesAPI.postFourSceneInfo(
|
||||
deviceId: sixSceneId,
|
||||
sceneUuid: event.sceneUuid,
|
||||
spaceUuid: event.unit!.id,
|
||||
switchName: event.switchName);
|
||||
|
||||
emit(SaveSelectionSuccessState());
|
||||
CustomSnackBar.displaySnackBar('Save Successfully');
|
||||
} catch (e) {
|
||||
emit(SixSceneFailedState(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
void _onSearchFaq(SearchFaqEvent event, Emitter<SixSceneState> emit) {
|
||||
emit(SixSceneLoadingState());
|
||||
// Filter FAQ questions based on search query
|
||||
@ -77,8 +213,6 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
.toLowerCase()
|
||||
.contains(event.query.toLowerCase());
|
||||
}).toList();
|
||||
|
||||
print(_faqQuestions);
|
||||
emit(FaqSearchState(filteredFaqQuestions: _faqQuestions));
|
||||
}
|
||||
|
||||
@ -101,16 +235,6 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
try {
|
||||
closingReminder = event.isClosingEnabled;
|
||||
emit(UpdateState(sensor: deviceStatus));
|
||||
|
||||
// API call to update the state, if necessary
|
||||
// await DevicesAPI.controlDevice(
|
||||
// DeviceControlModel(
|
||||
// deviceId: sosId,
|
||||
// code: 'closing_reminder',
|
||||
// value: closingReminder,
|
||||
// ),
|
||||
// sosId,
|
||||
// );
|
||||
} catch (e) {
|
||||
emit(SixSceneFailedState(errorMessage: e.toString()));
|
||||
}
|
||||
@ -119,29 +243,6 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
DeviceReport recordGroups =
|
||||
DeviceReport(startTime: '0', endTime: '0', data: []);
|
||||
|
||||
Future<void> fetchLogsForLastMonth(
|
||||
ReportLogsInitial event, Emitter<SixSceneState> emit) async {
|
||||
DateTime now = DateTime.now();
|
||||
DateTime lastMonth = DateTime(now.year, now.month - 1, now.day);
|
||||
int startTime = lastMonth.millisecondsSinceEpoch;
|
||||
int endTime = now.millisecondsSinceEpoch;
|
||||
try {
|
||||
emit(SixSceneLoadingState());
|
||||
var response = await DevicesAPI.getReportLogs(
|
||||
startTime: startTime.toString(),
|
||||
endTime: endTime.toString(),
|
||||
deviceUuid: sixSceneId,
|
||||
code: 'sossensor_state',
|
||||
);
|
||||
recordGroups = response;
|
||||
emit(UpdateState(sensor: deviceStatus));
|
||||
} on DioException catch (e) {
|
||||
final errorData = e.response!.data;
|
||||
String errorMessage = errorData['message'];
|
||||
emit(SixSceneFailedState(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
final List<SixSceneQuestionModel> faqQuestions = [
|
||||
SixSceneQuestionModel(
|
||||
id: 1,
|
||||
@ -196,15 +297,28 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
}
|
||||
|
||||
bool switchStatus = true;
|
||||
void changeSwitchStatus(
|
||||
ChangeSwitchStatusEvent event, Emitter<SixSceneState> emit) {
|
||||
emit(SixSceneLoadingState());
|
||||
switchStatus = !switchStatus;
|
||||
emit(ChangeSwitchState(isEnable: switchStatus));
|
||||
Future<void> changeSwitchStatus(
|
||||
ChangeSwitchStatusEvent event, Emitter<SixSceneState> emit) async {
|
||||
try {
|
||||
emit(SixSceneLoadingState());
|
||||
switchStatus = deviceStatus.switch_backlight;
|
||||
switchStatus = !switchStatus;
|
||||
final response = await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: sixSceneId,
|
||||
code: 'switch_backlight',
|
||||
value: switchStatus),
|
||||
sixSceneId);
|
||||
deviceStatus.switch_backlight = switchStatus;
|
||||
if (!response['success']) {
|
||||
add(const SixSceneInitial());
|
||||
}
|
||||
emit(ChangeSwitchState(isEnable: switchStatus));
|
||||
} catch (_) {
|
||||
add(const SixSceneInitial());
|
||||
}
|
||||
}
|
||||
|
||||
// List<ScenesModel> allScenes = [];
|
||||
|
||||
Future<void> _onLoadScenes(
|
||||
LoadScenes event, Emitter<SixSceneState> emit) async {
|
||||
emit(SixSceneLoadingState());
|
||||
@ -226,12 +340,6 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
}
|
||||
|
||||
bool selecedScene = false;
|
||||
String selectedSceneId = '';
|
||||
_selectScene(SelectSceneEvent event, Emitter<SixSceneState> emit) {
|
||||
emit(SixSceneLoadingState());
|
||||
selecedScene = !selecedScene;
|
||||
emit(SelectedSceneState());
|
||||
}
|
||||
|
||||
List<ScenesModel> allScenes = [];
|
||||
List<ScenesModel> filteredScenes = [];
|
||||
@ -278,19 +386,6 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
dec: 'Syncroom', icon: Assets.addDevicesIcon, name: '6 Scene Switch')
|
||||
];
|
||||
|
||||
// @override
|
||||
// Stream<SixSceneState> mapEventToState(SixSceneEvent event) async* {
|
||||
// if (event is AddDeviceToGroup) {
|
||||
// devices.remove(event.device);
|
||||
// groupDevices.add(event.device);
|
||||
// yield UpdateStateList(groupDevices: groupDevices, devices: devices);
|
||||
// } else if (event is RemoveDeviceFromGroup) {
|
||||
// groupDevices.remove(event.device);
|
||||
// devices.add(event.device);
|
||||
// yield UpdateStateList(groupDevices: groupDevices, devices: devices);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Handler for AddDeviceToGroup
|
||||
void _addDeviceToGroup(AddDeviceToGroup event, Emitter<SixSceneState> emit) {
|
||||
devices.remove(event.device);
|
||||
@ -306,9 +401,30 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
RemoveDeviceFromGroup event, Emitter<SixSceneState> emit) {
|
||||
groupDevices.remove(event.device);
|
||||
devices.add(event.device);
|
||||
for (var device in groupDevices) {
|
||||
for (var device in groupDevices) {
|
||||
device.icon = event.icon;
|
||||
}
|
||||
emit(UpdateStateList(groupDevices: groupDevices, devices: devices));
|
||||
}
|
||||
|
||||
void _controlDevice(
|
||||
ControlDeviceScene event, Emitter<SixSceneState> emit) async {
|
||||
emit(SixSceneLoadingState());
|
||||
try {
|
||||
deviceStatus.switch_backlight = !event.backLight!;
|
||||
emit(UpdateState(sensor: deviceStatus));
|
||||
final response = await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: sixSceneId,
|
||||
code: 'switch_backlight',
|
||||
value: !event.backLight!),
|
||||
sixSceneId);
|
||||
|
||||
if (!response['success']) {
|
||||
// add(InitialEvent(groupScreen: oneTouchGroup));
|
||||
}
|
||||
} catch (_) {
|
||||
// add(InitialEvent(groupScreen: oneTouchGroup));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,10 +24,24 @@ class SixSceneSwitch extends SixSceneEvent {
|
||||
|
||||
class SixSceneUpdated extends SixSceneEvent {}
|
||||
|
||||
class GetSceneBySwitchName extends SixSceneEvent {
|
||||
final String? switchName;
|
||||
|
||||
const GetSceneBySwitchName({this.switchName});
|
||||
}
|
||||
|
||||
class SixSceneInitial extends SixSceneEvent {
|
||||
const SixSceneInitial();
|
||||
}
|
||||
|
||||
class SixSceneInitialInfo extends SixSceneEvent {
|
||||
const SixSceneInitialInfo();
|
||||
}
|
||||
|
||||
class SexSceneSwitchInitial extends SixSceneEvent {
|
||||
const SexSceneSwitchInitial();
|
||||
}
|
||||
|
||||
class ReportLogsInitial extends SixSceneEvent {
|
||||
const ReportLogsInitial();
|
||||
}
|
||||
@ -171,3 +185,19 @@ class RemoveDeviceFromGroup extends SixSceneEvent {
|
||||
|
||||
RemoveDeviceFromGroup(this.device, this.icon);
|
||||
}
|
||||
|
||||
class AssignDeviceScene extends SixSceneEvent {
|
||||
final String? sceneUuid;
|
||||
final String? switchName;
|
||||
final SpaceModel? unit;
|
||||
const AssignDeviceScene({
|
||||
this.sceneUuid,
|
||||
this.unit,
|
||||
this.switchName,
|
||||
});
|
||||
}
|
||||
|
||||
class ControlDeviceScene extends SixSceneEvent {
|
||||
final bool? backLight;
|
||||
const ControlDeviceScene({this.backLight});
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/group_devices_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/scene_switch_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/sex_scene_question_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/six_scene_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/subspace_model.dart';
|
||||
@ -111,3 +112,17 @@ class OptionSelectedState extends SixSceneState {
|
||||
@override
|
||||
List<Object> get props => [selectedOption, hasSelectionChanged];
|
||||
}
|
||||
|
||||
class SceneSelectionUpdatedState extends SixSceneState {
|
||||
final String selectedSceneId;
|
||||
|
||||
SceneSelectionUpdatedState({required this.selectedSceneId});
|
||||
}
|
||||
|
||||
class LoadingDeviceInfo extends SixSceneState {
|
||||
final SceneSwitch deviceInfo;
|
||||
const LoadingDeviceInfo({required this.deviceInfo});
|
||||
|
||||
@override
|
||||
List<Object> get props => [deviceInfo];
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
on<FetchRoomsEvent>(_fetchRoomsAndDevices);
|
||||
on<ChangeSwitchStatusEvent>(changeSwitchStatus);
|
||||
on<LoadScenes>(_onLoadScenes);
|
||||
on<SelectSceneEvent>(_selectScene);
|
||||
on<SearchScenesEvent>(searchScene);
|
||||
on<AssignRoomEvent>(_assignDevice);
|
||||
on<SelectOptionEvent>(_onOptionSelected);
|
||||
@ -47,6 +46,7 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
on<FourSceneSwitchInitial>(_fetchFourSceneSwitches);
|
||||
on<AssignDeviceScene>(assignScene);
|
||||
on<GetSceneBySwitchName>(getSceneByName);
|
||||
on<SelectSceneEvent>(_selectScene);
|
||||
}
|
||||
|
||||
final TextEditingController nameController =
|
||||
@ -99,7 +99,17 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
subspaceName: "",
|
||||
),
|
||||
);
|
||||
String sceneId = '';
|
||||
String selectedFormApiSceneId = '';
|
||||
|
||||
String selectedSceneId = '';
|
||||
|
||||
_selectScene(SelectSceneEvent event, Emitter<FourSceneState> emit) {
|
||||
emit(FourSceneLoadingState());
|
||||
|
||||
selectedSceneId = event.selectedSceneId;
|
||||
emit(SceneSelectionUpdatedState(selectedSceneId: selectedSceneId));
|
||||
}
|
||||
|
||||
Future<void> saveName(
|
||||
SaveNameEvent event, Emitter<FourSceneState> emit) async {
|
||||
if (_validateInputs()) return;
|
||||
@ -119,6 +129,34 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
}
|
||||
}
|
||||
|
||||
void getSceneByName(
|
||||
GetSceneBySwitchName event, Emitter<FourSceneState> emit) async {
|
||||
emit(FourSceneLoadingState());
|
||||
try {
|
||||
final response = await DevicesAPI.getSceneBySwitchName(
|
||||
deviceId: fourSceneId, switchName: event.switchName);
|
||||
selectedFormApiSceneId = response['scene']['uuid'];
|
||||
emit(UpdateState(device: deviceStatus));
|
||||
} catch (e) {
|
||||
emit(FourSceneFailedState(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
bool selecedScene = false;
|
||||
|
||||
String _selectedOption = '';
|
||||
bool _hasSelectionChanged = false;
|
||||
|
||||
void _onOptionSelected(
|
||||
SelectOptionEvent event, Emitter<FourSceneState> emit) {
|
||||
emit(FourSceneLoadingState());
|
||||
_selectedOption = event.selectedOption;
|
||||
_hasSelectionChanged = true;
|
||||
emit(OptionSelectedState(
|
||||
selectedOption: _selectedOption,
|
||||
hasSelectionChanged: _hasSelectionChanged));
|
||||
}
|
||||
|
||||
List<FourSceneSwitchModel> fourScene = [];
|
||||
|
||||
void _fetchFourSceneSwitches(
|
||||
@ -130,15 +168,13 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
"scene_1": '',
|
||||
"scene_2": '',
|
||||
"scene_3": '',
|
||||
"scene_4": ''
|
||||
"scene_4": '',
|
||||
};
|
||||
for (var item in response) {
|
||||
if (item["switchName"] != null) {
|
||||
sceneTitles[item["switchName"]] = item["scene"]["name"] ?? '';
|
||||
}
|
||||
}
|
||||
print('object======4${response}');
|
||||
|
||||
FourSceneModelState deviceStatus = FourSceneModelState(
|
||||
scene_1: sceneTitles["scene_1"] ?? '',
|
||||
scene_2: sceneTitles["scene_2"] ?? '',
|
||||
@ -182,20 +218,9 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
sceneUuid: event.sceneUuid,
|
||||
spaceUuid: event.unit!.id,
|
||||
switchName: event.switchName);
|
||||
emit(SaveSelectionSuccessState());
|
||||
} catch (e) {
|
||||
emit(FourSceneFailedState(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
void getSceneByName(
|
||||
GetSceneBySwitchName event, Emitter<FourSceneState> emit) async {
|
||||
emit(FourSceneLoadingState());
|
||||
try {
|
||||
final response = await DevicesAPI.getSceneBySwitchName(
|
||||
deviceId: fourSceneId, switchName: event.switchName);
|
||||
sceneId = response['scene']['uuid'];
|
||||
emit(SaveSelectionSuccessState());
|
||||
CustomSnackBar.displaySnackBar('Save Successfully');
|
||||
} catch (e) {
|
||||
emit(FourSceneFailedState(errorMessage: e.toString()));
|
||||
}
|
||||
@ -398,14 +423,6 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
}
|
||||
}
|
||||
|
||||
bool selecedScene = false;
|
||||
String selectedSceneId = '';
|
||||
_selectScene(SelectSceneEvent event, Emitter<FourSceneState> emit) {
|
||||
emit(FourSceneLoadingState());
|
||||
selecedScene = !selecedScene;
|
||||
emit(SelectedSceneState());
|
||||
}
|
||||
|
||||
List<ScenesModel> allScenes = [];
|
||||
List<ScenesModel> filteredScenes = [];
|
||||
|
||||
@ -420,19 +437,6 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
emit(SearchResultsState());
|
||||
}
|
||||
|
||||
String _selectedOption = '';
|
||||
bool _hasSelectionChanged = false;
|
||||
|
||||
void _onOptionSelected(
|
||||
SelectOptionEvent event, Emitter<FourSceneState> emit) {
|
||||
emit(FourSceneLoadingState());
|
||||
_selectedOption = event.selectedOption;
|
||||
_hasSelectionChanged = true;
|
||||
emit(OptionSelectedState(
|
||||
selectedOption: _selectedOption,
|
||||
hasSelectionChanged: _hasSelectionChanged));
|
||||
}
|
||||
|
||||
List<GroupDevicesModel> groupDevices = [
|
||||
GroupDevicesModel(
|
||||
dec: 'Syncroom', icon: Assets.minusIcon, name: '6 Scene Switch')
|
||||
|
@ -148,9 +148,11 @@ class LoadScenes extends FourSceneEvent {
|
||||
}
|
||||
|
||||
class SelectSceneEvent extends FourSceneEvent {
|
||||
final String unitId;
|
||||
final String selectedSceneId;
|
||||
// final String unitId;
|
||||
const SelectSceneEvent({
|
||||
required this.unitId,
|
||||
// required this.unitId,
|
||||
required this.selectedSceneId,
|
||||
});
|
||||
}
|
||||
|
||||
@ -212,6 +214,7 @@ class ControlDeviceScene extends FourSceneEvent {
|
||||
class FourSceneSwitchInitial extends FourSceneEvent {
|
||||
const FourSceneSwitchInitial();
|
||||
}
|
||||
|
||||
class SaveSelectionSceneEvent extends FourSceneEvent {
|
||||
const SaveSelectionSceneEvent();
|
||||
}
|
||||
@ -220,12 +223,15 @@ class AssignDeviceScene extends FourSceneEvent {
|
||||
final String? sceneUuid;
|
||||
final String? switchName;
|
||||
final SpaceModel? unit;
|
||||
const AssignDeviceScene({this.sceneUuid, this.unit,this.switchName});
|
||||
const AssignDeviceScene({
|
||||
this.sceneUuid,
|
||||
this.unit,
|
||||
this.switchName,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
class GetSceneBySwitchName extends FourSceneEvent {
|
||||
final String? switchName;
|
||||
final String? switchName;
|
||||
|
||||
const GetSceneBySwitchName({this.switchName});
|
||||
}
|
@ -122,3 +122,9 @@ class LoadingDeviceInfo extends FourSceneState {
|
||||
@override
|
||||
List<Object> get props => [deviceInfo];
|
||||
}
|
||||
|
||||
class SceneSelectionUpdatedState extends FourSceneState {
|
||||
final String selectedSceneId;
|
||||
|
||||
SceneSelectionUpdatedState({required this.selectedSceneId});
|
||||
}
|
||||
|
@ -1,28 +1,64 @@
|
||||
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
||||
|
||||
class SixSceneModel {
|
||||
String waterContactState;
|
||||
int batteryPercentage;
|
||||
dynamic scene_1;
|
||||
dynamic scene_2;
|
||||
dynamic scene_3;
|
||||
dynamic scene_4;
|
||||
dynamic scene_5;
|
||||
dynamic scene_6;
|
||||
dynamic scene_id_group_id;
|
||||
dynamic switch_backlight;
|
||||
|
||||
SixSceneModel({
|
||||
required this.waterContactState,
|
||||
required this.batteryPercentage,
|
||||
required this.scene_1,
|
||||
required this.scene_2,
|
||||
required this.scene_3,
|
||||
required this.scene_4,
|
||||
required this.scene_5,
|
||||
required this.scene_6,
|
||||
required this.scene_id_group_id,
|
||||
required this.switch_backlight,
|
||||
});
|
||||
|
||||
factory SixSceneModel.fromJson(List<StatusModel> jsonList) {
|
||||
late String _waterContactState;
|
||||
late int _batteryPercentage;
|
||||
late dynamic _scene_1;
|
||||
late dynamic _scene_2;
|
||||
late dynamic _scene_3;
|
||||
late dynamic _scene_4;
|
||||
late dynamic _scene_5;
|
||||
late dynamic _scene_6;
|
||||
late dynamic _scene_id_group_id;
|
||||
late dynamic _switch_backlight;
|
||||
|
||||
for (int i = 0; i < jsonList.length; i++) {
|
||||
if (jsonList[i].code == 'sossensor_state') {
|
||||
_waterContactState = jsonList[i].value ?? false;
|
||||
} else if (jsonList[i].code == 'battery_percentage') {
|
||||
_batteryPercentage = jsonList[i].value ?? 0;
|
||||
if (jsonList[i].code == 'scene_1') {
|
||||
_scene_1 = jsonList[i].value ?? '';
|
||||
} else if (jsonList[i].code == 'scene_2') {
|
||||
_scene_2 = jsonList[i].value ?? '';
|
||||
} else if (jsonList[i].code == 'scene_3') {
|
||||
_scene_3 = jsonList[i].value ?? '';
|
||||
} else if (jsonList[i].code == 'scene_4') {
|
||||
_scene_4 = jsonList[i].value ?? '';
|
||||
} else if (jsonList[i].code == 'scene_5') {
|
||||
_scene_5 = jsonList[i].value ?? '';
|
||||
} else if (jsonList[i].code == 'scene_6') {
|
||||
_scene_6 = jsonList[i].value ?? '';
|
||||
} else if (jsonList[i].code == 'scene_id_group_id') {
|
||||
_scene_id_group_id = jsonList[i].value ?? 0;
|
||||
} else if (jsonList[i].code == 'switch_backlight') {
|
||||
_switch_backlight = jsonList[i].value ?? false;
|
||||
}
|
||||
}
|
||||
return SixSceneModel(
|
||||
waterContactState: _waterContactState,
|
||||
batteryPercentage: _batteryPercentage,
|
||||
scene_1: _scene_1,
|
||||
scene_2: _scene_2,
|
||||
scene_3: _scene_3,
|
||||
scene_4: _scene_4,
|
||||
scene_5: _scene_5,
|
||||
scene_6: _scene_6,
|
||||
scene_id_group_id: _scene_id_group_id,
|
||||
switch_backlight: _switch_backlight,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,14 @@ class _LocationSixScenePageState extends State<LocationSixScenePage> {
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
||||
SixSceneModel model = SixSceneModel(
|
||||
batteryPercentage: 0, waterContactState: 'normal');
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
scene_4: '',
|
||||
scene_5: '',
|
||||
scene_6: '',
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
List<SubSpaceModel>? rooms = [];
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.sosSensor;
|
||||
|
@ -30,7 +30,14 @@ class QuestionPage extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
||||
SixSceneModel model = SixSceneModel(
|
||||
batteryPercentage: 0, waterContactState: 'normal');
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
scene_4: '',
|
||||
scene_5: '',
|
||||
scene_6: '',
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.sosSensor;
|
||||
} else if (state is UpdateState) {
|
||||
|
@ -29,7 +29,14 @@ class ShareSixScenePage extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
||||
SixSceneModel model = SixSceneModel(
|
||||
batteryPercentage: 0, waterContactState: 'normal');
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
scene_4: '',
|
||||
scene_5: '',
|
||||
scene_6: '',
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.sosSensor;
|
||||
} else if (state is UpdateState) {
|
||||
|
@ -29,8 +29,15 @@ class SixSceneCreateGroup extends StatelessWidget {
|
||||
child: BlocBuilder<SixSceneBloc, SixSceneState>(
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
||||
SixSceneModel model = SixSceneModel(
|
||||
batteryPercentage: 0, waterContactState: 'normal');
|
||||
SixSceneModel model = SixSceneModel(
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
scene_4: '',
|
||||
scene_5: '',
|
||||
scene_6: '',
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.sosSensor;
|
||||
} else if (state is UpdateState) {
|
||||
|
@ -28,8 +28,15 @@ class SixSceneInfoPage extends StatelessWidget {
|
||||
child: BlocBuilder<SixSceneBloc, SixSceneState>(
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
||||
SixSceneModel model = SixSceneModel(
|
||||
batteryPercentage: 0, waterContactState: 'normal');
|
||||
SixSceneModel model = SixSceneModel(
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
scene_4: '',
|
||||
scene_5: '',
|
||||
scene_6: '',
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.sosSensor;
|
||||
} else if (state is UpdateState) {
|
||||
|
@ -32,8 +32,15 @@ class SixSceneProfilePage extends StatelessWidget {
|
||||
child: BlocBuilder<SixSceneBloc, SixSceneState>(
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
||||
SixSceneModel model = SixSceneModel(
|
||||
batteryPercentage: 0, waterContactState: 'normal');
|
||||
SixSceneModel model = SixSceneModel(
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
scene_4: '',
|
||||
scene_5: '',
|
||||
scene_6: '',
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.sosSensor;
|
||||
} else if (state is UpdateState) {
|
||||
|
@ -38,8 +38,15 @@ class SixSceneSettings extends StatelessWidget {
|
||||
child: BlocBuilder<SixSceneBloc, SixSceneState>(
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
||||
SixSceneModel model = SixSceneModel(
|
||||
batteryPercentage: 0, waterContactState: 'normal');
|
||||
SixSceneModel model = SixSceneModel(
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
scene_4: '',
|
||||
scene_5: '',
|
||||
scene_6: '',
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.sosSensor;
|
||||
} else if (state is UpdateState) {
|
||||
@ -74,8 +81,7 @@ class SixSceneSettings extends StatelessWidget {
|
||||
child: Stack(
|
||||
children: [
|
||||
const Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.stretch,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(height: 20),
|
||||
DefaultContainer(
|
||||
|
@ -16,8 +16,10 @@ import 'package:syncrow_app/navigation/navigation_service.dart';
|
||||
import 'package:syncrow_app/navigation/routing_constants.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class SelectSceneSixPage extends StatelessWidget {
|
||||
SelectSceneSixPage({super.key});
|
||||
class SixSelectSceneFourPage extends StatelessWidget {
|
||||
final String? switchSelected;
|
||||
final String? deviceId;
|
||||
SixSelectSceneFourPage({super.key, this.switchSelected, this.deviceId});
|
||||
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
final int? selectedSwitchIndex = 0;
|
||||
@ -26,22 +28,26 @@ class SelectSceneSixPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => SixSceneBloc(sixSceneId: '')
|
||||
create: (context) => SixSceneBloc(sixSceneId: deviceId!)
|
||||
..add(LoadScenes(
|
||||
unit: spaces!.first,
|
||||
unitId: spaces!.first.id,
|
||||
showInDevice: false,
|
||||
)),
|
||||
))
|
||||
..add(GetSceneBySwitchName(switchName: switchSelected)),
|
||||
child: BlocBuilder<SixSceneBloc, SixSceneState>(
|
||||
builder: (context, state) {
|
||||
final sensorBloc = BlocProvider.of<SixSceneBloc>(context);
|
||||
|
||||
if (state is SaveSelectionSuccessState) {
|
||||
Navigator.of(context).pop(true);
|
||||
Navigator.of(context).pop(true);
|
||||
}
|
||||
return DefaultScaffold(
|
||||
title: 'Select Scene',
|
||||
actions: [_buildSaveButton(context, state, sensorBloc)],
|
||||
child: state is SixSceneLoadingState
|
||||
? _buildLoadingIndicator()
|
||||
: _buildSceneContent(context, sensorBloc),
|
||||
: _buildSceneContent(context, sensorBloc, state),
|
||||
);
|
||||
},
|
||||
),
|
||||
@ -51,14 +57,15 @@ class SelectSceneSixPage extends StatelessWidget {
|
||||
// Save button builder
|
||||
Widget _buildSaveButton(
|
||||
BuildContext context, SixSceneState state, SixSceneBloc sensorBloc) {
|
||||
final bool canSave =
|
||||
state is OptionSelectedState && state.hasSelectionChanged;
|
||||
final bool canSave = state is SceneSelectionUpdatedState;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: canSave
|
||||
? () {
|
||||
print('object');
|
||||
context.read<SixSceneBloc>().add(SaveSelectionEvent());
|
||||
context.read<SixSceneBloc>().add(AssignDeviceScene(
|
||||
sceneUuid: sensorBloc.selectedSceneId,
|
||||
switchName: switchSelected,
|
||||
unit: spaces!.first));
|
||||
}
|
||||
: null,
|
||||
child: BodyMedium(
|
||||
@ -84,13 +91,14 @@ class SelectSceneSixPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
// Main scene content with search bar and grid
|
||||
Widget _buildSceneContent(BuildContext context, SixSceneBloc sensorBloc) {
|
||||
Widget _buildSceneContent(
|
||||
BuildContext context, SixSceneBloc sensorBloc, SixSceneState state) {
|
||||
return Column(
|
||||
children: [
|
||||
_buildSearchBar(sensorBloc),
|
||||
const SizedBox(height: 20),
|
||||
Expanded(
|
||||
child: _buildSceneGrid(sensorBloc),
|
||||
child: _buildSceneGrid(sensorBloc, state),
|
||||
),
|
||||
],
|
||||
);
|
||||
@ -125,7 +133,7 @@ class SelectSceneSixPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
// Scene grid builder
|
||||
Widget _buildSceneGrid(SixSceneBloc sensorBloc) {
|
||||
Widget _buildSceneGrid(SixSceneBloc sensorBloc, SixSceneState state) {
|
||||
final scenes = sensorBloc.filteredScenes;
|
||||
|
||||
return GridView.builder(
|
||||
@ -152,13 +160,18 @@ class SelectSceneSixPage extends StatelessWidget {
|
||||
);
|
||||
} else {
|
||||
final scene = scenes[index];
|
||||
bool isSelected = scene.id ==
|
||||
(state is SceneSelectionUpdatedState
|
||||
? state.selectedSceneId
|
||||
: sensorBloc.selectedFormApiSceneId);
|
||||
return SceneItem(
|
||||
id: scene.id,
|
||||
value: sensorBloc.selectedSceneId == scene.id,
|
||||
value: isSelected,
|
||||
disablePlayButton: false,
|
||||
onChanged: (isSelected) {
|
||||
sensorBloc.selectedSceneId = isSelected ? scene.id : 'null';
|
||||
sensorBloc.add(SelectOptionEvent(selectedOption: scene.id));
|
||||
|
||||
sensorBloc.add(SelectSceneEvent(unitId: scene.id));
|
||||
},
|
||||
icon: scene.iconInBytes,
|
||||
title: scene.name,
|
||||
@ -169,8 +182,8 @@ class SelectSceneSixPage extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class SceneItem extends StatefulWidget {
|
||||
final String id; // Unique ID for each scene
|
||||
class SceneItem extends StatelessWidget {
|
||||
final String id;
|
||||
final Uint8List icon;
|
||||
final String title;
|
||||
final bool disablePlayButton;
|
||||
@ -186,11 +199,6 @@ class SceneItem extends StatefulWidget {
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
State<SceneItem> createState() => _SceneItemState();
|
||||
}
|
||||
|
||||
class _SceneItemState extends State<SceneItem> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
@ -215,9 +223,9 @@ class _SceneItemState extends State<SceneItem> {
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
if (!widget.disablePlayButton)
|
||||
if (!disablePlayButton)
|
||||
Image.memory(
|
||||
widget.icon,
|
||||
icon,
|
||||
height: 32,
|
||||
width: 32,
|
||||
fit: BoxFit.fill,
|
||||
@ -228,7 +236,7 @@ class _SceneItemState extends State<SceneItem> {
|
||||
fit: BoxFit.fill),
|
||||
),
|
||||
BodyMedium(
|
||||
text: widget.title,
|
||||
text: title,
|
||||
style: const TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w700,
|
||||
@ -238,8 +246,8 @@ class _SceneItemState extends State<SceneItem> {
|
||||
],
|
||||
),
|
||||
CircularCheckbox(
|
||||
value: widget.value,
|
||||
onChanged: (isSelected) => widget.onChanged(isSelected!),
|
||||
value: value,
|
||||
onChanged: (isSelected) => onChanged(isSelected!),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -1,16 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/switches_card.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/six_switches_card.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class SelectSwitchDialog extends StatefulWidget {
|
||||
final Function()? cancelTab;
|
||||
final Function()? confirmTab;
|
||||
final Function(String)? confirmTab;
|
||||
String? switch1Title;
|
||||
String? switch2Title;
|
||||
String? switch3Title;
|
||||
String? switch4Title;
|
||||
String? switch5Title;
|
||||
String? switch6Title;
|
||||
SelectSwitchDialog(
|
||||
{super.key,
|
||||
required this.cancelTab,
|
||||
@ -18,14 +20,16 @@ class SelectSwitchDialog extends StatefulWidget {
|
||||
this.switch1Title,
|
||||
this.switch2Title,
|
||||
this.switch3Title,
|
||||
this.switch4Title});
|
||||
this.switch4Title,
|
||||
this.switch5Title,
|
||||
this.switch6Title});
|
||||
|
||||
@override
|
||||
State<SelectSwitchDialog> createState() => _SelectSwitchDialogState();
|
||||
}
|
||||
|
||||
class _SelectSwitchDialogState extends State<SelectSwitchDialog> {
|
||||
int? selectedSwitchIndex = 0;
|
||||
String selectedSwitchName = '';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -49,34 +53,48 @@ class _SelectSwitchDialogState extends State<SelectSwitchDialog> {
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
children: [
|
||||
SwitchsCard(
|
||||
SixSwitchsCardDialog(
|
||||
switch1Title: widget.switch1Title,
|
||||
switch2Title: widget.switch2Title,
|
||||
switch3Title: widget.switch3Title,
|
||||
switch4Title: widget.switch4Title,
|
||||
switch1Down: selectedSwitchIndex == -1
|
||||
switch5Title: widget.switch5Title,
|
||||
switch6Title: widget.switch6Title,
|
||||
switch1Down: selectedSwitchName == 'scene_4'
|
||||
? Assets.removeSceneIcon
|
||||
: Assets.addSwitchIcon,
|
||||
switch1Up: selectedSwitchIndex == 1
|
||||
switch1Up: selectedSwitchName == 'scene_1'
|
||||
? Assets.removeSceneIcon
|
||||
: Assets.addSwitchIcon,
|
||||
switch2Down: selectedSwitchIndex == -2
|
||||
switch2Down: selectedSwitchName == 'scene_5'
|
||||
? Assets.removeSceneIcon
|
||||
: Assets.addSwitchIcon,
|
||||
switch2Up: selectedSwitchIndex == 2
|
||||
switch2Up: selectedSwitchName == 'scene_2'
|
||||
? Assets.removeSceneIcon
|
||||
: Assets.addSwitchIcon,
|
||||
switch3Up: selectedSwitchName == 'scene_3'
|
||||
? Assets.removeSceneIcon
|
||||
: Assets.addSwitchIcon,
|
||||
switch3Down: selectedSwitchName == 'scene_6'
|
||||
? Assets.removeSceneIcon
|
||||
: Assets.addSwitchIcon,
|
||||
onSwitch3DownTap: () {
|
||||
setState(() => selectedSwitchName = 'scene_3');
|
||||
},
|
||||
onSwitch3UpTap: () {
|
||||
setState(() => selectedSwitchName = 'scene_6');
|
||||
},
|
||||
onSwitch1UpTap: () {
|
||||
setState(() => selectedSwitchIndex = 1);
|
||||
setState(() => selectedSwitchName = 'scene_1');
|
||||
},
|
||||
onSwitch1DownTap: () {
|
||||
setState(() => selectedSwitchIndex = -1);
|
||||
setState(() => selectedSwitchName = 'scene_4');
|
||||
},
|
||||
onSwitch2UpTap: () {
|
||||
setState(() => selectedSwitchIndex = 2);
|
||||
setState(() => selectedSwitchName = 'scene_5');
|
||||
},
|
||||
onSwitch2DownTap: () {
|
||||
setState(() => selectedSwitchIndex = -2);
|
||||
setState(() => selectedSwitchName = 'scene_2');
|
||||
},
|
||||
),
|
||||
],
|
||||
@ -125,14 +143,16 @@ class _SelectSwitchDialogState extends State<SelectSwitchDialog> {
|
||||
top: BorderSide(color: ColorsManager.textGray, width: 1.0),
|
||||
)),
|
||||
child: InkWell(
|
||||
onTap: selectedSwitchIndex == 0 ? () {} : widget.confirmTab,
|
||||
onTap: selectedSwitchName == ''
|
||||
? () {}
|
||||
: () => widget.confirmTab!(selectedSwitchName),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Next',
|
||||
style: TextStyle(
|
||||
color: selectedSwitchIndex == 0
|
||||
color: selectedSwitchName == ''
|
||||
? ColorsManager.textPrimaryColor
|
||||
.withOpacity(0.6)
|
||||
: ColorsManager.primaryColor,
|
||||
|
@ -11,7 +11,7 @@ import 'package:syncrow_app/features/devices/model/six_scene_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/6_scene_setting/six_scene_settings.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/select_scene_page.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/select_switch_dialog.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/switches_card.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/six_switches_card.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_small.dart';
|
||||
@ -41,12 +41,22 @@ class SixSceneScreen extends StatelessWidget {
|
||||
],
|
||||
child: BlocProvider(
|
||||
create: (context) => SixSceneBloc(sixSceneId: device?.uuid ?? '')
|
||||
..add(const SixSceneInitial()),
|
||||
..add(const SixSceneInitial())
|
||||
..add(const SixSceneInitialInfo())
|
||||
..add(const SexSceneSwitchInitial()),
|
||||
child: BlocBuilder<SixSceneBloc, SixSceneState>(
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
||||
final _bloc = BlocProvider.of<SixSceneBloc>(context);
|
||||
SixSceneModel model = SixSceneModel(
|
||||
batteryPercentage: 0, waterContactState: 'normal');
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
scene_4: '',
|
||||
scene_5: '',
|
||||
scene_6: '',
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.sosSensor;
|
||||
} else if (state is UpdateState) {
|
||||
@ -61,7 +71,7 @@ class SixSceneScreen extends StatelessWidget {
|
||||
)
|
||||
: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
sensor.add(const SixSceneInitial());
|
||||
_bloc.add(const SixSceneInitial());
|
||||
},
|
||||
child: ListView(
|
||||
children: [
|
||||
@ -69,24 +79,43 @@ class SixSceneScreen extends StatelessWidget {
|
||||
height: MediaQuery.sizeOf(context).height * 0.8,
|
||||
child: Column(
|
||||
children: [
|
||||
SwitchsCard(
|
||||
// switch1Title: ,
|
||||
// switch2Title: ,
|
||||
// switch3Title: ,
|
||||
// switch4Title: ,
|
||||
switch1Down: sensor.switchStatus == true
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch1Up: sensor.switchStatus == true
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch2Down: sensor.switchStatus == true
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch2Up: sensor.switchStatus == true
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
|
||||
SixSwitchsCardDialog(
|
||||
switch1Title: model.scene_1,
|
||||
switch2Title: model.scene_2,
|
||||
switch3Title: model.scene_3,
|
||||
switch4Title: model.scene_4,
|
||||
switch5Title: model.scene_5,
|
||||
switch6Title: model.scene_6,
|
||||
switch1Down:
|
||||
_bloc.deviceStatus.switch_backlight == true
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch1Up:
|
||||
_bloc.deviceStatus.switch_backlight == true
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch2Down:
|
||||
_bloc.deviceStatus.switch_backlight == true
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch2Up:
|
||||
_bloc.deviceStatus.switch_backlight == true
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch3Up:
|
||||
_bloc.deviceStatus.switch_backlight == true
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch3Down:
|
||||
_bloc.deviceStatus.switch_backlight == true
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
onSwitch3DownTap: () {
|
||||
debugPrint("onSwitch3DownTap");
|
||||
},
|
||||
onSwitch3UpTap: () {
|
||||
debugPrint("onSwitch3UpTap");
|
||||
},
|
||||
onSwitch1UpTap: () {
|
||||
debugPrint("Switch 1 Up tapped");
|
||||
},
|
||||
@ -106,7 +135,7 @@ class SixSceneScreen extends StatelessWidget {
|
||||
Expanded(
|
||||
child: DefaultContainer(
|
||||
onTap: () {
|
||||
sensor.add(ChangeSwitchStatusEvent());
|
||||
_bloc.add(ChangeSwitchStatusEvent());
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
@ -140,19 +169,29 @@ class SixSceneScreen extends StatelessWidget {
|
||||
),
|
||||
Expanded(
|
||||
child: DefaultContainer(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
onTap: () async {
|
||||
var value = await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return SelectSwitchDialog(
|
||||
switch1Title: model.scene_1,
|
||||
switch2Title: model.scene_2,
|
||||
switch3Title: model.scene_3,
|
||||
switch4Title: model.scene_4,
|
||||
switch5Title: model.scene_5,
|
||||
switch6Title: model.scene_6,
|
||||
cancelTab: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
confirmTab: () {
|
||||
confirmTab: (v) {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
SelectSceneSixPage()),
|
||||
SixSelectSceneFourPage(
|
||||
deviceId:
|
||||
device!.uuid,
|
||||
switchSelected: v,
|
||||
)),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -0,0 +1,193 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class SixSwitchsCardDialog extends StatelessWidget {
|
||||
final String? switch1Title;
|
||||
final String? switch2Title;
|
||||
final String? switch3Title;
|
||||
final String? switch4Title;
|
||||
final String? switch5Title;
|
||||
final String? switch6Title;
|
||||
|
||||
final String switch1Up;
|
||||
final String switch1Down;
|
||||
final String switch2Up;
|
||||
final String switch2Down;
|
||||
|
||||
final String switch3Down;
|
||||
final String switch3Up;
|
||||
|
||||
final VoidCallback onSwitch1UpTap;
|
||||
final VoidCallback onSwitch1DownTap;
|
||||
final VoidCallback onSwitch2UpTap;
|
||||
final VoidCallback onSwitch2DownTap;
|
||||
|
||||
final VoidCallback onSwitch3DownTap;
|
||||
final VoidCallback onSwitch3UpTap;
|
||||
|
||||
SixSwitchsCardDialog(
|
||||
{required this.switch1Down,
|
||||
required this.switch1Up,
|
||||
required this.switch2Down,
|
||||
required this.switch2Up,
|
||||
required this.onSwitch1UpTap,
|
||||
required this.onSwitch1DownTap,
|
||||
required this.onSwitch2UpTap,
|
||||
required this.onSwitch2DownTap,
|
||||
required this.onSwitch3DownTap,
|
||||
required this.onSwitch3UpTap,
|
||||
required this.switch3Down,
|
||||
this.switch1Title,
|
||||
this.switch2Title,
|
||||
this.switch3Title,
|
||||
this.switch4Title,
|
||||
this.switch5Title,
|
||||
this.switch6Title,
|
||||
required this.switch3Up});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
flex: 4,
|
||||
child: InkWell(
|
||||
overlayColor: MaterialStateProperty.all(Colors.transparent),
|
||||
onTap: () {},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 10),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.onPrimaryColor,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.white.withOpacity(0.1),
|
||||
blurRadius: 24,
|
||||
offset: const Offset(-2, -2),
|
||||
blurStyle: BlurStyle.outer,
|
||||
),
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.11),
|
||||
blurRadius: 5,
|
||||
offset: const Offset(2, 0),
|
||||
blurStyle: BlurStyle.outer,
|
||||
),
|
||||
BoxShadow(
|
||||
color: Colors.white.withOpacity(0.13),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(5, 1),
|
||||
blurStyle: BlurStyle.inner,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: SizedBox(
|
||||
height: 300,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
// Switch 1
|
||||
_buildSwitchColumn(
|
||||
switchUp: switch1Up,
|
||||
switchDown: switch1Down,
|
||||
onUpTap: onSwitch1UpTap,
|
||||
onDownTap: onSwitch1DownTap,
|
||||
titleDown: switch4Title!,
|
||||
titleUp: switch1Title!),
|
||||
_buildDivider(),
|
||||
// Switch 2
|
||||
_buildSwitchColumn(
|
||||
switchUp: switch2Up,
|
||||
switchDown: switch2Down,
|
||||
onDownTap: onSwitch2UpTap,
|
||||
onUpTap: onSwitch2DownTap,
|
||||
titleDown: switch5Title!,
|
||||
titleUp: switch2Title!),
|
||||
_buildDivider(),
|
||||
// Switch 3
|
||||
_buildSwitchColumn(
|
||||
switchUp: switch3Up,
|
||||
switchDown: switch3Down,
|
||||
onDownTap: onSwitch3UpTap,
|
||||
onUpTap: onSwitch3DownTap,
|
||||
titleDown: switch6Title!,
|
||||
titleUp: switch3Title!),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSwitchColumn({
|
||||
String switchUp = '',
|
||||
String titleUp = '',
|
||||
String titleDown = '',
|
||||
String switchDown = '',
|
||||
VoidCallback? onUpTap,
|
||||
VoidCallback? onDownTap,
|
||||
}) {
|
||||
return Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 30, bottom: 30),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: onUpTap,
|
||||
child: Container(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: SvgPicture.asset(switchUp),
|
||||
),
|
||||
),
|
||||
BodySmall(
|
||||
text: titleUp,
|
||||
)
|
||||
],
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: onDownTap,
|
||||
child: Container(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: SvgPicture.asset(switchDown),
|
||||
),
|
||||
),
|
||||
BodySmall(
|
||||
text: titleDown,
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDivider() {
|
||||
return Container(
|
||||
width: 3,
|
||||
color: ColorsManager.dividerColor,
|
||||
);
|
||||
}
|
||||
}
|
@ -150,8 +150,8 @@ class FourSceneScreen extends StatelessWidget {
|
||||
),
|
||||
Expanded(
|
||||
child: DefaultContainer(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
onTap: () async {
|
||||
var value = await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return FourSelectSwitchDialog(
|
||||
@ -162,18 +162,29 @@ class FourSceneScreen extends StatelessWidget {
|
||||
cancelTab: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
confirmTab: (switchSelected) {
|
||||
confirmTab:
|
||||
(switchSelected) async {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
FourSelectSceneFourPage(
|
||||
switchSelected: switchSelected,
|
||||
deviceId:device!.uuid)),
|
||||
switchSelected:
|
||||
switchSelected,
|
||||
deviceId:
|
||||
device!
|
||||
.uuid)),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
if (value == true) {
|
||||
_bloc.add(const FourSceneInitial());
|
||||
_bloc.add(
|
||||
const FourSceneInitialInfo());
|
||||
_bloc.add(
|
||||
const FourSceneSwitchInitial());
|
||||
}
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
|
@ -67,11 +67,22 @@ class FourSceneProfilePage extends StatelessWidget {
|
||||
backgroundColor: Colors.white,
|
||||
child: CircleAvatar(
|
||||
radius: 55,
|
||||
backgroundColor: Colors.grey,
|
||||
backgroundColor: ColorsManager.graysColor,
|
||||
child: ClipOval(
|
||||
child: SvgPicture.asset(
|
||||
Assets.sosProfileIcon,
|
||||
fit: BoxFit.fill,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Center(
|
||||
child: SvgPicture.asset(
|
||||
Assets.fourSceneIcon,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -15,7 +15,6 @@ import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four
|
||||
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_update_dialog.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_update_page.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_scene_setting/share_four_scene_page.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_medium.dart';
|
||||
@ -139,9 +138,24 @@ class FourSceneSettings extends StatelessWidget {
|
||||
radius: 40,
|
||||
backgroundColor:
|
||||
ColorsManager.backgroundColor,
|
||||
child: SvgPicture.asset(
|
||||
Assets.sixSceneIcon,
|
||||
fit: BoxFit.fill,
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 8),
|
||||
child: SizedBox(
|
||||
height: 70,
|
||||
child: SvgPicture.asset(
|
||||
Assets.fourSceneIcon,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)),
|
||||
|
@ -38,13 +38,16 @@ class FourSelectSceneFourPage extends StatelessWidget {
|
||||
child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
||||
builder: (context, state) {
|
||||
final sensorBloc = BlocProvider.of<FourSceneBloc>(context);
|
||||
|
||||
if (state is SaveSelectionSuccessState) {
|
||||
Navigator.of(context).pop(true);
|
||||
Navigator.of(context).pop(true);
|
||||
}
|
||||
return DefaultScaffold(
|
||||
title: 'Select Scene',
|
||||
actions: [_buildSaveButton(context, state, sensorBloc)],
|
||||
child: state is FourSceneLoadingState
|
||||
? _buildLoadingIndicator()
|
||||
: _buildSceneContent(context, sensorBloc),
|
||||
: _buildSceneContent(context, sensorBloc, state),
|
||||
);
|
||||
},
|
||||
),
|
||||
@ -54,8 +57,7 @@ class FourSelectSceneFourPage extends StatelessWidget {
|
||||
// Save button builder
|
||||
Widget _buildSaveButton(
|
||||
BuildContext context, FourSceneState state, FourSceneBloc sensorBloc) {
|
||||
final bool canSave =
|
||||
state is OptionSelectedState && state.hasSelectionChanged;
|
||||
final bool canSave = state is SceneSelectionUpdatedState;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: canSave
|
||||
@ -89,13 +91,14 @@ class FourSelectSceneFourPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
// Main scene content with search bar and grid
|
||||
Widget _buildSceneContent(BuildContext context, FourSceneBloc sensorBloc) {
|
||||
Widget _buildSceneContent(
|
||||
BuildContext context, FourSceneBloc sensorBloc, FourSceneState state) {
|
||||
return Column(
|
||||
children: [
|
||||
_buildSearchBar(sensorBloc),
|
||||
const SizedBox(height: 20),
|
||||
Expanded(
|
||||
child: _buildSceneGrid(sensorBloc),
|
||||
child: _buildSceneGrid(sensorBloc, state),
|
||||
),
|
||||
],
|
||||
);
|
||||
@ -130,8 +133,9 @@ class FourSelectSceneFourPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
// Scene grid builder
|
||||
Widget _buildSceneGrid(FourSceneBloc sensorBloc) {
|
||||
Widget _buildSceneGrid(FourSceneBloc sensorBloc, FourSceneState state) {
|
||||
final scenes = sensorBloc.filteredScenes;
|
||||
|
||||
return GridView.builder(
|
||||
itemCount: scenes.length + 1,
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
@ -141,7 +145,6 @@ class FourSelectSceneFourPage extends StatelessWidget {
|
||||
mainAxisExtent: 120,
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
// sensorBloc.sceneId;
|
||||
if (index == scenes.length) {
|
||||
return InkWell(
|
||||
onTap: () => Navigator.pushNamed(
|
||||
@ -157,13 +160,18 @@ class FourSelectSceneFourPage extends StatelessWidget {
|
||||
);
|
||||
} else {
|
||||
final scene = scenes[index];
|
||||
bool isSelected = scene.id ==
|
||||
(state is SceneSelectionUpdatedState
|
||||
? state.selectedSceneId
|
||||
: sensorBloc.selectedFormApiSceneId);
|
||||
return SceneItem(
|
||||
id: scene.id,
|
||||
value: (sensorBloc.selectedSceneId == scene.id),
|
||||
value: isSelected,
|
||||
disablePlayButton: false,
|
||||
onChanged: (isSelected) {
|
||||
sensorBloc.selectedSceneId = isSelected ? scene.id : 'null';
|
||||
sensorBloc.add(SelectOptionEvent(selectedOption: scene.id));
|
||||
|
||||
sensorBloc.add(SelectSceneEvent(selectedSceneId: scene.id));
|
||||
},
|
||||
icon: scene.iconInBytes,
|
||||
title: scene.name,
|
||||
@ -174,8 +182,8 @@ class FourSelectSceneFourPage extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class SceneItem extends StatefulWidget {
|
||||
final String id; // Unique ID for each scene
|
||||
class SceneItem extends StatelessWidget {
|
||||
final String id;
|
||||
final Uint8List icon;
|
||||
final String title;
|
||||
final bool disablePlayButton;
|
||||
@ -191,11 +199,6 @@ class SceneItem extends StatefulWidget {
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
State<SceneItem> createState() => _SceneItemState();
|
||||
}
|
||||
|
||||
class _SceneItemState extends State<SceneItem> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
@ -220,9 +223,9 @@ class _SceneItemState extends State<SceneItem> {
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
if (!widget.disablePlayButton)
|
||||
if (!disablePlayButton)
|
||||
Image.memory(
|
||||
widget.icon,
|
||||
icon,
|
||||
height: 32,
|
||||
width: 32,
|
||||
fit: BoxFit.fill,
|
||||
@ -233,7 +236,7 @@ class _SceneItemState extends State<SceneItem> {
|
||||
fit: BoxFit.fill),
|
||||
),
|
||||
BodyMedium(
|
||||
text: widget.title,
|
||||
text: title,
|
||||
style: const TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w700,
|
||||
@ -243,8 +246,8 @@ class _SceneItemState extends State<SceneItem> {
|
||||
],
|
||||
),
|
||||
CircularCheckbox(
|
||||
value: widget.value,
|
||||
onChanged: (isSelected) => widget.onChanged(isSelected!),
|
||||
value: value,
|
||||
onChanged: (isSelected) => onChanged(isSelected!),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/switches_card.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_switches_card_dialog.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
@ -51,7 +51,7 @@ class _FourSelectSwitchDialogState extends State<FourSelectSwitchDialog> {
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
children: [
|
||||
SwitchsCard(
|
||||
FourSwitchsCardDialog(
|
||||
switch1Title: widget.switch1Title,
|
||||
switch2Title: widget.switch2Title,
|
||||
switch3Title: widget.switch3Title,
|
||||
|
@ -3,7 +3,7 @@ import 'package:flutter_svg/svg.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class SwitchsCard extends StatelessWidget {
|
||||
class FourSwitchsCardDialog extends StatelessWidget {
|
||||
final String? switch1Title;
|
||||
final String? switch2Title;
|
||||
final String? switch3Title;
|
||||
@ -19,7 +19,7 @@ class SwitchsCard extends StatelessWidget {
|
||||
final VoidCallback onSwitch2UpTap;
|
||||
final VoidCallback onSwitch2DownTap;
|
||||
|
||||
SwitchsCard({
|
||||
FourSwitchsCardDialog({
|
||||
required this.switch1Down,
|
||||
required this.switch1Up,
|
||||
required this.switch2Down,
|
@ -7,6 +7,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/six_scene_screen.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/ACs/acs_view.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/curtains/curtain_view.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/door_sensor/door_sensor_screen.dart';
|
||||
@ -213,6 +214,13 @@ void showDeviceInterface(DeviceModel device, BuildContext context) {
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
WaterLeakScreen(device: device)));
|
||||
|
||||
case DeviceType.SixScene:
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
SixSceneScreen(device: device)));
|
||||
|
||||
case DeviceType.FourScene:
|
||||
Navigator.push(
|
||||
context,
|
||||
|
@ -1117,6 +1117,7 @@ class Assets {
|
||||
static const String sixSceneIcon = "assets/icons/six_scene_icon.svg";
|
||||
static const String minusIcon = "assets/icons/minus_icon.svg";
|
||||
static const String addDevicesIcon = "assets/icons/add_devices_icon.svg";
|
||||
static const String fourSceneIcon = "assets/icons/four_scene_icon.svg";
|
||||
|
||||
//powerClampIcon
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ enum DeviceType {
|
||||
WaterLeak,
|
||||
PC,
|
||||
FourScene,
|
||||
SixScene,
|
||||
Other,
|
||||
}
|
||||
|
||||
@ -90,6 +91,7 @@ Map<String, DeviceType> devicesTypesMap = {
|
||||
"WL": DeviceType.WaterLeak,
|
||||
"PC": DeviceType.PC,
|
||||
"4S": DeviceType.FourScene,
|
||||
"6S": DeviceType.SixScene,
|
||||
};
|
||||
Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = {
|
||||
DeviceType.AC: [
|
||||
@ -544,6 +546,52 @@ Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = {
|
||||
code: 'switch_backlight',
|
||||
type: functionTypesMap['Enum'],
|
||||
values: ValueModel.fromJson({})),
|
||||
],
|
||||
DeviceType.SixScene: [
|
||||
FunctionModel(
|
||||
code: 'scene_1',
|
||||
type: functionTypesMap['Boolean'],
|
||||
values: ValueModel.fromJson({
|
||||
"range": ["scene"]
|
||||
})),
|
||||
FunctionModel(
|
||||
code: 'scene_2',
|
||||
type: functionTypesMap['Integer'],
|
||||
values: ValueModel.fromJson({
|
||||
"range": ["scene"]
|
||||
})),
|
||||
FunctionModel(
|
||||
code: 'scene_3',
|
||||
type: functionTypesMap['Integer'],
|
||||
values: ValueModel.fromJson({
|
||||
"range": ["scene"]
|
||||
})),
|
||||
FunctionModel(
|
||||
code: 'scene_4',
|
||||
type: functionTypesMap['Integer'],
|
||||
values: ValueModel.fromJson({
|
||||
"range": ["scene"]
|
||||
})),
|
||||
FunctionModel(
|
||||
code: 'scene_5',
|
||||
type: functionTypesMap['Integer'],
|
||||
values: ValueModel.fromJson({
|
||||
"range": ["scene"]
|
||||
})),
|
||||
FunctionModel(
|
||||
code: 'scene_6',
|
||||
type: functionTypesMap['Integer'],
|
||||
values: ValueModel.fromJson({
|
||||
"range": ["scene"]
|
||||
})),
|
||||
FunctionModel(
|
||||
code: 'scene_id_group_id',
|
||||
type: functionTypesMap['Raw'],
|
||||
values: ValueModel.fromJson({})),
|
||||
FunctionModel(
|
||||
code: 'switch_backlight',
|
||||
type: functionTypesMap['Enum'],
|
||||
values: ValueModel.fromJson({})),
|
||||
]
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user