mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-27 22:44:54 +00:00
push fixes
This commit is contained in:
@ -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,
|
||||
|
||||
Reference in New Issue
Block a user