added internal id for mapping spaces internally

This commit is contained in:
hannathkadher
2024-11-27 19:17:15 +04:00
parent 2d7415448c
commit 79b3d116ca
4 changed files with 45 additions and 43 deletions

View File

@ -286,6 +286,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
if (parentIndex != null && direction != null) {
SpaceModel parentSpace = spaces[parentIndex];
parentSpace.internalId = spaces[parentIndex].internalId;
newSpace.parent = parentSpace;
final newConnection = Connection(
startSpace: parentSpace,
@ -371,13 +372,11 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
for (var child in parent.children) {
if (child.status == SpaceStatus.deleted) continue;
// Create a connection object
connections.add(
Connection(
startSpace: parent,
endSpace: child,
direction: child.incomingConnection?.direction ??
"down", // Assuming "down" for all direct children
direction: child.incomingConnection?.direction ?? "down",
),
);
@ -478,11 +477,15 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
bool _isHighlightedSpace(SpaceModel space) {
if (widget.selectedSpace == null) return true;
if (space == widget.selectedSpace) return true;
if (widget.selectedSpace?.parent?.name == space.name &&
widget.selectedSpace?.parent?.position == space.position) return true;
if (widget.selectedSpace?.children.contains(space) == true) return true;
return false; // Otherwise, reduce opacity
if (widget.selectedSpace?.parent?.internalId == space.internalId) return true;
if (widget.selectedSpace?.children != null) {
for (var child in widget.selectedSpace!.children) {
if (child.internalId == space.internalId) {
return true;
}
}
}
return false;
}
void _deselectSpace() {