Refactors SceneView constructor and improves conditional rendering for automation list

This commit is contained in:
Faris Armoush
2025-04-13 15:49:13 +03:00
parent 8219de6821
commit 31025e9176

View File

@ -16,8 +16,12 @@ 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/color_manager.dart';
class SceneView extends StatelessWidget { class SceneView extends StatelessWidget {
const SceneView({
this.pageType = false,
super.key,
});
final bool pageType; final bool pageType;
const SceneView({super.key, this.pageType = false});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -30,9 +34,7 @@ class SceneView extends StatelessWidget {
builder: (context, state) { builder: (context, state) {
final selectedSpace = HomeCubit.getInstance().selectedSpace; final selectedSpace = HomeCubit.getInstance().selectedSpace;
if (state is DeleteSceneSuccess) { if (state is DeleteSceneSuccess) {
if (state.success) { if (state.success) _loadScenesAndAutomations(context, selectedSpace);
_loadScenesAndAutomations(context, selectedSpace);
}
} }
if (state is CreateSceneWithTasks) { if (state is CreateSceneWithTasks) {
if (state.success) { if (state.success) {
@ -124,19 +126,20 @@ class SceneView extends StatelessWidget {
), ),
title: const BodyMedium(text: 'Automation'), title: const BodyMedium(text: 'Automation'),
children: [ children: [
automationList.isNotEmpty if (automationList.isNotEmpty)
? SceneGrid( SceneGrid(
scenes: automationList, scenes: automationList,
loadingSceneId: state.loadingSceneId, loadingSceneId: state.loadingSceneId,
disablePlayButton: true, disablePlayButton: true,
loadingStates: state.loadingStates, loadingStates: state.loadingStates,
) )
: const Center( else
child: BodyMedium( const Center(
text: child: BodyMedium(
'No automations have been added yet', text:
), 'No automations have been added yet',
), ),
),
const SizedBox(height: 10), const SizedBox(height: 10),
], ],
), ),