mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-27 21:34:54 +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: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_event.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart';
|
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_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/device_report_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/group_devices_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/sex_scene_question_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/six_scene_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/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/devices_api.dart';
|
||||||
import 'package:syncrow_app/services/api/scene_api.dart';
|
import 'package:syncrow_app/services/api/scene_api.dart';
|
||||||
import 'package:syncrow_app/services/api/spaces_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> {
|
class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||||
final String sixSceneId;
|
final String sixSceneId;
|
||||||
SixSceneBloc({
|
SixSceneBloc({
|
||||||
required this.sixSceneId,
|
required this.sixSceneId,
|
||||||
}) : super(const SixSceneState()) {
|
}) : super(const SixSceneState()) {
|
||||||
on<SixSceneInitial>(_fetchStatus);
|
on<SixSceneInitial>(_fetchDeviceStatus);
|
||||||
on<ReportLogsInitial>(fetchLogsForLastMonth);
|
|
||||||
on<ToggleNotificationEvent>(_toggleNotification);
|
on<ToggleNotificationEvent>(_toggleNotification);
|
||||||
on<ChangeNameEvent>(_changeName);
|
on<ChangeNameEvent>(_changeName);
|
||||||
on<SearchFaqEvent>(_onSearchFaq);
|
on<SearchFaqEvent>(_onSearchFaq);
|
||||||
on<FetchRoomsEvent>(_fetchRoomsAndDevices);
|
on<FetchRoomsEvent>(_fetchRoomsAndDevices);
|
||||||
on<ChangeSwitchStatusEvent>(changeSwitchStatus);
|
on<ChangeSwitchStatusEvent>(changeSwitchStatus);
|
||||||
on<LoadScenes>(_onLoadScenes);
|
on<LoadScenes>(_onLoadScenes);
|
||||||
on<SelectSceneEvent>(_selectScene);
|
|
||||||
on<SearchScenesEvent>(searchScene);
|
on<SearchScenesEvent>(searchScene);
|
||||||
on<SaveSelectionEvent>(_onSaveSelection);
|
on<SaveSelectionEvent>(_onSaveSelection);
|
||||||
on<SelectOptionEvent>(_onOptionSelected);
|
on<SelectOptionEvent>(_onOptionSelected);
|
||||||
on<AddDeviceToGroup>(_addDeviceToGroup); // Register handler here
|
on<AddDeviceToGroup>(_addDeviceToGroup); // Register handler here
|
||||||
on<RemoveDeviceFromGroup>(_removeDeviceFromGroup);
|
on<RemoveDeviceFromGroup>(_removeDeviceFromGroup);
|
||||||
|
on<SexSceneSwitchInitial>(_fetchFourSceneSwitches);
|
||||||
|
on<AssignDeviceScene>(assignScene);
|
||||||
|
on<GetSceneBySwitchName>(getSceneByName);
|
||||||
|
on<SelectSceneEvent>(_selectScene);
|
||||||
|
on<SixSceneInitialInfo>(fetchDeviceInfo);
|
||||||
|
on<ControlDeviceScene>(_controlDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
final TextEditingController nameController =
|
final TextEditingController nameController =
|
||||||
TextEditingController(text: '${'firstName'}');
|
TextEditingController(text: deviceName);
|
||||||
bool isSaving = false;
|
bool isSaving = false;
|
||||||
bool editName = false;
|
bool editName = false;
|
||||||
final FocusNode focusNode = FocusNode();
|
final FocusNode focusNode = FocusNode();
|
||||||
bool closingReminder = false;
|
bool closingReminder = false;
|
||||||
bool waterAlarm = false;
|
bool waterAlarm = false;
|
||||||
|
static String deviceName = '';
|
||||||
|
|
||||||
SixSceneModel deviceStatus =
|
SixSceneModel deviceStatus = SixSceneModel(
|
||||||
SixSceneModel(waterContactState: 'normal', batteryPercentage: 0);
|
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());
|
emit(SixSceneLoadingState());
|
||||||
try {
|
try {
|
||||||
var response = await DevicesAPI.getDeviceStatus(sixSceneId);
|
var response = await DevicesAPI.getDeviceStatus(sixSceneId);
|
||||||
@ -59,16 +121,90 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
|||||||
deviceStatus = SixSceneModel.fromJson(
|
deviceStatus = SixSceneModel.fromJson(
|
||||||
statusModelList,
|
statusModelList,
|
||||||
);
|
);
|
||||||
|
add(const SexSceneSwitchInitial());
|
||||||
emit(UpdateState(sensor: deviceStatus));
|
emit(UpdateState(sensor: deviceStatus));
|
||||||
|
|
||||||
Future.delayed(const Duration(milliseconds: 500));
|
|
||||||
// _listenToChanges();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(SixSceneFailedState(errorMessage: e.toString()));
|
emit(SixSceneFailedState(errorMessage: e.toString()));
|
||||||
return;
|
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) {
|
void _onSearchFaq(SearchFaqEvent event, Emitter<SixSceneState> emit) {
|
||||||
emit(SixSceneLoadingState());
|
emit(SixSceneLoadingState());
|
||||||
// Filter FAQ questions based on search query
|
// Filter FAQ questions based on search query
|
||||||
@ -77,8 +213,6 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
|||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.contains(event.query.toLowerCase());
|
.contains(event.query.toLowerCase());
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
print(_faqQuestions);
|
|
||||||
emit(FaqSearchState(filteredFaqQuestions: _faqQuestions));
|
emit(FaqSearchState(filteredFaqQuestions: _faqQuestions));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,16 +235,6 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
|||||||
try {
|
try {
|
||||||
closingReminder = event.isClosingEnabled;
|
closingReminder = event.isClosingEnabled;
|
||||||
emit(UpdateState(sensor: deviceStatus));
|
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) {
|
} catch (e) {
|
||||||
emit(SixSceneFailedState(errorMessage: e.toString()));
|
emit(SixSceneFailedState(errorMessage: e.toString()));
|
||||||
}
|
}
|
||||||
@ -119,29 +243,6 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
|||||||
DeviceReport recordGroups =
|
DeviceReport recordGroups =
|
||||||
DeviceReport(startTime: '0', endTime: '0', data: []);
|
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 = [
|
final List<SixSceneQuestionModel> faqQuestions = [
|
||||||
SixSceneQuestionModel(
|
SixSceneQuestionModel(
|
||||||
id: 1,
|
id: 1,
|
||||||
@ -196,14 +297,27 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool switchStatus = true;
|
bool switchStatus = true;
|
||||||
void changeSwitchStatus(
|
Future<void> changeSwitchStatus(
|
||||||
ChangeSwitchStatusEvent event, Emitter<SixSceneState> emit) {
|
ChangeSwitchStatusEvent event, Emitter<SixSceneState> emit) async {
|
||||||
|
try {
|
||||||
emit(SixSceneLoadingState());
|
emit(SixSceneLoadingState());
|
||||||
|
switchStatus = deviceStatus.switch_backlight;
|
||||||
switchStatus = !switchStatus;
|
switchStatus = !switchStatus;
|
||||||
emit(ChangeSwitchState(isEnable: 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(
|
Future<void> _onLoadScenes(
|
||||||
LoadScenes event, Emitter<SixSceneState> emit) async {
|
LoadScenes event, Emitter<SixSceneState> emit) async {
|
||||||
@ -226,12 +340,6 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool selecedScene = false;
|
bool selecedScene = false;
|
||||||
String selectedSceneId = '';
|
|
||||||
_selectScene(SelectSceneEvent event, Emitter<SixSceneState> emit) {
|
|
||||||
emit(SixSceneLoadingState());
|
|
||||||
selecedScene = !selecedScene;
|
|
||||||
emit(SelectedSceneState());
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ScenesModel> allScenes = [];
|
List<ScenesModel> allScenes = [];
|
||||||
List<ScenesModel> filteredScenes = [];
|
List<ScenesModel> filteredScenes = [];
|
||||||
@ -278,19 +386,6 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
|||||||
dec: 'Syncroom', icon: Assets.addDevicesIcon, name: '6 Scene Switch')
|
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
|
// Handler for AddDeviceToGroup
|
||||||
void _addDeviceToGroup(AddDeviceToGroup event, Emitter<SixSceneState> emit) {
|
void _addDeviceToGroup(AddDeviceToGroup event, Emitter<SixSceneState> emit) {
|
||||||
devices.remove(event.device);
|
devices.remove(event.device);
|
||||||
@ -311,4 +406,25 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
|||||||
}
|
}
|
||||||
emit(UpdateStateList(groupDevices: groupDevices, devices: devices));
|
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 SixSceneUpdated extends SixSceneEvent {}
|
||||||
|
|
||||||
|
class GetSceneBySwitchName extends SixSceneEvent {
|
||||||
|
final String? switchName;
|
||||||
|
|
||||||
|
const GetSceneBySwitchName({this.switchName});
|
||||||
|
}
|
||||||
|
|
||||||
class SixSceneInitial extends SixSceneEvent {
|
class SixSceneInitial extends SixSceneEvent {
|
||||||
const SixSceneInitial();
|
const SixSceneInitial();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SixSceneInitialInfo extends SixSceneEvent {
|
||||||
|
const SixSceneInitialInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
class SexSceneSwitchInitial extends SixSceneEvent {
|
||||||
|
const SexSceneSwitchInitial();
|
||||||
|
}
|
||||||
|
|
||||||
class ReportLogsInitial extends SixSceneEvent {
|
class ReportLogsInitial extends SixSceneEvent {
|
||||||
const ReportLogsInitial();
|
const ReportLogsInitial();
|
||||||
}
|
}
|
||||||
@ -171,3 +185,19 @@ class RemoveDeviceFromGroup extends SixSceneEvent {
|
|||||||
|
|
||||||
RemoveDeviceFromGroup(this.device, this.icon);
|
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:equatable/equatable.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/group_devices_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/sex_scene_question_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/six_scene_model.dart';
|
import 'package:syncrow_app/features/devices/model/six_scene_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/subspace_model.dart';
|
import 'package:syncrow_app/features/devices/model/subspace_model.dart';
|
||||||
@ -111,3 +112,17 @@ class OptionSelectedState extends SixSceneState {
|
|||||||
@override
|
@override
|
||||||
List<Object> get props => [selectedOption, hasSelectionChanged];
|
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<FetchRoomsEvent>(_fetchRoomsAndDevices);
|
||||||
on<ChangeSwitchStatusEvent>(changeSwitchStatus);
|
on<ChangeSwitchStatusEvent>(changeSwitchStatus);
|
||||||
on<LoadScenes>(_onLoadScenes);
|
on<LoadScenes>(_onLoadScenes);
|
||||||
on<SelectSceneEvent>(_selectScene);
|
|
||||||
on<SearchScenesEvent>(searchScene);
|
on<SearchScenesEvent>(searchScene);
|
||||||
on<AssignRoomEvent>(_assignDevice);
|
on<AssignRoomEvent>(_assignDevice);
|
||||||
on<SelectOptionEvent>(_onOptionSelected);
|
on<SelectOptionEvent>(_onOptionSelected);
|
||||||
@ -47,6 +46,7 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
|||||||
on<FourSceneSwitchInitial>(_fetchFourSceneSwitches);
|
on<FourSceneSwitchInitial>(_fetchFourSceneSwitches);
|
||||||
on<AssignDeviceScene>(assignScene);
|
on<AssignDeviceScene>(assignScene);
|
||||||
on<GetSceneBySwitchName>(getSceneByName);
|
on<GetSceneBySwitchName>(getSceneByName);
|
||||||
|
on<SelectSceneEvent>(_selectScene);
|
||||||
}
|
}
|
||||||
|
|
||||||
final TextEditingController nameController =
|
final TextEditingController nameController =
|
||||||
@ -99,7 +99,17 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
|||||||
subspaceName: "",
|
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(
|
Future<void> saveName(
|
||||||
SaveNameEvent event, Emitter<FourSceneState> emit) async {
|
SaveNameEvent event, Emitter<FourSceneState> emit) async {
|
||||||
if (_validateInputs()) return;
|
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 = [];
|
List<FourSceneSwitchModel> fourScene = [];
|
||||||
|
|
||||||
void _fetchFourSceneSwitches(
|
void _fetchFourSceneSwitches(
|
||||||
@ -130,15 +168,13 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
|||||||
"scene_1": '',
|
"scene_1": '',
|
||||||
"scene_2": '',
|
"scene_2": '',
|
||||||
"scene_3": '',
|
"scene_3": '',
|
||||||
"scene_4": ''
|
"scene_4": '',
|
||||||
};
|
};
|
||||||
for (var item in response) {
|
for (var item in response) {
|
||||||
if (item["switchName"] != null) {
|
if (item["switchName"] != null) {
|
||||||
sceneTitles[item["switchName"]] = item["scene"]["name"] ?? '';
|
sceneTitles[item["switchName"]] = item["scene"]["name"] ?? '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print('object======4${response}');
|
|
||||||
|
|
||||||
FourSceneModelState deviceStatus = FourSceneModelState(
|
FourSceneModelState deviceStatus = FourSceneModelState(
|
||||||
scene_1: sceneTitles["scene_1"] ?? '',
|
scene_1: sceneTitles["scene_1"] ?? '',
|
||||||
scene_2: sceneTitles["scene_2"] ?? '',
|
scene_2: sceneTitles["scene_2"] ?? '',
|
||||||
@ -182,20 +218,9 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
|||||||
sceneUuid: event.sceneUuid,
|
sceneUuid: event.sceneUuid,
|
||||||
spaceUuid: event.unit!.id,
|
spaceUuid: event.unit!.id,
|
||||||
switchName: event.switchName);
|
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());
|
emit(SaveSelectionSuccessState());
|
||||||
|
CustomSnackBar.displaySnackBar('Save Successfully');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(FourSceneFailedState(errorMessage: e.toString()));
|
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> allScenes = [];
|
||||||
List<ScenesModel> filteredScenes = [];
|
List<ScenesModel> filteredScenes = [];
|
||||||
|
|
||||||
@ -420,19 +437,6 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
|||||||
emit(SearchResultsState());
|
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 = [
|
List<GroupDevicesModel> groupDevices = [
|
||||||
GroupDevicesModel(
|
GroupDevicesModel(
|
||||||
dec: 'Syncroom', icon: Assets.minusIcon, name: '6 Scene Switch')
|
dec: 'Syncroom', icon: Assets.minusIcon, name: '6 Scene Switch')
|
||||||
|
|||||||
@ -148,9 +148,11 @@ class LoadScenes extends FourSceneEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SelectSceneEvent extends FourSceneEvent {
|
class SelectSceneEvent extends FourSceneEvent {
|
||||||
final String unitId;
|
final String selectedSceneId;
|
||||||
|
// final String unitId;
|
||||||
const SelectSceneEvent({
|
const SelectSceneEvent({
|
||||||
required this.unitId,
|
// required this.unitId,
|
||||||
|
required this.selectedSceneId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,6 +214,7 @@ class ControlDeviceScene extends FourSceneEvent {
|
|||||||
class FourSceneSwitchInitial extends FourSceneEvent {
|
class FourSceneSwitchInitial extends FourSceneEvent {
|
||||||
const FourSceneSwitchInitial();
|
const FourSceneSwitchInitial();
|
||||||
}
|
}
|
||||||
|
|
||||||
class SaveSelectionSceneEvent extends FourSceneEvent {
|
class SaveSelectionSceneEvent extends FourSceneEvent {
|
||||||
const SaveSelectionSceneEvent();
|
const SaveSelectionSceneEvent();
|
||||||
}
|
}
|
||||||
@ -220,10 +223,13 @@ class AssignDeviceScene extends FourSceneEvent {
|
|||||||
final String? sceneUuid;
|
final String? sceneUuid;
|
||||||
final String? switchName;
|
final String? switchName;
|
||||||
final SpaceModel? unit;
|
final SpaceModel? unit;
|
||||||
const AssignDeviceScene({this.sceneUuid, this.unit,this.switchName});
|
const AssignDeviceScene({
|
||||||
|
this.sceneUuid,
|
||||||
|
this.unit,
|
||||||
|
this.switchName,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class GetSceneBySwitchName extends FourSceneEvent {
|
class GetSceneBySwitchName extends FourSceneEvent {
|
||||||
final String? switchName;
|
final String? switchName;
|
||||||
|
|
||||||
|
|||||||
@ -122,3 +122,9 @@ class LoadingDeviceInfo extends FourSceneState {
|
|||||||
@override
|
@override
|
||||||
List<Object> get props => [deviceInfo];
|
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';
|
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
||||||
|
|
||||||
class SixSceneModel {
|
class SixSceneModel {
|
||||||
String waterContactState;
|
dynamic scene_1;
|
||||||
int batteryPercentage;
|
dynamic scene_2;
|
||||||
|
dynamic scene_3;
|
||||||
|
dynamic scene_4;
|
||||||
|
dynamic scene_5;
|
||||||
|
dynamic scene_6;
|
||||||
|
dynamic scene_id_group_id;
|
||||||
|
dynamic switch_backlight;
|
||||||
|
|
||||||
SixSceneModel({
|
SixSceneModel({
|
||||||
required this.waterContactState,
|
required this.scene_1,
|
||||||
required this.batteryPercentage,
|
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) {
|
factory SixSceneModel.fromJson(List<StatusModel> jsonList) {
|
||||||
late String _waterContactState;
|
late dynamic _scene_1;
|
||||||
late int _batteryPercentage;
|
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++) {
|
for (int i = 0; i < jsonList.length; i++) {
|
||||||
if (jsonList[i].code == 'sossensor_state') {
|
if (jsonList[i].code == 'scene_1') {
|
||||||
_waterContactState = jsonList[i].value ?? false;
|
_scene_1 = jsonList[i].value ?? '';
|
||||||
} else if (jsonList[i].code == 'battery_percentage') {
|
} else if (jsonList[i].code == 'scene_2') {
|
||||||
_batteryPercentage = jsonList[i].value ?? 0;
|
_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(
|
return SixSceneModel(
|
||||||
waterContactState: _waterContactState,
|
scene_1: _scene_1,
|
||||||
batteryPercentage: _batteryPercentage,
|
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) {
|
builder: (context, state) {
|
||||||
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
||||||
SixSceneModel model = SixSceneModel(
|
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 = [];
|
List<SubSpaceModel>? rooms = [];
|
||||||
if (state is LoadingNewSate) {
|
if (state is LoadingNewSate) {
|
||||||
model = state.sosSensor;
|
model = state.sosSensor;
|
||||||
|
|||||||
@ -30,7 +30,14 @@ class QuestionPage extends StatelessWidget {
|
|||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
||||||
SixSceneModel model = SixSceneModel(
|
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) {
|
if (state is LoadingNewSate) {
|
||||||
model = state.sosSensor;
|
model = state.sosSensor;
|
||||||
} else if (state is UpdateState) {
|
} else if (state is UpdateState) {
|
||||||
|
|||||||
@ -29,7 +29,14 @@ class ShareSixScenePage extends StatelessWidget {
|
|||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
||||||
SixSceneModel model = SixSceneModel(
|
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) {
|
if (state is LoadingNewSate) {
|
||||||
model = state.sosSensor;
|
model = state.sosSensor;
|
||||||
} else if (state is UpdateState) {
|
} else if (state is UpdateState) {
|
||||||
|
|||||||
@ -30,7 +30,14 @@ class SixSceneCreateGroup extends StatelessWidget {
|
|||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
||||||
SixSceneModel model = SixSceneModel(
|
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) {
|
if (state is LoadingNewSate) {
|
||||||
model = state.sosSensor;
|
model = state.sosSensor;
|
||||||
} else if (state is UpdateState) {
|
} else if (state is UpdateState) {
|
||||||
|
|||||||
@ -29,7 +29,14 @@ class SixSceneInfoPage extends StatelessWidget {
|
|||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
||||||
SixSceneModel model = SixSceneModel(
|
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) {
|
if (state is LoadingNewSate) {
|
||||||
model = state.sosSensor;
|
model = state.sosSensor;
|
||||||
} else if (state is UpdateState) {
|
} else if (state is UpdateState) {
|
||||||
|
|||||||
@ -33,7 +33,14 @@ class SixSceneProfilePage extends StatelessWidget {
|
|||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
||||||
SixSceneModel model = SixSceneModel(
|
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) {
|
if (state is LoadingNewSate) {
|
||||||
model = state.sosSensor;
|
model = state.sosSensor;
|
||||||
} else if (state is UpdateState) {
|
} else if (state is UpdateState) {
|
||||||
|
|||||||
@ -39,7 +39,14 @@ class SixSceneSettings extends StatelessWidget {
|
|||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
||||||
SixSceneModel model = SixSceneModel(
|
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) {
|
if (state is LoadingNewSate) {
|
||||||
model = state.sosSensor;
|
model = state.sosSensor;
|
||||||
} else if (state is UpdateState) {
|
} else if (state is UpdateState) {
|
||||||
@ -74,8 +81,7 @@ class SixSceneSettings extends StatelessWidget {
|
|||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
const Column(
|
const Column(
|
||||||
crossAxisAlignment:
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
CrossAxisAlignment.stretch,
|
|
||||||
children: [
|
children: [
|
||||||
SizedBox(height: 20),
|
SizedBox(height: 20),
|
||||||
DefaultContainer(
|
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/navigation/routing_constants.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
class SelectSceneSixPage extends StatelessWidget {
|
class SixSelectSceneFourPage extends StatelessWidget {
|
||||||
SelectSceneSixPage({super.key});
|
final String? switchSelected;
|
||||||
|
final String? deviceId;
|
||||||
|
SixSelectSceneFourPage({super.key, this.switchSelected, this.deviceId});
|
||||||
|
|
||||||
final TextEditingController _searchController = TextEditingController();
|
final TextEditingController _searchController = TextEditingController();
|
||||||
final int? selectedSwitchIndex = 0;
|
final int? selectedSwitchIndex = 0;
|
||||||
@ -26,22 +28,26 @@ class SelectSceneSixPage extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => SixSceneBloc(sixSceneId: '')
|
create: (context) => SixSceneBloc(sixSceneId: deviceId!)
|
||||||
..add(LoadScenes(
|
..add(LoadScenes(
|
||||||
unit: spaces!.first,
|
unit: spaces!.first,
|
||||||
unitId: spaces!.first.id,
|
unitId: spaces!.first.id,
|
||||||
showInDevice: false,
|
showInDevice: false,
|
||||||
)),
|
))
|
||||||
|
..add(GetSceneBySwitchName(switchName: switchSelected)),
|
||||||
child: BlocBuilder<SixSceneBloc, SixSceneState>(
|
child: BlocBuilder<SixSceneBloc, SixSceneState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final sensorBloc = BlocProvider.of<SixSceneBloc>(context);
|
final sensorBloc = BlocProvider.of<SixSceneBloc>(context);
|
||||||
|
if (state is SaveSelectionSuccessState) {
|
||||||
|
Navigator.of(context).pop(true);
|
||||||
|
Navigator.of(context).pop(true);
|
||||||
|
}
|
||||||
return DefaultScaffold(
|
return DefaultScaffold(
|
||||||
title: 'Select Scene',
|
title: 'Select Scene',
|
||||||
actions: [_buildSaveButton(context, state, sensorBloc)],
|
actions: [_buildSaveButton(context, state, sensorBloc)],
|
||||||
child: state is SixSceneLoadingState
|
child: state is SixSceneLoadingState
|
||||||
? _buildLoadingIndicator()
|
? _buildLoadingIndicator()
|
||||||
: _buildSceneContent(context, sensorBloc),
|
: _buildSceneContent(context, sensorBloc, state),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -51,14 +57,15 @@ class SelectSceneSixPage extends StatelessWidget {
|
|||||||
// Save button builder
|
// Save button builder
|
||||||
Widget _buildSaveButton(
|
Widget _buildSaveButton(
|
||||||
BuildContext context, SixSceneState state, SixSceneBloc sensorBloc) {
|
BuildContext context, SixSceneState state, SixSceneBloc sensorBloc) {
|
||||||
final bool canSave =
|
final bool canSave = state is SceneSelectionUpdatedState;
|
||||||
state is OptionSelectedState && state.hasSelectionChanged;
|
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: canSave
|
onTap: canSave
|
||||||
? () {
|
? () {
|
||||||
print('object');
|
context.read<SixSceneBloc>().add(AssignDeviceScene(
|
||||||
context.read<SixSceneBloc>().add(SaveSelectionEvent());
|
sceneUuid: sensorBloc.selectedSceneId,
|
||||||
|
switchName: switchSelected,
|
||||||
|
unit: spaces!.first));
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
child: BodyMedium(
|
child: BodyMedium(
|
||||||
@ -84,13 +91,14 @@ class SelectSceneSixPage extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Main scene content with search bar and grid
|
// Main scene content with search bar and grid
|
||||||
Widget _buildSceneContent(BuildContext context, SixSceneBloc sensorBloc) {
|
Widget _buildSceneContent(
|
||||||
|
BuildContext context, SixSceneBloc sensorBloc, SixSceneState state) {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
_buildSearchBar(sensorBloc),
|
_buildSearchBar(sensorBloc),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _buildSceneGrid(sensorBloc),
|
child: _buildSceneGrid(sensorBloc, state),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -125,7 +133,7 @@ class SelectSceneSixPage extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Scene grid builder
|
// Scene grid builder
|
||||||
Widget _buildSceneGrid(SixSceneBloc sensorBloc) {
|
Widget _buildSceneGrid(SixSceneBloc sensorBloc, SixSceneState state) {
|
||||||
final scenes = sensorBloc.filteredScenes;
|
final scenes = sensorBloc.filteredScenes;
|
||||||
|
|
||||||
return GridView.builder(
|
return GridView.builder(
|
||||||
@ -152,13 +160,18 @@ class SelectSceneSixPage extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
final scene = scenes[index];
|
final scene = scenes[index];
|
||||||
|
bool isSelected = scene.id ==
|
||||||
|
(state is SceneSelectionUpdatedState
|
||||||
|
? state.selectedSceneId
|
||||||
|
: sensorBloc.selectedFormApiSceneId);
|
||||||
return SceneItem(
|
return SceneItem(
|
||||||
id: scene.id,
|
id: scene.id,
|
||||||
value: sensorBloc.selectedSceneId == scene.id,
|
value: isSelected,
|
||||||
disablePlayButton: false,
|
disablePlayButton: false,
|
||||||
onChanged: (isSelected) {
|
onChanged: (isSelected) {
|
||||||
sensorBloc.selectedSceneId = isSelected ? scene.id : 'null';
|
|
||||||
sensorBloc.add(SelectOptionEvent(selectedOption: scene.id));
|
sensorBloc.add(SelectOptionEvent(selectedOption: scene.id));
|
||||||
|
|
||||||
|
sensorBloc.add(SelectSceneEvent(unitId: scene.id));
|
||||||
},
|
},
|
||||||
icon: scene.iconInBytes,
|
icon: scene.iconInBytes,
|
||||||
title: scene.name,
|
title: scene.name,
|
||||||
@ -169,8 +182,8 @@ class SelectSceneSixPage extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SceneItem extends StatefulWidget {
|
class SceneItem extends StatelessWidget {
|
||||||
final String id; // Unique ID for each scene
|
final String id;
|
||||||
final Uint8List icon;
|
final Uint8List icon;
|
||||||
final String title;
|
final String title;
|
||||||
final bool disablePlayButton;
|
final bool disablePlayButton;
|
||||||
@ -186,11 +199,6 @@ class SceneItem extends StatefulWidget {
|
|||||||
required this.onChanged,
|
required this.onChanged,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
|
||||||
State<SceneItem> createState() => _SceneItemState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _SceneItemState extends State<SceneItem> {
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
@ -215,9 +223,9 @@ class _SceneItemState extends State<SceneItem> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
if (!widget.disablePlayButton)
|
if (!disablePlayButton)
|
||||||
Image.memory(
|
Image.memory(
|
||||||
widget.icon,
|
icon,
|
||||||
height: 32,
|
height: 32,
|
||||||
width: 32,
|
width: 32,
|
||||||
fit: BoxFit.fill,
|
fit: BoxFit.fill,
|
||||||
@ -228,7 +236,7 @@ class _SceneItemState extends State<SceneItem> {
|
|||||||
fit: BoxFit.fill),
|
fit: BoxFit.fill),
|
||||||
),
|
),
|
||||||
BodyMedium(
|
BodyMedium(
|
||||||
text: widget.title,
|
text: title,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 17,
|
fontSize: 17,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
@ -238,8 +246,8 @@ class _SceneItemState extends State<SceneItem> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
CircularCheckbox(
|
CircularCheckbox(
|
||||||
value: widget.value,
|
value: value,
|
||||||
onChanged: (isSelected) => widget.onChanged(isSelected!),
|
onChanged: (isSelected) => onChanged(isSelected!),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -1,16 +1,18 @@
|
|||||||
import 'package:flutter/material.dart';
|
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/features/shared_widgets/text_widgets/body_large.dart';
|
||||||
import 'package:syncrow_app/generated/assets.dart';
|
import 'package:syncrow_app/generated/assets.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
class SelectSwitchDialog extends StatefulWidget {
|
class SelectSwitchDialog extends StatefulWidget {
|
||||||
final Function()? cancelTab;
|
final Function()? cancelTab;
|
||||||
final Function()? confirmTab;
|
final Function(String)? confirmTab;
|
||||||
String? switch1Title;
|
String? switch1Title;
|
||||||
String? switch2Title;
|
String? switch2Title;
|
||||||
String? switch3Title;
|
String? switch3Title;
|
||||||
String? switch4Title;
|
String? switch4Title;
|
||||||
|
String? switch5Title;
|
||||||
|
String? switch6Title;
|
||||||
SelectSwitchDialog(
|
SelectSwitchDialog(
|
||||||
{super.key,
|
{super.key,
|
||||||
required this.cancelTab,
|
required this.cancelTab,
|
||||||
@ -18,14 +20,16 @@ class SelectSwitchDialog extends StatefulWidget {
|
|||||||
this.switch1Title,
|
this.switch1Title,
|
||||||
this.switch2Title,
|
this.switch2Title,
|
||||||
this.switch3Title,
|
this.switch3Title,
|
||||||
this.switch4Title});
|
this.switch4Title,
|
||||||
|
this.switch5Title,
|
||||||
|
this.switch6Title});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<SelectSwitchDialog> createState() => _SelectSwitchDialogState();
|
State<SelectSwitchDialog> createState() => _SelectSwitchDialogState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SelectSwitchDialogState extends State<SelectSwitchDialog> {
|
class _SelectSwitchDialogState extends State<SelectSwitchDialog> {
|
||||||
int? selectedSwitchIndex = 0;
|
String selectedSwitchName = '';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -49,34 +53,48 @@ class _SelectSwitchDialogState extends State<SelectSwitchDialog> {
|
|||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
SwitchsCard(
|
SixSwitchsCardDialog(
|
||||||
switch1Title: widget.switch1Title,
|
switch1Title: widget.switch1Title,
|
||||||
switch2Title: widget.switch2Title,
|
switch2Title: widget.switch2Title,
|
||||||
switch3Title: widget.switch3Title,
|
switch3Title: widget.switch3Title,
|
||||||
switch4Title: widget.switch4Title,
|
switch4Title: widget.switch4Title,
|
||||||
switch1Down: selectedSwitchIndex == -1
|
switch5Title: widget.switch5Title,
|
||||||
|
switch6Title: widget.switch6Title,
|
||||||
|
switch1Down: selectedSwitchName == 'scene_4'
|
||||||
? Assets.removeSceneIcon
|
? Assets.removeSceneIcon
|
||||||
: Assets.addSwitchIcon,
|
: Assets.addSwitchIcon,
|
||||||
switch1Up: selectedSwitchIndex == 1
|
switch1Up: selectedSwitchName == 'scene_1'
|
||||||
? Assets.removeSceneIcon
|
? Assets.removeSceneIcon
|
||||||
: Assets.addSwitchIcon,
|
: Assets.addSwitchIcon,
|
||||||
switch2Down: selectedSwitchIndex == -2
|
switch2Down: selectedSwitchName == 'scene_5'
|
||||||
? Assets.removeSceneIcon
|
? Assets.removeSceneIcon
|
||||||
: Assets.addSwitchIcon,
|
: Assets.addSwitchIcon,
|
||||||
switch2Up: selectedSwitchIndex == 2
|
switch2Up: selectedSwitchName == 'scene_2'
|
||||||
? Assets.removeSceneIcon
|
? Assets.removeSceneIcon
|
||||||
: Assets.addSwitchIcon,
|
: 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: () {
|
onSwitch1UpTap: () {
|
||||||
setState(() => selectedSwitchIndex = 1);
|
setState(() => selectedSwitchName = 'scene_1');
|
||||||
},
|
},
|
||||||
onSwitch1DownTap: () {
|
onSwitch1DownTap: () {
|
||||||
setState(() => selectedSwitchIndex = -1);
|
setState(() => selectedSwitchName = 'scene_4');
|
||||||
},
|
},
|
||||||
onSwitch2UpTap: () {
|
onSwitch2UpTap: () {
|
||||||
setState(() => selectedSwitchIndex = 2);
|
setState(() => selectedSwitchName = 'scene_5');
|
||||||
},
|
},
|
||||||
onSwitch2DownTap: () {
|
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),
|
top: BorderSide(color: ColorsManager.textGray, width: 1.0),
|
||||||
)),
|
)),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: selectedSwitchIndex == 0 ? () {} : widget.confirmTab,
|
onTap: selectedSwitchName == ''
|
||||||
|
? () {}
|
||||||
|
: () => widget.confirmTab!(selectedSwitchName),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(15),
|
padding: EdgeInsets.all(15),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
'Next',
|
'Next',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: selectedSwitchIndex == 0
|
color: selectedSwitchName == ''
|
||||||
? ColorsManager.textPrimaryColor
|
? ColorsManager.textPrimaryColor
|
||||||
.withOpacity(0.6)
|
.withOpacity(0.6)
|
||||||
: ColorsManager.primaryColor,
|
: 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/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_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/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_container.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||||
@ -41,12 +41,22 @@ class SixSceneScreen extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
child: BlocProvider(
|
child: BlocProvider(
|
||||||
create: (context) => SixSceneBloc(sixSceneId: device?.uuid ?? '')
|
create: (context) => SixSceneBloc(sixSceneId: device?.uuid ?? '')
|
||||||
..add(const SixSceneInitial()),
|
..add(const SixSceneInitial())
|
||||||
|
..add(const SixSceneInitialInfo())
|
||||||
|
..add(const SexSceneSwitchInitial()),
|
||||||
child: BlocBuilder<SixSceneBloc, SixSceneState>(
|
child: BlocBuilder<SixSceneBloc, SixSceneState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final sensor = BlocProvider.of<SixSceneBloc>(context);
|
final _bloc = BlocProvider.of<SixSceneBloc>(context);
|
||||||
SixSceneModel model = SixSceneModel(
|
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) {
|
if (state is LoadingNewSate) {
|
||||||
model = state.sosSensor;
|
model = state.sosSensor;
|
||||||
} else if (state is UpdateState) {
|
} else if (state is UpdateState) {
|
||||||
@ -61,7 +71,7 @@ class SixSceneScreen extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
: RefreshIndicator(
|
: RefreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
sensor.add(const SixSceneInitial());
|
_bloc.add(const SixSceneInitial());
|
||||||
},
|
},
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: [
|
children: [
|
||||||
@ -69,24 +79,43 @@ class SixSceneScreen extends StatelessWidget {
|
|||||||
height: MediaQuery.sizeOf(context).height * 0.8,
|
height: MediaQuery.sizeOf(context).height * 0.8,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
SwitchsCard(
|
SixSwitchsCardDialog(
|
||||||
// switch1Title: ,
|
switch1Title: model.scene_1,
|
||||||
// switch2Title: ,
|
switch2Title: model.scene_2,
|
||||||
// switch3Title: ,
|
switch3Title: model.scene_3,
|
||||||
// switch4Title: ,
|
switch4Title: model.scene_4,
|
||||||
switch1Down: sensor.switchStatus == true
|
switch5Title: model.scene_5,
|
||||||
|
switch6Title: model.scene_6,
|
||||||
|
switch1Down:
|
||||||
|
_bloc.deviceStatus.switch_backlight == true
|
||||||
? Assets.switchOn
|
? Assets.switchOn
|
||||||
: Assets.switchOff,
|
: Assets.switchOff,
|
||||||
switch1Up: sensor.switchStatus == true
|
switch1Up:
|
||||||
|
_bloc.deviceStatus.switch_backlight == true
|
||||||
? Assets.switchOn
|
? Assets.switchOn
|
||||||
: Assets.switchOff,
|
: Assets.switchOff,
|
||||||
switch2Down: sensor.switchStatus == true
|
switch2Down:
|
||||||
|
_bloc.deviceStatus.switch_backlight == true
|
||||||
? Assets.switchOn
|
? Assets.switchOn
|
||||||
: Assets.switchOff,
|
: Assets.switchOff,
|
||||||
switch2Up: sensor.switchStatus == true
|
switch2Up:
|
||||||
|
_bloc.deviceStatus.switch_backlight == true
|
||||||
? Assets.switchOn
|
? Assets.switchOn
|
||||||
: Assets.switchOff,
|
: 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: () {
|
onSwitch1UpTap: () {
|
||||||
debugPrint("Switch 1 Up tapped");
|
debugPrint("Switch 1 Up tapped");
|
||||||
},
|
},
|
||||||
@ -106,7 +135,7 @@ class SixSceneScreen extends StatelessWidget {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: DefaultContainer(
|
child: DefaultContainer(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
sensor.add(ChangeSwitchStatusEvent());
|
_bloc.add(ChangeSwitchStatusEvent());
|
||||||
},
|
},
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment:
|
crossAxisAlignment:
|
||||||
@ -140,19 +169,29 @@ class SixSceneScreen extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DefaultContainer(
|
child: DefaultContainer(
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
showDialog(
|
var value = await showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return SelectSwitchDialog(
|
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: () {
|
cancelTab: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
confirmTab: () {
|
confirmTab: (v) {
|
||||||
Navigator.of(context).push(
|
Navigator.of(context).push(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) =>
|
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(
|
Expanded(
|
||||||
child: DefaultContainer(
|
child: DefaultContainer(
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
showDialog(
|
var value = await showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return FourSelectSwitchDialog(
|
return FourSelectSwitchDialog(
|
||||||
@ -162,18 +162,29 @@ class FourSceneScreen extends StatelessWidget {
|
|||||||
cancelTab: () {
|
cancelTab: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
confirmTab: (switchSelected) {
|
confirmTab:
|
||||||
|
(switchSelected) async {
|
||||||
Navigator.of(context).push(
|
Navigator.of(context).push(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) =>
|
builder: (context) =>
|
||||||
FourSelectSceneFourPage(
|
FourSelectSceneFourPage(
|
||||||
switchSelected: switchSelected,
|
switchSelected:
|
||||||
deviceId:device!.uuid)),
|
switchSelected,
|
||||||
|
deviceId:
|
||||||
|
device!
|
||||||
|
.uuid)),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
if (value == true) {
|
||||||
|
_bloc.add(const FourSceneInitial());
|
||||||
|
_bloc.add(
|
||||||
|
const FourSceneInitialInfo());
|
||||||
|
_bloc.add(
|
||||||
|
const FourSceneSwitchInitial());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment:
|
crossAxisAlignment:
|
||||||
|
|||||||
@ -67,11 +67,22 @@ class FourSceneProfilePage extends StatelessWidget {
|
|||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
child: CircleAvatar(
|
child: CircleAvatar(
|
||||||
radius: 55,
|
radius: 55,
|
||||||
backgroundColor: Colors.grey,
|
backgroundColor: ColorsManager.graysColor,
|
||||||
child: ClipOval(
|
child: ClipOval(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
Center(
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
Assets.sosProfileIcon,
|
Assets.fourSceneIcon,
|
||||||
fit: BoxFit.fill,
|
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_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/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/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_container.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||||
@ -139,9 +138,24 @@ class FourSceneSettings extends StatelessWidget {
|
|||||||
radius: 40,
|
radius: 40,
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
ColorsManager.backgroundColor,
|
ColorsManager.backgroundColor,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.center,
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
top: 8),
|
||||||
|
child: SizedBox(
|
||||||
|
height: 70,
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
Assets.sixSceneIcon,
|
Assets.fourSceneIcon,
|
||||||
fit: BoxFit.fill,
|
fit: BoxFit.contain,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
|
|||||||
@ -38,13 +38,16 @@ class FourSelectSceneFourPage extends StatelessWidget {
|
|||||||
child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final sensorBloc = BlocProvider.of<FourSceneBloc>(context);
|
final sensorBloc = BlocProvider.of<FourSceneBloc>(context);
|
||||||
|
if (state is SaveSelectionSuccessState) {
|
||||||
|
Navigator.of(context).pop(true);
|
||||||
|
Navigator.of(context).pop(true);
|
||||||
|
}
|
||||||
return DefaultScaffold(
|
return DefaultScaffold(
|
||||||
title: 'Select Scene',
|
title: 'Select Scene',
|
||||||
actions: [_buildSaveButton(context, state, sensorBloc)],
|
actions: [_buildSaveButton(context, state, sensorBloc)],
|
||||||
child: state is FourSceneLoadingState
|
child: state is FourSceneLoadingState
|
||||||
? _buildLoadingIndicator()
|
? _buildLoadingIndicator()
|
||||||
: _buildSceneContent(context, sensorBloc),
|
: _buildSceneContent(context, sensorBloc, state),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -54,8 +57,7 @@ class FourSelectSceneFourPage extends StatelessWidget {
|
|||||||
// Save button builder
|
// Save button builder
|
||||||
Widget _buildSaveButton(
|
Widget _buildSaveButton(
|
||||||
BuildContext context, FourSceneState state, FourSceneBloc sensorBloc) {
|
BuildContext context, FourSceneState state, FourSceneBloc sensorBloc) {
|
||||||
final bool canSave =
|
final bool canSave = state is SceneSelectionUpdatedState;
|
||||||
state is OptionSelectedState && state.hasSelectionChanged;
|
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: canSave
|
onTap: canSave
|
||||||
@ -89,13 +91,14 @@ class FourSelectSceneFourPage extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Main scene content with search bar and grid
|
// Main scene content with search bar and grid
|
||||||
Widget _buildSceneContent(BuildContext context, FourSceneBloc sensorBloc) {
|
Widget _buildSceneContent(
|
||||||
|
BuildContext context, FourSceneBloc sensorBloc, FourSceneState state) {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
_buildSearchBar(sensorBloc),
|
_buildSearchBar(sensorBloc),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _buildSceneGrid(sensorBloc),
|
child: _buildSceneGrid(sensorBloc, state),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -130,8 +133,9 @@ class FourSelectSceneFourPage extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Scene grid builder
|
// Scene grid builder
|
||||||
Widget _buildSceneGrid(FourSceneBloc sensorBloc) {
|
Widget _buildSceneGrid(FourSceneBloc sensorBloc, FourSceneState state) {
|
||||||
final scenes = sensorBloc.filteredScenes;
|
final scenes = sensorBloc.filteredScenes;
|
||||||
|
|
||||||
return GridView.builder(
|
return GridView.builder(
|
||||||
itemCount: scenes.length + 1,
|
itemCount: scenes.length + 1,
|
||||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
@ -141,7 +145,6 @@ class FourSelectSceneFourPage extends StatelessWidget {
|
|||||||
mainAxisExtent: 120,
|
mainAxisExtent: 120,
|
||||||
),
|
),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
// sensorBloc.sceneId;
|
|
||||||
if (index == scenes.length) {
|
if (index == scenes.length) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () => Navigator.pushNamed(
|
onTap: () => Navigator.pushNamed(
|
||||||
@ -157,13 +160,18 @@ class FourSelectSceneFourPage extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
final scene = scenes[index];
|
final scene = scenes[index];
|
||||||
|
bool isSelected = scene.id ==
|
||||||
|
(state is SceneSelectionUpdatedState
|
||||||
|
? state.selectedSceneId
|
||||||
|
: sensorBloc.selectedFormApiSceneId);
|
||||||
return SceneItem(
|
return SceneItem(
|
||||||
id: scene.id,
|
id: scene.id,
|
||||||
value: (sensorBloc.selectedSceneId == scene.id),
|
value: isSelected,
|
||||||
disablePlayButton: false,
|
disablePlayButton: false,
|
||||||
onChanged: (isSelected) {
|
onChanged: (isSelected) {
|
||||||
sensorBloc.selectedSceneId = isSelected ? scene.id : 'null';
|
|
||||||
sensorBloc.add(SelectOptionEvent(selectedOption: scene.id));
|
sensorBloc.add(SelectOptionEvent(selectedOption: scene.id));
|
||||||
|
|
||||||
|
sensorBloc.add(SelectSceneEvent(selectedSceneId: scene.id));
|
||||||
},
|
},
|
||||||
icon: scene.iconInBytes,
|
icon: scene.iconInBytes,
|
||||||
title: scene.name,
|
title: scene.name,
|
||||||
@ -174,8 +182,8 @@ class FourSelectSceneFourPage extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SceneItem extends StatefulWidget {
|
class SceneItem extends StatelessWidget {
|
||||||
final String id; // Unique ID for each scene
|
final String id;
|
||||||
final Uint8List icon;
|
final Uint8List icon;
|
||||||
final String title;
|
final String title;
|
||||||
final bool disablePlayButton;
|
final bool disablePlayButton;
|
||||||
@ -191,11 +199,6 @@ class SceneItem extends StatefulWidget {
|
|||||||
required this.onChanged,
|
required this.onChanged,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
|
||||||
State<SceneItem> createState() => _SceneItemState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _SceneItemState extends State<SceneItem> {
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
@ -220,9 +223,9 @@ class _SceneItemState extends State<SceneItem> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
if (!widget.disablePlayButton)
|
if (!disablePlayButton)
|
||||||
Image.memory(
|
Image.memory(
|
||||||
widget.icon,
|
icon,
|
||||||
height: 32,
|
height: 32,
|
||||||
width: 32,
|
width: 32,
|
||||||
fit: BoxFit.fill,
|
fit: BoxFit.fill,
|
||||||
@ -233,7 +236,7 @@ class _SceneItemState extends State<SceneItem> {
|
|||||||
fit: BoxFit.fill),
|
fit: BoxFit.fill),
|
||||||
),
|
),
|
||||||
BodyMedium(
|
BodyMedium(
|
||||||
text: widget.title,
|
text: title,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 17,
|
fontSize: 17,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
@ -243,8 +246,8 @@ class _SceneItemState extends State<SceneItem> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
CircularCheckbox(
|
CircularCheckbox(
|
||||||
value: widget.value,
|
value: value,
|
||||||
onChanged: (isSelected) => widget.onChanged(isSelected!),
|
onChanged: (isSelected) => onChanged(isSelected!),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
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/features/shared_widgets/text_widgets/body_large.dart';
|
||||||
import 'package:syncrow_app/generated/assets.dart';
|
import 'package:syncrow_app/generated/assets.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
@ -51,7 +51,7 @@ class _FourSelectSwitchDialogState extends State<FourSelectSwitchDialog> {
|
|||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
SwitchsCard(
|
FourSwitchsCardDialog(
|
||||||
switch1Title: widget.switch1Title,
|
switch1Title: widget.switch1Title,
|
||||||
switch2Title: widget.switch2Title,
|
switch2Title: widget.switch2Title,
|
||||||
switch3Title: widget.switch3Title,
|
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/features/shared_widgets/text_widgets/body_small.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
class SwitchsCard extends StatelessWidget {
|
class FourSwitchsCardDialog extends StatelessWidget {
|
||||||
final String? switch1Title;
|
final String? switch1Title;
|
||||||
final String? switch2Title;
|
final String? switch2Title;
|
||||||
final String? switch3Title;
|
final String? switch3Title;
|
||||||
@ -19,7 +19,7 @@ class SwitchsCard extends StatelessWidget {
|
|||||||
final VoidCallback onSwitch2UpTap;
|
final VoidCallback onSwitch2UpTap;
|
||||||
final VoidCallback onSwitch2DownTap;
|
final VoidCallback onSwitch2DownTap;
|
||||||
|
|
||||||
SwitchsCard({
|
FourSwitchsCardDialog({
|
||||||
required this.switch1Down,
|
required this.switch1Down,
|
||||||
required this.switch1Up,
|
required this.switch1Up,
|
||||||
required this.switch2Down,
|
required this.switch2Down,
|
||||||
@ -7,6 +7,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_model.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/ACs/acs_view.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/curtains/curtain_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';
|
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) =>
|
pageBuilder: (context, animation1, animation2) =>
|
||||||
WaterLeakScreen(device: device)));
|
WaterLeakScreen(device: device)));
|
||||||
|
|
||||||
|
case DeviceType.SixScene:
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
PageRouteBuilder(
|
||||||
|
pageBuilder: (context, animation1, animation2) =>
|
||||||
|
SixSceneScreen(device: device)));
|
||||||
|
|
||||||
case DeviceType.FourScene:
|
case DeviceType.FourScene:
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
|
|||||||
@ -1117,6 +1117,7 @@ class Assets {
|
|||||||
static const String sixSceneIcon = "assets/icons/six_scene_icon.svg";
|
static const String sixSceneIcon = "assets/icons/six_scene_icon.svg";
|
||||||
static const String minusIcon = "assets/icons/minus_icon.svg";
|
static const String minusIcon = "assets/icons/minus_icon.svg";
|
||||||
static const String addDevicesIcon = "assets/icons/add_devices_icon.svg";
|
static const String addDevicesIcon = "assets/icons/add_devices_icon.svg";
|
||||||
|
static const String fourSceneIcon = "assets/icons/four_scene_icon.svg";
|
||||||
|
|
||||||
//powerClampIcon
|
//powerClampIcon
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,6 +57,7 @@ enum DeviceType {
|
|||||||
WaterLeak,
|
WaterLeak,
|
||||||
PC,
|
PC,
|
||||||
FourScene,
|
FourScene,
|
||||||
|
SixScene,
|
||||||
Other,
|
Other,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,6 +91,7 @@ Map<String, DeviceType> devicesTypesMap = {
|
|||||||
"WL": DeviceType.WaterLeak,
|
"WL": DeviceType.WaterLeak,
|
||||||
"PC": DeviceType.PC,
|
"PC": DeviceType.PC,
|
||||||
"4S": DeviceType.FourScene,
|
"4S": DeviceType.FourScene,
|
||||||
|
"6S": DeviceType.SixScene,
|
||||||
};
|
};
|
||||||
Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = {
|
Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = {
|
||||||
DeviceType.AC: [
|
DeviceType.AC: [
|
||||||
@ -544,6 +546,52 @@ Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = {
|
|||||||
code: 'switch_backlight',
|
code: 'switch_backlight',
|
||||||
type: functionTypesMap['Enum'],
|
type: functionTypesMap['Enum'],
|
||||||
values: ValueModel.fromJson({})),
|
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