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 {
final List<CommunityModel> 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

View File

@ -30,6 +30,9 @@ class SpaceManagementPageState extends State<SpaceManagementPage> {
// 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<SpaceManagementPage> {
SidebarWidget(
communities: communities,
onCommunitySelected: (community) {
context.read<SpaceManagementBloc>().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()
],
);
}

View File

@ -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;