diff --git a/lib/pages/spaces_management/view/community_list_view.dart b/lib/pages/spaces_management/view/community_list_view.dart index 0812b8f9..eafd4066 100644 --- a/lib/pages/spaces_management/view/community_list_view.dart +++ b/lib/pages/spaces_management/view/community_list_view.dart @@ -3,10 +3,12 @@ import 'package:syncrow_web/pages/spaces_management/model/community_model.dart'; class CommunityListViewWidget extends StatelessWidget { final List communities; + final Function(CommunityModel) onCommunitySelected; const CommunityListViewWidget({ Key? key, required this.communities, + required this.onCommunitySelected, }) : super(key: key); @override @@ -25,13 +27,18 @@ class CommunityListViewWidget extends StatelessWidget { mainAxisSpacing: size.width * 0.015, childAspectRatio: 361 / 239, // Aspect ratio based on container size ), - itemCount: communities.length + 1, // One additional item for the blank community + itemCount: communities.length + + 1, // One additional item for the blank community itemBuilder: (context, index) { // If the index is 0, display the blank community, otherwise display the normal ones if (index == 0) { return _buildBlankCommunityCard(size); } else { - return _buildCommunityCard(communities[index - 1], size); + return GestureDetector( + onTap: () => onCommunitySelected( + communities[index - 1]), // Trigger callback when tapped + child: _buildCommunityCard(communities[index - 1], size), + ); } }, ), @@ -60,7 +67,9 @@ class CommunityListViewWidget extends StatelessWidget { ), ), ), - SizedBox(height: size.height * 0.02), // Add spacing between container and text + SizedBox( + height: + size.height * 0.02), // Add spacing between container and text // Text saying "Blank" for the blank community Text( 'Blank', @@ -98,7 +107,9 @@ class CommunityListViewWidget extends StatelessWidget { ), ), ), - SizedBox(height: size.height * 0.02), // Add spacing between container and text + SizedBox( + height: + size.height * 0.02), // Add spacing between container and text // Community name text Text( community.name ?? 'Blank', // Display community name diff --git a/lib/pages/spaces_management/view/spaces_management_page.dart b/lib/pages/spaces_management/view/spaces_management_page.dart index 4427234b..e774455c 100644 --- a/lib/pages/spaces_management/view/spaces_management_page.dart +++ b/lib/pages/spaces_management/view/spaces_management_page.dart @@ -30,6 +30,9 @@ class SpaceManagementPageState extends State { // Track whether to show the community list view or community structure bool showCommunityStructure = false; + // Selected community + CommunityModel? selectedCommunity; + // API instance final CommunitySpaceManagementApi _api = CommunitySpaceManagementApi(); @@ -80,20 +83,23 @@ class SpaceManagementPageState extends State { SidebarWidget( communities: communities, onCommunitySelected: (community) { - context.read().add( - LoadCommunityAndSpacesEvent(), // Re-fetch or perform community-specific actions - ); + }, ), - const SizedBox(width: 45), showCommunityStructure ? _buildCommunityStructureArea(context, screenSize) : CommunityListViewWidget( communities: communities, + onCommunitySelected: (community) { + setState(() { + selectedCommunity = community; + showCommunityStructure = true; + }); + }, ), ], ), - const GradientBorderWidget() + const GradientCanvasBorderWidget() ], ); } diff --git a/lib/pages/spaces_management/widgets/gradient_canvas_border_widget.dart b/lib/pages/spaces_management/widgets/gradient_canvas_border_widget.dart index 638434dc..2e156f06 100644 --- a/lib/pages/spaces_management/widgets/gradient_canvas_border_widget.dart +++ b/lib/pages/spaces_management/widgets/gradient_canvas_border_widget.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:syncrow_web/utils/color_manager.dart'; -class GradientBorderWidget extends StatelessWidget { +class GradientCanvasBorderWidget extends StatelessWidget { final double top; final double bottom; final double left;