added on select for community

This commit is contained in:
hannathkadher
2024-10-09 10:42:35 +04:00
parent 1046690f9b
commit ec4bb9bc04
3 changed files with 27 additions and 10 deletions

View File

@ -3,10 +3,12 @@ import 'package:syncrow_web/pages/spaces_management/model/community_model.dart';
class CommunityListViewWidget extends StatelessWidget { class CommunityListViewWidget extends StatelessWidget {
final List<CommunityModel> communities; final List<CommunityModel> communities;
final Function(CommunityModel) onCommunitySelected;
const CommunityListViewWidget({ const CommunityListViewWidget({
Key? key, Key? key,
required this.communities, required this.communities,
required this.onCommunitySelected,
}) : super(key: key); }) : super(key: key);
@override @override
@ -25,13 +27,18 @@ class CommunityListViewWidget extends StatelessWidget {
mainAxisSpacing: size.width * 0.015, mainAxisSpacing: size.width * 0.015,
childAspectRatio: 361 / 239, // Aspect ratio based on container size 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) { itemBuilder: (context, index) {
// If the index is 0, display the blank community, otherwise display the normal ones // If the index is 0, display the blank community, otherwise display the normal ones
if (index == 0) { if (index == 0) {
return _buildBlankCommunityCard(size); return _buildBlankCommunityCard(size);
} else { } 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 saying "Blank" for the blank community
Text( Text(
'Blank', '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 // Community name text
Text( Text(
community.name ?? 'Blank', // Display community name community.name ?? 'Blank', // Display community name

View File

@ -30,6 +30,9 @@ class SpaceManagementPageState extends State<SpaceManagementPage> {
// Track whether to show the community list view or community structure // Track whether to show the community list view or community structure
bool showCommunityStructure = false; bool showCommunityStructure = false;
// Selected community
CommunityModel? selectedCommunity;
// API instance // API instance
final CommunitySpaceManagementApi _api = CommunitySpaceManagementApi(); final CommunitySpaceManagementApi _api = CommunitySpaceManagementApi();
@ -80,20 +83,23 @@ class SpaceManagementPageState extends State<SpaceManagementPage> {
SidebarWidget( SidebarWidget(
communities: communities, communities: communities,
onCommunitySelected: (community) { onCommunitySelected: (community) {
context.read<SpaceManagementBloc>().add(
LoadCommunityAndSpacesEvent(), // Re-fetch or perform community-specific actions
);
}, },
), ),
const SizedBox(width: 45),
showCommunityStructure showCommunityStructure
? _buildCommunityStructureArea(context, screenSize) ? _buildCommunityStructureArea(context, screenSize)
: CommunityListViewWidget( : CommunityListViewWidget(
communities: communities, communities: communities,
onCommunitySelected: (community) {
setState(() {
selectedCommunity = community;
showCommunityStructure = true;
});
},
), ),
], ],
), ),
const GradientBorderWidget() const GradientCanvasBorderWidget()
], ],
); );
} }

View File

@ -1,7 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:syncrow_web/utils/color_manager.dart'; import 'package:syncrow_web/utils/color_manager.dart';
class GradientBorderWidget extends StatelessWidget { class GradientCanvasBorderWidget extends StatelessWidget {
final double top; final double top;
final double bottom; final double bottom;
final double left; final double left;