diff --git a/lib/pages/routines/widgets/main_routine_view/fetch_routine_scenes_automation.dart b/lib/pages/routines/widgets/main_routine_view/fetch_routine_scenes_automation.dart index 99c131ee..0a22208c 100644 --- a/lib/pages/routines/widgets/main_routine_view/fetch_routine_scenes_automation.dart +++ b/lib/pages/routines/widgets/main_routine_view/fetch_routine_scenes_automation.dart @@ -31,165 +31,185 @@ class _FetchRoutineScenesState extends State ? const Center( child: CircularProgressIndicator(), ) - : Padding( - padding: const EdgeInsets.symmetric(vertical: 16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - "Scenes (Tab to Run)", - style: Theme.of(context).textTheme.titleLarge?.copyWith( - color: ColorsManager.grayColor, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 10), - if (state.scenes.isEmpty) - Expanded( - child: Text( + : SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + "Scenes (Tab to Run)", + style: Theme.of(context).textTheme.titleLarge?.copyWith( + color: ColorsManager.grayColor, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 10), + if (state.scenes.isEmpty) + Text( "No scenes found", style: context.textTheme.bodyMedium?.copyWith( color: ColorsManager.grayColor, ), ), - ), - if (state.scenes.isNotEmpty) - ConstrainedBox( - constraints: BoxConstraints( - maxHeight: isSmallScreenSize(context) ? 190 : 200, - maxWidth: MediaQuery.sizeOf(context).width * 0.8), - child: ListView.builder( - scrollDirection: Axis.horizontal, - itemCount: state.scenes.length, - itemBuilder: (context, index) { - final scene = state.scenes[index]; - final isLoading = - state.loadingSceneId == scene.id; + if (state.scenes.isNotEmpty) + SizedBox( + height: 200, + child: ListView.builder( + shrinkWrap: true, + scrollDirection: Axis.horizontal, + itemCount: state.scenes.length, + itemBuilder: (context, index) { + final scene = state.scenes[index]; + final isLoading = + state.loadingSceneId == scene.id; - return Padding( - padding: EdgeInsets.only( - right: isSmallScreenSize(context) ? 4.0 : 8.0, - ), - child: RoutineViewCard( - isLoading: isLoading, - sceneOnTap: () { - context.read().add( - SceneTrigger( - sceneId: scene.id, - name: scene.name)); - }, - status: state.scenes[index].status, - communityId: - state.scenes[index].communityId ?? '', - spaceId: state.scenes[index].spaceId, - sceneId: state.scenes[index].sceneTuyaId!, - automationId: state.scenes[index].id, - cardType: 'scenes', - spaceName: state.scenes[index].spaceName, - onTap: () { - BlocProvider.of(context).add( - const CreateNewRoutineViewEvent( - createRoutineView: true), - ); - context.read().add( - GetSceneDetails( - sceneId: state.scenes[index].id, - isTabToRun: true, - isUpdate: true, - ), - ); - }, - textString: state.scenes[index].name, - icon: state.scenes[index].icon ?? - Assets.logoHorizontal, - isFromScenes: true, - iconInBytes: state.scenes[index].iconInBytes, - ), - ); - }), + return Padding( + padding: EdgeInsets.only( + right: + isSmallScreenSize(context) ? 4.0 : 8.0, + ), + child: Column( + children: [ + RoutineViewCard( + isLoading: isLoading, + sceneOnTap: () { + context.read().add( + SceneTrigger( + sceneId: scene.id, + name: scene.name)); + }, + status: state.scenes[index].status, + communityId: + state.scenes[index].communityId ?? + '', + spaceId: state.scenes[index].spaceId, + sceneId: + state.scenes[index].sceneTuyaId!, + automationId: state.scenes[index].id, + cardType: 'scenes', + spaceName: + state.scenes[index].spaceName, + onTap: () { + BlocProvider.of(context) + .add( + const CreateNewRoutineViewEvent( + createRoutineView: true), + ); + context.read().add( + GetSceneDetails( + sceneId: + state.scenes[index].id, + isTabToRun: true, + isUpdate: true, + ), + ); + }, + textString: state.scenes[index].name, + icon: state.scenes[index].icon ?? + Assets.logoHorizontal, + isFromScenes: true, + iconInBytes: + state.scenes[index].iconInBytes, + ), + ], + ), + ); + }), + ), + const SizedBox(height: 10), + Text( + "Automations", + style: Theme.of(context).textTheme.titleLarge?.copyWith( + color: ColorsManager.grayColor, + fontWeight: FontWeight.bold, + ), ), - const SizedBox(height: 10), - Text( - "Automations", - style: Theme.of(context).textTheme.titleLarge?.copyWith( - color: ColorsManager.grayColor, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 3), - if (state.automations.isEmpty) - Expanded( - child: Text( + const SizedBox(height: 3), + if (state.automations.isEmpty) + Text( "No automations found", style: context.textTheme.bodyMedium?.copyWith( color: ColorsManager.grayColor, ), ), - ), - if (state.automations.isNotEmpty) - ConstrainedBox( - constraints: BoxConstraints( - maxHeight: isSmallScreenSize(context) ? 190 : 195, - ), - child: ListView.builder( - scrollDirection: Axis.horizontal, - itemCount: state.automations.length, - itemBuilder: (context, index) { - final isLoading = state.automations! - .contains(state.automations[index].id); + if (state.automations.isNotEmpty) + SizedBox( + height: 200, - return Padding( - padding: EdgeInsets.only( - right: isSmallScreenSize(context) ? 4.0 : 8.0, - ), - child: RoutineViewCard( - isLoading: isLoading, - onChanged: (v) { - // BlocProvider.of(context) - context.read().add( - UpdateAutomationStatus( - automationId: - state.automations[index].id, - automationStatusUpdate: - AutomationStatusUpdate( - spaceUuid: state - .automations[index] - .spaceId, - isEnable: v), - communityId: state - .automations[index].communityId, - ), - ); - }, - status: state.automations[index].status, - communityId: '', - spaceId: state.automations[index].spaceId, - sceneId: '', - automationId: state.automations[index].id, - cardType: 'automations', - spaceName: state.scenes[index].spaceName, - onTap: () { - BlocProvider.of(context).add( - const CreateNewRoutineViewEvent( - createRoutineView: true), - ); - context.read().add( - GetAutomationDetails( - automationId: - state.automations[index].id, - isAutomation: true, - isUpdate: true), - ); - }, - textString: state.automations[index].name, - icon: state.automations[index].icon ?? - Assets.automation, - ), - ); - }), - ), - ], + child: ListView.builder( + shrinkWrap: true, + scrollDirection: Axis.horizontal, + itemCount: state.automations.length, + itemBuilder: (context, index) { + final isLoading = state.automations! + .contains(state.automations[index].id); + + return Column( + children: [ + Padding( + padding: EdgeInsets.only( + right: isSmallScreenSize(context) + ? 4.0 + : 8.0, + ), + child: RoutineViewCard( + isLoading: isLoading, + onChanged: (v) { + context.read().add( + UpdateAutomationStatus( + automationId: state + .automations[index].id, + automationStatusUpdate: + AutomationStatusUpdate( + spaceUuid: state + .automations[ + index] + .spaceId, + isEnable: v), + communityId: state + .automations[index] + .communityId, + ), + ); + }, + status: state.automations[index].status, + communityId: '', + spaceId: + state.automations[index].spaceId, + sceneId: '', + automationId: + state.automations[index].id, + cardType: 'automations', + spaceName: + state.scenes[index].spaceName, + onTap: () { + BlocProvider.of(context) + .add( + const CreateNewRoutineViewEvent( + createRoutineView: true), + ); + context.read().add( + GetAutomationDetails( + automationId: state + .automations[index].id, + isAutomation: true, + isUpdate: true), + ); + }, + textString: + state.automations[index].name, + icon: state.automations[index].icon ?? + Assets.automation, + ), + ), + ], + ); + }), + ), + ], + ), ), ); }, diff --git a/lib/pages/routines/widgets/main_routine_view/routine_view_card.dart b/lib/pages/routines/widgets/main_routine_view/routine_view_card.dart index 5f471973..841ffa6e 100644 --- a/lib/pages/routines/widgets/main_routine_view/routine_view_card.dart +++ b/lib/pages/routines/widgets/main_routine_view/routine_view_card.dart @@ -177,6 +177,8 @@ class _RoutineViewCardState extends State { : (widget.icon is String && widget.icon.endsWith('.svg')) ? SvgPicture.asset( + height: iconSize, + width: iconSize, widget.icon, fit: BoxFit.contain, )