pass selected space

This commit is contained in:
hannathkadher
2024-11-19 18:16:53 +04:00
parent a464788e88
commit 8a2efb2694
4 changed files with 29 additions and 8 deletions

View File

@ -15,9 +15,11 @@ import 'package:syncrow_web/utils/style.dart';
class SidebarWidget extends StatefulWidget {
final Function(CommunityModel)? onCommunitySelected;
final Function(SpaceModel)? onSpaceSelected;
final List<CommunityModel> communities;
const SidebarWidget({super.key, this.onCommunitySelected, required this.communities});
const SidebarWidget(
{super.key, this.onCommunitySelected, this.onSpaceSelected, required this.communities});
@override
_SidebarWidgetState createState() => _SidebarWidgetState();
@ -204,11 +206,14 @@ class _SidebarWidgetState extends State<SidebarWidget> {
onExpansionChanged: (bool expanded) {
_handleExpansionChange(space.uuid ?? '', expanded);
},
onItemSelected: () => {
if (widget.onCommunitySelected != null)
{
widget.onCommunitySelected!(community) // Pass the entire community
}
onItemSelected: () {
if (widget.onCommunitySelected != null || widget.onSpaceSelected != null) {
widget.onCommunitySelected!(community); // Pass the entire community
}
if (widget.onSpaceSelected != null) {
widget.onSpaceSelected!(space); // Pass the entire community
}
},
children: space.children.isNotEmpty
? space.children.map((childSpace) => _buildSpaceTile(childSpace, community)).toList()