mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-26 08:54:54 +00:00
Merge pull request #42 from SyncrowIOT/automation_fixes2
Automation fixes2
This commit is contained in:
@ -63,8 +63,7 @@ class HomeCubit extends Cubit<HomeState> {
|
|||||||
|
|
||||||
Future fetchUserInfo() async {
|
Future fetchUserInfo() async {
|
||||||
try {
|
try {
|
||||||
var uuid =
|
var uuid = await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
||||||
await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
|
||||||
user = await ProfileApi().fetchUserInfo(uuid);
|
user = await ProfileApi().fetchUserInfo(uuid);
|
||||||
emit(HomeUserInfoLoaded(user!)); // Emit state after fetching user info
|
emit(HomeUserInfoLoaded(user!)); // Emit state after fetching user info
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -85,12 +84,9 @@ class HomeCubit extends Cubit<HomeState> {
|
|||||||
selectedSpace = null;
|
selectedSpace = null;
|
||||||
selectedRoom = null;
|
selectedRoom = null;
|
||||||
pageIndex = 0;
|
pageIndex = 0;
|
||||||
OneSignal.User.pushSubscription
|
OneSignal.User.pushSubscription.removeObserver((stateChanges) => oneSignalSubscriptionObserver);
|
||||||
.removeObserver((stateChanges) => oneSignalSubscriptionObserver);
|
OneSignal.Notifications.removePermissionObserver((permission) => oneSignalPermissionObserver);
|
||||||
OneSignal.Notifications.removePermissionObserver(
|
OneSignal.Notifications.removeClickListener((event) => oneSignalClickListenerObserver);
|
||||||
(permission) => oneSignalPermissionObserver);
|
|
||||||
OneSignal.Notifications.removeClickListener(
|
|
||||||
(event) => oneSignalClickListenerObserver);
|
|
||||||
return super.close();
|
return super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,9 +128,7 @@ class HomeCubit extends Cubit<HomeState> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var userUuid =
|
var userUuid = await const FlutterSecureStorage().read(key: UserModel.userUuidKey) ?? '';
|
||||||
await const FlutterSecureStorage().read(key: UserModel.userUuidKey) ??
|
|
||||||
'';
|
|
||||||
if (userUuid.isNotEmpty) {
|
if (userUuid.isNotEmpty) {
|
||||||
await OneSignal.login(userUuid);
|
await OneSignal.login(userUuid);
|
||||||
}
|
}
|
||||||
@ -142,24 +136,21 @@ class HomeCubit extends Cubit<HomeState> {
|
|||||||
await OneSignal.User.pushSubscription.optIn();
|
await OneSignal.User.pushSubscription.optIn();
|
||||||
|
|
||||||
//this function will be called once a user is subscribed
|
//this function will be called once a user is subscribed
|
||||||
oneSignalSubscriptionObserver =
|
oneSignalSubscriptionObserver = OneSignal.User.pushSubscription.addObserver((state) async {
|
||||||
OneSignal.User.pushSubscription.addObserver((state) async {
|
|
||||||
if (state.current.optedIn) {
|
if (state.current.optedIn) {
|
||||||
await _sendSubscriptionId();
|
await _sendSubscriptionId();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Send the player id when a user allows notifications
|
// Send the player id when a user allows notifications
|
||||||
oneSignalPermissionObserver =
|
oneSignalPermissionObserver = OneSignal.Notifications.addPermissionObserver((state) async {
|
||||||
OneSignal.Notifications.addPermissionObserver((state) async {
|
|
||||||
await _sendSubscriptionId();
|
await _sendSubscriptionId();
|
||||||
});
|
});
|
||||||
|
|
||||||
//check if the player id is sent, if not send it again
|
//check if the player id is sent, if not send it again
|
||||||
await _sendSubscriptionId();
|
await _sendSubscriptionId();
|
||||||
|
|
||||||
oneSignalClickListenerObserver =
|
oneSignalClickListenerObserver = OneSignal.Notifications.addClickListener((event) async {
|
||||||
OneSignal.Notifications.addClickListener((event) async {
|
|
||||||
//Once the user clicks on the notification
|
//Once the user clicks on the notification
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -246,9 +237,7 @@ class HomeCubit extends Cubit<HomeState> {
|
|||||||
|
|
||||||
Future<bool> joinAUnit(String code) async {
|
Future<bool> joinAUnit(String code) async {
|
||||||
try {
|
try {
|
||||||
var uuid =
|
var uuid = await const FlutterSecureStorage().read(key: UserModel.userUuidKey) ?? '';
|
||||||
await const FlutterSecureStorage().read(key: UserModel.userUuidKey) ??
|
|
||||||
'';
|
|
||||||
Map<String, String> body = {'userUuid': uuid, 'inviteCode': code};
|
Map<String, String> body = {'userUuid': uuid, 'inviteCode': code};
|
||||||
|
|
||||||
final success = await SpacesAPI.joinUnit(body);
|
final success = await SpacesAPI.joinUnit(body);
|
||||||
@ -360,50 +349,47 @@ class HomeCubit extends Cubit<HomeState> {
|
|||||||
// ),
|
// ),
|
||||||
// onPressed: () {},
|
// onPressed: () {},
|
||||||
// ),
|
// ),
|
||||||
IconButton(
|
// IconButton(
|
||||||
icon: const Icon(
|
// icon: const Icon(
|
||||||
Icons.add,
|
// Icons.add,
|
||||||
size: 32,
|
// size: 32,
|
||||||
),
|
// ),
|
||||||
style: ButtonStyle(
|
// style: ButtonStyle(
|
||||||
foregroundColor:
|
// foregroundColor: WidgetStateProperty.all(ColorsManager.textPrimaryColor),
|
||||||
WidgetStateProperty.all(ColorsManager.textPrimaryColor),
|
// ),
|
||||||
),
|
// onPressed: () {
|
||||||
onPressed: () {
|
// Navigator.pushNamed(
|
||||||
Navigator.pushNamed(
|
// NavigationService.navigatorKey.currentContext!,
|
||||||
NavigationService.navigatorKey.currentContext!,
|
// Routes.sceneTasksRoute,
|
||||||
Routes.sceneTasksRoute,
|
// arguments: SceneSettingsRouteArguments(
|
||||||
arguments: SceneSettingsRouteArguments(
|
// sceneType: '',
|
||||||
sceneType: '',
|
// sceneId: '',
|
||||||
sceneId: '',
|
// sceneName: '',
|
||||||
sceneName: '',
|
// ),
|
||||||
),
|
// );
|
||||||
);
|
// NavigationService.navigatorKey.currentContext!
|
||||||
NavigationService.navigatorKey.currentContext!
|
// .read<CreateSceneBloc>()
|
||||||
.read<CreateSceneBloc>()
|
// .add(const ClearTaskListEvent());
|
||||||
.add(const ClearTaskListEvent());
|
// NavigationService.navigatorKey.currentContext!
|
||||||
NavigationService.navigatorKey.currentContext!
|
// .read<CreateSceneBloc>()
|
||||||
.read<CreateSceneBloc>()
|
// .add(const SceneTypeEvent(CreateSceneEnum.none));
|
||||||
.add(const SceneTypeEvent(CreateSceneEnum.none));
|
// NavigationService.navigatorKey.currentContext!
|
||||||
NavigationService.navigatorKey.currentContext!
|
// .read<SmartSceneSelectBloc>()
|
||||||
.read<SmartSceneSelectBloc>()
|
// .add(const SmartSceneClearEvent());
|
||||||
.add(const SmartSceneClearEvent());
|
// BlocProvider.of<EffectPeriodBloc>(NavigationService.navigatorKey.currentState!.context)
|
||||||
BlocProvider.of<EffectPeriodBloc>(
|
// .add(ResetEffectivePeriod());
|
||||||
NavigationService.navigatorKey.currentState!.context)
|
// },
|
||||||
.add(ResetEffectivePeriod());
|
// ),
|
||||||
},
|
// IconButton(
|
||||||
),
|
// icon: const Icon(
|
||||||
IconButton(
|
// Icons.more_vert,
|
||||||
icon: const Icon(
|
// size: 28,
|
||||||
Icons.more_vert,
|
// ),
|
||||||
size: 28,
|
// style: ButtonStyle(
|
||||||
),
|
// foregroundColor: WidgetStateProperty.all(ColorsManager.textPrimaryColor),
|
||||||
style: ButtonStyle(
|
// ),
|
||||||
foregroundColor:
|
// onPressed: () {},
|
||||||
WidgetStateProperty.all(ColorsManager.textPrimaryColor),
|
// ),
|
||||||
),
|
|
||||||
onPressed: () {},
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
'Menu': [
|
'Menu': [
|
||||||
IconButton(
|
IconButton(
|
||||||
@ -433,8 +419,7 @@ class HomeCubit extends Cubit<HomeState> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static var bottomNavItems = [
|
static var bottomNavItems = [
|
||||||
defaultBottomNavBarItem(
|
defaultBottomNavBarItem(icon: Assets.assetsIconsDashboard, label: 'Dashboard'),
|
||||||
icon: Assets.assetsIconsDashboard, label: 'Dashboard'),
|
|
||||||
// defaultBottomNavBarItem(icon: Assets.assetsIconslayout, label: 'Layout'),
|
// defaultBottomNavBarItem(icon: Assets.assetsIconslayout, label: 'Layout'),
|
||||||
defaultBottomNavBarItem(icon: Assets.assetsIconsDevices, label: 'Devices'),
|
defaultBottomNavBarItem(icon: Assets.assetsIconsDevices, label: 'Devices'),
|
||||||
defaultBottomNavBarItem(icon: Assets.assetsIconsRoutines, label: 'Routine'),
|
defaultBottomNavBarItem(icon: Assets.assetsIconsRoutines, label: 'Routine'),
|
||||||
@ -460,8 +445,7 @@ class HomeCubit extends Cubit<HomeState> {
|
|||||||
|
|
||||||
void updateDevice(String deviceId) async {
|
void updateDevice(String deviceId) async {
|
||||||
try {
|
try {
|
||||||
final response = await DevicesAPI.firmwareDevice(
|
final response = await DevicesAPI.firmwareDevice(deviceId: deviceId, firmwareVersion: '0');
|
||||||
deviceId: deviceId, firmwareVersion: '0');
|
|
||||||
if (response['success'] ?? false) {
|
if (response['success'] ?? false) {
|
||||||
CustomSnackBar.displaySnackBar('No updates available');
|
CustomSnackBar.displaySnackBar('No updates available');
|
||||||
}
|
}
|
||||||
@ -469,8 +453,7 @@ class HomeCubit extends Cubit<HomeState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BottomNavigationBarItem defaultBottomNavBarItem(
|
BottomNavigationBarItem defaultBottomNavBarItem({required String icon, required String label}) {
|
||||||
{required String icon, required String label}) {
|
|
||||||
return BottomNavigationBarItem(
|
return BottomNavigationBarItem(
|
||||||
icon: SvgPicture.asset(icon),
|
icon: SvgPicture.asset(icon),
|
||||||
activeIcon: SvgPicture.asset(
|
activeIcon: SvgPicture.asset(
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
||||||
import 'package:syncrow_app/features/scene/bloc/effective_period/effect_period_bloc.dart';
|
|
||||||
import 'package:syncrow_app/features/scene/bloc/effective_period/effect_period_event.dart';
|
|
||||||
import 'package:syncrow_app/features/scene/bloc/smart_scene/smart_scene_select_dart_bloc.dart';
|
import 'package:syncrow_app/features/scene/bloc/smart_scene/smart_scene_select_dart_bloc.dart';
|
||||||
import 'package:syncrow_app/features/scene/enum/create_scene_enum.dart';
|
import 'package:syncrow_app/features/scene/enum/create_scene_enum.dart';
|
||||||
import 'package:syncrow_app/features/scene/model/scene_settings_route_arguments.dart';
|
import 'package:syncrow_app/features/scene/model/scene_settings_route_arguments.dart';
|
||||||
@ -29,7 +27,6 @@ class SceneListview extends StatelessWidget {
|
|||||||
itemCount: scenes.length,
|
itemCount: scenes.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final scene = scenes[index];
|
final scene = scenes[index];
|
||||||
final isLoading = loadingSceneId == scene.id;
|
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.only(right: 10),
|
padding: const EdgeInsets.only(right: 10),
|
||||||
child: DefaultContainer(
|
child: DefaultContainer(
|
||||||
@ -43,8 +40,17 @@ class SceneListview extends StatelessWidget {
|
|||||||
sceneName: scene.name,
|
sceneName: scene.name,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
context
|
||||||
|
.read<SmartSceneSelectBloc>()
|
||||||
|
.add(const SmartSceneClearEvent());
|
||||||
|
|
||||||
|
BlocProvider.of<CreateSceneBloc>(context).add(
|
||||||
|
FetchSceneTasksEvent(
|
||||||
|
sceneId: scene.id, isAutomation: false));
|
||||||
|
|
||||||
|
/// the state to set the scene type must be after the fetch
|
||||||
BlocProvider.of<CreateSceneBloc>(context)
|
BlocProvider.of<CreateSceneBloc>(context)
|
||||||
.add(FetchSceneTasksEvent(sceneId: scene.id));
|
.add(const SceneTypeEvent(CreateSceneEnum.tabToRun));
|
||||||
},
|
},
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: MediaQuery.of(context).size.width * 0.4,
|
width: MediaQuery.of(context).size.width * 0.4,
|
||||||
|
|||||||
@ -26,12 +26,14 @@ class RoomsView extends StatelessWidget {
|
|||||||
title: 'Space Management',
|
title: 'Space Management',
|
||||||
child: state is LoadingState
|
child: state is LoadingState
|
||||||
? const Center(child: RefreshProgressIndicator())
|
? const Center(child: RefreshProgressIndicator())
|
||||||
: Container(
|
: SizedBox(
|
||||||
margin: const EdgeInsets.only(top: 32),
|
|
||||||
width: MediaQuery.sizeOf(context).width,
|
width: MediaQuery.sizeOf(context).width,
|
||||||
height: MediaQuery.sizeOf(context).height,
|
height: MediaQuery.sizeOf(context).height,
|
||||||
child: Column(
|
child: ListView(
|
||||||
children: [
|
children: [
|
||||||
|
const SizedBox(
|
||||||
|
height: 32,
|
||||||
|
),
|
||||||
if (state is FetchRoomsState)
|
if (state is FetchRoomsState)
|
||||||
Container(
|
Container(
|
||||||
decoration: const ShapeDecoration(
|
decoration: const ShapeDecoration(
|
||||||
|
|||||||
@ -55,7 +55,7 @@ class ProfileTab extends StatelessWidget {
|
|||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
BodyMedium(
|
BodyMedium(
|
||||||
text: HomeCubit.user!.lastName ?? '',
|
text: HomeCubit.user?.lastName ?? '',
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import 'package:syncrow_app/features/scene/model/create_scene_model.dart';
|
|||||||
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
||||||
import 'package:syncrow_app/navigation/navigation_service.dart';
|
import 'package:syncrow_app/navigation/navigation_service.dart';
|
||||||
import 'package:syncrow_app/services/api/scene_api.dart';
|
import 'package:syncrow_app/services/api/scene_api.dart';
|
||||||
|
import 'package:syncrow_app/utils/helpers/snack_bar.dart';
|
||||||
|
|
||||||
part 'create_scene_event.dart';
|
part 'create_scene_event.dart';
|
||||||
part 'create_scene_state.dart';
|
part 'create_scene_state.dart';
|
||||||
@ -52,8 +53,7 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
String conditionRule = 'or';
|
String conditionRule = 'or';
|
||||||
EffectiveTime? effectiveTime;
|
EffectiveTime? effectiveTime;
|
||||||
|
|
||||||
FutureOr<void> _onAddSceneTask(
|
FutureOr<void> _onAddSceneTask(AddTaskEvent event, Emitter<CreateSceneState> emit) {
|
||||||
AddTaskEvent event, Emitter<CreateSceneState> emit) {
|
|
||||||
emit(CreateSceneLoading());
|
emit(CreateSceneLoading());
|
||||||
if (event.isAutomation == true) {
|
if (event.isAutomation == true) {
|
||||||
final copyList = List<SceneStaticFunction>.from(automationTempTasksList);
|
final copyList = List<SceneStaticFunction>.from(automationTempTasksList);
|
||||||
@ -88,32 +88,33 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addToTempTaskList(
|
void addToTempTaskList(TempHoldSceneTasksEvent event, Emitter<CreateSceneState> emit) {
|
||||||
TempHoldSceneTasksEvent event, Emitter<CreateSceneState> emit) {
|
|
||||||
emit(CreateSceneLoading());
|
emit(CreateSceneLoading());
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
|
|
||||||
// Check and update if the task exists in tempTasksList
|
// Check and update if the task exists in tempTasksList
|
||||||
for (var element in tempTasksList) {
|
for (var element in tempTasksList) {
|
||||||
var updatedElement = element.copyWith(
|
if (element.code == event.deviceControlModel.code) {
|
||||||
operationName: event.operation,
|
var updatedElement = element.copyWith(
|
||||||
deviceName: event.deviceName,
|
operationName: event.operation,
|
||||||
icon: event.icon,
|
deviceName: event.deviceName,
|
||||||
code: event.deviceControlModel.code ?? '',
|
icon: event.icon,
|
||||||
deviceId: event.deviceId,
|
code: event.deviceControlModel.code ?? '',
|
||||||
functionValue: event.deviceControlModel.value,
|
deviceId: event.deviceId,
|
||||||
operationDialogType: event.operationType,
|
functionValue: event.deviceControlModel.value,
|
||||||
operationalValues: [
|
operationDialogType: event.operationType,
|
||||||
SceneOperationalValue(
|
operationalValues: [
|
||||||
value: event.deviceControlModel.value,
|
SceneOperationalValue(
|
||||||
icon: '',
|
value: event.deviceControlModel.value,
|
||||||
),
|
icon: '',
|
||||||
],
|
),
|
||||||
);
|
],
|
||||||
tempTasksList[tempTasksList.indexOf(element)] = updatedElement;
|
);
|
||||||
selectedValues[updatedElement.code] = event.deviceControlModel.value;
|
tempTasksList[tempTasksList.indexOf(element)] = updatedElement;
|
||||||
updated = true;
|
selectedValues[updatedElement.code] = event.deviceControlModel.value;
|
||||||
break;
|
updated = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!updated) {
|
if (!updated) {
|
||||||
@ -172,8 +173,7 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
void addToTempAutomationTaskList(
|
void addToTempAutomationTaskList(TempHoldSceneTasksEvent event, Emitter<CreateSceneState> emit) {
|
||||||
TempHoldSceneTasksEvent event, Emitter<CreateSceneState> emit) {
|
|
||||||
emit(CreateSceneLoading());
|
emit(CreateSceneLoading());
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
for (var element in automationTempTasksList) {
|
for (var element in automationTempTasksList) {
|
||||||
@ -195,10 +195,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
],
|
],
|
||||||
comparator: automationComparatorValues[element.code],
|
comparator: automationComparatorValues[element.code],
|
||||||
);
|
);
|
||||||
automationTempTasksList[automationTempTasksList.indexOf(element)] =
|
automationTempTasksList[automationTempTasksList.indexOf(element)] = updatedElement;
|
||||||
updatedElement;
|
automationSelectedValues[updatedElement.code] = event.deviceControlModel.value;
|
||||||
automationSelectedValues[updatedElement.code] =
|
|
||||||
event.deviceControlModel.value;
|
|
||||||
updated = true;
|
updated = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -218,12 +216,10 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
icon: '',
|
icon: '',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
comparator:
|
comparator: automationComparatorValues[event.deviceControlModel.code] ?? '==',
|
||||||
automationComparatorValues[event.deviceControlModel.code] ?? '==',
|
|
||||||
);
|
);
|
||||||
automationTempTasksList.add(newElement);
|
automationTempTasksList.add(newElement);
|
||||||
automationSelectedValues[newElement.code] =
|
automationSelectedValues[newElement.code] = event.deviceControlModel.value;
|
||||||
event.deviceControlModel.value;
|
|
||||||
}
|
}
|
||||||
emit(AddSceneTask(
|
emit(AddSceneTask(
|
||||||
tasksList: tasksList,
|
tasksList: tasksList,
|
||||||
@ -232,8 +228,7 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
FutureOr<void> _selectedValue(
|
FutureOr<void> _selectedValue(SelectedValueEvent event, Emitter<CreateSceneState> emit) {
|
||||||
SelectedValueEvent event, Emitter<CreateSceneState> emit) {
|
|
||||||
if (event.isAutomation == true) {
|
if (event.isAutomation == true) {
|
||||||
automationSelectedValues[event.code] = event.value;
|
automationSelectedValues[event.code] = event.value;
|
||||||
automationComparatorValues[event.code] = event.comparator ?? '==';
|
automationComparatorValues[event.code] = event.comparator ?? '==';
|
||||||
@ -248,6 +243,15 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < tasksList.length; i++) {
|
||||||
|
if (tasksList[i].code == event.code) {
|
||||||
|
tasksList[i] = tasksList[i].copyWith(
|
||||||
|
comparator: event.comparator ?? '==',
|
||||||
|
functionValue: event.value,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
selectedValues[event.code] = event.value;
|
selectedValues[event.code] = event.value;
|
||||||
}
|
}
|
||||||
@ -261,8 +265,7 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
FutureOr<void> _removeTaskById(
|
FutureOr<void> _removeTaskById(RemoveTaskByIdEvent event, Emitter<CreateSceneState> emit) {
|
||||||
RemoveTaskByIdEvent event, Emitter<CreateSceneState> emit) {
|
|
||||||
emit(CreateSceneLoading());
|
emit(CreateSceneLoading());
|
||||||
if (event.isAutomation == true) {
|
if (event.isAutomation == true) {
|
||||||
for (var element in automationTasksList) {
|
for (var element in automationTasksList) {
|
||||||
@ -335,8 +338,7 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
: await SceneApi.createScene(event.createSceneModel!);
|
: await SceneApi.createScene(event.createSceneModel!);
|
||||||
} else if (event.createAutomationModel != null) {
|
} else if (event.createAutomationModel != null) {
|
||||||
response = event.updateScene
|
response = event.updateScene
|
||||||
? await SceneApi.updateAutomation(
|
? await SceneApi.updateAutomation(event.createAutomationModel!, event.sceneId)
|
||||||
event.createAutomationModel!, event.sceneId)
|
|
||||||
: await SceneApi.createAutomation(event.createAutomationModel!);
|
: await SceneApi.createAutomation(event.createAutomationModel!);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,11 +350,12 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
automationTempTasksList.clear();
|
automationTempTasksList.clear();
|
||||||
automationSelectedValues.clear();
|
automationSelectedValues.clear();
|
||||||
automationComparatorValues.clear();
|
automationComparatorValues.clear();
|
||||||
effectiveTime =
|
effectiveTime = EffectiveTime(start: '00:00', end: '23:59', loops: '1111111');
|
||||||
EffectiveTime(start: '00:00', end: '23:59', loops: '1111111');
|
|
||||||
sceneType = CreateSceneEnum.none;
|
sceneType = CreateSceneEnum.none;
|
||||||
conditionRule = 'or';
|
conditionRule = 'or';
|
||||||
emit(const CreateSceneWithTasks(success: true));
|
emit(const CreateSceneWithTasks(success: true));
|
||||||
|
CustomSnackBar.greenSnackBar(
|
||||||
|
event.updateScene ? 'Scene updated successfully' : 'Scene created successfully');
|
||||||
} else {
|
} else {
|
||||||
emit(const CreateSceneError(message: 'Something went wrong'));
|
emit(const CreateSceneError(message: 'Something went wrong'));
|
||||||
}
|
}
|
||||||
@ -366,8 +369,7 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FutureOr<void> _clearTaskList(
|
FutureOr<void> _clearTaskList(ClearTaskListEvent event, Emitter<CreateSceneState> emit) {
|
||||||
ClearTaskListEvent event, Emitter<CreateSceneState> emit) {
|
|
||||||
emit(CreateSceneLoading());
|
emit(CreateSceneLoading());
|
||||||
automationTasksList.clear();
|
automationTasksList.clear();
|
||||||
tasksList.clear();
|
tasksList.clear();
|
||||||
@ -383,19 +385,26 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
emit(CreateSceneLoading());
|
emit(CreateSceneLoading());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
tasksList.clear();
|
||||||
|
tempTasksList.clear();
|
||||||
|
selectedValues.clear();
|
||||||
|
automationTasksList.clear();
|
||||||
|
automationTempTasksList.clear();
|
||||||
|
automationSelectedValues.clear();
|
||||||
|
automationComparatorValues.clear();
|
||||||
|
effectiveTime = EffectiveTime(start: '00:00', end: '23:59', loops: '1111111');
|
||||||
|
sceneType = CreateSceneEnum.none;
|
||||||
|
conditionRule = 'or';
|
||||||
|
|
||||||
final response = event.isAutomation
|
final response = event.isAutomation
|
||||||
? await SceneApi.getAutomationDetails(event.sceneId)
|
? await SceneApi.getAutomationDetails(event.sceneId)
|
||||||
: await SceneApi.getSceneDetails(event.sceneId);
|
: await SceneApi.getSceneDetails(event.sceneId);
|
||||||
if (response.id.isNotEmpty) {
|
if (response.id.isNotEmpty) {
|
||||||
if (event.isAutomation) {
|
if (event.isAutomation) {
|
||||||
automationTasksList = List<SceneStaticFunction>.from(
|
automationTasksList = List<SceneStaticFunction>.from(getTaskListFunctionsFromApi(
|
||||||
getTaskListFunctionsFromApi(
|
actions: [], isAutomation: true, conditions: response.conditions));
|
||||||
actions: [],
|
|
||||||
isAutomation: true,
|
|
||||||
conditions: response.conditions));
|
|
||||||
tasksList = List<SceneStaticFunction>.from(
|
tasksList = List<SceneStaticFunction>.from(
|
||||||
getTaskListFunctionsFromApi(
|
getTaskListFunctionsFromApi(actions: response.actions, isAutomation: false));
|
||||||
actions: response.actions, isAutomation: false));
|
|
||||||
|
|
||||||
conditionRule = response.decisionExpr ?? conditionRule;
|
conditionRule = response.decisionExpr ?? conditionRule;
|
||||||
|
|
||||||
@ -407,25 +416,14 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
)
|
)
|
||||||
: EffectiveTime(start: '00:00', end: '23:59', loops: '1111111');
|
: EffectiveTime(start: '00:00', end: '23:59', loops: '1111111');
|
||||||
|
|
||||||
|
// Set the days directly from the API response
|
||||||
|
BlocProvider.of<EffectPeriodBloc>(NavigationService.navigatorKey.currentContext!)
|
||||||
|
.add(SetDays(response.effectiveTime?.loops ?? '1111111'));
|
||||||
|
|
||||||
// Set Custom Time and reset days first
|
// Set Custom Time and reset days first
|
||||||
BlocProvider.of<EffectPeriodBloc>(
|
BlocProvider.of<EffectPeriodBloc>(NavigationService.navigatorKey.currentContext!)
|
||||||
NavigationService.navigatorKey.currentContext!)
|
|
||||||
.add(SetCustomTime(effectiveTime!.start, effectiveTime!.end));
|
.add(SetCustomTime(effectiveTime!.start, effectiveTime!.end));
|
||||||
|
|
||||||
// Reset all days to not selected before toggling
|
|
||||||
BlocProvider.of<EffectPeriodBloc>(
|
|
||||||
NavigationService.navigatorKey.currentContext!)
|
|
||||||
.add(ResetDays());
|
|
||||||
|
|
||||||
// Iterate over the loops and toggle each day
|
|
||||||
for (int i = 0; i < effectiveTime!.loops.length; i++) {
|
|
||||||
if (effectiveTime!.loops[i] == '1') {
|
|
||||||
BlocProvider.of<EffectPeriodBloc>(
|
|
||||||
NavigationService.navigatorKey.currentContext!)
|
|
||||||
.add(ToggleDay(_getDayFromIndex(i)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
emit(AddSceneTask(
|
emit(AddSceneTask(
|
||||||
automationTasksList: automationTasksList,
|
automationTasksList: automationTasksList,
|
||||||
tasksList: tasksList,
|
tasksList: tasksList,
|
||||||
@ -433,8 +431,7 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
tasksList = List<SceneStaticFunction>.from(
|
tasksList = List<SceneStaticFunction>.from(
|
||||||
getTaskListFunctionsFromApi(
|
getTaskListFunctionsFromApi(actions: response.actions, isAutomation: false));
|
||||||
actions: response.actions, isAutomation: false));
|
|
||||||
emit(AddSceneTask(
|
emit(AddSceneTask(
|
||||||
tasksList: tasksList,
|
tasksList: tasksList,
|
||||||
condition: conditionRule,
|
condition: conditionRule,
|
||||||
@ -453,8 +450,7 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
return days[index];
|
return days[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
FutureOr<void> _clearTempTaskList(
|
FutureOr<void> _clearTempTaskList(ClearTempTaskListEvent event, Emitter<CreateSceneState> emit) {
|
||||||
ClearTempTaskListEvent event, Emitter<CreateSceneState> emit) {
|
|
||||||
emit(CreateSceneLoading());
|
emit(CreateSceneLoading());
|
||||||
if (event.isAutomation == true) {
|
if (event.isAutomation == true) {
|
||||||
automationTempTasksList.clear();
|
automationTempTasksList.clear();
|
||||||
@ -498,17 +494,13 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FutureOr<void> _deleteScene(
|
FutureOr<void> _deleteScene(DeleteSceneEvent event, Emitter<CreateSceneState> emit) async {
|
||||||
DeleteSceneEvent event, Emitter<CreateSceneState> emit) async {
|
|
||||||
emit(DeleteSceneLoading());
|
emit(DeleteSceneLoading());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final response =
|
final response = sceneType.name == CreateSceneEnum.deviceStatusChanges.name
|
||||||
sceneType.name == CreateSceneEnum.deviceStatusChanges.name
|
? await SceneApi.deleteAutomation(automationId: event.sceneId, unitUuid: event.unitUuid)
|
||||||
? await SceneApi.deleteAutomation(
|
: await SceneApi.deleteScene(sceneId: event.sceneId, unitUuid: event.unitUuid);
|
||||||
automationId: event.sceneId, unitUuid: event.unitUuid)
|
|
||||||
: await SceneApi.deleteScene(
|
|
||||||
sceneId: event.sceneId, unitUuid: event.unitUuid);
|
|
||||||
if (response == true) {
|
if (response == true) {
|
||||||
emit(const DeleteSceneSuccess(true));
|
emit(const DeleteSceneSuccess(true));
|
||||||
} else {
|
} else {
|
||||||
@ -519,8 +511,7 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FutureOr<void> _updateTaskValue(
|
FutureOr<void> _updateTaskValue(UpdateTaskEvent event, Emitter<CreateSceneState> emit) {
|
||||||
UpdateTaskEvent event, Emitter<CreateSceneState> emit) {
|
|
||||||
emit(CreateSceneLoading());
|
emit(CreateSceneLoading());
|
||||||
if (event.isAutomation == true) {
|
if (event.isAutomation == true) {
|
||||||
for (var i = 0; i < automationTasksList.length; i++) {
|
for (var i = 0; i < automationTasksList.length; i++) {
|
||||||
@ -531,6 +522,14 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (var i = 0; i < tasksList.length; i++) {
|
||||||
|
if (tasksList[i].uniqueCustomId == event.taskId) {
|
||||||
|
tasksList[i] = tasksList[i].copyWith(
|
||||||
|
functionValue: event.newValue,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for (var i = 0; i < tasksList.length; i++) {
|
for (var i = 0; i < tasksList.length; i++) {
|
||||||
if (tasksList[i].uniqueCustomId == event.taskId) {
|
if (tasksList[i].uniqueCustomId == event.taskId) {
|
||||||
@ -548,8 +547,7 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
FutureOr<void> _selectConditionRule(
|
FutureOr<void> _selectConditionRule(SelectConditionEvent event, Emitter<CreateSceneState> emit) {
|
||||||
SelectConditionEvent event, Emitter<CreateSceneState> emit) {
|
|
||||||
emit(CreateSceneInitial());
|
emit(CreateSceneInitial());
|
||||||
if (event.condition.contains('any')) {
|
if (event.condition.contains('any')) {
|
||||||
conditionRule = 'or';
|
conditionRule = 'or';
|
||||||
@ -564,9 +562,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
FutureOr<void> _sceneTypeEvent(
|
FutureOr<void> _sceneTypeEvent(SceneTypeEvent event, Emitter<CreateSceneState> emit) {
|
||||||
SceneTypeEvent event, Emitter<CreateSceneState> emit) {
|
// emit(CreateSceneInitial());
|
||||||
emit(CreateSceneInitial());
|
|
||||||
|
|
||||||
if (event.type == CreateSceneEnum.tabToRun) {
|
if (event.type == CreateSceneEnum.tabToRun) {
|
||||||
sceneType = CreateSceneEnum.tabToRun;
|
sceneType = CreateSceneEnum.tabToRun;
|
||||||
@ -576,7 +573,7 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
sceneType = CreateSceneEnum.none;
|
sceneType = CreateSceneEnum.none;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit(SceneTypeState(event.type));
|
// emit(SceneTypeState(event.type));
|
||||||
}
|
}
|
||||||
|
|
||||||
FutureOr<void> _onEffectiveTimeEvent(
|
FutureOr<void> _onEffectiveTimeEvent(
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
||||||
@ -14,6 +16,7 @@ class EffectPeriodBloc extends Bloc<EffectPeriodEvent, EffectPeriodState> {
|
|||||||
on<SetCustomTime>(_onSetCustomTime);
|
on<SetCustomTime>(_onSetCustomTime);
|
||||||
on<ResetEffectivePeriod>(_onResetEffectivePeriod);
|
on<ResetEffectivePeriod>(_onResetEffectivePeriod);
|
||||||
on<ResetDays>(_onResetDays);
|
on<ResetDays>(_onResetDays);
|
||||||
|
on<SetDays>(_setAllDays);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onSetPeriod(SetPeriod event, Emitter<EffectPeriodState> emit) {
|
void _onSetPeriod(SetPeriod event, Emitter<EffectPeriodState> emit) {
|
||||||
@ -120,4 +123,8 @@ class EffectPeriodBloc extends Bloc<EffectPeriodEvent, EffectPeriodState> {
|
|||||||
const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
||||||
return days.indexOf(day);
|
return days.indexOf(day);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FutureOr<void> _setAllDays(SetDays event, Emitter<EffectPeriodState> emit) {
|
||||||
|
emit(state.copyWith(selectedDaysBinary: event.daysBinary));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,3 +42,9 @@ class ResetDays extends EffectPeriodEvent {
|
|||||||
@override
|
@override
|
||||||
List<Object> get props => [];
|
List<Object> get props => [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SetDays extends EffectPeriodEvent {
|
||||||
|
final String daysBinary;
|
||||||
|
|
||||||
|
const SetDays(this.daysBinary);
|
||||||
|
}
|
||||||
|
|||||||
@ -16,10 +16,8 @@ class DoorLockHelperFunctions {
|
|||||||
code: 'normal_open_switch',
|
code: 'normal_open_switch',
|
||||||
operationDialogType: OperationDialogType.onOff,
|
operationDialogType: OperationDialogType.onOff,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||||
icon: Assets.assetsAcPower, description: "ON", value: true),
|
SceneOperationalValue(icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
||||||
SceneOperationalValue(
|
|
||||||
icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
@ -98,7 +96,7 @@ class DoorLockHelperFunctions {
|
|||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
icon: Assets.assetsFingerprintUnlock,
|
icon: Assets.assetsFingerprintUnlock,
|
||||||
description: "Fingerprint Mismatch",
|
description: "Fingerprint Mismatch",
|
||||||
value: 0,
|
value: 'wrong_finger',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -15,9 +15,13 @@ import 'package:syncrow_app/utils/context_extension.dart';
|
|||||||
|
|
||||||
mixin SceneLogicHelper {
|
mixin SceneLogicHelper {
|
||||||
bool isOnlyDelayOrDelayLast(List<SceneStaticFunction> tasks) {
|
bool isOnlyDelayOrDelayLast(List<SceneStaticFunction> tasks) {
|
||||||
final lastTask = tasks.last;
|
final lastTask = tasks.isNotEmpty ? tasks.last : null;
|
||||||
return tasks.every((task) => task.code == 'delay') ||
|
|
||||||
lastTask.code == 'delay';
|
return tasks.isNotEmpty
|
||||||
|
? tasks.every((task) => task.code == 'delay') ||
|
||||||
|
lastTask!.code == 'delay' ||
|
||||||
|
lastTask.deviceId == 'delay'
|
||||||
|
: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleSaveButtonPress(
|
void handleSaveButtonPress(
|
||||||
@ -155,24 +159,21 @@ mixin SceneLogicHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getTheCorrectDialogBody(
|
Widget getTheCorrectDialogBody(SceneStaticFunction taskItem, dynamic functionValue,
|
||||||
SceneStaticFunction taskItem, dynamic functionValue,
|
|
||||||
{required bool isAutomation}) {
|
{required bool isAutomation}) {
|
||||||
if (taskItem.operationDialogType == OperationDialogType.temperature) {
|
if (taskItem.operationDialogType == OperationDialogType.temperature) {
|
||||||
return AlertDialogTemperatureBody(
|
return AlertDialogTemperatureBody(
|
||||||
taskItem: taskItem,
|
taskItem: taskItem,
|
||||||
functionValue: functionValue ?? taskItem.functionValue,
|
functionValue: functionValue ?? taskItem.functionValue,
|
||||||
);
|
);
|
||||||
} else if ((taskItem.operationDialogType ==
|
} else if ((taskItem.operationDialogType == OperationDialogType.countdown) ||
|
||||||
OperationDialogType.countdown) ||
|
|
||||||
(taskItem.operationDialogType == OperationDialogType.delay)) {
|
(taskItem.operationDialogType == OperationDialogType.delay)) {
|
||||||
return AlertDialogCountdown(
|
return AlertDialogCountdown(
|
||||||
durationValue: taskItem.functionValue ?? 0,
|
durationValue: taskItem.functionValue ?? 0,
|
||||||
functionValue: functionValue ?? taskItem.functionValue,
|
functionValue: functionValue ?? taskItem.functionValue,
|
||||||
function: taskItem,
|
function: taskItem,
|
||||||
);
|
);
|
||||||
} else if (taskItem.operationDialogType ==
|
} else if (taskItem.operationDialogType == OperationDialogType.integerSteps) {
|
||||||
OperationDialogType.integerSteps) {
|
|
||||||
return AlertDialogSliderSteps(
|
return AlertDialogSliderSteps(
|
||||||
taskItem: taskItem,
|
taskItem: taskItem,
|
||||||
functionValue: functionValue ?? taskItem.functionValue,
|
functionValue: functionValue ?? taskItem.functionValue,
|
||||||
|
|||||||
@ -14,9 +14,8 @@ import 'package:syncrow_app/generated/assets.dart';
|
|||||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
|
|
||||||
mixin SceneOperationsDataHelper {
|
mixin SceneOperationsDataHelper {
|
||||||
final Map<DeviceType,
|
final Map<DeviceType, Function(List<FunctionModel>, String, String, dynamic, bool)> _functionMap =
|
||||||
Function(List<FunctionModel>, String, String, dynamic, bool)>
|
{
|
||||||
_functionMap = {
|
|
||||||
DeviceType.LightBulb: lightBulbFunctions,
|
DeviceType.LightBulb: lightBulbFunctions,
|
||||||
DeviceType.CeilingSensor: ceilingSensorFunctions,
|
DeviceType.CeilingSensor: ceilingSensorFunctions,
|
||||||
DeviceType.WallSensor: wallSensorFunctions,
|
DeviceType.WallSensor: wallSensorFunctions,
|
||||||
@ -46,22 +45,16 @@ mixin SceneOperationsDataHelper {
|
|||||||
required bool isAutomation,
|
required bool isAutomation,
|
||||||
}) {
|
}) {
|
||||||
final functionValue = null;
|
final functionValue = null;
|
||||||
return _functionMap[type]?.call(
|
return _functionMap[type]?.call(functions, deviceId, deviceName, functionValue, isAutomation) ??
|
||||||
functions, deviceId, deviceName, functionValue, isAutomation) ??
|
lightBulbFunctions(functions, deviceId, deviceName, functionValue, isAutomation);
|
||||||
lightBulbFunctions(
|
|
||||||
functions, deviceId, deviceName, functionValue, isAutomation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String getTitle({DeviceType? type}) {
|
String getTitle({DeviceType? type}) {
|
||||||
return _titleMap[type] ?? '';
|
return _titleMap[type] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> ceilingSensorFunctions(
|
static List<SceneStaticFunction> ceilingSensorFunctions(List<FunctionModel> functions,
|
||||||
List<FunctionModel> functions,
|
String deviceId, String deviceName, dynamic functionValue, bool isAutomation) {
|
||||||
String deviceId,
|
|
||||||
String deviceName,
|
|
||||||
dynamic functionValue,
|
|
||||||
bool isAutomation) {
|
|
||||||
if (isAutomation) {
|
if (isAutomation) {
|
||||||
return PresenceSensorHelperFunctions.automationPresenceSensorFunctions(
|
return PresenceSensorHelperFunctions.automationPresenceSensorFunctions(
|
||||||
deviceId, deviceName, functionValue);
|
deviceId, deviceName, functionValue);
|
||||||
@ -70,35 +63,22 @@ mixin SceneOperationsDataHelper {
|
|||||||
deviceId, deviceName, functionValue);
|
deviceId, deviceName, functionValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> curtainFunctions(
|
static List<SceneStaticFunction> curtainFunctions(List<FunctionModel> functions, String deviceId,
|
||||||
List<FunctionModel> functions,
|
String deviceName, dynamic functionValue, bool isAutomation) {
|
||||||
String deviceId,
|
|
||||||
String deviceName,
|
|
||||||
dynamic functionValue,
|
|
||||||
bool isAutomation) {
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> doorLockFunctions(
|
static List<SceneStaticFunction> doorLockFunctions(List<FunctionModel> functions, String deviceId,
|
||||||
List<FunctionModel> functions,
|
String deviceName, dynamic functionValue, bool isAutomation) {
|
||||||
String deviceId,
|
|
||||||
String deviceName,
|
|
||||||
dynamic functionValue,
|
|
||||||
bool isAutomation) {
|
|
||||||
if (isAutomation) {
|
if (isAutomation) {
|
||||||
return DoorLockHelperFunctions.doorLockAutomationFunctions(
|
return DoorLockHelperFunctions.doorLockAutomationFunctions(
|
||||||
deviceId, deviceName, functionValue);
|
deviceId, deviceName, functionValue);
|
||||||
}
|
}
|
||||||
return DoorLockHelperFunctions.doorLockTapToRunFunctions(
|
return DoorLockHelperFunctions.doorLockTapToRunFunctions(deviceId, deviceName, functionValue);
|
||||||
deviceId, deviceName, functionValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> wallSensorFunctions(
|
static List<SceneStaticFunction> wallSensorFunctions(List<FunctionModel> functions,
|
||||||
List<FunctionModel> functions,
|
String deviceId, String deviceName, dynamic functionValue, bool isAutomation) {
|
||||||
String deviceId,
|
|
||||||
String deviceName,
|
|
||||||
dynamic functionValue,
|
|
||||||
bool isAutomation) {
|
|
||||||
if (isAutomation) {
|
if (isAutomation) {
|
||||||
return HumanPresenceHelperFunctions.automationHumanPresenceFunctions(
|
return HumanPresenceHelperFunctions.automationHumanPresenceFunctions(
|
||||||
deviceId, deviceName, functionValue);
|
deviceId, deviceName, functionValue);
|
||||||
@ -107,51 +87,31 @@ mixin SceneOperationsDataHelper {
|
|||||||
deviceId, deviceName, functionValue);
|
deviceId, deviceName, functionValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> lightBulbFunctions(
|
static List<SceneStaticFunction> lightBulbFunctions(List<FunctionModel> functions,
|
||||||
List<FunctionModel> functions,
|
String deviceId, String deviceName, dynamic functionValue, bool isAutomation) {
|
||||||
String deviceId,
|
|
||||||
String deviceName,
|
|
||||||
dynamic functionValue,
|
|
||||||
bool isAutomation) {
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> gatewayFunctions(
|
static List<SceneStaticFunction> gatewayFunctions(List<FunctionModel> functions, String deviceId,
|
||||||
List<FunctionModel> functions,
|
String deviceName, dynamic functionValue, bool isAutomation) {
|
||||||
String deviceId,
|
return GatewayHelperFunctions.tabToRunGatewayFunctions(deviceId, deviceName, functionValue);
|
||||||
String deviceName,
|
|
||||||
dynamic functionValue,
|
|
||||||
bool isAutomation) {
|
|
||||||
return GatewayHelperFunctions.tabToRunGatewayFunctions(
|
|
||||||
deviceId, deviceName, functionValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> threeGangFunctions(
|
static List<SceneStaticFunction> threeGangFunctions(List<FunctionModel> functions,
|
||||||
List<FunctionModel> functions,
|
String deviceId, String deviceName, dynamic functionValue, bool isAutomation) {
|
||||||
String deviceId,
|
|
||||||
String deviceName,
|
|
||||||
dynamic functionValue,
|
|
||||||
bool isAutomation) {
|
|
||||||
if (isAutomation) {
|
if (isAutomation) {
|
||||||
return ThreeGangHelperFunctions.threeGangAutomationFunctions(
|
return ThreeGangHelperFunctions.threeGangAutomationFunctions(
|
||||||
deviceId, deviceName, functionValue);
|
deviceId, deviceName, functionValue);
|
||||||
}
|
}
|
||||||
return ThreeGangHelperFunctions.threeGangHelperFunctions(
|
return ThreeGangHelperFunctions.threeGangHelperFunctions(deviceId, deviceName, functionValue);
|
||||||
deviceId, deviceName, functionValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> acFunctions(
|
static List<SceneStaticFunction> acFunctions(List<FunctionModel> functions, String deviceId,
|
||||||
List<FunctionModel> functions,
|
String deviceName, dynamic functionValue, bool isAutomation) {
|
||||||
String deviceId,
|
|
||||||
String deviceName,
|
|
||||||
dynamic functionValue,
|
|
||||||
bool isAutomation) {
|
|
||||||
if (isAutomation) {
|
if (isAutomation) {
|
||||||
return ACFunctionsHelper.automationAcFunctions(
|
return ACFunctionsHelper.automationAcFunctions(deviceId, deviceName, functionValue);
|
||||||
deviceId, deviceName, functionValue);
|
|
||||||
}
|
}
|
||||||
return ACFunctionsHelper.tabToRunAcFunctions(
|
return ACFunctionsHelper.tabToRunAcFunctions(deviceId, deviceName, functionValue);
|
||||||
deviceId, deviceName, functionValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SceneStaticFunction> getTaskListFunctionsFromApi({
|
List<SceneStaticFunction> getTaskListFunctionsFromApi({
|
||||||
@ -189,12 +149,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
SceneStaticFunction(
|
SceneStaticFunction(
|
||||||
deviceId: action.entityId,
|
deviceId: action.entityId,
|
||||||
deviceName: action.name.toString(),
|
deviceName: action.name.toString(),
|
||||||
deviceIcon: action.type == 'automation'
|
deviceIcon: action.type == 'automation' ? Assets.player : Assets.handClickIcon,
|
||||||
? Assets.player
|
icon: action.type == 'automation' ? Assets.player : Assets.handClickIcon,
|
||||||
: Assets.handClickIcon,
|
|
||||||
icon: action.type == 'automation'
|
|
||||||
? Assets.player
|
|
||||||
: Assets.handClickIcon,
|
|
||||||
operationName: action.type.toString(),
|
operationName: action.type.toString(),
|
||||||
operationDialogType: OperationDialogType.onOff,
|
operationDialogType: OperationDialogType.onOff,
|
||||||
functionValue: action.actionExecutor,
|
functionValue: action.actionExecutor,
|
||||||
@ -214,8 +170,7 @@ mixin SceneOperationsDataHelper {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
functions
|
functions.add(_mapExecutorPropertyToSceneFunction(action, isAutomation));
|
||||||
.add(_mapExecutorPropertyToSceneFunction(action, isAutomation));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,11 +202,11 @@ mixin SceneOperationsDataHelper {
|
|||||||
Action action,
|
Action action,
|
||||||
bool isAutomation, {
|
bool isAutomation, {
|
||||||
String? comparator,
|
String? comparator,
|
||||||
|
String? uniqueCustomId,
|
||||||
}) {
|
}) {
|
||||||
final executorProperty = action.executorProperty;
|
final executorProperty = action.executorProperty;
|
||||||
|
|
||||||
final Map<String, SceneStaticFunction Function(Action, bool, String?)>
|
final Map<String, SceneStaticFunction Function(Action, bool, String?, String?)> functionMap = {
|
||||||
functionMap = {
|
|
||||||
'sensitivity': _createSensitivityFunction,
|
'sensitivity': _createSensitivityFunction,
|
||||||
'normal_open_switch': _createNormalOpenSwitchFunction,
|
'normal_open_switch': _createNormalOpenSwitchFunction,
|
||||||
'unlock_fingerprint': _createUnlockFingerprintFunction,
|
'unlock_fingerprint': _createUnlockFingerprintFunction,
|
||||||
@ -294,7 +249,7 @@ mixin SceneOperationsDataHelper {
|
|||||||
final functionCode = executorProperty?.functionCode ?? '';
|
final functionCode = executorProperty?.functionCode ?? '';
|
||||||
final createFunction = functionMap[functionCode];
|
final createFunction = functionMap[functionCode];
|
||||||
if (createFunction != null) {
|
if (createFunction != null) {
|
||||||
return createFunction(action, isAutomation, comparator);
|
return createFunction(action, isAutomation, comparator, uniqueCustomId);
|
||||||
} else {
|
} else {
|
||||||
throw ArgumentError('Unsupported function code: $functionCode');
|
throw ArgumentError('Unsupported function code: $functionCode');
|
||||||
}
|
}
|
||||||
@ -309,9 +264,11 @@ mixin SceneOperationsDataHelper {
|
|||||||
List<SceneOperationalValue> operationalValues,
|
List<SceneOperationalValue> operationalValues,
|
||||||
bool isAutomation, [
|
bool isAutomation, [
|
||||||
String? comparator,
|
String? comparator,
|
||||||
|
String? uniqueCustomId,
|
||||||
]) {
|
]) {
|
||||||
final functionValue = action.executorProperty?.functionValue;
|
final functionValue = action.executorProperty?.functionValue;
|
||||||
return SceneStaticFunction(
|
return SceneStaticFunction(
|
||||||
|
uniqueCustomId: uniqueCustomId,
|
||||||
deviceId: action.entityId,
|
deviceId: action.entityId,
|
||||||
deviceName: deviceName,
|
deviceName: deviceName,
|
||||||
deviceIcon: icon,
|
deviceIcon: icon,
|
||||||
@ -326,23 +283,22 @@ mixin SceneOperationsDataHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createSensitivityFunction(
|
SceneStaticFunction _createSensitivityFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Presence Sensor',
|
'Presence Sensor',
|
||||||
Assets.assetsIconsSensors,
|
Assets.assetsIconsSensors,
|
||||||
'Sensitivity',
|
'Sensitivity',
|
||||||
isAutomation
|
isAutomation ? OperationDialogType.integerSteps : OperationDialogType.listOfOptions,
|
||||||
? OperationDialogType.integerSteps
|
|
||||||
: OperationDialogType.listOfOptions,
|
|
||||||
isAutomation ? _createIntegerStepsOptions() : _createSensitivityOptions(),
|
isAutomation ? _createIntegerStepsOptions() : _createSensitivityOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createNormalOpenSwitchFunction(
|
SceneStaticFunction _createNormalOpenSwitchFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -352,6 +308,7 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createOnOffOptions(),
|
_createOnOffOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,7 +352,7 @@ mixin SceneOperationsDataHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createUnlockFingerprintFunction(
|
SceneStaticFunction _createUnlockFingerprintFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -405,11 +362,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createFingerprintUnlockOptions(),
|
_createFingerprintUnlockOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createUnlockPasswordFunction(
|
SceneStaticFunction _createUnlockPasswordFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -419,11 +377,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createPasswordUnlockOptions(),
|
_createPasswordUnlockOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createUnlockCardFunction(
|
SceneStaticFunction _createUnlockCardFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -433,11 +392,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createCardUnlockOptions(),
|
_createCardUnlockOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createAlarmLockFunction(
|
SceneStaticFunction _createAlarmLockFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -447,11 +407,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createLockAlarmOptions(),
|
_createLockAlarmOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createUnlockRequestFunction(
|
SceneStaticFunction _createUnlockRequestFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -461,11 +422,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createUnlockRequestOptions(),
|
_createUnlockRequestOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createResidualElectricityFunction(
|
SceneStaticFunction _createResidualElectricityFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -475,11 +437,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createResidualElectricityOptions(),
|
_createResidualElectricityOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createReverseLockFunction(
|
SceneStaticFunction _createReverseLockFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -489,11 +452,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createOnOffOptions(),
|
_createOnOffOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createUnlockAppFunction(
|
SceneStaticFunction _createUnlockAppFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -503,11 +467,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createUnlockAppOptions(),
|
_createUnlockAppOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createHijackFunction(
|
SceneStaticFunction _createHijackFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -517,11 +482,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createOnOffOptions(),
|
_createOnOffOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createDoorbellFunction(
|
SceneStaticFunction _createDoorbellFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -531,11 +497,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createOnOffOptions(),
|
_createOnOffOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createUnlockTemporaryFunction(
|
SceneStaticFunction _createUnlockTemporaryFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -545,11 +512,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createTemporaryPasswordUnlockOptions(),
|
_createTemporaryPasswordUnlockOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createFarDetectionFunction(
|
SceneStaticFunction _createFarDetectionFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -559,11 +527,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createFarDetectionOptions(),
|
_createFarDetectionOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createMotionSensitivityFunction(
|
SceneStaticFunction _createMotionSensitivityFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -573,11 +542,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createSensitivityOptions(),
|
_createSensitivityOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createMotionlessSensitivityFunction(
|
SceneStaticFunction _createMotionlessSensitivityFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -587,11 +557,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createSensitivityOptions(),
|
_createSensitivityOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createIndicatorFunction(
|
SceneStaticFunction _createIndicatorFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -601,11 +572,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createOnOffOptions(),
|
_createOnOffOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createPresenceTimeFunction(
|
SceneStaticFunction _createPresenceTimeFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -615,11 +587,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createCountdownOptions(),
|
_createCountdownOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createPresenceStateFunction(
|
SceneStaticFunction _createPresenceStateFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -629,27 +602,27 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createPresenceStateOptions(),
|
_createPresenceStateOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createDisCurrentFunction(
|
SceneStaticFunction _createDisCurrentFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
Assets.assetsIconsSensors,
|
Assets.assetsIconsSensors,
|
||||||
'Current Distance',
|
'Current Distance',
|
||||||
isAutomation
|
isAutomation ? OperationDialogType.integerSteps : OperationDialogType.countdown,
|
||||||
? OperationDialogType.integerSteps
|
|
||||||
: OperationDialogType.countdown,
|
|
||||||
_createCurrentDistanceOptions(),
|
_createCurrentDistanceOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createIlluminanceValueFunction(
|
SceneStaticFunction _createIlluminanceValueFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -659,11 +632,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createIlluminanceValueOptions(),
|
_createIlluminanceValueOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createCheckingResultFunction(
|
SceneStaticFunction _createCheckingResultFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -673,11 +647,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createSelfTestResultOptions(),
|
_createSelfTestResultOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createSwitchFunction(
|
SceneStaticFunction _createSwitchFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Smart AC Thermostat - Grey - Model A',
|
'Smart AC Thermostat - Grey - Model A',
|
||||||
@ -687,29 +662,27 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createOnOffOptions(),
|
_createOnOffOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createTempSetFunction(
|
SceneStaticFunction _createTempSetFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Smart AC Thermostat - Grey - Model A',
|
'Smart AC Thermostat - Grey - Model A',
|
||||||
Assets.assetsIconsAC,
|
Assets.assetsIconsAC,
|
||||||
'Set Temperature',
|
'Set Temperature',
|
||||||
isAutomation
|
isAutomation ? OperationDialogType.integerSteps : OperationDialogType.temperature,
|
||||||
? OperationDialogType.integerSteps
|
isAutomation ? _createAutomationTemperatureOptions() : _createTemperatureOptions(),
|
||||||
: OperationDialogType.temperature,
|
|
||||||
isAutomation
|
|
||||||
? _createAutomationTemperatureOptions()
|
|
||||||
: _createTemperatureOptions(),
|
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createTempCurrentFunction(
|
SceneStaticFunction _createTempCurrentFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Smart AC Thermostat - Grey - Model A',
|
'Smart AC Thermostat - Grey - Model A',
|
||||||
@ -719,11 +692,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createCurrentTemperatureOptions(),
|
_createCurrentTemperatureOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createModeFunction(
|
SceneStaticFunction _createModeFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Smart AC Thermostat - Grey - Model A',
|
'Smart AC Thermostat - Grey - Model A',
|
||||||
@ -733,11 +707,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createAcModeOptions(),
|
_createAcModeOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createLevelFunction(
|
SceneStaticFunction _createLevelFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Smart AC Thermostat - Grey - Model A',
|
'Smart AC Thermostat - Grey - Model A',
|
||||||
@ -747,11 +722,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createFanSpeedOptions(),
|
_createFanSpeedOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createChildLockFunction(
|
SceneStaticFunction _createChildLockFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Smart AC Thermostat - Grey - Model A',
|
'Smart AC Thermostat - Grey - Model A',
|
||||||
@ -761,11 +737,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createOnOffOptions(),
|
_createOnOffOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createSwitch1Function(
|
SceneStaticFunction _createSwitch1Function(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'3 Gang Button Switch L-L',
|
'3 Gang Button Switch L-L',
|
||||||
@ -775,11 +752,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createOnOffOptions(),
|
_createOnOffOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createSwitch2Function(
|
SceneStaticFunction _createSwitch2Function(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'3 Gang Button Switch L-L',
|
'3 Gang Button Switch L-L',
|
||||||
@ -789,11 +767,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createOnOffOptions(),
|
_createOnOffOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createSwitch3Function(
|
SceneStaticFunction _createSwitch3Function(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'3 Gang Button Switch L-L',
|
'3 Gang Button Switch L-L',
|
||||||
@ -803,65 +782,57 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createOnOffOptions(),
|
_createOnOffOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createCountdown1Function(
|
SceneStaticFunction _createCountdown1Function(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'3 Gang Button Switch L-L',
|
'3 Gang Button Switch L-L',
|
||||||
Assets.assetsIcons3GangSwitch,
|
Assets.assetsIcons3GangSwitch,
|
||||||
'Light 1 CountDown',
|
'Light 1 CountDown',
|
||||||
isAutomation
|
isAutomation ? OperationDialogType.integerSteps : OperationDialogType.countdown,
|
||||||
? OperationDialogType.integerSteps
|
isAutomation ? _createAutomationCountDownOptions() : _createCountdownOptions(),
|
||||||
: OperationDialogType.countdown,
|
|
||||||
isAutomation
|
|
||||||
? _createAutomationCountDownOptions()
|
|
||||||
: _createCountdownOptions(),
|
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createCountdown2Function(
|
SceneStaticFunction _createCountdown2Function(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'3 Gang Button Switch L-L',
|
'3 Gang Button Switch L-L',
|
||||||
Assets.assetsIcons3GangSwitch,
|
Assets.assetsIcons3GangSwitch,
|
||||||
'Light 2 CountDown',
|
'Light 2 CountDown',
|
||||||
isAutomation
|
isAutomation ? OperationDialogType.integerSteps : OperationDialogType.countdown,
|
||||||
? OperationDialogType.integerSteps
|
isAutomation ? _createAutomationCountDownOptions() : _createCountdownOptions(),
|
||||||
: OperationDialogType.countdown,
|
|
||||||
isAutomation
|
|
||||||
? _createAutomationCountDownOptions()
|
|
||||||
: _createCountdownOptions(),
|
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createCountdown3Function(
|
SceneStaticFunction _createCountdown3Function(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'3 Gang Button Switch L-L',
|
'3 Gang Button Switch L-L',
|
||||||
Assets.assetsIcons3GangSwitch,
|
Assets.assetsIcons3GangSwitch,
|
||||||
'Light 3 CountDown',
|
'Light 3 CountDown',
|
||||||
isAutomation
|
isAutomation ? OperationDialogType.integerSteps : OperationDialogType.countdown,
|
||||||
? OperationDialogType.integerSteps
|
isAutomation ? _createAutomationCountDownOptions() : _createCountdownOptions(),
|
||||||
: OperationDialogType.countdown,
|
|
||||||
isAutomation
|
|
||||||
? _createAutomationCountDownOptions()
|
|
||||||
: _createCountdownOptions(),
|
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createSwitchAlarmSoundFunction(
|
SceneStaticFunction _createSwitchAlarmSoundFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Gateway',
|
'Gateway',
|
||||||
@ -871,11 +842,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createOnOffOptions(),
|
_createOnOffOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createMasterStateFunction(
|
SceneStaticFunction _createMasterStateFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Gateway',
|
'Gateway',
|
||||||
@ -885,11 +857,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createMasterStateOptions(),
|
_createMasterStateOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createFactoryResetFunction(
|
SceneStaticFunction _createFactoryResetFunction(
|
||||||
Action action, bool isAutomation, String? comparator) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Gateway',
|
'Gateway',
|
||||||
@ -899,6 +872,7 @@ mixin SceneOperationsDataHelper {
|
|||||||
_createOnOffOptions(),
|
_createOnOffOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -946,7 +920,7 @@ mixin SceneOperationsDataHelper {
|
|||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
icon: Assets.assetsFingerprintUnlock,
|
icon: Assets.assetsFingerprintUnlock,
|
||||||
description: "Fingerprint Mismatch",
|
description: "Fingerprint Mismatch",
|
||||||
value: 0,
|
value: 'wrong_finger',
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -1181,6 +1155,7 @@ mixin SceneOperationsDataHelper {
|
|||||||
if (deviceId.contains('delay')) {
|
if (deviceId.contains('delay')) {
|
||||||
return [
|
return [
|
||||||
SceneStaticFunction(
|
SceneStaticFunction(
|
||||||
|
uniqueCustomId: taskItem.uniqueCustomId,
|
||||||
deviceId: taskItem.deviceId,
|
deviceId: taskItem.deviceId,
|
||||||
deviceName: 'delay',
|
deviceName: 'delay',
|
||||||
deviceIcon: Assets.delay,
|
deviceIcon: Assets.delay,
|
||||||
@ -1202,14 +1177,11 @@ mixin SceneOperationsDataHelper {
|
|||||||
if (taskItem.code == CreateSceneEnum.smartSceneSelect.name) {
|
if (taskItem.code == CreateSceneEnum.smartSceneSelect.name) {
|
||||||
return [
|
return [
|
||||||
SceneStaticFunction(
|
SceneStaticFunction(
|
||||||
|
uniqueCustomId: taskItem.uniqueCustomId,
|
||||||
deviceId: taskItem.deviceId,
|
deviceId: taskItem.deviceId,
|
||||||
deviceName: taskItem.deviceName.toString(),
|
deviceName: taskItem.deviceName.toString(),
|
||||||
deviceIcon: taskItem.operationName == 'automation'
|
deviceIcon: taskItem.operationName == 'automation' ? Assets.player : Assets.handClickIcon,
|
||||||
? Assets.player
|
icon: taskItem.operationName == 'automation' ? Assets.player : Assets.handClickIcon,
|
||||||
: Assets.handClickIcon,
|
|
||||||
icon: taskItem.operationName == 'automation'
|
|
||||||
? Assets.player
|
|
||||||
: Assets.handClickIcon,
|
|
||||||
operationName: taskItem.operationName,
|
operationName: taskItem.operationName,
|
||||||
operationDialogType: OperationDialogType.onOff,
|
operationDialogType: OperationDialogType.onOff,
|
||||||
functionValue: taskItem.functionValue == 'rule_enable' ? true : false,
|
functionValue: taskItem.functionValue == 'rule_enable' ? true : false,
|
||||||
@ -1241,6 +1213,7 @@ mixin SceneOperationsDataHelper {
|
|||||||
),
|
),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator: taskItem.comparator,
|
comparator: taskItem.comparator,
|
||||||
|
uniqueCustomId: taskItem.uniqueCustomId,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,7 @@ class SceneStaticFunction {
|
|||||||
final List<SceneOperationalValue> operationalValues;
|
final List<SceneOperationalValue> operationalValues;
|
||||||
final String deviceId;
|
final String deviceId;
|
||||||
final String operationName;
|
final String operationName;
|
||||||
final String uniqueCustomId;
|
final String? uniqueCustomId;
|
||||||
final dynamic functionValue;
|
final dynamic functionValue;
|
||||||
final String? deviceIcon;
|
final String? deviceIcon;
|
||||||
final OperationDialogType operationDialogType;
|
final OperationDialogType operationDialogType;
|
||||||
@ -28,7 +28,8 @@ class SceneStaticFunction {
|
|||||||
this.deviceIcon,
|
this.deviceIcon,
|
||||||
required this.operationDialogType,
|
required this.operationDialogType,
|
||||||
this.comparator,
|
this.comparator,
|
||||||
}) : uniqueCustomId = const Uuid().v4();
|
String? uniqueCustomId,
|
||||||
|
}) : uniqueCustomId = uniqueCustomId ?? const Uuid().v4();
|
||||||
|
|
||||||
SceneStaticFunction copyWith({
|
SceneStaticFunction copyWith({
|
||||||
String? icon,
|
String? icon,
|
||||||
@ -42,6 +43,7 @@ class SceneStaticFunction {
|
|||||||
String? deviceName,
|
String? deviceName,
|
||||||
OperationDialogType? operationDialogType,
|
OperationDialogType? operationDialogType,
|
||||||
String? comparator,
|
String? comparator,
|
||||||
|
String? uniqueCustomId,
|
||||||
}) {
|
}) {
|
||||||
return SceneStaticFunction(
|
return SceneStaticFunction(
|
||||||
icon: icon ?? this.icon,
|
icon: icon ?? this.icon,
|
||||||
@ -54,6 +56,7 @@ class SceneStaticFunction {
|
|||||||
deviceIcon: deviceIcon ?? this.deviceIcon,
|
deviceIcon: deviceIcon ?? this.deviceIcon,
|
||||||
operationDialogType: operationDialogType ?? this.operationDialogType,
|
operationDialogType: operationDialogType ?? this.operationDialogType,
|
||||||
comparator: comparator ?? this.comparator,
|
comparator: comparator ?? this.comparator,
|
||||||
|
uniqueCustomId: uniqueCustomId ?? const Uuid().v4(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +71,8 @@ class SceneStaticFunction {
|
|||||||
'functionValue': functionValue,
|
'functionValue': functionValue,
|
||||||
'deviceIcon': deviceIcon,
|
'deviceIcon': deviceIcon,
|
||||||
'operationDialogType': operationDialogType.name,
|
'operationDialogType': operationDialogType.name,
|
||||||
'comparator': comparator
|
'comparator': comparator,
|
||||||
|
'uniqueCustomId': uniqueCustomId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,6 +92,7 @@ class SceneStaticFunction {
|
|||||||
? OperationDialogType.values.byName(map['operationDialogType'])
|
? OperationDialogType.values.byName(map['operationDialogType'])
|
||||||
: OperationDialogType.none,
|
: OperationDialogType.none,
|
||||||
comparator: map['comparator'],
|
comparator: map['comparator'],
|
||||||
|
uniqueCustomId: map['uniqueCustomId'] ?? const Uuid().v4(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +103,7 @@ class SceneStaticFunction {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'SceneStaticFunction(icon: $icon, name: $deviceName, code: $code, operationalValues: $operationalValues, deviceId: $deviceId, operationName: $operationName, functionValue: $functionValue, deviceIcon: $deviceIcon, operationDialogType: $operationDialogType, comparator: $comparator)';
|
return 'SceneStaticFunction(icon: $icon, name: $deviceName, code: $code, operationalValues: $operationalValues, deviceId: $deviceId, operationName: $operationName, functionValue: $functionValue, deviceIcon: $deviceIcon, operationDialogType: $operationDialogType, comparator: $comparator, uniqueCustomId: $uniqueCustomId)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -113,6 +118,7 @@ class SceneStaticFunction {
|
|||||||
other.functionValue == functionValue &&
|
other.functionValue == functionValue &&
|
||||||
other.deviceIcon == deviceIcon &&
|
other.deviceIcon == deviceIcon &&
|
||||||
other.comparator == comparator &&
|
other.comparator == comparator &&
|
||||||
|
other.uniqueCustomId == uniqueCustomId &&
|
||||||
other.operationDialogType == operationDialogType &&
|
other.operationDialogType == operationDialogType &&
|
||||||
listEquals(other.operationalValues, operationalValues) &&
|
listEquals(other.operationalValues, operationalValues) &&
|
||||||
other.deviceId == deviceId;
|
other.deviceId == deviceId;
|
||||||
@ -128,6 +134,7 @@ class SceneStaticFunction {
|
|||||||
functionValue.hashCode ^
|
functionValue.hashCode ^
|
||||||
deviceIcon.hashCode ^
|
deviceIcon.hashCode ^
|
||||||
comparator.hashCode ^
|
comparator.hashCode ^
|
||||||
|
uniqueCustomId.hashCode ^
|
||||||
operationDialogType.hashCode ^
|
operationDialogType.hashCode ^
|
||||||
operationalValues.hashCode;
|
operationalValues.hashCode;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -202,7 +202,7 @@ class DeviceFunctionsView extends StatelessWidget
|
|||||||
operation: function.operationName,
|
operation: function.operationName,
|
||||||
icon: device.icon ?? '',
|
icon: device.icon ?? '',
|
||||||
deviceName: device.name ?? '',
|
deviceName: device.name ?? '',
|
||||||
uniqueId: function.uniqueCustomId,
|
uniqueId: function.uniqueCustomId!,
|
||||||
operationType: function.operationDialogType,
|
operationType: function.operationDialogType,
|
||||||
));
|
));
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
@ -253,7 +253,7 @@ class DeviceFunctionsView extends StatelessWidget
|
|||||||
operation: function.operationName,
|
operation: function.operationName,
|
||||||
icon: device.icon ?? '',
|
icon: device.icon ?? '',
|
||||||
deviceName: device.name ?? '',
|
deviceName: device.name ?? '',
|
||||||
uniqueId: function.uniqueCustomId,
|
uniqueId: function.uniqueCustomId!,
|
||||||
operationType: function.operationDialogType,
|
operationType: function.operationDialogType,
|
||||||
isAutomation: true,
|
isAutomation: true,
|
||||||
));
|
));
|
||||||
|
|||||||
@ -29,6 +29,9 @@ class SceneTasksView extends StatelessWidget {
|
|||||||
|
|
||||||
final isAutomation =
|
final isAutomation =
|
||||||
sceneSettings.sceneType == CreateSceneEnum.deviceStatusChanges.name;
|
sceneSettings.sceneType == CreateSceneEnum.deviceStatusChanges.name;
|
||||||
|
// context.read<CreateSceneBloc>().add(SceneTypeEvent(isAutomation
|
||||||
|
// ? CreateSceneEnum.deviceStatusChanges
|
||||||
|
// : CreateSceneEnum.tabToRun));
|
||||||
|
|
||||||
return DefaultScaffold(
|
return DefaultScaffold(
|
||||||
title: sceneSettings.sceneName.isNotEmpty
|
title: sceneSettings.sceneName.isNotEmpty
|
||||||
|
|||||||
@ -19,6 +19,7 @@ class SmartAutomationSelectView extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final sceneType = context.read<CreateSceneBloc>().sceneType;
|
final sceneType = context.read<CreateSceneBloc>().sceneType;
|
||||||
|
final sceneId = ModalRoute.of(context)!.settings.arguments as String;
|
||||||
return DefaultScaffold(
|
return DefaultScaffold(
|
||||||
title: "Select Smart Scene",
|
title: "Select Smart Scene",
|
||||||
padding: const EdgeInsets.only(top: 24),
|
padding: const EdgeInsets.only(top: 24),
|
||||||
@ -41,7 +42,8 @@ class SmartAutomationSelectView extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Visibility(
|
Visibility(
|
||||||
visible: sceneType.name == CreateSceneEnum.deviceStatusChanges.name,
|
visible: sceneType.name ==
|
||||||
|
CreateSceneEnum.deviceStatusChanges.name,
|
||||||
child: SceneListTile(
|
child: SceneListTile(
|
||||||
assetPath: Assets.handClickIcon,
|
assetPath: Assets.handClickIcon,
|
||||||
titleString: "Tap To Run",
|
titleString: "Tap To Run",
|
||||||
@ -58,7 +60,8 @@ class SmartAutomationSelectView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Visibility(
|
Visibility(
|
||||||
visible: sceneType.name == CreateSceneEnum.deviceStatusChanges.name,
|
visible: sceneType.name ==
|
||||||
|
CreateSceneEnum.deviceStatusChanges.name,
|
||||||
child: const Divider(
|
child: const Divider(
|
||||||
color: ColorsManager.dividerColor,
|
color: ColorsManager.dividerColor,
|
||||||
),
|
),
|
||||||
@ -73,7 +76,7 @@ class SmartAutomationSelectView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.customBottomSheet(
|
context.customBottomSheet(
|
||||||
child: const SmartEnableAutomation(),
|
child: SmartEnableAutomation(automationId: sceneId),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@ -31,6 +31,10 @@ class _AlertDialogSliderStepsState extends State<AlertDialogSliderSteps> {
|
|||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
final createSceneBloc = context.read<CreateSceneBloc>();
|
final createSceneBloc = context.read<CreateSceneBloc>();
|
||||||
|
|
||||||
|
if (widget.taskItem.comparator != null) {
|
||||||
|
selectedToggleIndex = _comparatorToIndex(widget.taskItem.comparator);
|
||||||
|
}
|
||||||
|
|
||||||
if (widget.isAutomation) {
|
if (widget.isAutomation) {
|
||||||
final automationTempTaskList = createSceneBloc.automationTempTasksList;
|
final automationTempTaskList = createSceneBloc.automationTempTasksList;
|
||||||
final automationComparatorValues =
|
final automationComparatorValues =
|
||||||
@ -52,15 +56,20 @@ class _AlertDialogSliderStepsState extends State<AlertDialogSliderSteps> {
|
|||||||
_normalizeValue(widget.taskItem.operationalValues[0].minValue);
|
_normalizeValue(widget.taskItem.operationalValues[0].minValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (widget.taskItem.comparator != null) {
|
|
||||||
selectedToggleIndex = _comparatorToIndex(widget.taskItem.comparator);
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
|
||||||
|
context.read<CreateSceneBloc>().add(
|
||||||
|
SelectedValueEvent(
|
||||||
|
value: _deNormalizeValue(groupValue),
|
||||||
|
code: widget.taskItem.code,
|
||||||
|
isAutomation: widget.isAutomation,
|
||||||
|
comparator: _indexToComparator(selectedToggleIndex),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
double _normalizeValue(dynamic value) {
|
double _normalizeValue(dynamic value) {
|
||||||
if (((widget.taskItem.code == "temp_set" && value > 200) ||
|
if (((widget.taskItem.code == "temp_set" && value > 199) ||
|
||||||
widget.taskItem.code == "temp_current")) {
|
widget.taskItem.code == "temp_current")) {
|
||||||
return (value) / 10;
|
return (value) / 10;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,13 +49,18 @@ class _AlertDialogTemperatureBodyState
|
|||||||
temperature = _normalizeTemperature(widget.functionValue);
|
temperature = _normalizeTemperature(widget.functionValue);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// context.read<CreateSceneBloc>().add(SelectedValueEvent(
|
||||||
|
// value: temperature * 10,
|
||||||
|
// code: widget.taskItem.code,
|
||||||
|
// ));
|
||||||
}
|
}
|
||||||
|
|
||||||
int _normalizeTemperature(dynamic value) {
|
int _normalizeTemperature(dynamic value) {
|
||||||
if (value is int && value >= 100) {
|
if (value >= 100) {
|
||||||
return value ~/ 10;
|
return value ~/ 10;
|
||||||
}
|
}
|
||||||
return value as int? ?? 24;
|
return value ?? 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -17,7 +17,9 @@ import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
|||||||
class CustomBottomSheetWidget extends StatelessWidget {
|
class CustomBottomSheetWidget extends StatelessWidget {
|
||||||
const CustomBottomSheetWidget({
|
const CustomBottomSheetWidget({
|
||||||
super.key,
|
super.key,
|
||||||
|
required this.sceneId,
|
||||||
});
|
});
|
||||||
|
final String sceneId;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -58,7 +60,7 @@ class CustomBottomSheetWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
SceneListTile(
|
SceneListTile(
|
||||||
assetPath: Assets.player,
|
assetPath: Assets.player,
|
||||||
titleString: 'Select Automation',
|
titleString: 'Select Smart Scene',
|
||||||
minLeadingWidth: 30,
|
minLeadingWidth: 30,
|
||||||
assetHeight: 24,
|
assetHeight: 24,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
@ -68,7 +70,7 @@ class CustomBottomSheetWidget extends StatelessWidget {
|
|||||||
color: ColorsManager.greyColor,
|
color: ColorsManager.greyColor,
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pushNamed(context, Routes.smartAutomationSelectRoute);
|
Navigator.pushNamed(context, Routes.smartAutomationSelectRoute, arguments: sceneId);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SceneListTile(
|
SceneListTile(
|
||||||
@ -90,8 +92,7 @@ class CustomBottomSheetWidget extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _onDelayActionPressed(BuildContext context) {
|
void _onDelayActionPressed(BuildContext context) {
|
||||||
final functionValues =
|
final functionValues = context.read<CreateSceneBloc>().selectedValues['delay'];
|
||||||
context.read<CreateSceneBloc>().selectedValues['delay'];
|
|
||||||
final functions = [
|
final functions = [
|
||||||
SceneStaticFunction(
|
SceneStaticFunction(
|
||||||
deviceId: 'delay',
|
deviceId: 'delay',
|
||||||
@ -114,8 +115,7 @@ class CustomBottomSheetWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
title: functions[0].operationName,
|
title: functions[0].operationName,
|
||||||
onConfirm: () {
|
onConfirm: () {
|
||||||
final selectedValue =
|
final selectedValue = context.read<CreateSceneBloc>().selectedValues['delay'];
|
||||||
context.read<CreateSceneBloc>().selectedValues['delay'];
|
|
||||||
context.read<CreateSceneBloc>().add(TempHoldSceneTasksEvent(
|
context.read<CreateSceneBloc>().add(TempHoldSceneTasksEvent(
|
||||||
deviceControlModel: DeviceControlModel(
|
deviceControlModel: DeviceControlModel(
|
||||||
deviceId: '',
|
deviceId: '',
|
||||||
@ -126,7 +126,7 @@ class CustomBottomSheetWidget extends StatelessWidget {
|
|||||||
operation: functions[0].operationName,
|
operation: functions[0].operationName,
|
||||||
icon: Assets.delay,
|
icon: Assets.delay,
|
||||||
deviceName: 'Delay The Action',
|
deviceName: 'Delay The Action',
|
||||||
uniqueId: functions[0].uniqueCustomId,
|
uniqueId: functions[0].uniqueCustomId!,
|
||||||
operationType: functions[0].operationDialogType,
|
operationType: functions[0].operationDialogType,
|
||||||
));
|
));
|
||||||
context.read<CreateSceneBloc>().add(const AddTaskEvent());
|
context.read<CreateSceneBloc>().add(const AddTaskEvent());
|
||||||
@ -138,9 +138,7 @@ class CustomBottomSheetWidget extends StatelessWidget {
|
|||||||
|
|
||||||
for (var element in tempTaskList) {
|
for (var element in tempTaskList) {
|
||||||
if (element.code == functions[0].code) {
|
if (element.code == functions[0].code) {
|
||||||
context
|
context.read<CreateSceneBloc>().add(RemoveTempTaskByIdEvent(code: functions[0].code));
|
||||||
.read<CreateSceneBloc>()
|
|
||||||
.add(RemoveTempTaskByIdEvent(code: functions[0].code));
|
|
||||||
context
|
context
|
||||||
.read<CreateSceneBloc>()
|
.read<CreateSceneBloc>()
|
||||||
.add(RemoveFromSelectedValueById(code: functions[0].code));
|
.add(RemoveFromSelectedValueById(code: functions[0].code));
|
||||||
|
|||||||
@ -24,14 +24,13 @@ class CreateSceneSaveButton extends StatefulWidget {
|
|||||||
State<CreateSceneSaveButton> createState() => _CreateSceneSaveButtonState();
|
State<CreateSceneSaveButton> createState() => _CreateSceneSaveButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CreateSceneSaveButtonState extends State<CreateSceneSaveButton>
|
class _CreateSceneSaveButtonState extends State<CreateSceneSaveButton> with SceneLogicHelper {
|
||||||
with SceneLogicHelper {
|
|
||||||
late TextEditingController sceneNameController;
|
late TextEditingController sceneNameController;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
sceneNameController = TextEditingController(
|
sceneNameController =
|
||||||
text: widget.sceneName.isNotEmpty ? widget.sceneName : '');
|
TextEditingController(text: widget.sceneName.isNotEmpty ? widget.sceneName : '');
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,15 +45,8 @@ class _CreateSceneSaveButtonState extends State<CreateSceneSaveButton>
|
|||||||
return BlocConsumer<CreateSceneBloc, CreateSceneState>(
|
return BlocConsumer<CreateSceneBloc, CreateSceneState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is CreateSceneWithTasks) {
|
if (state is CreateSceneWithTasks) {
|
||||||
if (state.success == true) {
|
if (state.success) {
|
||||||
navigateToRoute(context, Routes.homeRoute);
|
navigateToRoute(context, Routes.homeRoute);
|
||||||
context.showCustomSnackbar(
|
|
||||||
message: 'Scene created successfully',
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.check,
|
|
||||||
color: Colors.green,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
sceneNameController.text = '';
|
sceneNameController.text = '';
|
||||||
}
|
}
|
||||||
} else if (state is CreateSceneError) {
|
} else if (state is CreateSceneError) {
|
||||||
@ -65,8 +57,24 @@ class _CreateSceneSaveButtonState extends State<CreateSceneSaveButton>
|
|||||||
return DefaultButton(
|
return DefaultButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
final sceneBloc = context.read<CreateSceneBloc>();
|
final sceneBloc = context.read<CreateSceneBloc>();
|
||||||
final isAutomation =
|
if (sceneBloc.tasksList.isEmpty && sceneBloc.automationTasksList.isEmpty) {
|
||||||
sceneBloc.sceneType == CreateSceneEnum.deviceStatusChanges;
|
return;
|
||||||
|
}
|
||||||
|
final isAutomation = sceneBloc.sceneType == CreateSceneEnum.deviceStatusChanges;
|
||||||
|
|
||||||
|
if (isAutomation && sceneBloc.automationTasksList.isEmpty) {
|
||||||
|
CustomSnackBar.displaySnackBar(
|
||||||
|
'Conditions Must not be empty!',
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isAutomation && sceneBloc.tasksList.isEmpty) {
|
||||||
|
CustomSnackBar.displaySnackBar(
|
||||||
|
'Actions Must not be empty!',
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (widget.sceneName.isNotEmpty) {
|
if (widget.sceneName.isNotEmpty) {
|
||||||
handleSaveButtonPress(
|
handleSaveButtonPress(
|
||||||
@ -89,13 +97,11 @@ class _CreateSceneSaveButtonState extends State<CreateSceneSaveButton>
|
|||||||
elevation: WidgetStateProperty.all(0),
|
elevation: WidgetStateProperty.all(0),
|
||||||
textStyle: WidgetStateProperty.all(context.bodyMedium),
|
textStyle: WidgetStateProperty.all(context.bodyMedium),
|
||||||
hintStyle: WidgetStateProperty.all(
|
hintStyle: WidgetStateProperty.all(
|
||||||
context.bodyMedium.copyWith(
|
context.bodyMedium
|
||||||
fontSize: 14,
|
.copyWith(fontSize: 14, color: ColorsManager.secondaryTextColor),
|
||||||
color: ColorsManager.secondaryTextColor),
|
|
||||||
),
|
),
|
||||||
hintText: 'Enter scene name',
|
hintText: 'Enter scene name',
|
||||||
backgroundColor: WidgetStateProperty.all(
|
backgroundColor: WidgetStateProperty.all(ColorsManager.backgroundColor),
|
||||||
ColorsManager.backgroundColor),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -19,6 +19,8 @@ import 'package:syncrow_app/utils/context_extension.dart';
|
|||||||
import 'package:syncrow_app/utils/helpers/snack_bar.dart';
|
import 'package:syncrow_app/utils/helpers/snack_bar.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
|
import '../../../../navigation/navigation_service.dart';
|
||||||
|
|
||||||
class ThenAddedTasksContainer extends StatelessWidget
|
class ThenAddedTasksContainer extends StatelessWidget
|
||||||
with SceneOperationsDataHelper, SceneLogicHelper {
|
with SceneOperationsDataHelper, SceneLogicHelper {
|
||||||
ThenAddedTasksContainer({
|
ThenAddedTasksContainer({
|
||||||
@ -48,9 +50,9 @@ class ThenAddedTasksContainer extends StatelessWidget
|
|||||||
"${duration.inHours}h ${duration.inMinutes.remainder(60)}m ";
|
"${duration.inHours}h ${duration.inMinutes.remainder(60)}m ";
|
||||||
} else if (taskItem.code.contains('temp_set') ||
|
} else if (taskItem.code.contains('temp_set') ||
|
||||||
taskItem.code.contains('temp_current')) {
|
taskItem.code.contains('temp_current')) {
|
||||||
if (taskItem.functionValue != null || taskItem.functionValue != 0) {
|
if ((taskItem.functionValue != null || taskItem.functionValue != 0)) {
|
||||||
operationValue =
|
operationValue =
|
||||||
'${((taskItem.functionValue / 10) as double).round().toString()}°C';
|
'${((taskItem.functionValue / 10) as double).toStringAsFixed(1)}°C';
|
||||||
} else {
|
} else {
|
||||||
operationValue = '0°C';
|
operationValue = '0°C';
|
||||||
}
|
}
|
||||||
@ -121,7 +123,7 @@ class ThenAddedTasksContainer extends StatelessWidget
|
|||||||
createSceneBloc.add(
|
createSceneBloc.add(
|
||||||
UpdateTaskEvent(
|
UpdateTaskEvent(
|
||||||
newValue: automationSelectedValue,
|
newValue: automationSelectedValue,
|
||||||
taskId: taskItem.uniqueCustomId,
|
taskId: taskItem.uniqueCustomId!,
|
||||||
isAutomation: true,
|
isAutomation: true,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -136,7 +138,7 @@ class ThenAddedTasksContainer extends StatelessWidget
|
|||||||
createSceneBloc.add(
|
createSceneBloc.add(
|
||||||
UpdateTaskEvent(
|
UpdateTaskEvent(
|
||||||
newValue: selectedValue,
|
newValue: selectedValue,
|
||||||
taskId: taskItem.uniqueCustomId,
|
taskId: taskItem.uniqueCustomId!,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -144,7 +146,10 @@ class ThenAddedTasksContainer extends StatelessWidget
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Navigator.pop(context);
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
Navigator.pop(
|
||||||
|
NavigationService.navigatorKey.currentContext!);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -172,7 +177,7 @@ class ThenAddedTasksContainer extends StatelessWidget
|
|||||||
),
|
),
|
||||||
direction: DismissDirection.endToStart,
|
direction: DismissDirection.endToStart,
|
||||||
onDismissed: (direction) {
|
onDismissed: (direction) {
|
||||||
String removeFunctionById = taskItem.uniqueCustomId;
|
String removeFunctionById = taskItem.uniqueCustomId!;
|
||||||
|
|
||||||
if (isAutomation == true) {
|
if (isAutomation == true) {
|
||||||
context.read<CreateSceneBloc>().add(RemoveTaskByIdEvent(
|
context.read<CreateSceneBloc>().add(RemoveTaskByIdEvent(
|
||||||
|
|||||||
@ -47,7 +47,7 @@ class ThenDefaultContainer extends StatelessWidget {
|
|||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: isClickable
|
onTap: isClickable
|
||||||
? () => context.customBottomSheet(
|
? () => context.customBottomSheet(
|
||||||
child: const CustomBottomSheetWidget(),
|
child: CustomBottomSheetWidget(sceneId: sceneId),
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
@ -99,7 +99,9 @@ class ThenDefaultContainer extends StatelessWidget {
|
|||||||
builder: (context) => const CreateSceneView()));
|
builder: (context) => const CreateSceneView()));
|
||||||
} else {
|
} else {
|
||||||
context.customBottomSheet(
|
context.customBottomSheet(
|
||||||
child: const CustomBottomSheetWidget(),
|
child: CustomBottomSheetWidget(
|
||||||
|
sceneId: sceneId,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -118,7 +118,7 @@ class SceneDevicesBody extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else if (state.error != null) {
|
} else if (state.error != null) {
|
||||||
return Center(child: Text(state.error!));
|
return const Center(child: Text('Something went wrong'));
|
||||||
} else {
|
} else {
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,23 @@ class SceneItem extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return DefaultContainer(
|
return DefaultContainer(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent());
|
||||||
|
if (disablePlayButton == false) {
|
||||||
|
BlocProvider.of<CreateSceneBloc>(context).add(
|
||||||
|
FetchSceneTasksEvent(sceneId: scene.id, isAutomation: false));
|
||||||
|
|
||||||
|
/// the state to set the scene type must be after the fetch
|
||||||
|
BlocProvider.of<CreateSceneBloc>(context)
|
||||||
|
.add(const SceneTypeEvent(CreateSceneEnum.tabToRun));
|
||||||
|
} else {
|
||||||
|
BlocProvider.of<CreateSceneBloc>(context)
|
||||||
|
.add(FetchSceneTasksEvent(sceneId: scene.id, isAutomation: true));
|
||||||
|
|
||||||
|
/// the state to set the scene type must be after the fetch
|
||||||
|
BlocProvider.of<CreateSceneBloc>(context)
|
||||||
|
.add(const SceneTypeEvent(CreateSceneEnum.deviceStatusChanges));
|
||||||
|
}
|
||||||
|
|
||||||
Navigator.pushNamed(
|
Navigator.pushNamed(
|
||||||
context,
|
context,
|
||||||
Routes.sceneTasksRoute,
|
Routes.sceneTasksRoute,
|
||||||
@ -46,18 +63,6 @@ class SceneItem extends StatelessWidget {
|
|||||||
sceneName: scene.name,
|
sceneName: scene.name,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent());
|
|
||||||
if (disablePlayButton == false) {
|
|
||||||
BlocProvider.of<CreateSceneBloc>(context)
|
|
||||||
.add(const SceneTypeEvent(CreateSceneEnum.tabToRun));
|
|
||||||
BlocProvider.of<CreateSceneBloc>(context).add(
|
|
||||||
FetchSceneTasksEvent(sceneId: scene.id, isAutomation: false));
|
|
||||||
} else {
|
|
||||||
BlocProvider.of<CreateSceneBloc>(context)
|
|
||||||
.add(const SceneTypeEvent(CreateSceneEnum.deviceStatusChanges));
|
|
||||||
BlocProvider.of<CreateSceneBloc>(context)
|
|
||||||
.add(FetchSceneTasksEvent(sceneId: scene.id, isAutomation: true));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|||||||
@ -15,15 +15,19 @@ class SmartSceneSelectAutomationList extends StatefulWidget {
|
|||||||
const SmartSceneSelectAutomationList({
|
const SmartSceneSelectAutomationList({
|
||||||
super.key,
|
super.key,
|
||||||
required this.automationList,
|
required this.automationList,
|
||||||
|
required this.automationId,
|
||||||
});
|
});
|
||||||
|
|
||||||
final List<ScenesModel> automationList;
|
final List<ScenesModel> automationList;
|
||||||
|
final String automationId;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<SmartSceneSelectAutomationList> createState() => _SmartSceneSelectAutomationListState();
|
State<SmartSceneSelectAutomationList> createState() =>
|
||||||
|
_SmartSceneSelectAutomationListState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SmartSceneSelectAutomationListState extends State<SmartSceneSelectAutomationList> {
|
class _SmartSceneSelectAutomationListState
|
||||||
|
extends State<SmartSceneSelectAutomationList> {
|
||||||
final List<Color> colorList = _generateDarkColors(100);
|
final List<Color> colorList = _generateDarkColors(100);
|
||||||
|
|
||||||
static List<Color> _generateDarkColors(int count) {
|
static List<Color> _generateDarkColors(int count) {
|
||||||
@ -31,7 +35,8 @@ class _SmartSceneSelectAutomationListState extends State<SmartSceneSelectAutomat
|
|||||||
final colors = <Color>[];
|
final colors = <Color>[];
|
||||||
|
|
||||||
while (colors.length < count) {
|
while (colors.length < count) {
|
||||||
final color = Color((random.nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0);
|
final color =
|
||||||
|
Color((random.nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0);
|
||||||
if (_isDark(color)) {
|
if (_isDark(color)) {
|
||||||
colors.add(color);
|
colors.add(color);
|
||||||
}
|
}
|
||||||
@ -40,12 +45,17 @@ class _SmartSceneSelectAutomationListState extends State<SmartSceneSelectAutomat
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool _isDark(Color color) {
|
static bool _isDark(Color color) {
|
||||||
final brightness = ((color.red * 299) + (color.green * 587) + (color.blue * 114)) / 1000;
|
final brightness =
|
||||||
|
((color.red * 299) + (color.green * 587) + (color.blue * 114)) / 1000;
|
||||||
return brightness < 128;
|
return brightness < 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
// Filter the automation list to exclude the sceneId
|
||||||
|
final filteredAutomationList = widget.automationList
|
||||||
|
.where((e) => e.id != widget.automationId.toString())
|
||||||
|
.toList();
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
@ -70,7 +80,8 @@ class _SmartSceneSelectAutomationListState extends State<SmartSceneSelectAutomat
|
|||||||
text: 'Automation',
|
text: 'Automation',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: context.bodyMedium.copyWith(
|
style: context.bodyMedium.copyWith(
|
||||||
color: ColorsManager.primaryColorWithOpacity, fontWeight: FontWeight.bold),
|
color: ColorsManager.primaryColorWithOpacity,
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -89,12 +100,15 @@ class _SmartSceneSelectAutomationListState extends State<SmartSceneSelectAutomat
|
|||||||
|
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
itemCount: widget.automationList.length,
|
itemCount: filteredAutomationList.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final automation = widget.automationList[index];
|
final automation = filteredAutomationList[index];
|
||||||
final isSelected = smartSceneEnable?.entityId == automation.id;
|
final isSelected =
|
||||||
|
smartSceneEnable?.entityId == automation.id;
|
||||||
final descriptionSelected = isSelected
|
final descriptionSelected = isSelected
|
||||||
? (smartSceneEnable?.actionExecutor == 'rule_enable' ? 'Enable' : 'Disable')
|
? (smartSceneEnable?.actionExecutor == 'rule_enable'
|
||||||
|
? 'Enable'
|
||||||
|
: 'Disable')
|
||||||
: automation.status == 'enable'
|
: automation.status == 'enable'
|
||||||
? 'Enable'
|
? 'Enable'
|
||||||
: 'Disable';
|
: 'Disable';
|
||||||
@ -128,14 +142,17 @@ class _SmartSceneSelectAutomationListState extends State<SmartSceneSelectAutomat
|
|||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
onDismiss: () {
|
onDismiss: () {
|
||||||
context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent());
|
context
|
||||||
|
.read<SmartSceneSelectBloc>()
|
||||||
|
.add(const SmartSceneClearEvent());
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
label: BodyMedium(
|
label: BodyMedium(
|
||||||
text: _capitalizeFirst(descriptionSelected),
|
text: _capitalizeFirst(descriptionSelected),
|
||||||
style: context.bodyMedium.copyWith(color: ColorsManager.greyColor),
|
style: context.bodyMedium
|
||||||
|
.copyWith(color: ColorsManager.greyColor),
|
||||||
),
|
),
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.arrow_forward_ios_rounded,
|
Icons.arrow_forward_ios_rounded,
|
||||||
@ -162,7 +179,9 @@ class _SmartSceneSelectAutomationListState extends State<SmartSceneSelectAutomat
|
|||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
onDismiss: () {
|
onDismiss: () {
|
||||||
context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent());
|
context
|
||||||
|
.read<SmartSceneSelectBloc>()
|
||||||
|
.add(const SmartSceneClearEvent());
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -198,10 +217,12 @@ class EnableDisableAutomationDialog extends StatefulWidget {
|
|||||||
final String type;
|
final String type;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<EnableDisableAutomationDialog> createState() => _EnableDisableAutomationDialogState();
|
State<EnableDisableAutomationDialog> createState() =>
|
||||||
|
_EnableDisableAutomationDialogState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _EnableDisableAutomationDialogState extends State<EnableDisableAutomationDialog> {
|
class _EnableDisableAutomationDialogState
|
||||||
|
extends State<EnableDisableAutomationDialog> {
|
||||||
String? groupValue;
|
String? groupValue;
|
||||||
final List<SceneOperationalValue> values = [
|
final List<SceneOperationalValue> values = [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
@ -219,14 +240,16 @@ class _EnableDisableAutomationDialogState extends State<EnableDisableAutomationD
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
groupValue = widget.descriptionSelected == 'Enable' ? 'rule_enable' : 'rule_disable';
|
groupValue =
|
||||||
|
widget.descriptionSelected == 'Enable' ? 'rule_enable' : 'rule_disable';
|
||||||
|
|
||||||
context.read<SmartSceneSelectBloc>().add(SmartSceneEnableEvent(SmartSceneEnable(
|
context.read<SmartSceneSelectBloc>().add(SmartSceneEnableEvent(
|
||||||
entityId: widget.automationId,
|
SmartSceneEnable(
|
||||||
actionExecutor: groupValue!,
|
entityId: widget.automationId,
|
||||||
sceneORAutomationName: widget.sceneORAutomationName,
|
actionExecutor: groupValue!,
|
||||||
type: widget.type,
|
sceneORAutomationName: widget.sceneORAutomationName,
|
||||||
isAutomation: true)));
|
type: widget.type,
|
||||||
|
isAutomation: true)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -252,11 +275,14 @@ class _EnableDisableAutomationDialogState extends State<EnableDisableAutomationD
|
|||||||
setState(() {
|
setState(() {
|
||||||
groupValue = value;
|
groupValue = value;
|
||||||
});
|
});
|
||||||
context.read<SmartSceneSelectBloc>().add(SmartSceneEnableEvent(
|
context
|
||||||
|
.read<SmartSceneSelectBloc>()
|
||||||
|
.add(SmartSceneEnableEvent(
|
||||||
SmartSceneEnable(
|
SmartSceneEnable(
|
||||||
entityId: widget.automationId,
|
entityId: widget.automationId,
|
||||||
actionExecutor: value!,
|
actionExecutor: value!,
|
||||||
sceneORAutomationName: widget.sceneORAutomationName,
|
sceneORAutomationName:
|
||||||
|
widget.sceneORAutomationName,
|
||||||
type: widget.type,
|
type: widget.type,
|
||||||
isAutomation: true),
|
isAutomation: true),
|
||||||
));
|
));
|
||||||
@ -266,7 +292,9 @@ class _EnableDisableAutomationDialogState extends State<EnableDisableAutomationD
|
|||||||
setState(() {
|
setState(() {
|
||||||
groupValue = operation.value;
|
groupValue = operation.value;
|
||||||
});
|
});
|
||||||
context.read<SmartSceneSelectBloc>().add(SmartSceneEnableEvent(
|
context
|
||||||
|
.read<SmartSceneSelectBloc>()
|
||||||
|
.add(SmartSceneEnableEvent(
|
||||||
SmartSceneEnable(
|
SmartSceneEnable(
|
||||||
entityId: widget.automationId,
|
entityId: widget.automationId,
|
||||||
actionExecutor: operation.value,
|
actionExecutor: operation.value,
|
||||||
|
|||||||
@ -10,7 +10,9 @@ import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
|||||||
import 'package:syncrow_app/utils/context_extension.dart';
|
import 'package:syncrow_app/utils/context_extension.dart';
|
||||||
|
|
||||||
class SmartEnableAutomation extends StatelessWidget {
|
class SmartEnableAutomation extends StatelessWidget {
|
||||||
const SmartEnableAutomation({super.key});
|
const SmartEnableAutomation({super.key, required this.automationId});
|
||||||
|
|
||||||
|
final String automationId;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -29,6 +31,7 @@ class SmartEnableAutomation extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
if (state is SceneLoaded) {
|
if (state is SceneLoaded) {
|
||||||
return SmartSceneSelectAutomationList(
|
return SmartSceneSelectAutomationList(
|
||||||
|
automationId: automationId,
|
||||||
automationList: state.automationList);
|
automationList: state.automationList);
|
||||||
}
|
}
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
|
|||||||
@ -13,6 +13,7 @@ class HomeManagementAPI {
|
|||||||
var userId = await storage.read(key: UserModel.userUuidKey) ?? '';
|
var userId = await storage.read(key: UserModel.userUuidKey) ?? '';
|
||||||
|
|
||||||
List<DeviceModel> list = [];
|
List<DeviceModel> list = [];
|
||||||
|
|
||||||
await _httpService.get(
|
await _httpService.get(
|
||||||
path: ApiEndpoints.getDevicesByUserId.replaceAll("{userId}", userId),
|
path: ApiEndpoints.getDevicesByUserId.replaceAll("{userId}", userId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
@ -21,14 +22,15 @@ class HomeManagementAPI {
|
|||||||
list.add(DeviceModel.fromJson(value));
|
list.add(DeviceModel.fromJson(value));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<List<DeviceModel>> fetchDevicesByUnitId() async {
|
static Future<List<DeviceModel>> fetchDevicesByUnitId() async {
|
||||||
List<DeviceModel> list = [];
|
List<DeviceModel> list = [];
|
||||||
await _httpService.get(
|
await _httpService.get(
|
||||||
path: ApiEndpoints.getDevicesByUnitId
|
path: ApiEndpoints.getDevicesByUnitId.replaceAll(
|
||||||
.replaceAll("{unitUuid}", HomeCubit.getInstance().selectedSpace?.id ?? ''),
|
"{unitUuid}", HomeCubit.getInstance().selectedSpace?.id ?? ''),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
json.forEach((value) {
|
json.forEach((value) {
|
||||||
@ -38,7 +40,8 @@ class HomeManagementAPI {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<Map<String, dynamic>> assignDeviceToRoom(Map<String, String> body) async {
|
static Future<Map<String, dynamic>> assignDeviceToRoom(
|
||||||
|
Map<String, String> body) async {
|
||||||
try {
|
try {
|
||||||
final response = await _httpService.put(
|
final response = await _httpService.put(
|
||||||
path: ApiEndpoints.assignDeviceToRoom,
|
path: ApiEndpoints.assignDeviceToRoom,
|
||||||
|
|||||||
@ -30,7 +30,7 @@ class CustomSnackBar {
|
|||||||
Text(
|
Text(
|
||||||
message,
|
message,
|
||||||
style: Theme.of(currentContext).textTheme.bodySmall!.copyWith(
|
style: Theme.of(currentContext).textTheme.bodySmall!.copyWith(
|
||||||
fontSize: 14, fontWeight: FontWeight.w500, color: Colors.green),
|
fontSize: 14, fontWeight: FontWeight.w500, color: Colors.white),
|
||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user