mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
fixed spaces api
This commit is contained in:
12
lib/pages/spaces_management/model/connection_model.dart
Normal file
12
lib/pages/spaces_management/model/connection_model.dart
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import 'package:syncrow_web/pages/spaces_management/model/space_data_model.dart';
|
||||||
|
|
||||||
|
class Connection {
|
||||||
|
final SpaceData startSpace;
|
||||||
|
final SpaceData endSpace;
|
||||||
|
final String direction;
|
||||||
|
|
||||||
|
Connection(
|
||||||
|
{required this.startSpace,
|
||||||
|
required this.endSpace,
|
||||||
|
required this.direction});
|
||||||
|
}
|
15
lib/pages/spaces_management/model/space_data_model.dart
Normal file
15
lib/pages/spaces_management/model/space_data_model.dart
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
|
class SpaceData {
|
||||||
|
final String name;
|
||||||
|
final String icon;
|
||||||
|
Offset position;
|
||||||
|
bool isHovered;
|
||||||
|
|
||||||
|
SpaceData({
|
||||||
|
required this.name,
|
||||||
|
required this.icon,
|
||||||
|
required this.position,
|
||||||
|
this.isHovered = false,
|
||||||
|
});
|
||||||
|
}
|
@ -9,7 +9,6 @@ class SpaceModel {
|
|||||||
final String name;
|
final String name;
|
||||||
final bool isPrivate;
|
final bool isPrivate;
|
||||||
final String? invitationCode;
|
final String? invitationCode;
|
||||||
final bool isParent;
|
|
||||||
final SpaceModel? parent;
|
final SpaceModel? parent;
|
||||||
final CommunityModel? community;
|
final CommunityModel? community;
|
||||||
final List<SpaceModel> children;
|
final List<SpaceModel> children;
|
||||||
@ -25,7 +24,6 @@ class SpaceModel {
|
|||||||
required this.name,
|
required this.name,
|
||||||
required this.isPrivate,
|
required this.isPrivate,
|
||||||
this.invitationCode,
|
this.invitationCode,
|
||||||
required this.isParent,
|
|
||||||
this.parent,
|
this.parent,
|
||||||
this.community,
|
this.community,
|
||||||
required this.children,
|
required this.children,
|
||||||
@ -40,10 +38,9 @@ class SpaceModel {
|
|||||||
createdAt: DateTime.parse(json['createdAt']),
|
createdAt: DateTime.parse(json['createdAt']),
|
||||||
updatedAt: DateTime.parse(json['updatedAt']),
|
updatedAt: DateTime.parse(json['updatedAt']),
|
||||||
spaceTuyaUuid: json['spaceTuyaUuid'],
|
spaceTuyaUuid: json['spaceTuyaUuid'],
|
||||||
name: json['name'],
|
name: json['spaceName'],
|
||||||
isPrivate: json['isPrivate'],
|
isPrivate: json['isPrivate'] ?? false,
|
||||||
invitationCode: json['invitationCode'],
|
invitationCode: json['invitationCode'],
|
||||||
isParent: json['isParent'],
|
|
||||||
parent:
|
parent:
|
||||||
json['parent'] != null ? SpaceModel.fromJson(json['parent']) : null,
|
json['parent'] != null ? SpaceModel.fromJson(json['parent']) : null,
|
||||||
community: json['community'] != null
|
community: json['community'] != null
|
||||||
@ -54,7 +51,7 @@ class SpaceModel {
|
|||||||
.map((child) => SpaceModel.fromJson(child))
|
.map((child) => SpaceModel.fromJson(child))
|
||||||
.toList()
|
.toList()
|
||||||
: [],
|
: [],
|
||||||
icon: json['icon'],
|
icon: json['icon'] as String?,
|
||||||
position: json['position'] != null
|
position: json['position'] != null
|
||||||
? Offset(json['position']['dx'], json['position']['dy'])
|
? Offset(json['position']['dx'], json['position']['dy'])
|
||||||
: const Offset(0, 0),
|
: const Offset(0, 0),
|
||||||
@ -71,7 +68,6 @@ class SpaceModel {
|
|||||||
'name': name,
|
'name': name,
|
||||||
'isPrivate': isPrivate,
|
'isPrivate': isPrivate,
|
||||||
'invitationCode': invitationCode,
|
'invitationCode': invitationCode,
|
||||||
'isParent': isParent,
|
|
||||||
'parent': parent?.toMap(),
|
'parent': parent?.toMap(),
|
||||||
'community': community?.toMap(),
|
'community': community?.toMap(),
|
||||||
'children': children.map((child) => child.toMap()).toList(),
|
'children': children.map((child) => child.toMap()).toList(),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/view/spaces_management_page.dart';
|
import 'package:syncrow_web/pages/spaces_management/model/connection_model.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
class CurvedLinePainter extends CustomPainter {
|
class CurvedLinePainter extends CustomPainter {
|
||||||
|
@ -7,6 +7,8 @@ import 'package:syncrow_web/pages/spaces_management/bloc/space_management_bloc.d
|
|||||||
import 'package:syncrow_web/pages/spaces_management/bloc/space_management_event.dart';
|
import 'package:syncrow_web/pages/spaces_management/bloc/space_management_event.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/bloc/space_management_state.dart';
|
import 'package:syncrow_web/pages/spaces_management/bloc/space_management_state.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/model/community_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/model/community_model.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/model/connection_model.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/model/space_data_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/model/space_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/model/space_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/view/curved_line_painter.dart';
|
import 'package:syncrow_web/pages/spaces_management/view/curved_line_painter.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/view/dialogs/create_space_dialog.dart';
|
import 'package:syncrow_web/pages/spaces_management/view/dialogs/create_space_dialog.dart';
|
||||||
@ -172,7 +174,7 @@ class SpaceManagementPageState extends State<SpaceManagementPage> {
|
|||||||
selectedCommunity!.name, // Show community name
|
selectedCommunity!.name, // Show community name
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
color: ColorsManager.blackColor, // Slightly muted color
|
color: ColorsManager.blackColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
@ -294,31 +296,3 @@ class SpaceManagementPageState extends State<SpaceManagementPage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to open the Create Space dialog
|
|
||||||
|
|
||||||
// Model for storing space information
|
|
||||||
class SpaceData {
|
|
||||||
final String name;
|
|
||||||
final String icon;
|
|
||||||
Offset position;
|
|
||||||
bool isHovered;
|
|
||||||
|
|
||||||
SpaceData({
|
|
||||||
required this.name,
|
|
||||||
required this.icon,
|
|
||||||
required this.position,
|
|
||||||
this.isHovered = false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Class for connection lines between spaces
|
|
||||||
class Connection {
|
|
||||||
final SpaceData startSpace;
|
|
||||||
final SpaceData endSpace;
|
|
||||||
final String direction;
|
|
||||||
|
|
||||||
Connection(
|
|
||||||
{required this.startSpace,
|
|
||||||
required this.endSpace,
|
|
||||||
required this.direction});
|
|
||||||
}
|
|
||||||
|
@ -50,7 +50,7 @@ abstract class ApiEndpoints {
|
|||||||
static const String getSpace =
|
static const String getSpace =
|
||||||
'/communities/{communityId}/spaces/{spaceId}';
|
'/communities/{communityId}/spaces/{spaceId}';
|
||||||
static const String getSpaceHierarchy =
|
static const String getSpaceHierarchy =
|
||||||
'/communities/{communityId}/spaces/hierarchy';
|
'/communities/{communityId}/spaces';
|
||||||
|
|
||||||
// Community Module
|
// Community Module
|
||||||
static const String createCommunity = '/communities';
|
static const String createCommunity = '/communities';
|
||||||
|
Reference in New Issue
Block a user