mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 20:27:55 +00:00
push autoamtion api connect
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import 'package:flutter/material.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/enum/create_scene_enum.dart';
|
||||
import 'package:syncrow_app/features/scene/helper/scene_logic_helper.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||
import 'package:syncrow_app/navigation/navigate_to_route.dart';
|
||||
import 'package:syncrow_app/navigation/routing_constants.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
@@ -43,8 +46,7 @@ class _CreateSceneSaveButtonState extends State<CreateSceneSaveButton>
|
||||
listener: (context, state) {
|
||||
if (state is CreateSceneWithTasks) {
|
||||
if (state.success == true) {
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(context);
|
||||
navigateToRoute(context, Routes.homeRoute);
|
||||
context.showCustomSnackbar(
|
||||
message: 'Scene created successfully',
|
||||
icon: const Icon(
|
||||
@@ -66,55 +68,59 @@ class _CreateSceneSaveButtonState extends State<CreateSceneSaveButton>
|
||||
},
|
||||
builder: (context, state) {
|
||||
return DefaultButton(
|
||||
onPressed: widget.sceneName.isNotEmpty
|
||||
? () {
|
||||
final tasks = context.read<CreateSceneBloc>().tasksList;
|
||||
handleSaveButtonPress(
|
||||
context,
|
||||
sceneNameController,
|
||||
tasks,
|
||||
updateScene: true,
|
||||
sceneId: widget.sceneId,
|
||||
);
|
||||
}
|
||||
: () {
|
||||
context.customAlertDialog(
|
||||
alertBody: Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(left: 8, right: 8, bottom: 8),
|
||||
child: SizedBox(
|
||||
height: 40,
|
||||
child: SearchBar(
|
||||
controller: sceneNameController,
|
||||
elevation: WidgetStateProperty.all(0),
|
||||
textStyle:
|
||||
WidgetStateProperty.all(context.bodyMedium),
|
||||
hintStyle: WidgetStateProperty.all(
|
||||
context.bodyMedium.copyWith(
|
||||
fontSize: 14,
|
||||
color: ColorsManager.secondaryTextColor),
|
||||
),
|
||||
hintText: 'Enter scene name',
|
||||
backgroundColor: WidgetStateProperty.all(
|
||||
ColorsManager.backgroundColor),
|
||||
),
|
||||
onPressed: () {
|
||||
final sceneBloc = context.read<CreateSceneBloc>();
|
||||
final isAutomation =
|
||||
sceneBloc.sceneType == CreateSceneEnum.deviceStatusChanges;
|
||||
|
||||
if (widget.sceneName.isNotEmpty) {
|
||||
handleSaveButtonPress(
|
||||
context,
|
||||
sceneName: sceneNameController,
|
||||
actions: sceneBloc.tasksList,
|
||||
updateScene: true,
|
||||
sceneId: widget.sceneId,
|
||||
isAutomation: isAutomation,
|
||||
conditions: sceneBloc.automationTasksList,
|
||||
);
|
||||
} else {
|
||||
context.customAlertDialog(
|
||||
alertBody: Padding(
|
||||
padding: const EdgeInsets.only(left: 8, right: 8, bottom: 8),
|
||||
child: SizedBox(
|
||||
height: 40,
|
||||
child: SearchBar(
|
||||
controller: sceneNameController,
|
||||
elevation: WidgetStateProperty.all(0),
|
||||
textStyle: WidgetStateProperty.all(context.bodyMedium),
|
||||
hintStyle: WidgetStateProperty.all(
|
||||
context.bodyMedium.copyWith(
|
||||
fontSize: 14,
|
||||
color: ColorsManager.secondaryTextColor),
|
||||
),
|
||||
hintText: 'Enter scene name',
|
||||
backgroundColor: WidgetStateProperty.all(
|
||||
ColorsManager.backgroundColor),
|
||||
),
|
||||
title: 'Scene Name',
|
||||
onConfirm: () {
|
||||
if (sceneNameController.text.isNotEmpty) {
|
||||
final tasks = context.read<CreateSceneBloc>().tasksList;
|
||||
handleSaveButtonPress(
|
||||
context,
|
||||
sceneNameController,
|
||||
tasks,
|
||||
updateScene: false,
|
||||
sceneId: widget.sceneId,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
),
|
||||
),
|
||||
title: 'Scene Name',
|
||||
onConfirm: () {
|
||||
if (sceneNameController.text.isNotEmpty) {
|
||||
handleSaveButtonPress(
|
||||
context,
|
||||
sceneName: sceneNameController,
|
||||
actions: sceneBloc.tasksList,
|
||||
updateScene: false,
|
||||
sceneId: widget.sceneId,
|
||||
isAutomation: isAutomation,
|
||||
conditions: sceneBloc.automationTasksList,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
customButtonStyle: ButtonStyle(
|
||||
backgroundColor: WidgetStateProperty.all<Color>(
|
||||
ColorsManager.primaryColor,
|
||||
|
||||
Reference in New Issue
Block a user