updated the duplicate

This commit is contained in:
hannathkadher
2025-01-27 14:21:07 +04:00
parent d0c6b13072
commit c72297e0c8
2 changed files with 30 additions and 2 deletions

View File

@ -703,8 +703,28 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
}
});
Offset childStartPosition = newPosition + Offset(0, verticalGap);
final childrenWithDownDirection = original.children
.where((child) =>
child.incomingConnection?.direction == "down" &&
child.status != SpaceStatus.deleted)
.toList();
Offset childStartPosition = childrenWithDownDirection.length == 1
? duplicated.position
: newPosition + Offset(0, verticalGap);
for (final child in original.children) {
final isDownDirection =
child.incomingConnection?.direction == "down" ?? false;
if (isDownDirection && childrenWithDownDirection.length == 1) {
// Place the only "down" child vertically aligned with the parent
childStartPosition = duplicated.position + Offset(0, verticalGap);
} else if (!isDownDirection) {
// Position children with other directions horizontally
childStartPosition = duplicated.position + Offset(horizontalGap, 0);
}
final duplicatedChild =
duplicateRecursive(child, childStartPosition, duplicated);
duplicated.children.add(duplicatedChild);