From 391d6349ccbae5972ee46b8bd2b7d2e34c32319b Mon Sep 17 00:00:00 2001 From: hannathkadher Date: Tue, 5 Nov 2024 15:54:48 +0400 Subject: [PATCH] Fixed the assets order --- .../widgets/scene_view_widget/scene_item.dart | 42 ++++++++++++------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/lib/features/scene/widgets/scene_view_widget/scene_item.dart b/lib/features/scene/widgets/scene_view_widget/scene_item.dart index be2be1b..220cd96 100644 --- a/lib/features/scene/widgets/scene_view_widget/scene_item.dart +++ b/lib/features/scene/widgets/scene_view_widget/scene_item.dart @@ -38,8 +38,8 @@ class SceneItem extends StatelessWidget { onTap: () { context.read().add(const SmartSceneClearEvent()); if (disablePlayButton == false) { - BlocProvider.of(context) - .add(FetchSceneTasksEvent(sceneId: scene.id, isAutomation: false)); + BlocProvider.of(context).add( + FetchSceneTasksEvent(sceneId: scene.id, isAutomation: false)); /// the state to set the scene type must be after the fetch BlocProvider.of(context) @@ -73,22 +73,32 @@ class SceneItem extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - if (!disablePlayButton) + if (!disablePlayButton && scene.iconInBytes != null && scene.iconInBytes.isNotEmpty) Image.memory( + scene.iconInBytes, + height: 32, + width: 32, + fit: BoxFit.fill, + errorBuilder: (context, error, stackTrace) => Image.asset( + Assets.assetsIconsLogo, + height: 32, + width: 32, + fit: BoxFit.fill), + ), + if (disablePlayButton || scene.iconInBytes == null || scene.iconInBytes.isEmpty) + SvgPicture.asset( + Assets.automationIcon, height: 32, width: 32, - scene.iconInBytes, fit: BoxFit.fill, - errorBuilder: (context, error, stackTrace) => - Image.asset(height: 32, width: 32, fit: BoxFit.fill, Assets.assetsIconsLogo), ), - if (disablePlayButton) - SvgPicture.asset(height: 32, width: 32, fit: BoxFit.fill, Assets.automationIcon), disablePlayButton == false ? IconButton( padding: EdgeInsets.zero, onPressed: () { - context.read().add(SceneTrigger(scene.id, scene.name)); + context + .read() + .add(SceneTrigger(scene.id, scene.name)); }, icon: isLoading ? const Center( @@ -110,11 +120,15 @@ class SceneItem extends StatelessWidget { activeColor: ColorsManager.primaryColor, value: scene.status == 'enable' ? true : false, onChanged: (value) { - context.read().add(UpdateAutomationStatus( - automationStatusUpdate: AutomationStatusUpdate( - isEnable: value, - spaceUuid: HomeCubit.getInstance().selectedSpace!.id!), - automationId: scene.id)); + context.read().add( + UpdateAutomationStatus( + automationStatusUpdate: + AutomationStatusUpdate( + isEnable: value, + spaceUuid: HomeCubit.getInstance() + .selectedSpace! + .id!), + automationId: scene.id)); }, ), ],