mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
formatted all files.
This commit is contained in:
@ -1,20 +1,19 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_event.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_state.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_event.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_state.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/create_subspace_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_event.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_state.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/subspace_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_body_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_update_model.dart';
|
||||
import 'package:syncrow_web/services/product_api.dart';
|
||||
import 'package:syncrow_web/services/space_mana_api.dart';
|
||||
@ -57,10 +56,10 @@ class SpaceManagementBloc
|
||||
UpdateSpaceModelCache event, Emitter<SpaceManagementState> emit) async {
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
List<SpaceTemplateModel> allSpaceModels = [];
|
||||
final allSpaceModels = <SpaceTemplateModel>[];
|
||||
|
||||
bool hasNext = true;
|
||||
int page = 1;
|
||||
var hasNext = true;
|
||||
var page = 1;
|
||||
|
||||
while (hasNext) {
|
||||
final spaceModels = await _spaceModelApi.listSpaceModels(
|
||||
@ -85,7 +84,7 @@ class SpaceManagementBloc
|
||||
allTags: _cachedTags ?? []));
|
||||
}
|
||||
|
||||
void _deleteSpaceModelFromCache(DeleteSpaceModelFromCache event,
|
||||
Future<void> _deleteSpaceModelFromCache(DeleteSpaceModelFromCache event,
|
||||
Emitter<SpaceManagementState> emit) async {
|
||||
if (_cachedSpaceModels != null) {
|
||||
_cachedSpaceModels = _cachedSpaceModels!
|
||||
@ -121,10 +120,10 @@ class SpaceManagementBloc
|
||||
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
List<SpaceTemplateModel> allSpaceModels = [];
|
||||
final allSpaceModels = <SpaceTemplateModel>[];
|
||||
|
||||
bool hasNext = true;
|
||||
int page = 1;
|
||||
var hasNext = true;
|
||||
var page = 1;
|
||||
|
||||
while (hasNext) {
|
||||
final spaceModels = await _spaceModelApi.listSpaceModels(
|
||||
@ -159,7 +158,7 @@ class SpaceManagementBloc
|
||||
}
|
||||
}
|
||||
|
||||
void _onUpdateCommunity(
|
||||
Future<void> _onUpdateCommunity(
|
||||
UpdateCommunityEvent event,
|
||||
Emitter<SpaceManagementState> emit,
|
||||
) async {
|
||||
@ -175,7 +174,7 @@ class SpaceManagementBloc
|
||||
if (previousState is SpaceManagementLoaded) {
|
||||
final updatedCommunities =
|
||||
List<CommunityModel>.from(previousState.communities);
|
||||
for (var community in updatedCommunities) {
|
||||
for (final community in updatedCommunities) {
|
||||
if (community.uuid == event.communityUuid) {
|
||||
community.name = event.name;
|
||||
_spaceTreeBloc.add(OnCommunityAdded(community));
|
||||
@ -184,7 +183,7 @@ class SpaceManagementBloc
|
||||
}
|
||||
}
|
||||
|
||||
var prevSpaceModels = await fetchSpaceModels();
|
||||
final prevSpaceModels = await fetchSpaceModels();
|
||||
|
||||
emit(SpaceManagementLoaded(
|
||||
communities: updatedCommunities,
|
||||
@ -201,14 +200,14 @@ class SpaceManagementBloc
|
||||
}
|
||||
}
|
||||
|
||||
void _onloadProducts() async {
|
||||
Future<void> _onloadProducts() async {
|
||||
if (_cachedProducts == null) {
|
||||
final products = await _productApi.fetchProducts();
|
||||
_cachedProducts = products;
|
||||
}
|
||||
}
|
||||
|
||||
void _onFetchProducts(
|
||||
Future<void> _onFetchProducts(
|
||||
FetchProductsEvent event,
|
||||
Emitter<SpaceManagementState> emit,
|
||||
) async {
|
||||
@ -223,7 +222,7 @@ class SpaceManagementBloc
|
||||
String communityUuid) async {
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
return await _api.getSpaceHierarchy(communityUuid, projectUuid);
|
||||
return _api.getSpaceHierarchy(communityUuid, projectUuid);
|
||||
}
|
||||
|
||||
Future<void> _onNewCommunity(
|
||||
@ -238,7 +237,7 @@ class SpaceManagementBloc
|
||||
return;
|
||||
}
|
||||
|
||||
var prevSpaceModels = await fetchSpaceModels();
|
||||
final prevSpaceModels = await fetchSpaceModels();
|
||||
|
||||
emit(BlankState(
|
||||
communities: event.communities,
|
||||
@ -255,15 +254,15 @@ class SpaceManagementBloc
|
||||
try {
|
||||
final previousState = state;
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
var spaceBloc = event.context.read<SpaceTreeBloc>();
|
||||
var spaceTreeState = event.context.read<SpaceTreeBloc>().state;
|
||||
final spaceBloc = event.context.read<SpaceTreeBloc>();
|
||||
final spaceTreeState = event.context.read<SpaceTreeBloc>().state;
|
||||
|
||||
List<CommunityModel> communities =
|
||||
final communities =
|
||||
await _waitForCommunityList(spaceBloc, spaceTreeState);
|
||||
await fetchSpaceModels();
|
||||
// await fetchTags();
|
||||
|
||||
var prevSpaceModels = await fetchSpaceModels();
|
||||
final prevSpaceModels = await fetchSpaceModels();
|
||||
|
||||
if (previousState is SpaceManagementLoaded ||
|
||||
previousState is BlankState) {
|
||||
@ -287,18 +286,17 @@ class SpaceManagementBloc
|
||||
}
|
||||
}
|
||||
|
||||
void _onLoadCommunityAndSpaces(
|
||||
Future<void> _onLoadCommunityAndSpaces(
|
||||
LoadCommunityAndSpacesEvent event,
|
||||
Emitter<SpaceManagementState> emit,
|
||||
) async {
|
||||
var spaceTreeState = event.context.read<SpaceTreeBloc>().state;
|
||||
var spaceBloc = event.context.read<SpaceTreeBloc>();
|
||||
final spaceTreeState = event.context.read<SpaceTreeBloc>().state;
|
||||
final spaceBloc = event.context.read<SpaceTreeBloc>();
|
||||
|
||||
_onloadProducts();
|
||||
await fetchTags();
|
||||
// Wait until `communityList` is loaded
|
||||
List<CommunityModel> communities =
|
||||
await _waitForCommunityList(spaceBloc, spaceTreeState);
|
||||
final communities = await _waitForCommunityList(spaceBloc, spaceTreeState);
|
||||
|
||||
// Fetch space models after communities are available
|
||||
final prevSpaceModels = await fetchSpaceModels();
|
||||
@ -344,7 +342,7 @@ class SpaceManagementBloc
|
||||
}
|
||||
}
|
||||
|
||||
void _onCommunityDelete(
|
||||
Future<void> _onCommunityDelete(
|
||||
DeleteCommunityEvent event,
|
||||
Emitter<SpaceManagementState> emit,
|
||||
) async {
|
||||
@ -365,7 +363,7 @@ class SpaceManagementBloc
|
||||
}
|
||||
}
|
||||
|
||||
void _onCreateCommunity(
|
||||
Future<void> _onCreateCommunity(
|
||||
CreateCommunityEvent event,
|
||||
Emitter<SpaceManagementState> emit,
|
||||
) async {
|
||||
@ -375,9 +373,9 @@ class SpaceManagementBloc
|
||||
try {
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
await fetchTags();
|
||||
CommunityModel? newCommunity = await _api.createCommunity(
|
||||
final newCommunity = await _api.createCommunity(
|
||||
event.name, event.description, projectUuid);
|
||||
var prevSpaceModels = await fetchSpaceModels();
|
||||
final prevSpaceModels = await fetchSpaceModels();
|
||||
|
||||
if (newCommunity != null) {
|
||||
if (previousState is SpaceManagementLoaded ||
|
||||
@ -405,7 +403,7 @@ class SpaceManagementBloc
|
||||
}
|
||||
}
|
||||
|
||||
void _onSelectCommunity(
|
||||
Future<void> _onSelectCommunity(
|
||||
SelectCommunityEvent event,
|
||||
Emitter<SpaceManagementState> emit,
|
||||
) async {
|
||||
@ -431,7 +429,7 @@ class SpaceManagementBloc
|
||||
);
|
||||
}
|
||||
|
||||
void _handleCommunitySpaceStateUpdate({
|
||||
Future<void> _handleCommunitySpaceStateUpdate({
|
||||
required Emitter<SpaceManagementState> emit,
|
||||
CommunityModel? selectedCommunity,
|
||||
SpaceModel? selectedSpace,
|
||||
@ -464,7 +462,7 @@ class SpaceManagementBloc
|
||||
}
|
||||
}
|
||||
|
||||
void _onSaveSpaces(
|
||||
Future<void> _onSaveSpaces(
|
||||
SaveSpacesEvent event,
|
||||
Emitter<SpaceManagementState> emit,
|
||||
) async {
|
||||
@ -494,9 +492,9 @@ class SpaceManagementBloc
|
||||
event.spaces.removeWhere(
|
||||
(space) => space.status == SpaceStatus.deleted,
|
||||
);
|
||||
event.spaces.forEach(
|
||||
(space) => space.status = SpaceStatus.unchanged,
|
||||
);
|
||||
for (final space in event.spaces) {
|
||||
space.status = SpaceStatus.unchanged;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// emit(SpaceManagementError('Error saving spaces: $e'));
|
||||
@ -515,7 +513,7 @@ class SpaceManagementBloc
|
||||
Emitter<SpaceManagementState> emit,
|
||||
) async {
|
||||
try {
|
||||
var prevSpaceModels = await fetchSpaceModels();
|
||||
final prevSpaceModels = await fetchSpaceModels();
|
||||
|
||||
await fetchTags();
|
||||
|
||||
@ -523,7 +521,7 @@ class SpaceManagementBloc
|
||||
? spaceTreeState.filteredCommunity
|
||||
: spaceTreeState.communityList;
|
||||
|
||||
for (var community in communities) {
|
||||
for (final community in communities) {
|
||||
if (community.uuid == communityUuid) {
|
||||
community.spaces = allSpaces;
|
||||
_spaceTreeBloc.add(InitialEvent());
|
||||
@ -540,7 +538,7 @@ class SpaceManagementBloc
|
||||
}
|
||||
}
|
||||
emit(previousState);
|
||||
} catch (e, stackTrace) {
|
||||
} catch (e) {
|
||||
emit(previousState);
|
||||
// rethrow;
|
||||
}
|
||||
@ -577,36 +575,36 @@ class SpaceManagementBloc
|
||||
space.status == SpaceStatus.deleted &&
|
||||
(space.parent == null || space.parent?.status != SpaceStatus.deleted));
|
||||
|
||||
for (var parent in parentsToDelete) {
|
||||
for (final parent in parentsToDelete) {
|
||||
try {
|
||||
if (parent.uuid != null) {
|
||||
await _api.deleteSpace(communityUuid, parent.uuid!, projectUuid);
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
orderedSpaces.removeWhere((space) => parentsToDelete.contains(space));
|
||||
orderedSpaces.removeWhere(parentsToDelete.contains);
|
||||
|
||||
for (var space in orderedSpaces) {
|
||||
for (final space in orderedSpaces) {
|
||||
try {
|
||||
if (space.uuid != null && space.uuid!.isNotEmpty) {
|
||||
List<TagModelUpdate> tagUpdates = [];
|
||||
var tagUpdates = <TagModelUpdate>[];
|
||||
|
||||
List<SpaceModel> matchedSpaces =
|
||||
final matchedSpaces =
|
||||
findMatchingSpaces(selectedCommunity.spaces, space.uuid!);
|
||||
|
||||
if (matchedSpaces.isEmpty) continue;
|
||||
|
||||
final prevSpace = matchedSpaces.elementAtOrNull(0);
|
||||
|
||||
final List<UpdateSubspaceTemplateModel> subspaceUpdates = [];
|
||||
final List<SubspaceModel>? prevSubspaces = prevSpace?.subspaces;
|
||||
final List<SubspaceModel>? newSubspaces = space.subspaces;
|
||||
final subspaceUpdates = <UpdateSubspaceTemplateModel>[];
|
||||
final prevSubspaces = prevSpace?.subspaces;
|
||||
final newSubspaces = space.subspaces;
|
||||
|
||||
tagUpdates = processTagUpdates(prevSpace?.tags, space.tags);
|
||||
|
||||
if (prevSubspaces != null || newSubspaces != null) {
|
||||
if (prevSubspaces != null && newSubspaces != null) {
|
||||
for (var prevSubspace in prevSubspaces) {
|
||||
for (final prevSubspace in prevSubspaces) {
|
||||
final existsInNew = newSubspaces
|
||||
.any((subspace) => subspace.uuid == prevSubspace.uuid);
|
||||
if (!existsInNew) {
|
||||
@ -616,7 +614,7 @@ class SpaceManagementBloc
|
||||
}
|
||||
}
|
||||
} else if (prevSubspaces != null && newSubspaces == null) {
|
||||
for (var prevSubspace in prevSubspaces) {
|
||||
for (final prevSubspace in prevSubspaces) {
|
||||
subspaceUpdates.add(UpdateSubspaceTemplateModel(
|
||||
action: custom_action.Action.delete,
|
||||
uuid: prevSubspace.uuid));
|
||||
@ -624,13 +622,13 @@ class SpaceManagementBloc
|
||||
}
|
||||
|
||||
if (newSubspaces != null) {
|
||||
for (var newSubspace in newSubspaces) {
|
||||
for (final newSubspace in newSubspaces) {
|
||||
// Tag without UUID
|
||||
if ((newSubspace.uuid == null || newSubspace.uuid!.isEmpty)) {
|
||||
final List<TagModelUpdate> tagUpdates = [];
|
||||
if (newSubspace.uuid == null || newSubspace.uuid!.isEmpty) {
|
||||
final tagUpdates = <TagModelUpdate>[];
|
||||
|
||||
if (newSubspace.tags != null) {
|
||||
for (var tag in newSubspace.tags!) {
|
||||
for (final tag in newSubspace.tags!) {
|
||||
tagUpdates.add(TagModelUpdate(
|
||||
action: custom_action.Action.add,
|
||||
newTagUuid: tag.uuid == '' ? null : tag.uuid,
|
||||
@ -648,14 +646,14 @@ class SpaceManagementBloc
|
||||
|
||||
if (prevSubspaces != null && newSubspaces != null) {
|
||||
final newSubspaceMap = {
|
||||
for (var subspace in newSubspaces) subspace.uuid: subspace
|
||||
for (final subspace in newSubspaces) subspace.uuid: subspace
|
||||
};
|
||||
|
||||
for (var prevSubspace in prevSubspaces) {
|
||||
for (final prevSubspace in prevSubspaces) {
|
||||
final newSubspace = newSubspaceMap[prevSubspace.uuid];
|
||||
|
||||
if (newSubspace != null) {
|
||||
final List<TagModelUpdate> tagSubspaceUpdates =
|
||||
final tagSubspaceUpdates =
|
||||
processTagUpdates(prevSubspace.tags, newSubspace.tags);
|
||||
subspaceUpdates.add(UpdateSubspaceTemplateModel(
|
||||
action: custom_action.Action.update,
|
||||
@ -669,7 +667,7 @@ class SpaceManagementBloc
|
||||
|
||||
final response = await _api.updateSpace(
|
||||
communityId: communityUuid,
|
||||
spaceId: space.uuid!,
|
||||
spaceId: space.uuid,
|
||||
name: space.name,
|
||||
parentId: space.parent?.uuid,
|
||||
isPrivate: space.isPrivate,
|
||||
@ -683,7 +681,7 @@ class SpaceManagementBloc
|
||||
projectId: projectUuid);
|
||||
} else {
|
||||
// Call create if the space does not have a UUID
|
||||
List<CreateTagBodyModel> tagBodyModels = space.tags != null
|
||||
var tagBodyModels = space.tags != null
|
||||
? space.tags!.map((tag) => tag.toCreateTagBodyModel()).toList()
|
||||
: [];
|
||||
|
||||
@ -731,17 +729,17 @@ class SpaceManagementBloc
|
||||
void visit(SpaceModel space) {
|
||||
if (!result.contains(space)) {
|
||||
result.add(space);
|
||||
for (var child in spaces.where((s) => s.parent == space)) {
|
||||
for (final child in spaces.where((s) => s.parent == space)) {
|
||||
visit(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var space in topLevelSpaces) {
|
||||
for (final space in topLevelSpaces) {
|
||||
visit(space);
|
||||
}
|
||||
|
||||
for (var space in spaces) {
|
||||
for (final space in spaces) {
|
||||
if (!result.contains(space)) {
|
||||
result.add(space);
|
||||
}
|
||||
@ -749,7 +747,7 @@ class SpaceManagementBloc
|
||||
return result.toList(); // Convert back to a list
|
||||
}
|
||||
|
||||
void _onLoadSpaceModel(
|
||||
Future<void> _onLoadSpaceModel(
|
||||
SpaceModelLoadEvent event, Emitter<SpaceManagementState> emit) async {
|
||||
emit(SpaceManagementLoading());
|
||||
|
||||
@ -760,9 +758,9 @@ class SpaceManagementBloc
|
||||
? spaceTreeState.filteredCommunity
|
||||
: spaceTreeState.communityList;
|
||||
|
||||
List<CommunityModel> communities = filteredCommunities;
|
||||
final communities = filteredCommunities;
|
||||
|
||||
var prevSpaceModels = await fetchSpaceModels();
|
||||
final prevSpaceModels = await fetchSpaceModels();
|
||||
|
||||
emit(SpaceModelLoaded(
|
||||
communities: communities,
|
||||
@ -778,11 +776,11 @@ class SpaceManagementBloc
|
||||
List<Tag>? prevTags,
|
||||
List<Tag>? newTags,
|
||||
) {
|
||||
final List<TagModelUpdate> tagUpdates = [];
|
||||
final tagUpdates = <TagModelUpdate>[];
|
||||
final processedTags = <String?>{};
|
||||
|
||||
if (prevTags == null && newTags != null) {
|
||||
for (var newTag in newTags) {
|
||||
for (final newTag in newTags) {
|
||||
tagUpdates.add(TagModelUpdate(
|
||||
action: custom_action.Action.add,
|
||||
tag: newTag.tag,
|
||||
@ -796,7 +794,7 @@ class SpaceManagementBloc
|
||||
if (newTags != null || prevTags != null) {
|
||||
// Case 1: Tags deleted
|
||||
if (prevTags != null && newTags != null) {
|
||||
for (var prevTag in prevTags) {
|
||||
for (final prevTag in prevTags) {
|
||||
final existsInNew =
|
||||
newTags.any((newTag) => newTag.uuid == prevTag.uuid);
|
||||
if (!existsInNew) {
|
||||
@ -805,7 +803,7 @@ class SpaceManagementBloc
|
||||
}
|
||||
}
|
||||
} else if (prevTags != null && newTags == null) {
|
||||
for (var prevTag in prevTags) {
|
||||
for (final prevTag in prevTags) {
|
||||
tagUpdates.add(TagModelUpdate(
|
||||
action: custom_action.Action.delete, uuid: prevTag.uuid));
|
||||
}
|
||||
@ -815,7 +813,7 @@ class SpaceManagementBloc
|
||||
if (newTags != null) {
|
||||
final prevTagUuids = prevTags?.map((t) => t.uuid).toSet() ?? {};
|
||||
|
||||
for (var newTag in newTags) {
|
||||
for (final newTag in newTags) {
|
||||
// Tag without UUID
|
||||
if ((newTag.uuid == null || !prevTagUuids.contains(newTag.uuid)) &&
|
||||
!processedTags.contains(newTag.tag)) {
|
||||
@ -831,9 +829,9 @@ class SpaceManagementBloc
|
||||
|
||||
// Case 3: Tags updated
|
||||
if (prevTags != null && newTags != null) {
|
||||
final newTagMap = {for (var tag in newTags) tag.uuid: tag};
|
||||
final newTagMap = {for (final tag in newTags) tag.uuid: tag};
|
||||
|
||||
for (var prevTag in prevTags) {
|
||||
for (final prevTag in prevTags) {
|
||||
final newTag = newTagMap[prevTag.uuid];
|
||||
if (newTag != null) {
|
||||
tagUpdates.add(TagModelUpdate(
|
||||
@ -852,9 +850,9 @@ class SpaceManagementBloc
|
||||
|
||||
List<SpaceModel> findMatchingSpaces(
|
||||
List<SpaceModel> spaces, String targetUuid) {
|
||||
List<SpaceModel> matched = [];
|
||||
final matched = <SpaceModel>[];
|
||||
|
||||
for (var space in spaces) {
|
||||
for (final space in spaces) {
|
||||
if (space.uuid == targetUuid) {
|
||||
matched.add(space);
|
||||
}
|
||||
|
@ -166,10 +166,10 @@ class SpaceModelLoadEvent extends SpaceManagementEvent {
|
||||
|
||||
class UpdateSpaceModelCache extends SpaceManagementEvent {
|
||||
final SpaceTemplateModel updatedModel;
|
||||
UpdateSpaceModelCache(this.updatedModel);
|
||||
const UpdateSpaceModelCache(this.updatedModel);
|
||||
}
|
||||
|
||||
class DeleteSpaceModelFromCache extends SpaceManagementEvent {
|
||||
final String deletedUuid;
|
||||
DeleteSpaceModelFromCache(this.deletedUuid);
|
||||
const DeleteSpaceModelFromCache(this.deletedUuid);
|
||||
}
|
||||
|
@ -40,7 +40,10 @@ class BlankState extends SpaceManagementState {
|
||||
final List<Tag> allTags;
|
||||
|
||||
BlankState(
|
||||
{required this.communities, required this.products, this.spaceModels, required this.allTags});
|
||||
{required this.communities,
|
||||
required this.products,
|
||||
this.spaceModels,
|
||||
required this.allTags});
|
||||
}
|
||||
|
||||
class SpaceCreationSuccess extends SpaceManagementState {
|
||||
|
@ -16,7 +16,7 @@ abstract class BaseTag {
|
||||
this.location,
|
||||
}) : internalId = internalId ?? const Uuid().v4();
|
||||
|
||||
Map<String, dynamic> toJson();
|
||||
Map<String, dynamic> toJson();
|
||||
BaseTag copyWith({
|
||||
String? tag,
|
||||
ProductModel? product,
|
||||
|
@ -27,9 +27,12 @@ class CommunityModel {
|
||||
updatedAt: DateTime.parse(json['updatedAt'] ?? ''),
|
||||
name: json['name'] ?? '',
|
||||
description: json['description'] ?? '',
|
||||
region: json['region'] != null ? RegionModel.fromJson(json['region']) : null,
|
||||
region:
|
||||
json['region'] != null ? RegionModel.fromJson(json['region']) : null,
|
||||
spaces: json['spaces'] != null
|
||||
? (json['spaces'] as List).map((space) => SpaceModel.fromJson(space)).toList()
|
||||
? (json['spaces'] as List)
|
||||
.map((space) => SpaceModel.fromJson(space))
|
||||
.toList()
|
||||
: [],
|
||||
);
|
||||
}
|
||||
@ -42,7 +45,9 @@ class CommunityModel {
|
||||
'name': name,
|
||||
'description': description,
|
||||
'region': region?.toJson(),
|
||||
'spaces': spaces.map((space) => space.toMap()).toList(), // Convert spaces to Map
|
||||
'spaces': spaces
|
||||
.map((space) => space.toMap())
|
||||
.toList(), // Convert spaces to Map
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_product_model.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
|
||||
import 'selected_product_model.dart';
|
||||
|
||||
class ProductModel {
|
||||
final String uuid;
|
||||
final String catName;
|
||||
|
@ -6,7 +6,11 @@ class SelectedProduct {
|
||||
final String productName;
|
||||
final ProductModel? product;
|
||||
|
||||
SelectedProduct({required this.productId, required this.count, required this.productName, this.product});
|
||||
SelectedProduct(
|
||||
{required this.productId,
|
||||
required this.count,
|
||||
required this.productName,
|
||||
this.product});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
@ -16,7 +20,7 @@ class SelectedProduct {
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
@override
|
||||
String toString() {
|
||||
return 'SelectedProduct(productId: $productId, count: $count)';
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class SpaceModel {
|
||||
{String? parentInternalId}) {
|
||||
final String internalId = json['internalId'] ?? const Uuid().v4();
|
||||
|
||||
final List<SpaceModel> children = json['children'] != null
|
||||
final children = json['children'] != null
|
||||
? (json['children'] as List).map((childJson) {
|
||||
return SpaceModel.fromJson(
|
||||
childJson,
|
||||
@ -73,8 +73,8 @@ class SpaceModel {
|
||||
isPrivate: json['isPrivate'] ?? false,
|
||||
invitationCode: json['invitationCode'],
|
||||
subspaces: (json['subspaces'] as List<dynamic>?)
|
||||
?.where((e) => e is Map<String, dynamic>) // Validate type
|
||||
.map((e) => SubspaceModel.fromJson(e as Map<String, dynamic>))
|
||||
?.whereType<Map<String, dynamic>>() // Validate type
|
||||
.map(SubspaceModel.fromJson)
|
||||
.toList() ??
|
||||
[],
|
||||
parent: parentInternalId != null
|
||||
@ -102,8 +102,8 @@ class SpaceModel {
|
||||
? SpaceTemplateModel.fromJson(json['spaceModel'])
|
||||
: null,
|
||||
tags: (json['productAllocations'] as List<dynamic>?)
|
||||
?.where((item) => item is Map<String, dynamic>) // Validate type
|
||||
.map((item) => Tag.fromJson(item as Map<String, dynamic>))
|
||||
?.whereType<Map<String, dynamic>>() // Validate type
|
||||
.map(Tag.fromJson)
|
||||
.toList() ??
|
||||
[],
|
||||
);
|
||||
@ -150,7 +150,7 @@ class SpaceModel {
|
||||
|
||||
extension SpaceExtensions on SpaceModel {
|
||||
List<String> listAllTagValues() {
|
||||
final List<String> tagValues = [];
|
||||
final tagValues = <String>[];
|
||||
|
||||
if (tags != null) {
|
||||
tagValues.addAll(
|
||||
@ -174,10 +174,10 @@ extension SpaceExtensions on SpaceModel {
|
||||
|
||||
bool isNoChangesSubmited(String name, icon, SpaceTemplateModel? spaceModel,
|
||||
List<SubspaceModel>? subspaces, List<Tag>? tags) {
|
||||
return (name == this.name &&
|
||||
return name == this.name &&
|
||||
icon == this.icon &&
|
||||
spaceModel == this.spaceModel &&
|
||||
subspaces == this.subspaces &&
|
||||
tags == this.tags);
|
||||
tags == this.tags;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
|
||||
import 'space_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||
|
||||
class SpacesResponse {
|
||||
final List<SpaceModel> data;
|
||||
|
@ -1,9 +1,8 @@
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/utils/constants/action_enum.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
import 'tag.dart';
|
||||
|
||||
class SubspaceModel {
|
||||
final String? uuid;
|
||||
String subspaceName;
|
||||
|
@ -6,18 +6,12 @@ import 'package:uuid/uuid.dart';
|
||||
|
||||
class Tag extends BaseTag {
|
||||
Tag({
|
||||
String? uuid,
|
||||
required String? tag,
|
||||
ProductModel? product,
|
||||
String? internalId,
|
||||
String? location,
|
||||
}) : super(
|
||||
uuid: uuid,
|
||||
tag: tag,
|
||||
product: product,
|
||||
internalId: internalId,
|
||||
location: location,
|
||||
);
|
||||
super.uuid,
|
||||
required super.tag,
|
||||
super.product,
|
||||
super.internalId,
|
||||
super.location,
|
||||
});
|
||||
|
||||
factory Tag.fromJson(Map<String, dynamic> json) {
|
||||
final String internalId = json['internalId'] ?? const Uuid().v4();
|
||||
@ -50,6 +44,7 @@ class Tag extends BaseTag {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
if (uuid != null) 'uuid': uuid,
|
||||
|
@ -2,11 +2,11 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/shared/navigate_home_grid_view.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/structure_selector/bloc/center_body_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_event.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_state.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/loaded_space_widget.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/structure_selector/bloc/center_body_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/structure_selector/view/center_body_widget.dart';
|
||||
import 'package:syncrow_web/services/product_api.dart';
|
||||
import 'package:syncrow_web/services/space_mana_api.dart';
|
||||
@ -47,7 +47,7 @@ class SpaceManagementPageState extends State<SpaceManagementPage> {
|
||||
style: ResponsiveTextTheme.of(context).deviceManagementTitle,
|
||||
),
|
||||
enableMenuSidebar: false,
|
||||
centerBody: CenterBodyWidget(),
|
||||
centerBody: const CenterBodyWidget(),
|
||||
rightBody: const NavigateHomeGridView(),
|
||||
scaffoldBody: BlocBuilder<SpaceManagementBloc, SpaceManagementState>(
|
||||
builder: (context, state) {
|
||||
|
@ -32,8 +32,9 @@ class _AddDeviceWidgetState extends State<AddDeviceWidget> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
_scrollController = ScrollController();
|
||||
productCounts =
|
||||
widget.initialSelectedProducts != null ? List.from(widget.initialSelectedProducts!) : [];
|
||||
productCounts = widget.initialSelectedProducts != null
|
||||
? List.from(widget.initialSelectedProducts!)
|
||||
: [];
|
||||
}
|
||||
|
||||
@override
|
||||
@ -96,10 +97,12 @@ class _AddDeviceWidgetState extends State<AddDeviceWidget> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
_buildActionButton('Cancel', ColorsManager.boxColor, ColorsManager.blackColor, () {
|
||||
_buildActionButton(
|
||||
'Cancel', ColorsManager.boxColor, ColorsManager.blackColor, () {
|
||||
Navigator.of(context).pop();
|
||||
}),
|
||||
_buildActionButton('Continue', ColorsManager.secondaryColor, ColorsManager.whiteColors, () {
|
||||
_buildActionButton('Continue', ColorsManager.secondaryColor,
|
||||
ColorsManager.whiteColors, () {
|
||||
Navigator.of(context).pop();
|
||||
if (widget.onProductsSelected != null) {
|
||||
widget.onProductsSelected!(productCounts);
|
||||
@ -114,7 +117,11 @@ class _AddDeviceWidgetState extends State<AddDeviceWidget> {
|
||||
Widget _buildDeviceTypeTile(ProductModel product, Size size) {
|
||||
final selectedProduct = productCounts.firstWhere(
|
||||
(p) => p.productId == product.uuid,
|
||||
orElse: () => SelectedProduct(productId: product.uuid, count: 0, productName: product.catName, product: product),
|
||||
orElse: () => SelectedProduct(
|
||||
productId: product.uuid,
|
||||
count: 0,
|
||||
productName: product.catName,
|
||||
product: product),
|
||||
);
|
||||
|
||||
return SizedBox(
|
||||
@ -143,13 +150,17 @@ class _AddDeviceWidgetState extends State<AddDeviceWidget> {
|
||||
setState(() {
|
||||
if (newCount > 0) {
|
||||
if (!productCounts.contains(selectedProduct)) {
|
||||
productCounts
|
||||
.add(SelectedProduct(productId: product.uuid, count: newCount, productName: product.catName, product: product));
|
||||
productCounts.add(SelectedProduct(
|
||||
productId: product.uuid,
|
||||
count: newCount,
|
||||
productName: product.catName,
|
||||
product: product));
|
||||
} else {
|
||||
selectedProduct.count = newCount;
|
||||
}
|
||||
} else {
|
||||
productCounts.removeWhere((p) => p.productId == product.uuid);
|
||||
productCounts
|
||||
.removeWhere((p) => p.productId == product.uuid);
|
||||
}
|
||||
|
||||
if (widget.onProductsSelected != null) {
|
||||
@ -192,7 +203,8 @@ class _AddDeviceWidgetState extends State<AddDeviceWidget> {
|
||||
height: size.width > 800 ? 35 : 25,
|
||||
child: Text(
|
||||
product.name ?? '',
|
||||
style: context.textTheme.bodySmall?.copyWith(color: ColorsManager.blackColor),
|
||||
style: context.textTheme.bodySmall
|
||||
?.copyWith(color: ColorsManager.blackColor),
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
|
@ -9,7 +9,7 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
||||
class BlankCommunityWidget extends StatefulWidget {
|
||||
final List<CommunityModel> communities;
|
||||
|
||||
BlankCommunityWidget({required this.communities});
|
||||
const BlankCommunityWidget({super.key, required this.communities});
|
||||
|
||||
@override
|
||||
_BlankCommunityWidgetState createState() => _BlankCommunityWidgetState();
|
||||
@ -19,7 +19,7 @@ class _BlankCommunityWidgetState extends State<BlankCommunityWidget> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child: Container(
|
||||
child: ColoredBox(
|
||||
color:
|
||||
ColorsManager.whiteColors, // Parent container with white background
|
||||
child: GridView.builder(
|
||||
|
@ -36,7 +36,7 @@ class CommunityStructureHeaderActionButtons extends StatelessWidget {
|
||||
children: [
|
||||
if (isSave)
|
||||
CommunityStructureHeaderButton(
|
||||
label: "Save",
|
||||
label: 'Save',
|
||||
icon: const Icon(Icons.save,
|
||||
size: 18, color: ColorsManager.spaceColor),
|
||||
onPressed: onSave,
|
||||
@ -44,19 +44,19 @@ class CommunityStructureHeaderActionButtons extends StatelessWidget {
|
||||
),
|
||||
if (canShowActions) ...[
|
||||
CommunityStructureHeaderButton(
|
||||
label: "Edit",
|
||||
label: 'Edit',
|
||||
svgAsset: Assets.editSpace,
|
||||
onPressed: onEdit,
|
||||
theme: theme,
|
||||
),
|
||||
CommunityStructureHeaderButton(
|
||||
label: "Duplicate",
|
||||
label: 'Duplicate',
|
||||
svgAsset: Assets.duplicate,
|
||||
onPressed: onDuplicate,
|
||||
theme: theme,
|
||||
),
|
||||
CommunityStructureHeaderButton(
|
||||
label: "Delete",
|
||||
label: 'Delete',
|
||||
svgAsset: Assets.spaceDelete,
|
||||
onPressed: onDelete,
|
||||
theme: theme,
|
||||
|
@ -14,7 +14,7 @@ class CommunityStructureHeader extends StatefulWidget {
|
||||
final TextEditingController nameController;
|
||||
final VoidCallback onSave;
|
||||
final VoidCallback onDelete;
|
||||
final VoidCallback onEdit;
|
||||
final VoidCallback onEdit;
|
||||
final VoidCallback onDuplicate;
|
||||
|
||||
final VoidCallback onEditName;
|
||||
|
@ -3,24 +3,23 @@ import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
// Syncrow project imports
|
||||
import 'package:syncrow_web/pages/common/buttons/add_space_button.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/cancel_button.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_event.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/connection_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/connection_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/subspace_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/blank_community_widget.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/community_structure_header_widget.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/curved_line_painter.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/dialogs/duplicate_process_dialog.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/space_card_widget.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/space_container_widget.dart';
|
||||
@ -41,7 +40,8 @@ class CommunityStructureArea extends StatefulWidget {
|
||||
final List<Tag> projectTags;
|
||||
|
||||
CommunityStructureArea(
|
||||
{this.selectedCommunity,
|
||||
{super.key,
|
||||
this.selectedCommunity,
|
||||
this.selectedSpace,
|
||||
required this.communities,
|
||||
this.products,
|
||||
@ -120,7 +120,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
);
|
||||
}
|
||||
|
||||
Size screenSize = MediaQuery.of(context).size;
|
||||
final screenSize = MediaQuery.of(context).size;
|
||||
return Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
@ -173,16 +173,16 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
children: [
|
||||
InteractiveViewer(
|
||||
transformationController: _transformationController,
|
||||
boundaryMargin: EdgeInsets.all(500),
|
||||
boundaryMargin: const EdgeInsets.all(500),
|
||||
minScale: 0.5,
|
||||
maxScale: 3.0,
|
||||
constrained: false,
|
||||
child: Container(
|
||||
child: SizedBox(
|
||||
width: canvasWidth,
|
||||
height: canvasHeight,
|
||||
child: Stack(
|
||||
children: [
|
||||
for (var connection in connections)
|
||||
for (final connection in connections)
|
||||
Opacity(
|
||||
opacity: ConnectionHelper.isHighlightedConnection(
|
||||
connection, widget.selectedSpace)
|
||||
@ -191,7 +191,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
child: CustomPaint(
|
||||
painter: CurvedLinePainter([connection])),
|
||||
),
|
||||
for (var entry in spaces.asMap().entries)
|
||||
for (final entry in spaces.asMap().entries)
|
||||
if (entry.value.status != SpaceStatus.deleted &&
|
||||
entry.value.status != SpaceStatus.parentDeleted)
|
||||
Positioned(
|
||||
@ -214,7 +214,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
_updateNodePosition(entry.value, newPosition);
|
||||
},
|
||||
buildSpaceContainer: (int index) {
|
||||
final bool isHighlighted =
|
||||
final isHighlighted =
|
||||
SpaceHelper.isHighlightedSpace(
|
||||
spaces[index], widget.selectedSpace);
|
||||
|
||||
@ -267,9 +267,9 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
canvasHeight += 200;
|
||||
}
|
||||
if (node.position.dx <= 200) {
|
||||
double shiftAmount = 200;
|
||||
const double shiftAmount = 200;
|
||||
canvasWidth += shiftAmount;
|
||||
for (var n in spaces) {
|
||||
for (final n in spaces) {
|
||||
n.position = Offset(n.position.dx + shiftAmount, n.position.dy);
|
||||
}
|
||||
}
|
||||
@ -280,7 +280,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
}
|
||||
|
||||
void _adjustCanvasSizeForSpaces() {
|
||||
for (var space in spaces) {
|
||||
for (final space in spaces) {
|
||||
if (space.position.dx >= canvasWidth - 200) {
|
||||
canvasWidth = space.position.dx + 200;
|
||||
}
|
||||
@ -324,7 +324,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
position ?? ConnectionHelper.getCenterPosition(screenSize);
|
||||
}
|
||||
|
||||
SpaceModel newSpace = SpaceModel(
|
||||
final newSpace = SpaceModel(
|
||||
name: name,
|
||||
icon: icon,
|
||||
position: newPosition,
|
||||
@ -336,7 +336,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
tags: tags);
|
||||
|
||||
if (parentIndex != null) {
|
||||
SpaceModel parentSpace = spaces[parentIndex];
|
||||
final parentSpace = spaces[parentIndex];
|
||||
parentSpace.internalId = spaces[parentIndex].internalId;
|
||||
newSpace.parent = parentSpace;
|
||||
final newConnection = Connection(
|
||||
@ -406,7 +406,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
SpaceStatus.modified; // Mark as modified
|
||||
}
|
||||
|
||||
for (var space in spaces) {
|
||||
for (final space in spaces) {
|
||||
if (space.internalId == widget.selectedSpace?.internalId) {
|
||||
space.status = SpaceStatus.modified;
|
||||
space.subspaces = subspaces;
|
||||
@ -430,8 +430,8 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
}
|
||||
|
||||
List<SpaceModel> flattenSpaces(List<SpaceModel> spaces) {
|
||||
List<SpaceModel> result = [];
|
||||
Map<String, SpaceModel> idToSpace = {};
|
||||
final result = <SpaceModel>[];
|
||||
final idToSpace = <String, SpaceModel>{};
|
||||
|
||||
void flatten(SpaceModel space) {
|
||||
if (space.status == SpaceStatus.deleted ||
|
||||
@ -441,16 +441,16 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
result.add(space);
|
||||
idToSpace[space.internalId] = space;
|
||||
|
||||
for (var child in space.children) {
|
||||
for (final child in space.children) {
|
||||
flatten(child);
|
||||
}
|
||||
}
|
||||
|
||||
for (var space in spaces) {
|
||||
for (final space in spaces) {
|
||||
flatten(space);
|
||||
}
|
||||
|
||||
for (var space in result) {
|
||||
for (final space in result) {
|
||||
if (space.parent != null) {
|
||||
space.parent = idToSpace[space.parent!.internalId];
|
||||
}
|
||||
@ -460,12 +460,12 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
}
|
||||
|
||||
List<Connection> createConnections(List<SpaceModel> spaces) {
|
||||
List<Connection> connections = [];
|
||||
final connections = <Connection>[];
|
||||
|
||||
void addConnections(SpaceModel parent, String direction) {
|
||||
if (parent.status == SpaceStatus.deleted) return;
|
||||
|
||||
for (var child in parent.children) {
|
||||
for (final child in parent.children) {
|
||||
if (child.status == SpaceStatus.deleted) continue;
|
||||
|
||||
connections.add(
|
||||
@ -480,8 +480,8 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
}
|
||||
}
|
||||
|
||||
for (var space in spaces) {
|
||||
addConnections(space, "down");
|
||||
for (final space in spaces) {
|
||||
addConnections(space, 'down');
|
||||
}
|
||||
|
||||
return connections;
|
||||
@ -492,7 +492,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
return;
|
||||
}
|
||||
|
||||
List<SpaceModel> spacesToSave = spaces.where((space) {
|
||||
final spacesToSave = spaces.where((space) {
|
||||
return space.status == SpaceStatus.newSpace ||
|
||||
space.status == SpaceStatus.modified ||
|
||||
space.status == SpaceStatus.deleted;
|
||||
@ -502,7 +502,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
return;
|
||||
}
|
||||
|
||||
String communityUuid = widget.selectedCommunity!.uuid;
|
||||
final communityUuid = widget.selectedCommunity!.uuid;
|
||||
context.read<SpaceManagementBloc>().add(SaveSpacesEvent(
|
||||
context,
|
||||
spaces: spacesToSave,
|
||||
@ -513,7 +513,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
void _onDelete() {
|
||||
if (widget.selectedSpace != null) {
|
||||
setState(() {
|
||||
for (var space in spaces) {
|
||||
for (final space in spaces) {
|
||||
if (space.internalId == widget.selectedSpace?.internalId) {
|
||||
space.status = SpaceStatus.deleted;
|
||||
_markChildrenAsDeleted(space);
|
||||
@ -526,7 +526,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
}
|
||||
|
||||
void _markChildrenAsDeleted(SpaceModel parent) {
|
||||
for (var child in parent.children) {
|
||||
for (final child in parent.children) {
|
||||
child.status = SpaceStatus.parentDeleted;
|
||||
|
||||
_markChildrenAsDeleted(child);
|
||||
@ -543,11 +543,11 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
}
|
||||
|
||||
void _moveToSpace(SpaceModel space) {
|
||||
final double viewportWidth = MediaQuery.of(context).size.width;
|
||||
final double viewportHeight = MediaQuery.of(context).size.height;
|
||||
final viewportWidth = MediaQuery.of(context).size.width;
|
||||
final viewportHeight = MediaQuery.of(context).size.height;
|
||||
|
||||
final double dx = -space.position.dx + (viewportWidth / 2) - 400;
|
||||
final double dy = -space.position.dy + (viewportHeight / 2) - 300;
|
||||
final dx = -space.position.dx + (viewportWidth / 2) - 400;
|
||||
final dy = -space.position.dy + (viewportHeight / 2) - 300;
|
||||
|
||||
_transformationController.value = Matrix4.identity()
|
||||
..translate(dx, dy)
|
||||
@ -578,10 +578,10 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
return Offset(parent.position.dx, parent.position.dy + verticalGap);
|
||||
} else {
|
||||
// More children → arrange them spaced horizontally
|
||||
double totalWidth = (parent.children.length) * (nodeWidth + 60);
|
||||
double startX = parent.position.dx - (totalWidth / 2);
|
||||
final totalWidth = (parent.children.length) * (nodeWidth + 60);
|
||||
final startX = parent.position.dx - (totalWidth / 2);
|
||||
|
||||
double childX = startX + (parent.children.length * (nodeWidth + 60));
|
||||
final childX = startX + (parent.children.length * (nodeWidth + 60));
|
||||
return Offset(childX, parent.position.dy + verticalGap);
|
||||
}
|
||||
}
|
||||
@ -599,15 +599,15 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
double calculateSubtreeWidth(SpaceModel node) {
|
||||
if (node.children.isEmpty) return nodeWidth;
|
||||
double totalWidth = 0;
|
||||
for (var child in node.children) {
|
||||
for (final child in node.children) {
|
||||
totalWidth += calculateSubtreeWidth(child) + horizontalGap;
|
||||
}
|
||||
return totalWidth - horizontalGap;
|
||||
}
|
||||
|
||||
void layoutSubtree(SpaceModel node, double startX, double y) {
|
||||
double subtreeWidth = calculateSubtreeWidth(node);
|
||||
double centerX = startX + subtreeWidth / 2 - nodeWidth / 2;
|
||||
final subtreeWidth = calculateSubtreeWidth(node);
|
||||
final centerX = startX + subtreeWidth / 2 - nodeWidth / 2;
|
||||
node.position = Offset(centerX, y);
|
||||
|
||||
canvasRightEdge = max(canvasRightEdge, centerX + nodeWidth);
|
||||
@ -617,9 +617,9 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
final child = node.children.first;
|
||||
layoutSubtree(child, centerX, y + verticalGap);
|
||||
} else {
|
||||
double childX = startX;
|
||||
for (var child in node.children) {
|
||||
double childWidth = calculateSubtreeWidth(child);
|
||||
var childX = startX;
|
||||
for (final child in node.children) {
|
||||
final childWidth = calculateSubtreeWidth(child);
|
||||
layoutSubtree(child, childX, y + verticalGap);
|
||||
childX += childWidth + horizontalGap;
|
||||
}
|
||||
@ -627,7 +627,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
}
|
||||
|
||||
// ⚡ New: layout each root separately
|
||||
final List<SpaceModel> roots = spaces
|
||||
final roots = spaces
|
||||
.where((s) =>
|
||||
s.parent == null &&
|
||||
s.status != SpaceStatus.deleted &&
|
||||
@ -635,11 +635,11 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
.toList();
|
||||
|
||||
double currentX = 100; // start some margin from left
|
||||
double currentY = 100; // top margin
|
||||
const double currentY = 100; // top margin
|
||||
|
||||
for (var root in roots) {
|
||||
for (final root in roots) {
|
||||
layoutSubtree(root, currentX, currentY);
|
||||
double rootWidth = calculateSubtreeWidth(root);
|
||||
final rootWidth = calculateSubtreeWidth(root);
|
||||
currentX += rootWidth + rootGap;
|
||||
}
|
||||
|
||||
@ -659,7 +659,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
return AlertDialog(
|
||||
backgroundColor: ColorsManager.whiteColors,
|
||||
title: Text(
|
||||
"Duplicate Space",
|
||||
'Duplicate Space',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
@ -671,11 +671,11 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text("Are you sure you want to duplicate?",
|
||||
Text('Are you sure you want to duplicate?',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.headlineSmall),
|
||||
const SizedBox(height: 15),
|
||||
Text("All the child spaces will be duplicated.",
|
||||
Text('All the child spaces will be duplicated.',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
@ -693,7 +693,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
label: "Cancel",
|
||||
label: 'Cancel',
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
@ -731,16 +731,16 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
|
||||
void _duplicateSpace(SpaceModel space) {
|
||||
setState(() {
|
||||
SpaceModel? parent = space.parent;
|
||||
final parent = space.parent;
|
||||
|
||||
SpaceModel duplicated = _deepCloneSpaceTree(space, parent: parent);
|
||||
final duplicated = _deepCloneSpaceTree(space, parent: parent);
|
||||
|
||||
duplicated.position =
|
||||
Offset(space.position.dx + 300, space.position.dy + 100);
|
||||
List<SpaceModel> duplicatedSubtree = [];
|
||||
final duplicatedSubtree = <SpaceModel>[];
|
||||
void collectSubtree(SpaceModel node) {
|
||||
duplicatedSubtree.add(node);
|
||||
for (var child in node.children) {
|
||||
for (final child in node.children) {
|
||||
collectSubtree(child);
|
||||
}
|
||||
}
|
||||
@ -782,7 +782,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
parent: parent,
|
||||
);
|
||||
|
||||
for (var child in original.children) {
|
||||
for (final child in original.children) {
|
||||
final duplicatedChild = _deepCloneSpaceTree(child, parent: newSpace);
|
||||
newSpace.children.add(duplicatedChild);
|
||||
|
||||
|
@ -7,11 +7,10 @@ class CounterWidget extends StatefulWidget {
|
||||
final bool isCreate;
|
||||
|
||||
const CounterWidget(
|
||||
{Key? key,
|
||||
{super.key,
|
||||
this.initialCount = 0,
|
||||
required this.onCountChanged,
|
||||
required this.isCreate})
|
||||
: super(key: key);
|
||||
required this.isCreate});
|
||||
|
||||
@override
|
||||
State<CounterWidget> createState() => _CounterWidgetState();
|
||||
@ -55,7 +54,8 @@ class _CounterWidgetState extends State<CounterWidget> {
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_buildCounterButton(Icons.remove, _decrementCounter,!widget.isCreate ),
|
||||
_buildCounterButton(
|
||||
Icons.remove, _decrementCounter, !widget.isCreate),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'$_counter',
|
||||
@ -69,12 +69,15 @@ class _CounterWidgetState extends State<CounterWidget> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCounterButton(IconData icon, VoidCallback onPressed, bool isDisabled) {
|
||||
Widget _buildCounterButton(
|
||||
IconData icon, VoidCallback onPressed, bool isDisabled) {
|
||||
return GestureDetector(
|
||||
onTap: isDisabled? null: onPressed,
|
||||
onTap: isDisabled ? null : onPressed,
|
||||
child: Icon(
|
||||
icon,
|
||||
color: isDisabled? ColorsManager.spaceColor.withOpacity(0.3): ColorsManager.spaceColor,
|
||||
color: isDisabled
|
||||
? ColorsManager.spaceColor.withValues(alpha: 0.3)
|
||||
: ColorsManager.spaceColor,
|
||||
size: 18,
|
||||
),
|
||||
);
|
||||
|
@ -1,12 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
|
||||
import '../../../../../common/edit_chip.dart';
|
||||
import '../../../../../utils/color_manager.dart';
|
||||
import '../../../helper/tag_helper.dart';
|
||||
import '../../../space_model/widgets/button_content_widget.dart';
|
||||
import '../../model/subspace_model.dart';
|
||||
import '../../model/tag.dart';
|
||||
import 'package:syncrow_web/common/edit_chip.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/subspace_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/helper/tag_helper.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/button_content_widget.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
class DevicesPartWidget extends StatelessWidget {
|
||||
const DevicesPartWidget({
|
||||
@ -28,73 +27,73 @@ class DevicesPartWidget extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
(tags?.isNotEmpty == true ||
|
||||
subspaces?.any(
|
||||
(subspace) => subspace.tags?.isNotEmpty == true) ==
|
||||
true)
|
||||
? SizedBox(
|
||||
width: screenWidth * 0.25,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.textFieldGreyColor,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
border: Border.all(
|
||||
color: ColorsManager.textFieldGreyColor,
|
||||
width: 3.0, // Border width
|
||||
),
|
||||
),
|
||||
child: Wrap(
|
||||
spacing: 8.0,
|
||||
runSpacing: 8.0,
|
||||
children: [
|
||||
// Combine tags from spaceModel and subspaces
|
||||
...TagHelper.groupTags([
|
||||
...?tags,
|
||||
...?subspaces?.expand((subspace) => subspace.tags ?? [])
|
||||
]).entries.map(
|
||||
(entry) => Chip(
|
||||
avatar: SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: SvgPicture.asset(
|
||||
entry.key.icon ?? 'assets/icons/gateway.svg',
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
label: Text(
|
||||
'x${entry.value}', // Show count
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall
|
||||
?.copyWith(color: ColorsManager.spaceColor),
|
||||
),
|
||||
backgroundColor: ColorsManager.whiteColors,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
side: const BorderSide(
|
||||
color: ColorsManager.spaceColor,
|
||||
),
|
||||
),
|
||||
if (tags?.isNotEmpty == true ||
|
||||
subspaces?.any((subspace) => subspace.tags?.isNotEmpty == true) ==
|
||||
true)
|
||||
SizedBox(
|
||||
width: screenWidth * 0.25,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.textFieldGreyColor,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
border: Border.all(
|
||||
color: ColorsManager.textFieldGreyColor,
|
||||
width: 3.0, // Border width
|
||||
),
|
||||
),
|
||||
child: Wrap(
|
||||
spacing: 8.0,
|
||||
runSpacing: 8.0,
|
||||
children: [
|
||||
// Combine tags from spaceModel and subspaces
|
||||
...TagHelper.groupTags([
|
||||
...?tags,
|
||||
...?subspaces?.expand((subspace) => subspace.tags ?? [])
|
||||
]).entries.map(
|
||||
(entry) => Chip(
|
||||
avatar: SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: SvgPicture.asset(
|
||||
entry.key.icon ?? 'assets/icons/gateway.svg',
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
label: Text(
|
||||
'x${entry.value}', // Show count
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall
|
||||
?.copyWith(color: ColorsManager.spaceColor),
|
||||
),
|
||||
backgroundColor: ColorsManager.whiteColors,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
side: const BorderSide(
|
||||
color: ColorsManager.spaceColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
EditChip(onTap: onEditChip)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: TextButton(
|
||||
onPressed: onTextButtonPressed,
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
child: ButtonContentWidget(
|
||||
icon: Icons.add,
|
||||
label: 'Add Devices',
|
||||
disabled: isTagsAndSubspaceModelDisabled,
|
||||
),
|
||||
)
|
||||
EditChip(onTap: onEditChip)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
TextButton(
|
||||
onPressed: onTextButtonPressed,
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
child: ButtonContentWidget(
|
||||
icon: Icons.add,
|
||||
label: 'Add Devices',
|
||||
disabled: isTagsAndSubspaceModelDisabled,
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
|
||||
import '../../../../../utils/color_manager.dart';
|
||||
import '../../../../../utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
|
||||
class IconChoosePartWidget extends StatelessWidget {
|
||||
const IconChoosePartWidget({
|
||||
|
@ -1,9 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../utils/color_manager.dart';
|
||||
import '../../../../../utils/constants/assets.dart';
|
||||
import '../../../space_model/models/space_template_model.dart';
|
||||
import '../../../space_model/widgets/button_content_widget.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/button_content_widget.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
|
||||
class SpaceModelLinkingWidget extends StatelessWidget {
|
||||
const SpaceModelLinkingWidget({
|
||||
@ -23,66 +22,67 @@ class SpaceModelLinkingWidget extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
selectedSpaceModel == null
|
||||
? TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
onPressed: onPressed,
|
||||
child: ButtonContentWidget(
|
||||
svgAssets: Assets.link,
|
||||
label: 'Link a space model',
|
||||
disabled: isSpaceModelDisabled,
|
||||
),
|
||||
)
|
||||
: Container(
|
||||
width: screenWidth * 0.25,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 10.0, horizontal: 16.0),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.boxColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Wrap(
|
||||
spacing: 8.0,
|
||||
runSpacing: 8.0,
|
||||
children: [
|
||||
Chip(
|
||||
label: Text(
|
||||
selectedSpaceModel?.modelName ?? '',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium!
|
||||
.copyWith(color: ColorsManager.spaceColor),
|
||||
if (selectedSpaceModel == null)
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
onPressed: onPressed,
|
||||
child: ButtonContentWidget(
|
||||
svgAssets: Assets.link,
|
||||
label: 'Link a space model',
|
||||
disabled: isSpaceModelDisabled,
|
||||
),
|
||||
)
|
||||
else
|
||||
Container(
|
||||
width: screenWidth * 0.25,
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 10.0, horizontal: 16.0),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.boxColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Wrap(
|
||||
spacing: 8.0,
|
||||
runSpacing: 8.0,
|
||||
children: [
|
||||
Chip(
|
||||
label: Text(
|
||||
selectedSpaceModel?.modelName ?? '',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium!
|
||||
.copyWith(color: ColorsManager.spaceColor),
|
||||
),
|
||||
backgroundColor: ColorsManager.whiteColors,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
side: const BorderSide(
|
||||
color: ColorsManager.transparentColor,
|
||||
width: 0,
|
||||
),
|
||||
),
|
||||
deleteIcon: Container(
|
||||
width: 24,
|
||||
height: 24,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: ColorsManager.lightGrayColor,
|
||||
width: 1.5,
|
||||
),
|
||||
backgroundColor: ColorsManager.whiteColors,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
side: const BorderSide(
|
||||
color: ColorsManager.transparentColor,
|
||||
width: 0,
|
||||
),
|
||||
),
|
||||
deleteIcon: Container(
|
||||
width: 24,
|
||||
height: 24,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: ColorsManager.lightGrayColor,
|
||||
width: 1.5,
|
||||
),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.close,
|
||||
size: 16,
|
||||
color: ColorsManager.lightGrayColor,
|
||||
),
|
||||
),
|
||||
onDeleted: onDeleted),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.close,
|
||||
size: 16,
|
||||
color: ColorsManager.lightGrayColor,
|
||||
),
|
||||
),
|
||||
onDeleted: onDeleted),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
class SpaceNameTextfieldWidget extends StatelessWidget {
|
||||
SpaceNameTextfieldWidget({
|
||||
|
@ -1,10 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../common/edit_chip.dart';
|
||||
import '../../../../../utils/color_manager.dart';
|
||||
import '../../../space_model/widgets/button_content_widget.dart';
|
||||
import '../../../space_model/widgets/subspace_name_label_widget.dart';
|
||||
import '../../model/subspace_model.dart';
|
||||
import 'package:syncrow_web/common/edit_chip.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/subspace_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/button_content_widget.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/subspace_name_label_widget.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
class SubSpacePartWidget extends StatefulWidget {
|
||||
SubSpacePartWidget({
|
||||
@ -30,71 +29,72 @@ class _SubSpacePartWidgetState extends State<SubSpacePartWidget> {
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
widget.subspaces == null || widget.subspaces!.isEmpty
|
||||
? TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.zero,
|
||||
overlayColor: ColorsManager.transparentColor,
|
||||
if (widget.subspaces == null || widget.subspaces!.isEmpty)
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.zero,
|
||||
overlayColor: ColorsManager.transparentColor,
|
||||
),
|
||||
onPressed: widget.onPressed,
|
||||
child: ButtonContentWidget(
|
||||
icon: Icons.add,
|
||||
label: 'Create Sub Spaces',
|
||||
disabled: widget.isTagsAndSubspaceModelDisabled,
|
||||
),
|
||||
)
|
||||
else
|
||||
SizedBox(
|
||||
width: widget.screenWidth * 0.25,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.textFieldGreyColor,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
border: Border.all(
|
||||
color: ColorsManager.textFieldGreyColor,
|
||||
width: 3.0, // Border width
|
||||
),
|
||||
onPressed: widget.onPressed,
|
||||
child: ButtonContentWidget(
|
||||
icon: Icons.add,
|
||||
label: 'Create Sub Spaces',
|
||||
disabled: widget.isTagsAndSubspaceModelDisabled,
|
||||
),
|
||||
)
|
||||
: SizedBox(
|
||||
width: widget.screenWidth * 0.25,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.textFieldGreyColor,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
border: Border.all(
|
||||
color: ColorsManager.textFieldGreyColor,
|
||||
width: 3.0, // Border width
|
||||
),
|
||||
),
|
||||
child: Wrap(
|
||||
spacing: 8.0,
|
||||
runSpacing: 8.0,
|
||||
children: [
|
||||
if (widget.subspaces != null)
|
||||
...widget.subspaces!.map((subspace) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SubspaceNameDisplayWidget(
|
||||
text: subspace.subspaceName,
|
||||
validateName: (updatedName) {
|
||||
bool nameExists = widget.subspaces!.any((s) {
|
||||
bool isSameId =
|
||||
s.internalId == subspace.internalId;
|
||||
bool isSameName =
|
||||
s.subspaceName.trim().toLowerCase() ==
|
||||
updatedName.trim().toLowerCase();
|
||||
),
|
||||
child: Wrap(
|
||||
spacing: 8.0,
|
||||
runSpacing: 8.0,
|
||||
children: [
|
||||
if (widget.subspaces != null)
|
||||
...widget.subspaces!.map((subspace) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SubspaceNameDisplayWidget(
|
||||
text: subspace.subspaceName,
|
||||
validateName: (updatedName) {
|
||||
final nameExists = widget.subspaces!.any((s) {
|
||||
final isSameId =
|
||||
s.internalId == subspace.internalId;
|
||||
final isSameName =
|
||||
s.subspaceName.trim().toLowerCase() ==
|
||||
updatedName.trim().toLowerCase();
|
||||
|
||||
return !isSameId && isSameName;
|
||||
});
|
||||
return !isSameId && isSameName;
|
||||
});
|
||||
|
||||
return !nameExists;
|
||||
},
|
||||
onNameChanged: (updatedName) {
|
||||
setState(() {
|
||||
subspace.subspaceName = updatedName;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
EditChip(
|
||||
onTap: widget.editChipOnTap,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
return !nameExists;
|
||||
},
|
||||
onNameChanged: (updatedName) {
|
||||
setState(() {
|
||||
subspace.subspaceName = updatedName;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
EditChip(
|
||||
onTap: widget.editChipOnTap,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -19,15 +19,11 @@ class CurvedLinePainter extends CustomPainter {
|
||||
return; // Nothing to paint if there are no connections
|
||||
}
|
||||
|
||||
for (var connection in connections) {
|
||||
for (final connection in connections) {
|
||||
// Ensure positions are valid before drawing lines
|
||||
if (connection.endSpace.position == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Offset start = connection.startSpace.position +
|
||||
final start = connection.startSpace.position +
|
||||
const Offset(75, 60); // Center bottom of start space
|
||||
Offset end = connection.endSpace.position +
|
||||
final end = connection.endSpace.position +
|
||||
const Offset(75, 0); // Center top of end space
|
||||
|
||||
// Curved line for down connections
|
||||
|
@ -9,7 +9,6 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/subspace_mo
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/create_space_widgets/devices_part_widget.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/create_space_widgets/icon_choose_part_widget.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/create_space_widgets/space_model_linking_widget.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/create_space_widgets/space_name_textfield_widget.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/create_space_widgets/sub_space_part_widget.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/dialogs/icon_selection_dialog.dart';
|
||||
@ -99,9 +98,9 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool isSpaceModelDisabled = (tags != null && tags!.isNotEmpty ||
|
||||
subspaces != null && subspaces!.isNotEmpty);
|
||||
bool isTagsAndSubspaceModelDisabled = (selectedSpaceModel != null);
|
||||
final isSpaceModelDisabled = tags != null && tags!.isNotEmpty ||
|
||||
subspaces != null && subspaces!.isNotEmpty;
|
||||
final isTagsAndSubspaceModelDisabled = (selectedSpaceModel != null);
|
||||
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
return AlertDialog(
|
||||
@ -298,7 +297,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
} else if (isNameFieldExist) {
|
||||
return;
|
||||
} else {
|
||||
String newName = enteredName.isNotEmpty
|
||||
final newName = enteredName.isNotEmpty
|
||||
? enteredName
|
||||
: (widget.name ?? '');
|
||||
if (newName.isNotEmpty) {
|
||||
@ -381,7 +380,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
products: products,
|
||||
existingSubSpaces: existingSubSpaces,
|
||||
onSave: (slectedSubspaces, updatedSubSpaces) {
|
||||
final List<Tag> tagsToAppendToSpace = [];
|
||||
final tagsToAppendToSpace = <Tag>[];
|
||||
|
||||
if (slectedSubspaces != null && slectedSubspaces.isNotEmpty) {
|
||||
final updatedIds =
|
||||
@ -390,11 +389,11 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
final deletedSubspaces = existingSubSpaces
|
||||
.where((s) => !updatedIds.contains(s.internalId))
|
||||
.toList();
|
||||
for (var s in deletedSubspaces) {
|
||||
for (final s in deletedSubspaces) {
|
||||
if (s.tags != null) {
|
||||
s.tags!.forEach(
|
||||
(tag) => tag.location = null,
|
||||
);
|
||||
for (final tag in s.tags!) {
|
||||
tag.location = null;
|
||||
}
|
||||
tagsToAppendToSpace.addAll(s.tags!);
|
||||
}
|
||||
}
|
||||
@ -403,11 +402,11 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
if (existingSubSpaces != null) {
|
||||
final deletedSubspaces = existingSubSpaces;
|
||||
|
||||
for (var s in deletedSubspaces) {
|
||||
for (final s in deletedSubspaces) {
|
||||
if (s.tags != null) {
|
||||
s.tags!.forEach(
|
||||
(tag) => tag.location = null,
|
||||
);
|
||||
for (final tag in s.tags!) {
|
||||
tag.location = null;
|
||||
}
|
||||
tagsToAppendToSpace.addAll(s.tags!);
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,10 @@ import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/cancel_button.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
void showDeleteConfirmationDialog(BuildContext context, VoidCallback onConfirm, bool isSpace) {
|
||||
final String title = isSpace ? 'Delete Space' : 'Delete Community';
|
||||
final String subtitle = isSpace
|
||||
void showDeleteConfirmationDialog(
|
||||
BuildContext context, VoidCallback onConfirm, bool isSpace) {
|
||||
final title = isSpace ? 'Delete Space' : 'Delete Community';
|
||||
final subtitle = isSpace
|
||||
? 'All the data in the space will be lost'
|
||||
: 'All the data in the community will be lost';
|
||||
|
||||
@ -13,7 +14,8 @@ void showDeleteConfirmationDialog(BuildContext context, VoidCallback onConfirm,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0)),
|
||||
shape:
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0)),
|
||||
child: SizedBox(
|
||||
width: 500,
|
||||
child: Container(
|
||||
@ -41,7 +43,8 @@ void showDeleteConfirmationDialog(BuildContext context, VoidCallback onConfirm,
|
||||
showProcessingPopup(context, isSpace, onConfirm);
|
||||
},
|
||||
style: _dialogButtonStyle(ColorsManager.spaceColor),
|
||||
child: const Text('Continue', style: TextStyle(color: ColorsManager.whiteColors)),
|
||||
child: const Text('Continue',
|
||||
style: TextStyle(color: ColorsManager.whiteColors)),
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -54,15 +57,17 @@ void showDeleteConfirmationDialog(BuildContext context, VoidCallback onConfirm,
|
||||
);
|
||||
}
|
||||
|
||||
void showProcessingPopup(BuildContext context, bool isSpace, VoidCallback onDelete) {
|
||||
final String title = isSpace ? 'Delete Space' : 'Delete Community';
|
||||
void showProcessingPopup(
|
||||
BuildContext context, bool isSpace, VoidCallback onDelete) {
|
||||
final title = isSpace ? 'Delete Space' : 'Delete Community';
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0)),
|
||||
shape:
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0)),
|
||||
child: SizedBox(
|
||||
width: 500,
|
||||
child: Container(
|
||||
@ -75,7 +80,8 @@ void showProcessingPopup(BuildContext context, bool isSpace, VoidCallback onDele
|
||||
const SizedBox(height: 20),
|
||||
_buildDialogTitle(context, title),
|
||||
const SizedBox(height: 10),
|
||||
_buildDialogSubtitle(context, 'Are you sure you want to delete?'),
|
||||
_buildDialogSubtitle(
|
||||
context, 'Are you sure you want to delete?'),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
@ -83,7 +89,8 @@ void showProcessingPopup(BuildContext context, bool isSpace, VoidCallback onDele
|
||||
ElevatedButton(
|
||||
onPressed: onDelete,
|
||||
style: _dialogButtonStyle(ColorsManager.warningRed),
|
||||
child: const Text('Delete', style: TextStyle(color: ColorsManager.whiteColors)),
|
||||
child: const Text('Delete',
|
||||
style: TextStyle(color: ColorsManager.whiteColors)),
|
||||
),
|
||||
CancelButton(
|
||||
label: 'Cancel',
|
||||
@ -104,7 +111,7 @@ Widget _buildWarningIcon() {
|
||||
return Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
decoration: const BoxDecoration(
|
||||
color: ColorsManager.warningRed,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
@ -123,7 +130,10 @@ Widget _buildDialogSubtitle(BuildContext context, String subtitle) {
|
||||
return Text(
|
||||
subtitle,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(color: ColorsManager.grayColor),
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium
|
||||
?.copyWith(color: ColorsManager.grayColor),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,7 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
||||
class DuplicateProcessDialog extends StatefulWidget {
|
||||
final VoidCallback onDuplicate;
|
||||
|
||||
const DuplicateProcessDialog({required this.onDuplicate, Key? key})
|
||||
: super(key: key);
|
||||
const DuplicateProcessDialog({required this.onDuplicate, super.key});
|
||||
|
||||
@override
|
||||
_DuplicateProcessDialogState createState() => _DuplicateProcessDialogState();
|
||||
@ -20,7 +19,7 @@ class _DuplicateProcessDialogState extends State<DuplicateProcessDialog> {
|
||||
_startDuplication();
|
||||
}
|
||||
|
||||
void _startDuplication() async {
|
||||
Future<void> _startDuplication() async {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
widget.onDuplicate();
|
||||
});
|
||||
@ -55,7 +54,7 @@ class _DuplicateProcessDialogState extends State<DuplicateProcessDialog> {
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"Duplicating in progress",
|
||||
'Duplicating in progress',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineSmall
|
||||
@ -70,7 +69,7 @@ class _DuplicateProcessDialogState extends State<DuplicateProcessDialog> {
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"Duplicating successful",
|
||||
'Duplicating successful',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
|
@ -7,10 +7,10 @@ class IconSelectionDialog extends StatelessWidget {
|
||||
final Function(String selectedIcon) onIconSelected;
|
||||
|
||||
const IconSelectionDialog({
|
||||
Key? key,
|
||||
super.key,
|
||||
required this.spaceIconList,
|
||||
required this.onIconSelected,
|
||||
}) : super(key: key);
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -21,21 +21,23 @@ class IconSelectionDialog extends StatelessWidget {
|
||||
elevation: 0,
|
||||
backgroundColor: ColorsManager.transparentColor,
|
||||
child: Container(
|
||||
width: screenWidth * 0.44,
|
||||
width: screenWidth * 0.44,
|
||||
height: screenHeight * 0.45,
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.whiteColors,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: ColorsManager.blackColor.withOpacity(0.2), // Shadow color
|
||||
color: ColorsManager.blackColor
|
||||
.withValues(alpha: 0.2), // Shadow color
|
||||
blurRadius: 20, // Spread of the blur
|
||||
offset: const Offset(0, 8), // Offset of the shadow
|
||||
),
|
||||
],
|
||||
),
|
||||
child: AlertDialog(
|
||||
title: Text('Space Icon',style: Theme.of(context).textTheme.headlineMedium),
|
||||
title: Text('Space Icon',
|
||||
style: Theme.of(context).textTheme.headlineMedium),
|
||||
backgroundColor: ColorsManager.whiteColors,
|
||||
content: Container(
|
||||
width: screenWidth * 0.4,
|
||||
|
@ -28,7 +28,7 @@ class GradientCanvasBorderWidget extends StatelessWidget {
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
colors: [
|
||||
ColorsManager.semiTransparentBlackColor.withOpacity(0.1),
|
||||
ColorsManager.semiTransparentBlackColor.withValues(alpha: 0.1),
|
||||
ColorsManager.transparentColor,
|
||||
],
|
||||
),
|
||||
|
@ -8,11 +8,11 @@ class HoverableButton extends StatefulWidget {
|
||||
final VoidCallback onTap;
|
||||
|
||||
const HoverableButton({
|
||||
Key? key,
|
||||
super.key,
|
||||
required this.iconPath,
|
||||
required this.text,
|
||||
required this.onTap,
|
||||
}) : super(key: key);
|
||||
});
|
||||
|
||||
@override
|
||||
State<HoverableButton> createState() => _HoverableButtonState();
|
||||
@ -34,14 +34,17 @@ class _HoverableButtonState extends State<HoverableButton> {
|
||||
child: SizedBox(
|
||||
width: screenWidth * .07,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 13, vertical: 8),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 13, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: isHovered ? ColorsManager.warningRed : ColorsManager.whiteColors,
|
||||
color: isHovered
|
||||
? ColorsManager.warningRed
|
||||
: ColorsManager.whiteColors,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
if (isHovered)
|
||||
BoxShadow(
|
||||
color: ColorsManager.warningRed.withOpacity(0.4),
|
||||
color: ColorsManager.warningRed.withValues(alpha: 0.4),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
|
@ -81,49 +81,51 @@ class _LoadedSpaceViewState extends State<LoadedSpaceView> {
|
||||
return Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
widget.shouldNavigateToSpaceModelPage
|
||||
? Row(
|
||||
children: [
|
||||
SizedBox(width: 300, child: SpaceTreeView(onSelect: () {})),
|
||||
Expanded(
|
||||
child: BlocProvider(
|
||||
create: (context) => SpaceModelBloc(
|
||||
BlocProvider.of<SpaceTreeBloc>(context),
|
||||
api: SpaceModelManagementApi(),
|
||||
initialSpaceModels: widget.spaceModels ?? [],
|
||||
),
|
||||
child: SpaceModelPage(
|
||||
products: widget.products,
|
||||
onSpaceModelsUpdated: _onSpaceModelsUpdated,
|
||||
projectTags: widget.projectTags,
|
||||
),
|
||||
),
|
||||
if (widget.shouldNavigateToSpaceModelPage)
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(width: 300, child: SpaceTreeView(onSelect: () {})),
|
||||
Expanded(
|
||||
child: BlocProvider(
|
||||
create: (context) => SpaceModelBloc(
|
||||
BlocProvider.of<SpaceTreeBloc>(context),
|
||||
api: SpaceModelManagementApi(),
|
||||
initialSpaceModels: widget.spaceModels ?? [],
|
||||
),
|
||||
],
|
||||
)
|
||||
: Row(
|
||||
children: [
|
||||
SidebarWidget(
|
||||
communities: widget.communities,
|
||||
selectedSpaceUuid:
|
||||
widget.selectedSpace?.uuid ?? widget.selectedCommunity?.uuid ?? '',
|
||||
onCreateCommunity: (name, description) {
|
||||
context.read<SpaceManagementBloc>().add(
|
||||
CreateCommunityEvent(name, description, context),
|
||||
);
|
||||
},
|
||||
),
|
||||
CommunityStructureArea(
|
||||
selectedCommunity: widget.selectedCommunity,
|
||||
selectedSpace: widget.selectedSpace,
|
||||
spaces: widget.selectedCommunity?.spaces ?? [],
|
||||
child: SpaceModelPage(
|
||||
products: widget.products,
|
||||
communities: widget.communities,
|
||||
spaceModels: _spaceModels,
|
||||
onSpaceModelsUpdated: _onSpaceModelsUpdated,
|
||||
projectTags: widget.projectTags,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
else
|
||||
Row(
|
||||
children: [
|
||||
SidebarWidget(
|
||||
communities: widget.communities,
|
||||
selectedSpaceUuid: widget.selectedSpace?.uuid ??
|
||||
widget.selectedCommunity?.uuid ??
|
||||
'',
|
||||
onCreateCommunity: (name, description) {
|
||||
context.read<SpaceManagementBloc>().add(
|
||||
CreateCommunityEvent(name, description, context),
|
||||
);
|
||||
},
|
||||
),
|
||||
CommunityStructureArea(
|
||||
selectedCommunity: widget.selectedCommunity,
|
||||
selectedSpace: widget.selectedSpace,
|
||||
spaces: widget.selectedCommunity?.spaces ?? [],
|
||||
products: widget.products,
|
||||
communities: widget.communities,
|
||||
spaceModels: _spaceModels,
|
||||
projectTags: widget.projectTags,
|
||||
),
|
||||
],
|
||||
),
|
||||
const GradientCanvasBorderWidget(),
|
||||
],
|
||||
);
|
||||
|
@ -13,12 +13,12 @@ class SelectedProductsButtons extends StatelessWidget {
|
||||
final BuildContext context;
|
||||
|
||||
const SelectedProductsButtons({
|
||||
Key? key,
|
||||
super.key,
|
||||
required this.products,
|
||||
required this.selectedProducts,
|
||||
required this.onProductsUpdated,
|
||||
required this.context,
|
||||
}) : super(key: key);
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -86,9 +86,7 @@ class SelectedProductsButtons extends StatelessWidget {
|
||||
builder: (context) => AddDeviceWidget(
|
||||
products: products,
|
||||
initialSelectedProducts: selectedProducts,
|
||||
onProductsSelected: (selectedProductsMap) {
|
||||
onProductsUpdated(selectedProductsMap);
|
||||
},
|
||||
onProductsSelected: onProductsUpdated,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/common/widgets/search_bar.dart';
|
||||
import 'package:syncrow_web/common/widgets/sidebar_communities_list.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_event.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_state.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_event.dart';
|
||||
@ -18,8 +19,6 @@ import 'package:syncrow_web/pages/spaces_management/structure_selector/bloc/cent
|
||||
import 'package:syncrow_web/pages/spaces_management/structure_selector/bloc/center_body_event.dart';
|
||||
import 'package:syncrow_web/utils/style.dart';
|
||||
|
||||
import '../../../space_tree/bloc/space_tree_event.dart';
|
||||
|
||||
class SidebarWidget extends StatefulWidget {
|
||||
final List<CommunityModel> communities;
|
||||
final String? selectedSpaceUuid;
|
||||
@ -55,13 +54,15 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
}
|
||||
|
||||
void _onScroll() {
|
||||
if (_scrollController.position.pixels >= _scrollController.position.maxScrollExtent - 100) {
|
||||
if (_scrollController.position.pixels >=
|
||||
_scrollController.position.maxScrollExtent - 100) {
|
||||
// Trigger pagination event
|
||||
final bloc = context.read<SpaceTreeBloc>();
|
||||
if (!bloc.state.paginationIsLoading && bloc.state.paginationModel?.hasNext == true) {
|
||||
if (!bloc.state.paginationIsLoading &&
|
||||
bloc.state.paginationModel.hasNext == true) {
|
||||
bloc.add(
|
||||
PaginationEvent(
|
||||
bloc.state.paginationModel!,
|
||||
bloc.state.paginationModel,
|
||||
bloc.state.communityList,
|
||||
),
|
||||
);
|
||||
@ -134,24 +135,28 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
communities: filteredCommunities,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == filteredCommunities.length) {
|
||||
final spaceTreeState = context.read<SpaceTreeBloc>().state;
|
||||
final spaceTreeState =
|
||||
context.read<SpaceTreeBloc>().state;
|
||||
if (spaceTreeState.paginationIsLoading) {
|
||||
return const Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
child:
|
||||
Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}
|
||||
return _buildCommunityTile(context, filteredCommunities[index]);
|
||||
return _buildCommunityTile(
|
||||
context, filteredCommunities[index]);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
if (spaceTreeState.paginationIsLoading || spaceTreeState.isSearching)
|
||||
Center(
|
||||
if (spaceTreeState.paginationIsLoading ||
|
||||
spaceTreeState.isSearching)
|
||||
const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
],
|
||||
@ -214,7 +219,8 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
});
|
||||
|
||||
context.read<SpaceManagementBloc>().add(
|
||||
SelectSpaceEvent(selectedCommunity: community, selectedSpace: space),
|
||||
SelectSpaceEvent(
|
||||
selectedCommunity: community, selectedSpace: space),
|
||||
);
|
||||
},
|
||||
children: space.children
|
||||
@ -229,8 +235,9 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
);
|
||||
}
|
||||
|
||||
void _onAddCommunity() =>
|
||||
_selectedId?.isNotEmpty ?? true ? _clearSelection() : _showCreateCommunityDialog();
|
||||
void _onAddCommunity() => _selectedId?.isNotEmpty ?? true
|
||||
? _clearSelection()
|
||||
: _showCreateCommunityDialog();
|
||||
|
||||
void _clearSelection() {
|
||||
setState(() => _selectedId = '');
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'plus_button_widget.dart'; // Make sure to import your PlusButtonWidget
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/plus_button_widget.dart'; // Make sure to import your PlusButtonWidget
|
||||
|
||||
class SpaceCardWidget extends StatelessWidget {
|
||||
final int index;
|
||||
|
@ -78,7 +78,7 @@ class SpaceContainerWidget extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: ColorsManager.lightGrayColor.withOpacity(0.5),
|
||||
color: ColorsManager.lightGrayColor.withValues(alpha: 0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: const Offset(0, 3), // Shadow position
|
||||
|
@ -27,7 +27,7 @@ class SpaceWidget extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: ColorsManager.lightGrayColor.withOpacity(0.5),
|
||||
color: ColorsManager.lightGrayColor.withValues(alpha: 0.5),
|
||||
spreadRadius: 5,
|
||||
blurRadius: 7,
|
||||
offset: const Offset(0, 3),
|
||||
|
Reference in New Issue
Block a user