mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 23:37:55 +00:00
push automation details and update automation
This commit is contained in:
@@ -20,7 +20,7 @@ import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class DeviceFunctionsView extends StatelessWidget
|
||||
with SceneOperationsDataHelper, SceneLogicHelper {
|
||||
const DeviceFunctionsView({super.key});
|
||||
DeviceFunctionsView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -54,7 +54,7 @@ class DeviceFunctionsView extends StatelessWidget
|
||||
context
|
||||
.read<CreateSceneBloc>()
|
||||
.add(AddTaskEvent(isAutomation: isAutomation));
|
||||
navigateToRoute(context, Routes.sceneTasksRoute);
|
||||
navigateToRoute(context, Routes.sceneTasksRoute);
|
||||
},
|
||||
child: BodyMedium(
|
||||
text: 'Save',
|
||||
|
||||
@@ -13,6 +13,8 @@ import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
import 'package:syncrow_app/generated/assets.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';
|
||||
import 'package:syncrow_app/utils/resource_manager/strings_manager.dart';
|
||||
@@ -24,6 +26,7 @@ class SceneTasksView extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final sceneSettings = ModalRoute.of(context)!.settings.arguments
|
||||
as SceneSettingsRouteArguments;
|
||||
|
||||
return DefaultScaffold(
|
||||
title: sceneSettings.sceneName.isNotEmpty
|
||||
? sceneSettings.sceneName
|
||||
@@ -107,8 +110,7 @@ class DeleteBottomSheetContent extends StatelessWidget {
|
||||
listener: (context, state) {
|
||||
if (state is DeleteSceneSuccess) {
|
||||
if (state.success) {
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(context);
|
||||
navigateToRoute(context, Routes.homeRoute);
|
||||
BlocProvider.of<SceneBloc>(context).add(
|
||||
LoadScenes(HomeCubit.getInstance().selectedSpace!.id!));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/scene_listview.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';
|
||||
@@ -9,7 +8,9 @@ import 'package:syncrow_app/features/scene/widgets/scene_view_widget/scene_grid_
|
||||
import 'package:syncrow_app/features/scene/widgets/scene_view_widget/scene_header.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/create_unit.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class SceneView extends StatelessWidget {
|
||||
final bool pageType;
|
||||
@@ -19,7 +20,8 @@ class SceneView extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (BuildContext context) => SceneBloc()
|
||||
..add(LoadScenes(HomeCubit.getInstance().selectedSpace?.id ?? '')),
|
||||
..add(LoadScenes(HomeCubit.getInstance().selectedSpace?.id ?? ''))
|
||||
..add(LoadAutomation(HomeCubit.getInstance().selectedSpace?.id ?? '')),
|
||||
child: BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
||||
builder: (context, state) {
|
||||
if (state is DeleteSceneSuccess) {
|
||||
@@ -32,6 +34,8 @@ class SceneView extends StatelessWidget {
|
||||
if (state.success == true) {
|
||||
BlocProvider.of<SceneBloc>(context)
|
||||
.add(LoadScenes(HomeCubit.getInstance().selectedSpace!.id!));
|
||||
BlocProvider.of<SceneBloc>(context).add(
|
||||
LoadAutomation(HomeCubit.getInstance().selectedSpace!.id!));
|
||||
}
|
||||
}
|
||||
return BlocListener<SceneBloc, SceneState>(
|
||||
@@ -63,29 +67,69 @@ class SceneView extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
if (state is SceneLoaded) {
|
||||
if (state.scenes.isNotEmpty) {
|
||||
return pageType == false
|
||||
? Expanded(
|
||||
child: SceneGrid(
|
||||
scenes: state.scenes,
|
||||
loadingSceneId: state.loadingSceneId,
|
||||
final scenes = state.scenes;
|
||||
final automationList = state.automationList;
|
||||
|
||||
return Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
ExpansionTile(
|
||||
tilePadding: const EdgeInsets.symmetric(
|
||||
horizontal: 6),
|
||||
initiallyExpanded: true,
|
||||
iconColor: ColorsManager.grayColor,
|
||||
title: const BodySmall(
|
||||
text: 'Tap to run routines'),
|
||||
children: [
|
||||
scenes.isNotEmpty
|
||||
? SceneGrid(
|
||||
scenes: scenes,
|
||||
loadingSceneId:
|
||||
state.loadingSceneId,
|
||||
disablePLayButton: false,
|
||||
)
|
||||
: const Center(
|
||||
child: BodyMedium(
|
||||
text:
|
||||
'No scenes have been added yet',
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
)
|
||||
: Expanded(
|
||||
child: SceneListview(
|
||||
scenes: state.scenes,
|
||||
loadingSceneId: state.loadingSceneId,
|
||||
)
|
||||
);
|
||||
} else {
|
||||
return const Expanded(
|
||||
child: Center(
|
||||
child: BodyMedium(
|
||||
text: 'No scenes have been added yet',
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
ExpansionTile(
|
||||
initiallyExpanded: true,
|
||||
iconColor: ColorsManager.grayColor,
|
||||
tilePadding: const EdgeInsets.symmetric(
|
||||
horizontal: 6),
|
||||
title: const BodySmall(text: 'Automation'),
|
||||
children: [
|
||||
automationList.isNotEmpty
|
||||
? SceneGrid(
|
||||
scenes: automationList,
|
||||
loadingSceneId:
|
||||
state.loadingSceneId,
|
||||
disablePLayButton: true,
|
||||
)
|
||||
: const Center(
|
||||
child: BodyMedium(
|
||||
text:
|
||||
'No automations have been added yet',
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return const SizedBox();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user