From 31025e917696957e79f22dae37cae84da9ab5053 Mon Sep 17 00:00:00 2001 From: Faris Armoush Date: Sun, 13 Apr 2025 15:49:13 +0300 Subject: [PATCH] Refactors SceneView constructor and improves conditional rendering for automation list --- lib/features/scene/view/scene_view.dart | 37 +++++++++++++------------ 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/lib/features/scene/view/scene_view.dart b/lib/features/scene/view/scene_view.dart index b78e3b5..b9999bf 100644 --- a/lib/features/scene/view/scene_view.dart +++ b/lib/features/scene/view/scene_view.dart @@ -16,8 +16,12 @@ import 'package:syncrow_app/utils/context_extension.dart'; import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; class SceneView extends StatelessWidget { + const SceneView({ + this.pageType = false, + super.key, + }); + final bool pageType; - const SceneView({super.key, this.pageType = false}); @override Widget build(BuildContext context) { @@ -30,9 +34,7 @@ class SceneView extends StatelessWidget { builder: (context, state) { final selectedSpace = HomeCubit.getInstance().selectedSpace; if (state is DeleteSceneSuccess) { - if (state.success) { - _loadScenesAndAutomations(context, selectedSpace); - } + if (state.success) _loadScenesAndAutomations(context, selectedSpace); } if (state is CreateSceneWithTasks) { if (state.success) { @@ -124,19 +126,20 @@ class SceneView extends StatelessWidget { ), title: const BodyMedium(text: 'Automation'), children: [ - automationList.isNotEmpty - ? SceneGrid( - scenes: automationList, - loadingSceneId: state.loadingSceneId, - disablePlayButton: true, - loadingStates: state.loadingStates, - ) - : const Center( - child: BodyMedium( - text: - 'No automations have been added yet', - ), - ), + if (automationList.isNotEmpty) + SceneGrid( + scenes: automationList, + loadingSceneId: state.loadingSceneId, + disablePlayButton: true, + loadingStates: state.loadingStates, + ) + else + const Center( + child: BodyMedium( + text: + 'No automations have been added yet', + ), + ), const SizedBox(height: 10), ], ),