Compare commits

...

4 Commits

4 changed files with 24 additions and 16 deletions

View File

@ -2,6 +2,8 @@ import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/models/space_details_model.dart';
abstract final class SpacesRecursiveHelper {
const SpacesRecursiveHelper._();
static List<SpaceModel> recusrivelyUpdate(
List<SpaceModel> spaces,
SpaceDetailsModel updatedSpace,
@ -41,20 +43,26 @@ abstract final class SpacesRecursiveHelper {
return nonNullSpaces;
}
static List<SpaceModel> recusrivelyInsert(
List<SpaceModel> spaces,
SpaceModel newSpace,
String parentUuid,
) {
static List<SpaceModel> recursivelyInsert({
required List<SpaceModel> spaces,
required String parentUuid,
required SpaceModel newSpace,
}) {
return spaces.map((space) {
if (space.uuid == parentUuid) {
final isParentSpace = space.uuid == parentUuid;
if (isParentSpace) {
return space.copyWith(
children: [...space.children, newSpace],
);
}
if (space.children.isNotEmpty) {
final hasChildren = space.children.isNotEmpty;
if (hasChildren) {
return space.copyWith(
children: recusrivelyInsert(space.children, newSpace, parentUuid),
children: recursivelyInsert(
spaces: space.children,
parentUuid: parentUuid,
newSpace: newSpace,
),
);
}
return space;

View File

@ -330,10 +330,10 @@ class _CommunityStructureCanvasState extends State<CommunityStructureCanvas>
communityUuid: widget.community.uuid,
parentUuid: space.uuid,
onSuccess: (updatedSpaceModel) {
final updatedSpaces = SpacesRecursiveHelper.recusrivelyInsert(
spaces,
updatedSpaceModel,
space.uuid,
final updatedSpaces = SpacesRecursiveHelper.recursivelyInsert(
spaces: widget.community.spaces,
parentUuid: space.uuid,
newSpace: updatedSpaceModel,
);
context.read<CommunitiesBloc>().add(
CommunitiesUpdateCommunity(

View File

@ -20,9 +20,9 @@ class CommunityStructureHeader extends StatelessWidget {
color: ColorsManager.whiteColors,
boxShadow: [
BoxShadow(
color: ColorsManager.shadowBlackColor,
blurRadius: 8,
offset: const Offset(0, 4),
color: ColorsManager.shadowBlackColor.withValues(alpha: 0.1),
blurRadius: 20,
offset: const Offset(0, 1),
),
],
),

View File

@ -13,7 +13,7 @@ class CreateSpaceParam {
Map<String, dynamic> toJson() {
return {
'spaceModelUuid': parentUuid,
'parentUuid': parentUuid,
...space.toJson(),
'x': 0,
'y': 0,