mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
added the tap gesture for creating community
This commit is contained in:
@ -4,6 +4,7 @@ import 'package:syncrow_web/common/custom_expansion_tile.dart';
|
|||||||
import 'package:syncrow_web/common/search_bar.dart';
|
import 'package:syncrow_web/common/search_bar.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/model/space_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/model/space_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/view/community_tile.dart';
|
import 'package:syncrow_web/pages/spaces_management/view/community_tile.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/view/dialogs/create_community_dialog.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
import 'package:syncrow_web/utils/style.dart';
|
import 'package:syncrow_web/utils/style.dart';
|
||||||
@ -40,13 +41,29 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
// Helper function to log the spaces and their children
|
// Helper function to log the spaces and their children
|
||||||
void _logSpaces(List<SpaceModel> spaces, int level) {
|
void _logSpaces(List<SpaceModel> spaces, int level) {
|
||||||
for (SpaceModel space in spaces) {
|
for (SpaceModel space in spaces) {
|
||||||
debugPrint('${' ' * level}Space: ${space.name}, UUID: ${space.uuid}, Has children: ${space.children.isNotEmpty}');
|
debugPrint(
|
||||||
|
'${' ' * level}Space: ${space.name}, UUID: ${space.uuid}, Has children: ${space.children.isNotEmpty}');
|
||||||
if (space.children.isNotEmpty) {
|
if (space.children.isNotEmpty) {
|
||||||
_logSpaces(space.children, level + 1);
|
_logSpaces(space.children, level + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _showCreateCommunityDialog() {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => CreateCommunityDialog(
|
||||||
|
onCreateCommunity: (String communityName) {
|
||||||
|
setState(() {
|
||||||
|
debugPrint("hello");
|
||||||
|
|
||||||
|
// You can update the communitySpaces map here
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Function to filter communities based on the search query
|
// Function to filter communities based on the search query
|
||||||
Map<String, List<SpaceModel>> _filterCommunities() {
|
Map<String, List<SpaceModel>> _filterCommunities() {
|
||||||
if (_searchQuery.isEmpty) {
|
if (_searchQuery.isEmpty) {
|
||||||
@ -57,8 +74,8 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
final filteredCommunitySpaces = <String, List<SpaceModel>>{};
|
final filteredCommunitySpaces = <String, List<SpaceModel>>{};
|
||||||
widget.communitySpaces.forEach((communityName, spaces) {
|
widget.communitySpaces.forEach((communityName, spaces) {
|
||||||
if (communityName.toLowerCase().contains(_searchQuery.toLowerCase()) ||
|
if (communityName.toLowerCase().contains(_searchQuery.toLowerCase()) ||
|
||||||
spaces.any((space) =>
|
spaces.any(
|
||||||
_containsQuery(space, _searchQuery.toLowerCase()))) {
|
(space) => _containsQuery(space, _searchQuery.toLowerCase()))) {
|
||||||
filteredCommunitySpaces[communityName] = spaces;
|
filteredCommunitySpaces[communityName] = spaces;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -101,7 +118,7 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
),
|
),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// Handle add button action
|
_showCreateCommunityDialog();
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 30,
|
width: 30,
|
||||||
@ -135,7 +152,8 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: filteredCommunities.keys.map((communityName) {
|
children: filteredCommunities.keys.map((communityName) {
|
||||||
return _buildCommunityTile(communityName, filteredCommunities[communityName]!);
|
return _buildCommunityTile(
|
||||||
|
communityName, filteredCommunities[communityName]!);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -147,12 +165,14 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
Widget _buildCommunityTile(String communityName, List<SpaceModel> spaces) {
|
Widget _buildCommunityTile(String communityName, List<SpaceModel> spaces) {
|
||||||
bool hasChildren = spaces.isNotEmpty;
|
bool hasChildren = spaces.isNotEmpty;
|
||||||
|
|
||||||
debugPrint('Building CommunityTile for $communityName, hasChildren: $hasChildren');
|
debugPrint(
|
||||||
|
'Building CommunityTile for $communityName, hasChildren: $hasChildren');
|
||||||
return CommunityTile(
|
return CommunityTile(
|
||||||
title: communityName,
|
title: communityName,
|
||||||
isExpanded: _expandedTiles[communityName] ?? false,
|
isExpanded: _expandedTiles[communityName] ?? false,
|
||||||
onExpansionChanged: (String title, bool expanded) {
|
onExpansionChanged: (String title, bool expanded) {
|
||||||
debugPrint('CommunityTile onExpansionChanged called for $title, expanded: $expanded');
|
debugPrint(
|
||||||
|
'CommunityTile onExpansionChanged called for $title, expanded: $expanded');
|
||||||
_handleExpansionChange(title, expanded);
|
_handleExpansionChange(title, expanded);
|
||||||
},
|
},
|
||||||
children: hasChildren
|
children: hasChildren
|
||||||
@ -162,16 +182,20 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildSpaceTile(SpaceModel space) {
|
Widget _buildSpaceTile(SpaceModel space) {
|
||||||
debugPrint('Building SpaceTile for ${space.name}, hasChildren: ${space.children.isNotEmpty}');
|
debugPrint(
|
||||||
|
'Building SpaceTile for ${space.name}, hasChildren: ${space.children.isNotEmpty}');
|
||||||
return CustomExpansionTile(
|
return CustomExpansionTile(
|
||||||
title: space.name,
|
title: space.name,
|
||||||
isExpanded: _expandedTiles[space.uuid] ?? false,
|
isExpanded: _expandedTiles[space.uuid] ?? false,
|
||||||
onExpansionChanged: (bool expanded) {
|
onExpansionChanged: (bool expanded) {
|
||||||
debugPrint('SpaceTile onExpansionChanged called for ${space.name}, expanded: $expanded');
|
debugPrint(
|
||||||
|
'SpaceTile onExpansionChanged called for ${space.name}, expanded: $expanded');
|
||||||
_handleExpansionChange(space.uuid, expanded);
|
_handleExpansionChange(space.uuid, expanded);
|
||||||
},
|
},
|
||||||
children: space.children.isNotEmpty
|
children: space.children.isNotEmpty
|
||||||
? space.children.map((childSpace) => _buildSpaceTile(childSpace)).toList()
|
? space.children
|
||||||
|
.map((childSpace) => _buildSpaceTile(childSpace))
|
||||||
|
.toList()
|
||||||
: [], // Recursively render child spaces if available
|
: [], // Recursively render child spaces if available
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user