mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
added position elements to space
This commit is contained in:
@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user