mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-26 18:34:55 +00:00
push fixes
This commit is contained in:
@ -39,11 +39,11 @@ class PeriodOptions extends StatelessWidget {
|
||||
state.customStartTime != null && state.customEndTime != null
|
||||
? BodySmall(
|
||||
text:
|
||||
'${"${state.customStartTime} AM"} - ${"${state.customEndTime} PM"}',
|
||||
'${"${state.customStartTime}"} - ${"${state.customEndTime}"}',
|
||||
style: context.bodySmall.copyWith(fontSize: 10),
|
||||
)
|
||||
: BodySmall(
|
||||
text: '00:00 AM - 11:59 PM',
|
||||
text: '00:00 - 23:59',
|
||||
style: context.bodySmall.copyWith(fontSize: 10),
|
||||
),
|
||||
trailing: Radio<EnumEffectivePeriodOptions>(
|
||||
|
||||
@ -4,12 +4,14 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_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/helper/scene_logic_helper.dart';
|
||||
import 'package:syncrow_app/features/scene/helper/scene_operations_data_helper.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
||||
|
||||
import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/select_smart_scene/smart_automation_list.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
@ -63,7 +65,8 @@ class ThenAddedTasksContainer extends StatelessWidget
|
||||
operationValue = functionValue.toString();
|
||||
}
|
||||
return DefaultContainer(
|
||||
onTap: taskItem.code == CreateSceneEnum.smartSceneSelect.name
|
||||
onTap: taskItem.operationName == 'tap_to_run' ||
|
||||
taskItem.operationName == 'scene'
|
||||
? null
|
||||
: () {
|
||||
List<SceneStaticFunction> functionOperation = [];
|
||||
@ -74,51 +77,77 @@ class ThenAddedTasksContainer extends StatelessWidget
|
||||
deviceId: taskItem.deviceId,
|
||||
isAutomation: isAutomation ?? false));
|
||||
|
||||
/// show alert dialog based on type
|
||||
context.customAlertDialog(
|
||||
alertBody: getTheCorrectDialogBody(
|
||||
functionOperation.first, null,
|
||||
isAutomation: isAutomation ?? false),
|
||||
title: functionOperation.first.operationName,
|
||||
onConfirm: () {
|
||||
final savedCode =
|
||||
functionOperation.first.deviceId.contains('delay')
|
||||
? 'delay'
|
||||
: functionOperation.first.code;
|
||||
if (isAutomation == true) {
|
||||
final automationSelectedValue =
|
||||
createSceneBloc.automationSelectedValues[savedCode];
|
||||
if (taskItem.code == CreateSceneEnum.smartSceneSelect.name) {
|
||||
context.customAlertDialog(
|
||||
alertBody: EnableDisableAutomationDialog(
|
||||
automationId: taskItem.deviceId,
|
||||
descriptionSelected: taskItem.functionValue == 'rule_enable'
|
||||
? 'Enable'
|
||||
: "Disable",
|
||||
sceneORAutomationName: taskItem.deviceName,
|
||||
type: taskItem.operationName,
|
||||
),
|
||||
title: taskItem.deviceName,
|
||||
onConfirm: () {
|
||||
context
|
||||
.read<SmartSceneSelectBloc>()
|
||||
.add(const SmartSceneConfirmSelectionEvent());
|
||||
Navigator.pop(context);
|
||||
},
|
||||
onDismiss: () {
|
||||
context
|
||||
.read<SmartSceneSelectBloc>()
|
||||
.add(const SmartSceneClearEvent());
|
||||
Navigator.pop(context);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
/// show alert dialog based on type
|
||||
context.customAlertDialog(
|
||||
alertBody: getTheCorrectDialogBody(
|
||||
functionOperation.first, null,
|
||||
isAutomation: isAutomation ?? false),
|
||||
title: functionOperation.first.operationName,
|
||||
onConfirm: () {
|
||||
final savedCode =
|
||||
functionOperation.first.deviceId.contains('delay')
|
||||
? 'delay'
|
||||
: functionOperation.first.code;
|
||||
if (isAutomation == true) {
|
||||
final automationSelectedValue =
|
||||
createSceneBloc.automationSelectedValues[savedCode];
|
||||
|
||||
try {
|
||||
createSceneBloc.add(
|
||||
UpdateTaskEvent(
|
||||
newValue: automationSelectedValue,
|
||||
taskId: taskItem.uniqueCustomId,
|
||||
isAutomation: true,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
debugPrint('Error adding UpdateTaskEvent: $e');
|
||||
try {
|
||||
createSceneBloc.add(
|
||||
UpdateTaskEvent(
|
||||
newValue: automationSelectedValue,
|
||||
taskId: taskItem.uniqueCustomId,
|
||||
isAutomation: true,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
debugPrint('Error adding UpdateTaskEvent: $e');
|
||||
}
|
||||
} else {
|
||||
final selectedValue =
|
||||
createSceneBloc.selectedValues[savedCode];
|
||||
|
||||
try {
|
||||
createSceneBloc.add(
|
||||
UpdateTaskEvent(
|
||||
newValue: selectedValue,
|
||||
taskId: taskItem.uniqueCustomId,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
debugPrint('Error adding UpdateTaskEvent: $e');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
final selectedValue =
|
||||
createSceneBloc.selectedValues[savedCode];
|
||||
|
||||
try {
|
||||
createSceneBloc.add(
|
||||
UpdateTaskEvent(
|
||||
newValue: selectedValue,
|
||||
taskId: taskItem.uniqueCustomId,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
debugPrint('Error adding UpdateTaskEvent: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Navigator.pop(context);
|
||||
},
|
||||
);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
padding: EdgeInsets.zero,
|
||||
child: Dismissible(
|
||||
@ -155,6 +184,9 @@ class ThenAddedTasksContainer extends StatelessWidget
|
||||
taskId: removeFunctionById,
|
||||
));
|
||||
}
|
||||
context
|
||||
.read<SmartSceneSelectBloc>()
|
||||
.add(const SmartSceneClearEvent());
|
||||
|
||||
String removeFunction =
|
||||
"${taskItem.operationName} with value ${taskItem.operationalValues.first.value}";
|
||||
@ -177,17 +209,13 @@ class ThenAddedTasksContainer extends StatelessWidget
|
||||
subtitleWidget: Row(
|
||||
children: [
|
||||
BodyMedium(
|
||||
text: taskItem.code == CreateSceneEnum.smartSceneSelect.name
|
||||
? taskItem.icon.contains('player')
|
||||
? 'Automation: '
|
||||
: "Tab-To-Run: "
|
||||
: "${taskItem.operationName}: ",
|
||||
text: getTaskDescription(taskItem),
|
||||
fontColor: ColorsManager.secondaryTextColor,
|
||||
fontWeight: FontWeight.normal,
|
||||
),
|
||||
BodyMedium(
|
||||
text: taskItem.code == CreateSceneEnum.smartSceneSelect.name
|
||||
? taskItem.operationName == 'rule_enable'
|
||||
? taskItem.functionValue == 'rule_enable'
|
||||
? 'Enable'
|
||||
: "Disable"
|
||||
: operationValue,
|
||||
|
||||
@ -5,6 +5,7 @@ import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.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/model/scenes_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_settings_route_arguments.dart';
|
||||
@ -45,6 +46,7 @@ class SceneItem extends StatelessWidget {
|
||||
sceneName: scene.name,
|
||||
),
|
||||
);
|
||||
context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent());
|
||||
if (disablePlayButton == false) {
|
||||
BlocProvider.of<CreateSceneBloc>(context)
|
||||
.add(const SceneTypeEvent(CreateSceneEnum.tabToRun));
|
||||
|
||||
@ -126,9 +126,13 @@ class _SmartSceneSelectAutomationListState
|
||||
automationId: automation.id,
|
||||
descriptionSelected: descriptionSelected,
|
||||
sceneORAutomationName: automation.name,
|
||||
type: automation.type,
|
||||
),
|
||||
title: automation.name,
|
||||
onConfirm: () {
|
||||
context
|
||||
.read<SmartSceneSelectBloc>()
|
||||
.add(const SmartSceneConfirmSelectionEvent());
|
||||
Navigator.pop(context);
|
||||
},
|
||||
onDismiss: () {
|
||||
@ -159,9 +163,13 @@ class _SmartSceneSelectAutomationListState
|
||||
automationId: automation.id,
|
||||
descriptionSelected: descriptionSelected,
|
||||
sceneORAutomationName: automation.name,
|
||||
type: automation.type,
|
||||
),
|
||||
title: automation.name,
|
||||
onConfirm: () {
|
||||
context
|
||||
.read<SmartSceneSelectBloc>()
|
||||
.add(const SmartSceneConfirmSelectionEvent());
|
||||
Navigator.pop(context);
|
||||
},
|
||||
onDismiss: () {
|
||||
@ -194,11 +202,13 @@ class EnableDisableAutomationDialog extends StatefulWidget {
|
||||
required this.automationId,
|
||||
required this.descriptionSelected,
|
||||
required this.sceneORAutomationName,
|
||||
required this.type,
|
||||
});
|
||||
|
||||
final String automationId;
|
||||
final String descriptionSelected;
|
||||
final String sceneORAutomationName;
|
||||
final String type;
|
||||
|
||||
@override
|
||||
State<EnableDisableAutomationDialog> createState() =>
|
||||
@ -226,6 +236,14 @@ class _EnableDisableAutomationDialogState
|
||||
super.initState();
|
||||
groupValue =
|
||||
widget.descriptionSelected == 'Enable' ? 'rule_enable' : 'rule_disable';
|
||||
|
||||
context.read<SmartSceneSelectBloc>().add(SmartSceneEnableEvent(
|
||||
SmartSceneEnable(
|
||||
entityId: widget.automationId,
|
||||
actionExecutor: groupValue!,
|
||||
sceneORAutomationName: widget.sceneORAutomationName,
|
||||
type: widget.type,
|
||||
isAutomation: true)));
|
||||
}
|
||||
|
||||
@override
|
||||
@ -259,6 +277,7 @@ class _EnableDisableAutomationDialogState
|
||||
actionExecutor: value!,
|
||||
sceneORAutomationName:
|
||||
widget.sceneORAutomationName,
|
||||
type: widget.type,
|
||||
isAutomation: true),
|
||||
));
|
||||
},
|
||||
@ -274,6 +293,7 @@ class _EnableDisableAutomationDialogState
|
||||
entityId: widget.automationId,
|
||||
actionExecutor: operation.value,
|
||||
sceneORAutomationName: widget.sceneORAutomationName,
|
||||
type: widget.type,
|
||||
isAutomation: true,
|
||||
),
|
||||
));
|
||||
|
||||
@ -25,6 +25,7 @@ class SmartSceneSelectTabToRunList extends StatefulWidget {
|
||||
class _SmartSceneSelectTabToRunListState
|
||||
extends State<SmartSceneSelectTabToRunList> {
|
||||
String groupValue = '';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
@ -67,6 +68,13 @@ class _SmartSceneSelectTabToRunListState
|
||||
itemCount: widget.scenes.length,
|
||||
itemBuilder: (context, index) {
|
||||
final scene = widget.scenes[index];
|
||||
final selectedScene =
|
||||
context.read<SmartSceneSelectBloc>().smartSceneEnable;
|
||||
if (selectedScene != null) {
|
||||
if (scene.id == selectedScene.entityId) {
|
||||
groupValue = scene.id;
|
||||
}
|
||||
}
|
||||
return SceneListTile(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
leadingWidget: Image.asset(
|
||||
@ -84,14 +92,19 @@ class _SmartSceneSelectTabToRunListState
|
||||
setState(() {
|
||||
groupValue = value;
|
||||
});
|
||||
|
||||
context
|
||||
.read<SmartSceneSelectBloc>()
|
||||
.add(SmartSceneEnableEvent(SmartSceneEnable(
|
||||
entityId: scene.id,
|
||||
actionExecutor: 'rule_enable',
|
||||
sceneORAutomationName: scene.name,
|
||||
type: scene.type,
|
||||
isAutomation: false,
|
||||
)));
|
||||
context
|
||||
.read<SmartSceneSelectBloc>()
|
||||
.add(const SmartSceneConfirmSelectionEvent());
|
||||
}
|
||||
}),
|
||||
onPressed: () {
|
||||
@ -104,8 +117,12 @@ class _SmartSceneSelectTabToRunListState
|
||||
entityId: scene.id,
|
||||
actionExecutor: 'rule_enable',
|
||||
sceneORAutomationName: scene.name,
|
||||
type: scene.type,
|
||||
isAutomation: false,
|
||||
)));
|
||||
context
|
||||
.read<SmartSceneSelectBloc>()
|
||||
.add(const SmartSceneConfirmSelectionEvent());
|
||||
},
|
||||
);
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user