added position elements to space

This commit is contained in:
hannathkadher
2024-10-08 11:39:10 +04:00
parent cdd22f8d76
commit 081d6fd65f
8 changed files with 342 additions and 198 deletions

View File

@ -1,3 +1,4 @@
import 'dart:ui';
import 'package:syncrow_web/pages/spaces_management/model/community_model.dart';
class SpaceModel {
@ -11,7 +12,10 @@ class SpaceModel {
final bool isParent;
final SpaceModel? parent;
final CommunityModel? community;
final List<SpaceModel> children; // List of child spaces
final List<SpaceModel> children;
final String icon;
Offset position;
bool isHovered;
SpaceModel({
required this.uuid,
@ -25,6 +29,9 @@ class SpaceModel {
this.parent,
this.community,
required this.children,
required this.icon,
required this.position,
this.isHovered = false,
});
factory SpaceModel.fromJson(Map<String, dynamic> json) {
@ -47,6 +54,11 @@ class SpaceModel {
.map((child) => SpaceModel.fromJson(child))
.toList()
: [],
icon: json['icon'], // New field from JSON
position: json['position'] != null
? Offset(json['position']['dx'], json['position']['dy'])
: Offset(0, 0), // Default position if not provided in JSON
isHovered: json['isHovered'] ?? false, // Default isHovered if not in JSON
);
}
@ -63,6 +75,9 @@ class SpaceModel {
'parent': parent?.toMap(),
'community': community?.toMap(),
'children': children.map((child) => child.toMap()).toList(),
'icon': icon,
'position': {'dx': position.dx, 'dy': position.dy},
'isHovered': isHovered,
};
}
}