Revert "formatted all files."

This reverts commit 04250ebc98.
This commit is contained in:
Faris Armoush
2025-06-12 16:04:49 +03:00
parent 218f43bacb
commit c642ba2644
473 changed files with 4335 additions and 5417 deletions

View File

@ -1,7 +1,7 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/add_device_type/bloc/add_device_state.dart';
import 'package:syncrow_web/pages/spaces_management/add_device_type/bloc/add_device_type_model_event.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_product_model.dart';
import 'package:syncrow_web/pages/spaces_management/add_device_type/bloc/add_device_type_model_event.dart';
class AddDeviceTypeBloc extends Bloc<AddDeviceTypeEvent, AddDeviceState> {
AddDeviceTypeBloc() : super(AddDeviceInitial()) {

View File

@ -16,7 +16,7 @@ class UpdateProductCountEvent extends AddDeviceTypeEvent {
final String productName;
final ProductModel product;
const UpdateProductCountEvent(
UpdateProductCountEvent(
{required this.productId,
required this.count,
required this.productName,
@ -26,6 +26,7 @@ class UpdateProductCountEvent extends AddDeviceTypeEvent {
List<Object> get props => [productId, count];
}
class InitializeDevice extends AddDeviceTypeEvent {
final List<Tag> initialTags;
final List<SelectedProduct> addedProducts;

View File

@ -6,10 +6,10 @@ import 'package:syncrow_web/pages/spaces_management/add_device_type/bloc/add_dev
import 'package:syncrow_web/pages/spaces_management/add_device_type/bloc/add_device_state.dart';
import 'package:syncrow_web/pages/spaces_management/add_device_type/bloc/add_device_type_model_event.dart';
import 'package:syncrow_web/pages/spaces_management/add_device_type/widgets/scrollable_grid_view_widget.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/subspace_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.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/assign_tag/views/assign_tag_dialog.dart';
import 'package:syncrow_web/pages/spaces_management/helper/tag_helper.dart';
import 'package:syncrow_web/utils/color_manager.dart';
@ -24,7 +24,8 @@ class AddDeviceTypeWidget extends StatelessWidget {
final String spaceName;
final bool isCreate;
final Function(List<Tag>, List<SubspaceModel>?)? onSave;
final List<Tag> projectTags;
final List<Tag> projectTags;
const AddDeviceTypeWidget(
{super.key,

View File

@ -1,19 +1,20 @@
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';
@ -56,10 +57,10 @@ class SpaceManagementBloc
UpdateSpaceModelCache event, Emitter<SpaceManagementState> emit) async {
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
final allSpaceModels = <SpaceTemplateModel>[];
List<SpaceTemplateModel> allSpaceModels = [];
var hasNext = true;
var page = 1;
bool hasNext = true;
int page = 1;
while (hasNext) {
final spaceModels = await _spaceModelApi.listSpaceModels(
@ -84,7 +85,7 @@ class SpaceManagementBloc
allTags: _cachedTags ?? []));
}
Future<void> _deleteSpaceModelFromCache(DeleteSpaceModelFromCache event,
void _deleteSpaceModelFromCache(DeleteSpaceModelFromCache event,
Emitter<SpaceManagementState> emit) async {
if (_cachedSpaceModels != null) {
_cachedSpaceModels = _cachedSpaceModels!
@ -120,10 +121,10 @@ class SpaceManagementBloc
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
final allSpaceModels = <SpaceTemplateModel>[];
List<SpaceTemplateModel> allSpaceModels = [];
var hasNext = true;
var page = 1;
bool hasNext = true;
int page = 1;
while (hasNext) {
final spaceModels = await _spaceModelApi.listSpaceModels(
@ -158,7 +159,7 @@ class SpaceManagementBloc
}
}
Future<void> _onUpdateCommunity(
void _onUpdateCommunity(
UpdateCommunityEvent event,
Emitter<SpaceManagementState> emit,
) async {
@ -174,7 +175,7 @@ class SpaceManagementBloc
if (previousState is SpaceManagementLoaded) {
final updatedCommunities =
List<CommunityModel>.from(previousState.communities);
for (final community in updatedCommunities) {
for (var community in updatedCommunities) {
if (community.uuid == event.communityUuid) {
community.name = event.name;
_spaceTreeBloc.add(OnCommunityAdded(community));
@ -183,7 +184,7 @@ class SpaceManagementBloc
}
}
final prevSpaceModels = await fetchSpaceModels();
var prevSpaceModels = await fetchSpaceModels();
emit(SpaceManagementLoaded(
communities: updatedCommunities,
@ -200,14 +201,14 @@ class SpaceManagementBloc
}
}
Future<void> _onloadProducts() async {
void _onloadProducts() async {
if (_cachedProducts == null) {
final products = await _productApi.fetchProducts();
_cachedProducts = products;
}
}
Future<void> _onFetchProducts(
void _onFetchProducts(
FetchProductsEvent event,
Emitter<SpaceManagementState> emit,
) async {
@ -222,7 +223,7 @@ class SpaceManagementBloc
String communityUuid) async {
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
return _api.getSpaceHierarchy(communityUuid, projectUuid);
return await _api.getSpaceHierarchy(communityUuid, projectUuid);
}
Future<void> _onNewCommunity(
@ -237,7 +238,7 @@ class SpaceManagementBloc
return;
}
final prevSpaceModels = await fetchSpaceModels();
var prevSpaceModels = await fetchSpaceModels();
emit(BlankState(
communities: event.communities,
@ -254,15 +255,15 @@ class SpaceManagementBloc
try {
final previousState = state;
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
final spaceBloc = event.context.read<SpaceTreeBloc>();
final spaceTreeState = event.context.read<SpaceTreeBloc>().state;
var spaceBloc = event.context.read<SpaceTreeBloc>();
var spaceTreeState = event.context.read<SpaceTreeBloc>().state;
final communities =
List<CommunityModel> communities =
await _waitForCommunityList(spaceBloc, spaceTreeState);
await fetchSpaceModels();
// await fetchTags();
final prevSpaceModels = await fetchSpaceModels();
var prevSpaceModels = await fetchSpaceModels();
if (previousState is SpaceManagementLoaded ||
previousState is BlankState) {
@ -286,17 +287,18 @@ class SpaceManagementBloc
}
}
Future<void> _onLoadCommunityAndSpaces(
void _onLoadCommunityAndSpaces(
LoadCommunityAndSpacesEvent event,
Emitter<SpaceManagementState> emit,
) async {
final spaceTreeState = event.context.read<SpaceTreeBloc>().state;
final spaceBloc = event.context.read<SpaceTreeBloc>();
var spaceTreeState = event.context.read<SpaceTreeBloc>().state;
var spaceBloc = event.context.read<SpaceTreeBloc>();
_onloadProducts();
await fetchTags();
// Wait until `communityList` is loaded
final communities = await _waitForCommunityList(spaceBloc, spaceTreeState);
List<CommunityModel> communities =
await _waitForCommunityList(spaceBloc, spaceTreeState);
// Fetch space models after communities are available
final prevSpaceModels = await fetchSpaceModels();
@ -342,7 +344,7 @@ class SpaceManagementBloc
}
}
Future<void> _onCommunityDelete(
void _onCommunityDelete(
DeleteCommunityEvent event,
Emitter<SpaceManagementState> emit,
) async {
@ -363,7 +365,7 @@ class SpaceManagementBloc
}
}
Future<void> _onCreateCommunity(
void _onCreateCommunity(
CreateCommunityEvent event,
Emitter<SpaceManagementState> emit,
) async {
@ -373,9 +375,9 @@ class SpaceManagementBloc
try {
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
await fetchTags();
final newCommunity = await _api.createCommunity(
CommunityModel? newCommunity = await _api.createCommunity(
event.name, event.description, projectUuid);
final prevSpaceModels = await fetchSpaceModels();
var prevSpaceModels = await fetchSpaceModels();
if (newCommunity != null) {
if (previousState is SpaceManagementLoaded ||
@ -403,7 +405,7 @@ class SpaceManagementBloc
}
}
Future<void> _onSelectCommunity(
void _onSelectCommunity(
SelectCommunityEvent event,
Emitter<SpaceManagementState> emit,
) async {
@ -429,7 +431,7 @@ class SpaceManagementBloc
);
}
Future<void> _handleCommunitySpaceStateUpdate({
void _handleCommunitySpaceStateUpdate({
required Emitter<SpaceManagementState> emit,
CommunityModel? selectedCommunity,
SpaceModel? selectedSpace,
@ -462,7 +464,7 @@ class SpaceManagementBloc
}
}
Future<void> _onSaveSpaces(
void _onSaveSpaces(
SaveSpacesEvent event,
Emitter<SpaceManagementState> emit,
) async {
@ -492,9 +494,9 @@ class SpaceManagementBloc
event.spaces.removeWhere(
(space) => space.status == SpaceStatus.deleted,
);
for (final space in event.spaces) {
space.status = SpaceStatus.unchanged;
}
event.spaces.forEach(
(space) => space.status = SpaceStatus.unchanged,
);
}
} catch (e) {
// emit(SpaceManagementError('Error saving spaces: $e'));
@ -513,7 +515,7 @@ class SpaceManagementBloc
Emitter<SpaceManagementState> emit,
) async {
try {
final prevSpaceModels = await fetchSpaceModels();
var prevSpaceModels = await fetchSpaceModels();
await fetchTags();
@ -521,7 +523,7 @@ class SpaceManagementBloc
? spaceTreeState.filteredCommunity
: spaceTreeState.communityList;
for (final community in communities) {
for (var community in communities) {
if (community.uuid == communityUuid) {
community.spaces = allSpaces;
_spaceTreeBloc.add(InitialEvent());
@ -538,7 +540,7 @@ class SpaceManagementBloc
}
}
emit(previousState);
} catch (e) {
} catch (e, stackTrace) {
emit(previousState);
// rethrow;
}
@ -575,36 +577,36 @@ class SpaceManagementBloc
space.status == SpaceStatus.deleted &&
(space.parent == null || space.parent?.status != SpaceStatus.deleted));
for (final parent in parentsToDelete) {
for (var parent in parentsToDelete) {
try {
if (parent.uuid != null) {
await _api.deleteSpace(communityUuid, parent.uuid!, projectUuid);
}
} catch (e) {}
}
orderedSpaces.removeWhere(parentsToDelete.contains);
orderedSpaces.removeWhere((space) => parentsToDelete.contains(space));
for (final space in orderedSpaces) {
for (var space in orderedSpaces) {
try {
if (space.uuid != null && space.uuid!.isNotEmpty) {
var tagUpdates = <TagModelUpdate>[];
List<TagModelUpdate> tagUpdates = [];
final matchedSpaces =
List<SpaceModel> matchedSpaces =
findMatchingSpaces(selectedCommunity.spaces, space.uuid!);
if (matchedSpaces.isEmpty) continue;
final prevSpace = matchedSpaces.elementAtOrNull(0);
final subspaceUpdates = <UpdateSubspaceTemplateModel>[];
final prevSubspaces = prevSpace?.subspaces;
final newSubspaces = space.subspaces;
final List<UpdateSubspaceTemplateModel> subspaceUpdates = [];
final List<SubspaceModel>? prevSubspaces = prevSpace?.subspaces;
final List<SubspaceModel>? newSubspaces = space.subspaces;
tagUpdates = processTagUpdates(prevSpace?.tags, space.tags);
if (prevSubspaces != null || newSubspaces != null) {
if (prevSubspaces != null && newSubspaces != null) {
for (final prevSubspace in prevSubspaces) {
for (var prevSubspace in prevSubspaces) {
final existsInNew = newSubspaces
.any((subspace) => subspace.uuid == prevSubspace.uuid);
if (!existsInNew) {
@ -614,7 +616,7 @@ class SpaceManagementBloc
}
}
} else if (prevSubspaces != null && newSubspaces == null) {
for (final prevSubspace in prevSubspaces) {
for (var prevSubspace in prevSubspaces) {
subspaceUpdates.add(UpdateSubspaceTemplateModel(
action: custom_action.Action.delete,
uuid: prevSubspace.uuid));
@ -622,13 +624,13 @@ class SpaceManagementBloc
}
if (newSubspaces != null) {
for (final newSubspace in newSubspaces) {
for (var newSubspace in newSubspaces) {
// Tag without UUID
if (newSubspace.uuid == null || newSubspace.uuid!.isEmpty) {
final tagUpdates = <TagModelUpdate>[];
if ((newSubspace.uuid == null || newSubspace.uuid!.isEmpty)) {
final List<TagModelUpdate> tagUpdates = [];
if (newSubspace.tags != null) {
for (final tag in newSubspace.tags!) {
for (var tag in newSubspace.tags!) {
tagUpdates.add(TagModelUpdate(
action: custom_action.Action.add,
newTagUuid: tag.uuid == '' ? null : tag.uuid,
@ -646,14 +648,14 @@ class SpaceManagementBloc
if (prevSubspaces != null && newSubspaces != null) {
final newSubspaceMap = {
for (final subspace in newSubspaces) subspace.uuid: subspace
for (var subspace in newSubspaces) subspace.uuid: subspace
};
for (final prevSubspace in prevSubspaces) {
for (var prevSubspace in prevSubspaces) {
final newSubspace = newSubspaceMap[prevSubspace.uuid];
if (newSubspace != null) {
final tagSubspaceUpdates =
final List<TagModelUpdate> tagSubspaceUpdates =
processTagUpdates(prevSubspace.tags, newSubspace.tags);
subspaceUpdates.add(UpdateSubspaceTemplateModel(
action: custom_action.Action.update,
@ -667,7 +669,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,
@ -681,7 +683,7 @@ class SpaceManagementBloc
projectId: projectUuid);
} else {
// Call create if the space does not have a UUID
var tagBodyModels = space.tags != null
List<CreateTagBodyModel> tagBodyModels = space.tags != null
? space.tags!.map((tag) => tag.toCreateTagBodyModel()).toList()
: [];
@ -729,17 +731,17 @@ class SpaceManagementBloc
void visit(SpaceModel space) {
if (!result.contains(space)) {
result.add(space);
for (final child in spaces.where((s) => s.parent == space)) {
for (var child in spaces.where((s) => s.parent == space)) {
visit(child);
}
}
}
for (final space in topLevelSpaces) {
for (var space in topLevelSpaces) {
visit(space);
}
for (final space in spaces) {
for (var space in spaces) {
if (!result.contains(space)) {
result.add(space);
}
@ -747,7 +749,7 @@ class SpaceManagementBloc
return result.toList(); // Convert back to a list
}
Future<void> _onLoadSpaceModel(
void _onLoadSpaceModel(
SpaceModelLoadEvent event, Emitter<SpaceManagementState> emit) async {
emit(SpaceManagementLoading());
@ -758,9 +760,9 @@ class SpaceManagementBloc
? spaceTreeState.filteredCommunity
: spaceTreeState.communityList;
final communities = filteredCommunities;
List<CommunityModel> communities = filteredCommunities;
final prevSpaceModels = await fetchSpaceModels();
var prevSpaceModels = await fetchSpaceModels();
emit(SpaceModelLoaded(
communities: communities,
@ -776,11 +778,11 @@ class SpaceManagementBloc
List<Tag>? prevTags,
List<Tag>? newTags,
) {
final tagUpdates = <TagModelUpdate>[];
final List<TagModelUpdate> tagUpdates = [];
final processedTags = <String?>{};
if (prevTags == null && newTags != null) {
for (final newTag in newTags) {
for (var newTag in newTags) {
tagUpdates.add(TagModelUpdate(
action: custom_action.Action.add,
tag: newTag.tag,
@ -794,7 +796,7 @@ class SpaceManagementBloc
if (newTags != null || prevTags != null) {
// Case 1: Tags deleted
if (prevTags != null && newTags != null) {
for (final prevTag in prevTags) {
for (var prevTag in prevTags) {
final existsInNew =
newTags.any((newTag) => newTag.uuid == prevTag.uuid);
if (!existsInNew) {
@ -803,7 +805,7 @@ class SpaceManagementBloc
}
}
} else if (prevTags != null && newTags == null) {
for (final prevTag in prevTags) {
for (var prevTag in prevTags) {
tagUpdates.add(TagModelUpdate(
action: custom_action.Action.delete, uuid: prevTag.uuid));
}
@ -813,7 +815,7 @@ class SpaceManagementBloc
if (newTags != null) {
final prevTagUuids = prevTags?.map((t) => t.uuid).toSet() ?? {};
for (final newTag in newTags) {
for (var newTag in newTags) {
// Tag without UUID
if ((newTag.uuid == null || !prevTagUuids.contains(newTag.uuid)) &&
!processedTags.contains(newTag.tag)) {
@ -829,9 +831,9 @@ class SpaceManagementBloc
// Case 3: Tags updated
if (prevTags != null && newTags != null) {
final newTagMap = {for (final tag in newTags) tag.uuid: tag};
final newTagMap = {for (var tag in newTags) tag.uuid: tag};
for (final prevTag in prevTags) {
for (var prevTag in prevTags) {
final newTag = newTagMap[prevTag.uuid];
if (newTag != null) {
tagUpdates.add(TagModelUpdate(
@ -850,9 +852,9 @@ class SpaceManagementBloc
List<SpaceModel> findMatchingSpaces(
List<SpaceModel> spaces, String targetUuid) {
final matched = <SpaceModel>[];
List<SpaceModel> matched = [];
for (final space in spaces) {
for (var space in spaces) {
if (space.uuid == targetUuid) {
matched.add(space);
}

View File

@ -166,10 +166,10 @@ class SpaceModelLoadEvent extends SpaceManagementEvent {
class UpdateSpaceModelCache extends SpaceManagementEvent {
final SpaceTemplateModel updatedModel;
const UpdateSpaceModelCache(this.updatedModel);
UpdateSpaceModelCache(this.updatedModel);
}
class DeleteSpaceModelFromCache extends SpaceManagementEvent {
final String deletedUuid;
const DeleteSpaceModelFromCache(this.deletedUuid);
DeleteSpaceModelFromCache(this.deletedUuid);
}

View File

@ -40,10 +40,7 @@ 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 {

View File

@ -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,

View File

@ -27,12 +27,9 @@ 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()
: [],
);
}
@ -45,9 +42,7 @@ 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
};
}
}

View File

@ -1,6 +1,7 @@
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;

View File

@ -6,11 +6,7 @@ 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 {
@ -20,7 +16,7 @@ class SelectedProduct {
};
}
@override
@override
String toString() {
return 'SelectedProduct(productId: $productId, count: $count)';
}

View File

@ -56,7 +56,7 @@ class SpaceModel {
{String? parentInternalId}) {
final String internalId = json['internalId'] ?? const Uuid().v4();
final children = json['children'] != null
final List<SpaceModel> 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>?)
?.whereType<Map<String, dynamic>>() // Validate type
.map(SubspaceModel.fromJson)
?.where((e) => e is Map<String, dynamic>) // Validate type
.map((e) => SubspaceModel.fromJson(e as Map<String, dynamic>))
.toList() ??
[],
parent: parentInternalId != null
@ -102,8 +102,8 @@ class SpaceModel {
? SpaceTemplateModel.fromJson(json['spaceModel'])
: null,
tags: (json['productAllocations'] as List<dynamic>?)
?.whereType<Map<String, dynamic>>() // Validate type
.map(Tag.fromJson)
?.where((item) => item is Map<String, dynamic>) // Validate type
.map((item) => Tag.fromJson(item as Map<String, dynamic>))
.toList() ??
[],
);
@ -150,7 +150,7 @@ class SpaceModel {
extension SpaceExtensions on SpaceModel {
List<String> listAllTagValues() {
final tagValues = <String>[];
final List<String> tagValues = [];
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);
}
}

View File

@ -1,4 +1,5 @@
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
import 'space_model.dart';
class SpacesResponse {
final List<SpaceModel> data;

View File

@ -1,8 +1,9 @@
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;

View File

@ -6,12 +6,18 @@ import 'package:uuid/uuid.dart';
class Tag extends BaseTag {
Tag({
super.uuid,
required super.tag,
super.product,
super.internalId,
super.location,
});
String? uuid,
required String? tag,
ProductModel? product,
String? internalId,
String? location,
}) : super(
uuid: uuid,
tag: tag,
product: product,
internalId: internalId,
location: location,
);
factory Tag.fromJson(Map<String, dynamic> json) {
final String internalId = json['internalId'] ?? const Uuid().v4();
@ -44,7 +50,6 @@ class Tag extends BaseTag {
);
}
@override
Map<String, dynamic> toJson() {
return {
if (uuid != null) 'uuid': uuid,

View File

@ -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: const CenterBodyWidget(),
centerBody: CenterBodyWidget(),
rightBody: const NavigateHomeGridView(),
scaffoldBody: BlocBuilder<SpaceManagementBloc, SpaceManagementState>(
builder: (context, state) {

View File

@ -32,9 +32,8 @@ 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
@ -97,12 +96,10 @@ 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);
@ -117,11 +114,7 @@ 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(
@ -150,17 +143,13 @@ 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) {
@ -203,8 +192,7 @@ 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,

View File

@ -9,7 +9,7 @@ import 'package:syncrow_web/utils/color_manager.dart';
class BlankCommunityWidget extends StatefulWidget {
final List<CommunityModel> communities;
const BlankCommunityWidget({super.key, required this.communities});
BlankCommunityWidget({required this.communities});
@override
_BlankCommunityWidgetState createState() => _BlankCommunityWidgetState();
@ -19,7 +19,7 @@ class _BlankCommunityWidgetState extends State<BlankCommunityWidget> {
@override
Widget build(BuildContext context) {
return Expanded(
child: ColoredBox(
child: Container(
color:
ColorsManager.whiteColors, // Parent container with white background
child: GridView.builder(

View File

@ -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,

View File

@ -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;

View File

@ -3,23 +3,24 @@ 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/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/curved_line_painter.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';
@ -40,8 +41,7 @@ class CommunityStructureArea extends StatefulWidget {
final List<Tag> projectTags;
CommunityStructureArea(
{super.key,
this.selectedCommunity,
{this.selectedCommunity,
this.selectedSpace,
required this.communities,
this.products,
@ -120,7 +120,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
);
}
final screenSize = MediaQuery.of(context).size;
Size screenSize = MediaQuery.of(context).size;
return Expanded(
child: GestureDetector(
onTap: () {
@ -173,16 +173,16 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
children: [
InteractiveViewer(
transformationController: _transformationController,
boundaryMargin: const EdgeInsets.all(500),
boundaryMargin: EdgeInsets.all(500),
minScale: 0.5,
maxScale: 3.0,
constrained: false,
child: SizedBox(
child: Container(
width: canvasWidth,
height: canvasHeight,
child: Stack(
children: [
for (final connection in connections)
for (var 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 (final entry in spaces.asMap().entries)
for (var 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 isHighlighted =
final bool isHighlighted =
SpaceHelper.isHighlightedSpace(
spaces[index], widget.selectedSpace);
@ -267,9 +267,9 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
canvasHeight += 200;
}
if (node.position.dx <= 200) {
const double shiftAmount = 200;
double shiftAmount = 200;
canvasWidth += shiftAmount;
for (final n in spaces) {
for (var 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 (final space in spaces) {
for (var 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);
}
final newSpace = SpaceModel(
SpaceModel newSpace = SpaceModel(
name: name,
icon: icon,
position: newPosition,
@ -336,7 +336,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
tags: tags);
if (parentIndex != null) {
final parentSpace = spaces[parentIndex];
SpaceModel 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 (final space in spaces) {
for (var 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) {
final result = <SpaceModel>[];
final idToSpace = <String, SpaceModel>{};
List<SpaceModel> result = [];
Map<String, SpaceModel> idToSpace = {};
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 (final child in space.children) {
for (var child in space.children) {
flatten(child);
}
}
for (final space in spaces) {
for (var space in spaces) {
flatten(space);
}
for (final space in result) {
for (var 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) {
final connections = <Connection>[];
List<Connection> connections = [];
void addConnections(SpaceModel parent, String direction) {
if (parent.status == SpaceStatus.deleted) return;
for (final child in parent.children) {
for (var child in parent.children) {
if (child.status == SpaceStatus.deleted) continue;
connections.add(
@ -480,8 +480,8 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
}
}
for (final space in spaces) {
addConnections(space, 'down');
for (var space in spaces) {
addConnections(space, "down");
}
return connections;
@ -492,7 +492,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
return;
}
final spacesToSave = spaces.where((space) {
List<SpaceModel> 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;
}
final communityUuid = widget.selectedCommunity!.uuid;
String 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 (final space in spaces) {
for (var 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 (final child in parent.children) {
for (var child in parent.children) {
child.status = SpaceStatus.parentDeleted;
_markChildrenAsDeleted(child);
@ -543,11 +543,11 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
}
void _moveToSpace(SpaceModel space) {
final viewportWidth = MediaQuery.of(context).size.width;
final viewportHeight = MediaQuery.of(context).size.height;
final double viewportWidth = MediaQuery.of(context).size.width;
final double viewportHeight = MediaQuery.of(context).size.height;
final dx = -space.position.dx + (viewportWidth / 2) - 400;
final dy = -space.position.dy + (viewportHeight / 2) - 300;
final double dx = -space.position.dx + (viewportWidth / 2) - 400;
final double 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
final totalWidth = (parent.children.length) * (nodeWidth + 60);
final startX = parent.position.dx - (totalWidth / 2);
double totalWidth = (parent.children.length) * (nodeWidth + 60);
double startX = parent.position.dx - (totalWidth / 2);
final childX = startX + (parent.children.length * (nodeWidth + 60));
double 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 (final child in node.children) {
for (var child in node.children) {
totalWidth += calculateSubtreeWidth(child) + horizontalGap;
}
return totalWidth - horizontalGap;
}
void layoutSubtree(SpaceModel node, double startX, double y) {
final subtreeWidth = calculateSubtreeWidth(node);
final centerX = startX + subtreeWidth / 2 - nodeWidth / 2;
double subtreeWidth = calculateSubtreeWidth(node);
double 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 {
var childX = startX;
for (final child in node.children) {
final childWidth = calculateSubtreeWidth(child);
double childX = startX;
for (var child in node.children) {
double 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 roots = spaces
final List<SpaceModel> 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
const double currentY = 100; // top margin
double currentY = 100; // top margin
for (final root in roots) {
for (var root in roots) {
layoutSubtree(root, currentX, currentY);
final rootWidth = calculateSubtreeWidth(root);
double 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(() {
final parent = space.parent;
SpaceModel? parent = space.parent;
final duplicated = _deepCloneSpaceTree(space, parent: parent);
SpaceModel duplicated = _deepCloneSpaceTree(space, parent: parent);
duplicated.position =
Offset(space.position.dx + 300, space.position.dy + 100);
final duplicatedSubtree = <SpaceModel>[];
List<SpaceModel> duplicatedSubtree = [];
void collectSubtree(SpaceModel node) {
duplicatedSubtree.add(node);
for (final child in node.children) {
for (var child in node.children) {
collectSubtree(child);
}
}
@ -782,7 +782,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
parent: parent,
);
for (final child in original.children) {
for (var child in original.children) {
final duplicatedChild = _deepCloneSpaceTree(child, parent: newSpace);
newSpace.children.add(duplicatedChild);

View File

@ -7,10 +7,11 @@ class CounterWidget extends StatefulWidget {
final bool isCreate;
const CounterWidget(
{super.key,
{Key? key,
this.initialCount = 0,
required this.onCountChanged,
required this.isCreate});
required this.isCreate})
: super(key: key);
@override
State<CounterWidget> createState() => _CounterWidgetState();
@ -54,8 +55,7 @@ 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,15 +69,12 @@ 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.withValues(alpha: 0.3)
: ColorsManager.spaceColor,
color: isDisabled? ColorsManager.spaceColor.withOpacity(0.3): ColorsManager.spaceColor,
size: 18,
),
);

View File

@ -1,11 +1,12 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.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';
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';
class DevicesPartWidget extends StatelessWidget {
const DevicesPartWidget({
@ -27,73 +28,73 @@ class DevicesPartWidget extends StatelessWidget {
Widget build(BuildContext context) {
return Column(
children: [
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,
(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,
),
),
),
),
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)
],
),
),
)
else
TextButton(
onPressed: onTextButtonPressed,
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
),
child: ButtonContentWidget(
icon: Icons.add,
label: 'Add Devices',
disabled: isTagsAndSubspaceModelDisabled,
),
)
EditChip(onTap: onEditChip)
],
),
),
)
: TextButton(
onPressed: onTextButtonPressed,
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
),
child: ButtonContentWidget(
icon: Icons.add,
label: 'Add Devices',
disabled: isTagsAndSubspaceModelDisabled,
),
)
],
);
}

View File

@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
import '../../../../../utils/color_manager.dart';
import '../../../../../utils/constants/assets.dart';
class IconChoosePartWidget extends StatelessWidget {
const IconChoosePartWidget({

View File

@ -1,8 +1,9 @@
import 'package:flutter/material.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';
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';
class SpaceModelLinkingWidget extends StatelessWidget {
const SpaceModelLinkingWidget({
@ -22,67 +23,66 @@ class SpaceModelLinkingWidget extends StatelessWidget {
Widget build(BuildContext context) {
return Column(
children: [
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,
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),
),
),
child: const Icon(
Icons.close,
size: 16,
color: ColorsManager.lightGrayColor,
),
),
onDeleted: onDeleted),
],
),
),
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),
],
),
),
],
);
}

View File

@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import '../../../../../utils/color_manager.dart';
class SpaceNameTextfieldWidget extends StatelessWidget {
SpaceNameTextfieldWidget({

View File

@ -1,9 +1,10 @@
import 'package:flutter/material.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';
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';
class SubSpacePartWidget extends StatefulWidget {
SubSpacePartWidget({
@ -29,72 +30,71 @@ class _SubSpacePartWidgetState extends State<SubSpacePartWidget> {
Widget build(BuildContext context) {
return Column(
children: [
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
widget.subspaces == null || widget.subspaces!.isEmpty
? TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
overlayColor: ColorsManager.transparentColor,
),
),
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();
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();
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,
)
],
),
),
)
],
);
}

View File

@ -19,11 +19,15 @@ class CurvedLinePainter extends CustomPainter {
return; // Nothing to paint if there are no connections
}
for (final connection in connections) {
for (var connection in connections) {
// Ensure positions are valid before drawing lines
final start = connection.startSpace.position +
if (connection.endSpace.position == null) {
continue;
}
Offset start = connection.startSpace.position +
const Offset(75, 60); // Center bottom of start space
final end = connection.endSpace.position +
Offset end = connection.endSpace.position +
const Offset(75, 0); // Center top of end space
// Curved line for down connections

View File

@ -9,6 +9,7 @@ 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';
@ -98,9 +99,9 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
@override
Widget build(BuildContext context) {
final isSpaceModelDisabled = tags != null && tags!.isNotEmpty ||
subspaces != null && subspaces!.isNotEmpty;
final isTagsAndSubspaceModelDisabled = (selectedSpaceModel != null);
bool isSpaceModelDisabled = (tags != null && tags!.isNotEmpty ||
subspaces != null && subspaces!.isNotEmpty);
bool isTagsAndSubspaceModelDisabled = (selectedSpaceModel != null);
final screenWidth = MediaQuery.of(context).size.width;
return AlertDialog(
@ -297,7 +298,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
} else if (isNameFieldExist) {
return;
} else {
final newName = enteredName.isNotEmpty
String newName = enteredName.isNotEmpty
? enteredName
: (widget.name ?? '');
if (newName.isNotEmpty) {
@ -380,7 +381,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
products: products,
existingSubSpaces: existingSubSpaces,
onSave: (slectedSubspaces, updatedSubSpaces) {
final tagsToAppendToSpace = <Tag>[];
final List<Tag> tagsToAppendToSpace = [];
if (slectedSubspaces != null && slectedSubspaces.isNotEmpty) {
final updatedIds =
@ -389,11 +390,11 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
final deletedSubspaces = existingSubSpaces
.where((s) => !updatedIds.contains(s.internalId))
.toList();
for (final s in deletedSubspaces) {
for (var s in deletedSubspaces) {
if (s.tags != null) {
for (final tag in s.tags!) {
tag.location = null;
}
s.tags!.forEach(
(tag) => tag.location = null,
);
tagsToAppendToSpace.addAll(s.tags!);
}
}
@ -402,11 +403,11 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
if (existingSubSpaces != null) {
final deletedSubspaces = existingSubSpaces;
for (final s in deletedSubspaces) {
for (var s in deletedSubspaces) {
if (s.tags != null) {
for (final tag in s.tags!) {
tag.location = null;
}
s.tags!.forEach(
(tag) => tag.location = null,
);
tagsToAppendToSpace.addAll(s.tags!);
}
}

View File

@ -2,10 +2,9 @@ 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 title = isSpace ? 'Delete Space' : 'Delete Community';
final subtitle = isSpace
void showDeleteConfirmationDialog(BuildContext context, VoidCallback onConfirm, bool isSpace) {
final String title = isSpace ? 'Delete Space' : 'Delete Community';
final String subtitle = isSpace
? 'All the data in the space will be lost'
: 'All the data in the community will be lost';
@ -14,8 +13,7 @@ void showDeleteConfirmationDialog(
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(
@ -43,8 +41,7 @@ void showDeleteConfirmationDialog(
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)),
),
],
),
@ -57,17 +54,15 @@ void showDeleteConfirmationDialog(
);
}
void showProcessingPopup(
BuildContext context, bool isSpace, VoidCallback onDelete) {
final title = isSpace ? 'Delete Space' : 'Delete Community';
void showProcessingPopup(BuildContext context, bool isSpace, VoidCallback onDelete) {
final String 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(
@ -80,8 +75,7 @@ void showProcessingPopup(
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,
@ -89,8 +83,7 @@ void showProcessingPopup(
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',
@ -111,7 +104,7 @@ Widget _buildWarningIcon() {
return Container(
width: 50,
height: 50,
decoration: const BoxDecoration(
decoration: BoxDecoration(
color: ColorsManager.warningRed,
shape: BoxShape.circle,
),
@ -130,10 +123,7 @@ 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),
);
}

View File

@ -4,7 +4,8 @@ import 'package:syncrow_web/utils/color_manager.dart';
class DuplicateProcessDialog extends StatefulWidget {
final VoidCallback onDuplicate;
const DuplicateProcessDialog({required this.onDuplicate, super.key});
const DuplicateProcessDialog({required this.onDuplicate, Key? key})
: super(key: key);
@override
_DuplicateProcessDialogState createState() => _DuplicateProcessDialogState();
@ -19,7 +20,7 @@ class _DuplicateProcessDialogState extends State<DuplicateProcessDialog> {
_startDuplication();
}
Future<void> _startDuplication() async {
void _startDuplication() async {
WidgetsBinding.instance.addPostFrameCallback((_) {
widget.onDuplicate();
});
@ -54,7 +55,7 @@ class _DuplicateProcessDialogState extends State<DuplicateProcessDialog> {
),
const SizedBox(height: 15),
Text(
'Duplicating in progress',
"Duplicating in progress",
style: Theme.of(context)
.textTheme
.headlineSmall
@ -69,7 +70,7 @@ class _DuplicateProcessDialogState extends State<DuplicateProcessDialog> {
),
const SizedBox(height: 15),
Text(
'Duplicating successful',
"Duplicating successful",
textAlign: TextAlign.center,
style: Theme.of(context)
.textTheme

View File

@ -7,10 +7,10 @@ class IconSelectionDialog extends StatelessWidget {
final Function(String selectedIcon) onIconSelected;
const IconSelectionDialog({
super.key,
Key? key,
required this.spaceIconList,
required this.onIconSelected,
});
}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -21,23 +21,21 @@ 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
.withValues(alpha: 0.2), // Shadow color
color: ColorsManager.blackColor.withOpacity(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,

View File

@ -28,7 +28,7 @@ class GradientCanvasBorderWidget extends StatelessWidget {
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [
ColorsManager.semiTransparentBlackColor.withValues(alpha: 0.1),
ColorsManager.semiTransparentBlackColor.withOpacity(0.1),
ColorsManager.transparentColor,
],
),

View File

@ -8,11 +8,11 @@ class HoverableButton extends StatefulWidget {
final VoidCallback onTap;
const HoverableButton({
super.key,
Key? key,
required this.iconPath,
required this.text,
required this.onTap,
});
}) : super(key: key);
@override
State<HoverableButton> createState() => _HoverableButtonState();
@ -34,17 +34,14 @@ 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.withValues(alpha: 0.4),
color: ColorsManager.warningRed.withOpacity(0.4),
blurRadius: 8,
offset: const Offset(0, 4),
),

View File

@ -81,51 +81,49 @@ class _LoadedSpaceViewState extends State<LoadedSpaceView> {
return Stack(
clipBehavior: Clip.none,
children: [
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 ?? [],
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,
),
),
),
child: SpaceModelPage(
],
)
: 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,
onSpaceModelsUpdated: _onSpaceModelsUpdated,
communities: widget.communities,
spaceModels: _spaceModels,
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(),
],
);

View File

@ -13,12 +13,12 @@ class SelectedProductsButtons extends StatelessWidget {
final BuildContext context;
const SelectedProductsButtons({
super.key,
Key? key,
required this.products,
required this.selectedProducts,
required this.onProductsUpdated,
required this.context,
});
}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -86,7 +86,9 @@ class SelectedProductsButtons extends StatelessWidget {
builder: (context) => AddDeviceWidget(
products: products,
initialSelectedProducts: selectedProducts,
onProductsSelected: onProductsUpdated,
onProductsSelected: (selectedProductsMap) {
onProductsUpdated(selectedProductsMap);
},
),
);
}

View File

@ -5,7 +5,6 @@ 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';
@ -19,6 +18,8 @@ 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;
@ -54,15 +55,13 @@ 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,
),
);
@ -135,28 +134,24 @@ 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)
const Center(
if (spaceTreeState.paginationIsLoading || spaceTreeState.isSearching)
Center(
child: CircularProgressIndicator(),
)
],
@ -219,8 +214,7 @@ class _SidebarWidgetState extends State<SidebarWidget> {
});
context.read<SpaceManagementBloc>().add(
SelectSpaceEvent(
selectedCommunity: community, selectedSpace: space),
SelectSpaceEvent(selectedCommunity: community, selectedSpace: space),
);
},
children: space.children
@ -235,9 +229,8 @@ class _SidebarWidgetState extends State<SidebarWidget> {
);
}
void _onAddCommunity() => _selectedId?.isNotEmpty ?? true
? _clearSelection()
: _showCreateCommunityDialog();
void _onAddCommunity() =>
_selectedId?.isNotEmpty ?? true ? _clearSelection() : _showCreateCommunityDialog();
void _clearSelection() {
setState(() => _selectedId = '');

View File

@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/plus_button_widget.dart'; // Make sure to import your PlusButtonWidget
import 'plus_button_widget.dart'; // Make sure to import your PlusButtonWidget
class SpaceCardWidget extends StatelessWidget {
final int index;

View File

@ -78,7 +78,7 @@ class SpaceContainerWidget extends StatelessWidget {
borderRadius: BorderRadius.circular(15),
boxShadow: [
BoxShadow(
color: ColorsManager.lightGrayColor.withValues(alpha: 0.5),
color: ColorsManager.lightGrayColor.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: const Offset(0, 3), // Shadow position

View File

@ -27,7 +27,7 @@ class SpaceWidget extends StatelessWidget {
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: ColorsManager.lightGrayColor.withValues(alpha: 0.5),
color: ColorsManager.lightGrayColor.withOpacity(0.5),
spreadRadius: 5,
blurRadius: 7,
offset: const Offset(0, 3),

View File

@ -11,7 +11,7 @@ class AssignTagBloc extends Bloc<AssignTagEvent, AssignTagState> {
final initialTags = event.initialTags ?? [];
final existingTagCounts = <String, int>{};
for (final tag in initialTags) {
for (var tag in initialTags) {
if (tag.product != null) {
existingTagCounts[tag.product!.uuid] =
(existingTagCounts[tag.product!.uuid] ?? 0) + 1;
@ -20,7 +20,7 @@ class AssignTagBloc extends Bloc<AssignTagEvent, AssignTagState> {
final tags = <Tag>[];
for (final selectedProduct in event.addedProducts) {
for (var selectedProduct in event.addedProducts) {
final existingCount = existingTagCounts[selectedProduct.productId] ?? 0;
if (selectedProduct.count == 0 ||
@ -171,7 +171,7 @@ class AssignTagBloc extends Bloc<AssignTagEvent, AssignTagState> {
List<Tag> _calculateAvailableTags(List<Tag> allTags, List<Tag> selectedTags) {
final selectedTagSet = selectedTags
.where((tag) => tag.tag?.trim().isNotEmpty ?? false)
.where((tag) => (tag.tag?.trim().isNotEmpty ?? false))
.map((tag) => tag.tag!.trim())
.toSet();

View File

@ -1,6 +1,6 @@
import 'package:equatable/equatable.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/tag.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_product_model.dart';
abstract class AssignTagEvent extends Equatable {
const AssignTagEvent();

View File

@ -27,8 +27,7 @@ class AssignTagLoaded extends AssignTagState {
});
@override
List<Object?> get props =>
[tags, updatedTags, isSaveEnabled, errorMessage ?? ''];
List<Object?> get props => [tags, updatedTags, isSaveEnabled, errorMessage ?? ''];
}
class AssignTagError extends AssignTagState {

View File

@ -7,10 +7,11 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
import 'package:syncrow_web/pages/spaces_management/assign_tag/bloc/assign_tag_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/assign_tag/bloc/assign_tag_event.dart';
import 'package:syncrow_web/pages/spaces_management/assign_tag/bloc/assign_tag_state.dart';
import 'package:syncrow_web/pages/spaces_management/assign_tag/views/widgets/save_add_device_row_widget.dart';
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/views/widgets/assign_tags_tables_widget.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'widgets/save_add_device_row_widget.dart';
class AssignTagDialog extends StatelessWidget {
final List<ProductModel>? products;
final List<SubspaceModel>? subspaces;
@ -38,7 +39,7 @@ class AssignTagDialog extends StatelessWidget {
@override
Widget build(BuildContext context) {
final locations = (subspaces ?? [])
final List<String> locations = (subspaces ?? [])
.map((subspace) => subspace.subspaceName)
.toList()
..add('Main Space');

View File

@ -1,13 +1,14 @@
import 'package:flutter/material.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/add_device_type/views/add_device_type_widget.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_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/helper/tag_helper.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/utils/color_manager.dart';
import '../../../add_device_type/views/add_device_type_widget.dart';
import '../../../helper/tag_helper.dart';
class SaveAddDeviceRowWidget extends StatelessWidget {
const SaveAddDeviceRowWidget({
super.key,

View File

@ -3,8 +3,7 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/bloc/assign_tag_model_event.dart';
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/bloc/assign_tag_model_state.dart';
class AssignTagModelBloc
extends Bloc<AssignTagModelEvent, AssignTagModelState> {
class AssignTagModelBloc extends Bloc<AssignTagModelEvent, AssignTagModelState> {
final List<Tag> projectTags;
AssignTagModelBloc(this.projectTags) : super(AssignTagModelInitial()) {
@ -12,29 +11,25 @@ class AssignTagModelBloc
final initialTags = event.initialTags;
final existingTagCounts = <String, int>{};
for (final tag in initialTags) {
for (var tag in initialTags) {
if (tag.product != null) {
existingTagCounts[tag.product!.uuid] =
(existingTagCounts[tag.product!.uuid] ?? 0) + 1;
existingTagCounts[tag.product!.uuid] = (existingTagCounts[tag.product!.uuid] ?? 0) + 1;
}
}
final tags = <Tag>[];
for (final selectedProduct in event.addedProducts) {
for (var selectedProduct in event.addedProducts) {
final existingCount = existingTagCounts[selectedProduct.productId] ?? 0;
if (selectedProduct.count == 0 ||
selectedProduct.count <= existingCount) {
tags.addAll(initialTags
.where((tag) => tag.product?.uuid == selectedProduct.productId));
if (selectedProduct.count == 0 || selectedProduct.count <= existingCount) {
tags.addAll(initialTags.where((tag) => tag.product?.uuid == selectedProduct.productId));
continue;
}
final missingCount = selectedProduct.count - existingCount;
tags.addAll(initialTags
.where((tag) => tag.product?.uuid == selectedProduct.productId));
tags.addAll(initialTags.where((tag) => tag.product?.uuid == selectedProduct.productId));
if (missingCount > 0) {
tags.addAll(List.generate(
@ -59,8 +54,7 @@ class AssignTagModelBloc
on<UpdateTag>((event, emit) {
final currentState = state;
if (currentState is AssignTagModelLoaded &&
currentState.tags.isNotEmpty) {
if (currentState is AssignTagModelLoaded && currentState.tags.isNotEmpty) {
final tags = List<Tag>.from(currentState.tags);
if (event.index < 0 || event.index >= tags.length) return;
@ -87,12 +81,10 @@ class AssignTagModelBloc
on<UpdateLocation>((event, emit) {
final currentState = state;
if (currentState is AssignTagModelLoaded &&
currentState.tags.isNotEmpty) {
if (currentState is AssignTagModelLoaded && currentState.tags.isNotEmpty) {
final tags = List<Tag>.from(currentState.tags);
// Use copyWith for immutability
tags[event.index] =
tags[event.index].copyWith(location: event.location);
tags[event.index] = tags[event.index].copyWith(location: event.location);
final updatedTags = _calculateAvailableTags(projectTags, tags);
@ -108,8 +100,7 @@ class AssignTagModelBloc
on<ValidateTagModels>((event, emit) {
final currentState = state;
if (currentState is AssignTagModelLoaded &&
currentState.tags.isNotEmpty) {
if (currentState is AssignTagModelLoaded && currentState.tags.isNotEmpty) {
final tags = List<Tag>.from(currentState.tags);
emit(AssignTagModelLoaded(
@ -124,10 +115,8 @@ class AssignTagModelBloc
on<DeleteTagModel>((event, emit) {
final currentState = state;
if (currentState is AssignTagModelLoaded &&
currentState.tags.isNotEmpty) {
final tags = List<Tag>.from(currentState.tags)
..remove(event.tagToDelete);
if (currentState is AssignTagModelLoaded && currentState.tags.isNotEmpty) {
final tags = List<Tag>.from(currentState.tags)..remove(event.tagToDelete);
final updatedTags = _calculateAvailableTags(projectTags, tags);
@ -151,10 +140,8 @@ class AssignTagModelBloc
String? _getValidationError(List<Tag> tags) {
// Check for duplicate tags
final nonEmptyTags = tags
.map((tag) => tag.tag?.trim() ?? '')
.where((tag) => tag.isNotEmpty)
.toList();
final nonEmptyTags =
tags.map((tag) => tag.tag?.trim() ?? '').where((tag) => tag.isNotEmpty).toList();
final duplicateTags = nonEmptyTags
.fold<Map<String, int>>({}, (map, tag) {
@ -175,13 +162,12 @@ class AssignTagModelBloc
List<Tag> _calculateAvailableTags(List<Tag> allTags, List<Tag> selectedTags) {
final selectedTagSet = selectedTags
.where((tag) => tag.tag?.trim().isNotEmpty ?? false)
.where((tag) => (tag.tag?.trim().isNotEmpty ?? false))
.map((tag) => tag.tag!.trim())
.toSet();
final availableTags = allTags
.where((tag) =>
tag.tag != null && !selectedTagSet.contains(tag.tag!.trim()))
.where((tag) => tag.tag != null && !selectedTagSet.contains(tag.tag!.trim()))
.toList();
return availableTags;

View File

@ -1,6 +1,6 @@
import 'package:equatable/equatable.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/tag.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_product_model.dart';
abstract class AssignTagModelEvent extends Equatable {
const AssignTagModelEvent();

View File

@ -6,12 +6,13 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/bloc/assign_tag_model_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/bloc/assign_tag_model_event.dart';
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/bloc/assign_tag_model_state.dart';
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/views/widgets/RowOfCancelSaveWidget.dart';
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/views/widgets/assign_tags_tables_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/models/subspace_template_model.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'widgets/RowOfCancelSaveWidget.dart';
import 'widgets/assign_tags_tables_widget.dart';
class AssignTagModelsDialog extends StatelessWidget {
final List<ProductModel>? products;
final List<SubspaceTemplateModel>? subspaces;
@ -29,7 +30,7 @@ class AssignTagModelsDialog extends StatelessWidget {
final List<Tag> projectTags;
const AssignTagModelsDialog(
{super.key,
{Key? key,
required this.products,
required this.subspaces,
required this.addedProducts,
@ -42,11 +43,12 @@ class AssignTagModelsDialog extends StatelessWidget {
this.otherSpaceModels,
this.spaceModel,
this.allSpaceModels,
required this.projectTags});
required this.projectTags})
: super(key: key);
@override
Widget build(BuildContext context) {
final locations = (subspaces ?? [])
final List<String> locations = (subspaces ?? [])
.map((subspace) => subspace.subspaceName)
.toList()
..add('Main Space');

View File

@ -1,17 +1,18 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.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/model/product_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/bloc/assign_tag_model_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/bloc/assign_tag_model_state.dart';
import 'package:syncrow_web/pages/spaces_management/helper/tag_helper.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/subspace_template_model.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/dialog/create_space_model_dialog.dart';
import 'package:syncrow_web/pages/spaces_management/tag_model/views/add_device_type_model_widget.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import '../../../../../utils/color_manager.dart';
import '../../../../common/buttons/cancel_button.dart';
import '../../../../common/buttons/default_button.dart';
import '../../../all_spaces/model/product_model.dart';
import '../../../all_spaces/model/tag.dart';
import '../../../helper/tag_helper.dart';
import '../../../space_model/models/space_template_model.dart';
import '../../../space_model/models/subspace_template_model.dart';
import '../../../space_model/widgets/dialog/create_space_model_dialog.dart';
import '../../../tag_model/views/add_device_type_model_widget.dart';
import '../../bloc/assign_tag_model_bloc.dart';
import '../../bloc/assign_tag_model_state.dart';
class RowOfSaveCancelWidget extends StatelessWidget {
const RowOfSaveCancelWidget({

View File

@ -1,10 +1,11 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/common/dialog_dropdown.dart';
import 'package:syncrow_web/common/tag_dialog_textfield_dropdown.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:uuid/uuid.dart';
import '../../../../../common/dialog_dropdown.dart';
import '../../../../../common/tag_dialog_textfield_dropdown.dart';
import '../../../../../utils/color_manager.dart';
class AssignTagsTable extends StatelessWidget {
const AssignTagsTable({
super.key,

View File

@ -1,9 +1,8 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/create_community/bloc/community_dialog_event.dart';
import 'package:syncrow_web/pages/spaces_management/create_community/bloc/community_dialog_state.dart';
import 'community_dialog_event.dart';
import 'community_dialog_state.dart';
class CommunityDialogBloc
extends Bloc<CommunityDialogEvent, CommunityDialogState> {
class CommunityDialogBloc extends Bloc<CommunityDialogEvent, CommunityDialogState> {
final List<String> existingCommunityNames;
CommunityDialogBloc(this.existingCommunityNames)

View File

@ -1,11 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.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/create_community/bloc/community_dialog_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/create_community/bloc/community_dialog_event.dart';
import 'package:syncrow_web/pages/spaces_management/create_community/bloc/community_dialog_state.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/pages/common/buttons/cancel_button.dart';
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
class CreateCommunityDialog extends StatelessWidget {
final Function(String name, String description) onCreateCommunity;
@ -43,7 +43,7 @@ class CreateCommunityDialog extends StatelessWidget {
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: ColorsManager.blackColor.withValues(alpha: 0.25),
color: ColorsManager.blackColor.withOpacity(0.25),
blurRadius: 20,
spreadRadius: 5,
offset: const Offset(0, 5),
@ -53,8 +53,8 @@ class CreateCommunityDialog extends StatelessWidget {
child: SingleChildScrollView(
child: BlocBuilder<CommunityDialogBloc, CommunityDialogState>(
builder: (context, state) {
var isNameValid = true;
var isNameEmpty = false;
bool isNameValid = true;
bool isNameEmpty = false;
if (state is CommunityNameValidationState) {
isNameValid = state.isNameValid;
@ -139,7 +139,7 @@ class CreateCommunityDialog extends StatelessWidget {
if (isNameValid && !isNameEmpty) {
onCreateCommunity(
nameController.text.trim(),
'',
"",
);
Navigator.of(context).pop();
}

View File

@ -1,9 +1,10 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/subspace_model.dart';
import 'package:syncrow_web/pages/spaces_management/create_subspace/bloc/subspace_event.dart';
import 'package:syncrow_web/pages/spaces_management/create_subspace/bloc/subspace_state.dart';
import 'package:syncrow_web/utils/constants/action_enum.dart';
import 'subspace_event.dart';
import 'subspace_state.dart';
class SubSpaceBloc extends Bloc<SubSpaceEvent, SubSpaceState> {
SubSpaceBloc() : super(SubSpaceState([], [], '', {})) {
on<AddSubSpace>((event, emit) {
@ -76,7 +77,7 @@ class SubSpaceBloc extends Bloc<SubSpaceEvent, SubSpaceState> {
emit(SubSpaceState(
updatedSubSpaces,
updatedSubspaceModels,
errorMessage,
errorMessage ,
updatedDuplicates,
));
});

View File

@ -5,11 +5,12 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/subspace_mo
import 'package:syncrow_web/pages/spaces_management/create_subspace/bloc/subspace_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/create_subspace/bloc/subspace_event.dart';
import 'package:syncrow_web/pages/spaces_management/create_subspace/bloc/subspace_state.dart';
import 'package:syncrow_web/pages/spaces_management/create_subspace/views/widgets/ok_cancel_sub_space_widget.dart';
import 'package:syncrow_web/pages/spaces_management/create_subspace/views/widgets/textfield_sub_space_dialog_widget.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';
import 'widgets/ok_cancel_sub_space_widget.dart';
import 'widgets/textfield_sub_space_dialog_widget.dart';
class CreateSubSpaceDialog extends StatefulWidget {
final String dialogTitle;
final List<SubspaceModel>? existingSubSpaces;

View File

@ -1,11 +1,12 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/subspace_model.dart';
import 'package:syncrow_web/utils/color_manager.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/model/subspace_model.dart';
import 'package:syncrow_web/pages/spaces_management/create_subspace/bloc/subspace_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/create_subspace/bloc/subspace_event.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import '../../bloc/subspace_bloc.dart';
import '../../bloc/subspace_event.dart';
class OkCancelSubSpaceWidget extends StatelessWidget {
const OkCancelSubSpaceWidget({

View File

@ -1,13 +1,14 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/subspace_model.dart';
import 'package:syncrow_web/pages/spaces_management/create_subspace/bloc/subspace_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/create_subspace/bloc/subspace_event.dart';
import 'package:syncrow_web/pages/spaces_management/create_subspace_model/widgets/subspace_chip.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';
import '../../../../../utils/color_manager.dart';
import '../../../all_spaces/model/subspace_model.dart';
import '../../../create_subspace_model/widgets/subspace_chip.dart';
import '../../../space_model/models/subspace_template_model.dart';
import '../../bloc/subspace_bloc.dart';
import '../../bloc/subspace_event.dart';
class TextFieldSubSpaceDialogWidget extends StatelessWidget {
const TextFieldSubSpaceDialogWidget({
super.key,

View File

@ -60,7 +60,7 @@ class SubSpaceModelBloc extends Bloc<SubSpaceModelEvent, SubSpaceModelState> {
if (event.subSpace.uuid?.isNotEmpty ?? false) {
updatedSubspaceModels.add(UpdateSubspaceTemplateModel(
action: Action.delete,
uuid: event.subSpace.uuid,
uuid: event.subSpace.uuid!,
));
}
@ -104,7 +104,7 @@ class SubSpaceModelBloc extends Bloc<SubSpaceModelEvent, SubSpaceModelState> {
updatedSubspaceModels.add(UpdateSubspaceTemplateModel(
action: Action.update,
uuid: event.updatedSubSpace.uuid,
uuid: event.updatedSubSpace.uuid!,
));
emit(SubSpaceModelState(

View File

@ -28,8 +28,7 @@ class SubspaceChip extends StatelessWidget {
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: BorderSide(
color:
isDuplicate ? ColorsManager.red : ColorsManager.transparentColor,
color: isDuplicate ? ColorsManager.red : ColorsManager.transparentColor,
width: 0,
),
),

View File

@ -2,20 +2,18 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_m
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
class SpaceHelper {
static SpaceModel? findSpaceByUuid(
String? uuid, List<CommunityModel> communities) {
for (final community in communities) {
for (final space in community.spaces) {
static SpaceModel? findSpaceByUuid(String? uuid, List<CommunityModel> communities) {
for (var community in communities) {
for (var space in community.spaces) {
if (space.uuid == uuid) return space;
}
}
return null;
}
static SpaceModel? findSpaceByInternalId(
String? internalId, List<SpaceModel> spaces) {
static SpaceModel? findSpaceByInternalId(String? internalId, List<SpaceModel> spaces) {
if (internalId != null) {
for (final space in spaces) {
for (var space in spaces) {
if (space.internalId == internalId) return space;
}
}
@ -23,22 +21,21 @@ class SpaceHelper {
return null;
}
static String generateUniqueSpaceName(
String originalName, List<SpaceModel> spaces) {
static String generateUniqueSpaceName(String originalName, List<SpaceModel> spaces) {
final baseName = originalName.replaceAll(RegExp(r'\(\d+\)$'), '').trim();
var maxNumber = 0;
int maxNumber = 0;
for (final space in spaces) {
for (var space in spaces) {
final match = RegExp(r'^(.*?)\((\d+)\)$').firstMatch(space.name);
if (match != null && match.group(1)?.trim() == baseName) {
final existingNumber = int.parse(match.group(2)!);
int existingNumber = int.parse(match.group(2)!);
if (existingNumber > maxNumber) {
maxNumber = existingNumber;
}
}
}
return '$baseName(${maxNumber + 1})';
return "$baseName(${maxNumber + 1})";
}
static bool isSave(List<SpaceModel> spaces) {
@ -54,13 +51,10 @@ class SpaceHelper {
return space == selectedSpace ||
selectedSpace.parent?.internalId == space.internalId ||
selectedSpace.children
.any((child) => child.internalId == space.internalId) ==
true;
selectedSpace.children?.any((child) => child.internalId == space.internalId) == true;
}
static bool isNameConflict(
String value, SpaceModel? parentSpace, SpaceModel? editSpace) {
static bool isNameConflict(String value, SpaceModel? parentSpace, SpaceModel? editSpace) {
final siblings = parentSpace?.children
.where((child) => child.internalId != editSpace?.internalId)
.toList() ??
@ -71,19 +65,17 @@ class SpaceHelper {
.toList() ??
[];
final editSiblingConflict =
editSiblings.any((child) => child.name == value);
final editSiblingConflict = editSiblings.any((child) => child.name == value);
final siblingConflict = siblings.any((child) => child.name == value);
final parentConflict = parentSpace?.name == value &&
parentSpace?.internalId != editSpace?.internalId;
final parentConflict =
parentSpace?.name == value && parentSpace?.internalId != editSpace?.internalId;
final parentOfEditSpaceConflict = editSpace?.parent?.name == value &&
editSpace?.parent?.internalId != editSpace?.internalId;
final parentOfEditSpaceConflict =
editSpace?.parent?.name == value && editSpace?.parent?.internalId != editSpace?.internalId;
final childConflict =
editSpace?.children.any((child) => child.name == value) ?? false;
final childConflict = editSpace?.children.any((child) => child.name == value) ?? false;
return siblingConflict ||
parentConflict ||

View File

@ -24,7 +24,7 @@ class TagHelper {
final modifiedSubspaces = List<dynamic>.from(subspaces ?? []);
if (subspaces != null) {
for (final subspace in subspaces) {
for (var subspace in subspaces) {
getSubspaceTags(subspace)?.removeWhere(
(tag) => !modifiedTags.any(
(updatedTag) => getInternalId(updatedTag) == getInternalId(tag)),
@ -32,7 +32,7 @@ class TagHelper {
}
}
for (final tag in modifiedTags.toList()) {
for (var tag in modifiedTags.toList()) {
if (modifiedSubspaces.isEmpty) continue;
final prevIndice = checkTagExistInSubspace(tag, modifiedSubspaces);
@ -131,7 +131,8 @@ class TagHelper {
static List<String> getAvailableTagModels(
List<String> allTags, List<Tag> currentTags, Tag currentTag) {
final availableTagsForTagModel = TagHelper.getAvailableTags<Tag>(
List<String> availableTagsForTagModel =
TagHelper.getAvailableTags<Tag>(
allTags: allTags,
currentTags: currentTags,
currentTag: currentTag,
@ -144,14 +145,14 @@ class TagHelper {
List<Tag>? spaceTagModels,
List<SubspaceTemplateModel>? subspaces,
}) {
final initialTags = <Tag>[];
final List<Tag> initialTags = [];
if (spaceTagModels != null) {
initialTags.addAll(spaceTagModels);
}
if (subspaces != null) {
for (final subspace in subspaces) {
for (var subspace in subspaces) {
if (subspace.tags != null) {
initialTags.addAll(
subspace.tags!.map(
@ -173,14 +174,14 @@ class TagHelper {
List<Tag>? spaceTags,
List<SubspaceModel>? subspaces,
}) {
final initialTags = <Tag>[];
final List<Tag> initialTags = [];
if (spaceTags != null) {
initialTags.addAll(spaceTags);
}
if (subspaces != null) {
for (final subspace in subspaces) {
for (var subspace in subspaces) {
if (subspace.tags != null) {
initialTags.addAll(
subspace.tags!.map(
@ -199,8 +200,8 @@ class TagHelper {
}
static Map<ProductModel, int> groupTags(List<BaseTag> tags) {
final groupedTags = <ProductModel, int>{};
for (final tag in tags) {
final Map<ProductModel, int> groupedTags = {};
for (var tag in tags) {
if (tag.product != null) {
final product = tag.product!;
groupedTags[product] = (groupedTags[product] ?? 0) + 1;
@ -211,10 +212,10 @@ class TagHelper {
static List<SelectedProduct> createInitialSelectedProducts(
List<Tag>? tags, List<SubspaceTemplateModel>? subspaces) {
final productCounts = <ProductModel, int>{};
final Map<ProductModel, int> productCounts = {};
if (tags != null) {
for (final tag in tags) {
for (var tag in tags) {
if (tag.product != null) {
productCounts[tag.product!] = (productCounts[tag.product!] ?? 0) + 1;
}
@ -222,9 +223,9 @@ class TagHelper {
}
if (subspaces != null) {
for (final subspace in subspaces) {
for (var subspace in subspaces) {
if (subspace.tags != null) {
for (final tag in subspace.tags!) {
for (var tag in subspace.tags!) {
if (tag.product != null) {
productCounts[tag.product!] =
(productCounts[tag.product!] ?? 0) + 1;
@ -246,10 +247,10 @@ class TagHelper {
static List<SelectedProduct> createInitialSelectedProductsForTags(
List<Tag>? tags, List<SubspaceModel>? subspaces) {
final productCounts = <ProductModel, int>{};
final Map<ProductModel, int> productCounts = {};
if (tags != null) {
for (final tag in tags) {
for (var tag in tags) {
if (tag.product != null) {
productCounts[tag.product!] = (productCounts[tag.product!] ?? 0) + 1;
}
@ -257,9 +258,9 @@ class TagHelper {
}
if (subspaces != null) {
for (final subspace in subspaces) {
for (var subspace in subspaces) {
if (subspace.tags != null) {
for (final tag in subspace.tags!) {
for (var tag in subspace.tags!) {
if (tag.product != null) {
productCounts[tag.product!] =
(productCounts[tag.product!] ?? 0) + 1;
@ -279,13 +280,14 @@ class TagHelper {
.toList();
}
static int? checkTagExistInSubspaceModels(Tag tag, List<dynamic>? subspaces) {
static int? checkTagExistInSubspaceModels(
Tag tag, List<dynamic>? subspaces) {
if (subspaces == null) return null;
for (var i = 0; i < subspaces.length; i++) {
for (int i = 0; i < subspaces.length; i++) {
final subspace = subspaces[i] as SubspaceTemplateModel; // Explicit cast
if (subspace.tags == null) continue;
for (final t in subspace.tags!) {
for (var t in subspace.tags!) {
if (tag.internalId == t.internalId) {
return i;
}
@ -312,11 +314,11 @@ class TagHelper {
final processedSubspaces =
List<SubspaceTemplateModel>.from(result['subspaces'] as List<dynamic>);
for (final subspace in processedSubspaces) {
for (var subspace in processedSubspaces) {
final subspaceTags = subspace.tags;
if (subspaceTags != null) {
for (var i = 0; i < subspaceTags.length; i++) {
for (int i = 0; i < subspaceTags.length; i++) {
final tag = subspaceTags[i];
// Find the updated tag inside processedTags
@ -339,10 +341,10 @@ class TagHelper {
static int? checkTagExistInSubspace(Tag tag, List<dynamic>? subspaces) {
if (subspaces == null) return null;
for (var i = 0; i < subspaces.length; i++) {
for (int i = 0; i < subspaces.length; i++) {
final subspace = subspaces[i];
if (subspace.tags == null) continue;
for (final t in subspace.tags!) {
for (var t in subspace.tags!) {
if (tag.internalId == t.internalId) {
return i;
}
@ -369,11 +371,11 @@ class TagHelper {
final processedSubspaces =
List<SubspaceModel>.from(result['subspaces'] as List<dynamic>);
for (final subspace in processedSubspaces) {
for (var subspace in processedSubspaces) {
final subspaceTags = subspace.tags;
if (subspaceTags != null) {
for (var i = 0; i < subspaceTags.length; i++) {
for (int i = 0; i < subspaceTags.length; i++) {
final tag = subspaceTags[i];
final changedTag = updatedTags.firstWhere(
@ -395,10 +397,10 @@ class TagHelper {
static List<String> getAllTagValues(
List<CommunityModel> communities, List<SpaceTemplateModel>? spaceModels) {
final allTags = <String>{};
final Set<String> allTags = {};
if (spaceModels != null) {
for (final model in spaceModels) {
for (var model in spaceModels) {
allTags.addAll(model.listAllTagValues());
}
}

View File

@ -26,27 +26,27 @@ class LinkSpaceToModelBloc
Future<void> _getSpaceIds(LinkSpaceModelSelectedIdsEvent event,
Emitter<LinkSpaceToModelState> emit) async {
try {
final context = NavigationService.navigatorKey.currentContext!;
final spaceBloc = context.read<SpaceTreeBloc>();
spacesListIds.clear();
for (final communityId in spaceBloc.state.selectedCommunities) {
final spacesList =
BuildContext context = NavigationService.navigatorKey.currentContext!;
var spaceBloc = context.read<SpaceTreeBloc>();
spacesListIds.clear();
for (var communityId in spaceBloc.state.selectedCommunities) {
List<String> spacesList =
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
spacesListIds.addAll(spacesList);
spacesListIds.addAll(spacesList);
}
hasSelectedSpaces =
spaceBloc.state.selectedCommunities.any((communityId) {
final spacesList =
List<String> spacesList =
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
return spacesList.isNotEmpty;
});
if (hasSelectedSpaces) {
debugPrint('At least one space is selected.');
debugPrint("At least one space is selected.");
} else {
debugPrint('No spaces selected.');
debugPrint("No spaces selected.");
}
} catch (e) {
debugPrint('Error in _getSpaceIds: $e');
debugPrint("Error in _getSpaceIds: $e");
}
}

View File

@ -5,9 +5,9 @@ abstract class LinkSpaceToModelState {
class SpaceModelInitial extends LinkSpaceToModelState {}
class SpaceModelLoading extends LinkSpaceToModelState {}
class LinkSpaceModelLoading extends LinkSpaceToModelState {}
class SpaceModelSelectedState extends LinkSpaceToModelState {
final int selectedIndex;
const SpaceModelSelectedState(this.selectedIndex);

View File

@ -15,11 +15,11 @@ class LinkSpaceModelDialog extends StatelessWidget {
final List<SpaceTemplateModel> spaceModels;
const LinkSpaceModelDialog({
super.key,
Key? key,
this.onSave,
this.initialSelectedIndex,
required this.spaceModels,
});
}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -39,10 +39,9 @@ class LinkSpaceModelDialog extends StatelessWidget {
color: ColorsManager.textFieldGreyColor,
width: MediaQuery.of(context).size.width * 0.7,
height: MediaQuery.of(context).size.height * 0.6,
child: BlocBuilder<LinkSpaceToModelBloc,
LinkSpaceToModelState>(
child: BlocBuilder<LinkSpaceToModelBloc, LinkSpaceToModelState>(
builder: (context, state) {
var selectedIndex = -1;
int selectedIndex = -1;
if (state is SpaceModelSelectedState) {
selectedIndex = state.selectedIndex;
}
@ -73,9 +72,7 @@ class LinkSpaceModelDialog extends StatelessWidget {
),
borderRadius: BorderRadius.circular(8.0),
),
child: SpaceModelCardWidget(
model: model,
),
child: SpaceModelCardWidget(model: model,),
),
);
},

View File

@ -5,6 +5,7 @@ import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_spac
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_state.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/models/create_space_template_body_model.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/subspace_template_model.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_update_model.dart';
import 'package:syncrow_web/services/space_model_mang_api.dart';
import 'package:syncrow_web/utils/constants/action_enum.dart';
@ -20,7 +21,7 @@ class CreateSpaceModelBloc
try {
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
late final spaceTemplate = event.spaceTemplate;
late SpaceTemplateModel spaceTemplate = event.spaceTemplate;
final tagBodyModels =
spaceTemplate.tags?.map((tag) => tag.toTagBodyModel()).toList() ??
@ -54,7 +55,7 @@ class CreateSpaceModelBloc
}
}
} catch (e) {
emit(const CreateSpaceModelError('Error creating space model'));
emit(CreateSpaceModelError('Error creating space model'));
}
});
@ -64,14 +65,14 @@ class CreateSpaceModelBloc
if (_space != null) {
emit(CreateSpaceModelLoaded(_space!));
} else {
emit(const CreateSpaceModelError('No space template found'));
emit(CreateSpaceModelError("No space template found"));
}
});
});
on<UpdateSpaceTemplate>((event, emit) {
_space = event.spaceTemplate;
final errorMessage = _checkDuplicateModelName(
final String? errorMessage = _checkDuplicateModelName(
event.allModels ?? [], event.spaceTemplate.modelName);
emit(CreateSpaceModelLoaded(_space!, errorMessage: errorMessage));
});
@ -93,8 +94,9 @@ class CreateSpaceModelBloc
orElse: () => subspace,
);
final updatedTags = [
...subspace.tags?.map<Tag>((tag) {
...?subspace.tags?.map<Tag>((tag) {
final matchingTag =
matchingEventSubspace.tags?.firstWhere(
(e) => e.internalId == tag.internalId,
@ -106,7 +108,7 @@ class CreateSpaceModelBloc
: tag;
}) ??
<Tag>[],
...matchingEventSubspace.tags?.where(
...?matchingEventSubspace.tags?.where(
(e) =>
subspace.tags
?.every((t) => t.internalId != e.internalId) ??
@ -125,7 +127,9 @@ class CreateSpaceModelBloc
event.subspaces
.where((e) =>
updatedSubspaces.every((s) => s.internalId != e.internalId))
.forEach(updatedSubspaces.add);
.forEach((newSubspace) {
updatedSubspaces.add(newSubspace);
});
final updatedSpace =
currentState.space.copyWith(subspaceModels: updatedSubspaces);
@ -133,7 +137,7 @@ class CreateSpaceModelBloc
emit(CreateSpaceModelLoaded(updatedSpace,
errorMessage: currentState.errorMessage));
} else {
emit(const CreateSpaceModelError('Space template not initialized'));
emit(CreateSpaceModelError("Space template not initialized"));
}
});
@ -159,12 +163,14 @@ class CreateSpaceModelBloc
event.tags
.where(
(e) => updatedTags.every((t) => t.internalId != e.internalId))
.forEach(updatedTags.add);
.forEach((e) {
updatedTags.add(e);
});
emit(CreateSpaceModelLoaded(
currentState.space.copyWith(tags: updatedTags)));
} else {
emit(const CreateSpaceModelError('Space template not initialized'));
emit(CreateSpaceModelError("Space template not initialized"));
}
});
@ -174,12 +180,12 @@ class CreateSpaceModelBloc
if (event.allModels.contains(event.name) == true) {
emit(CreateSpaceModelLoaded(
currentState.space,
errorMessage: 'Duplicate Model name',
errorMessage: "Duplicate Model name",
));
} else if (event.name.trim().isEmpty) {
emit(CreateSpaceModelLoaded(
currentState.space,
errorMessage: 'Model name cannot be empty',
errorMessage: "Model name cannot be empty",
));
} else {
final updatedSpaceModel =
@ -188,7 +194,7 @@ class CreateSpaceModelBloc
emit(CreateSpaceModelLoaded(updatedSpaceModel));
}
} else {
emit(const CreateSpaceModelError('Space template not initialized'));
emit(CreateSpaceModelError("Space template not initialized"));
}
});
@ -205,17 +211,19 @@ class CreateSpaceModelBloc
if (prevSpaceModel?.modelName != newSpaceModel.modelName) {
spaceModelName = newSpaceModel.modelName;
}
var tagUpdates = <TagModelUpdate>[];
final subspaceUpdates = <UpdateSubspaceTemplateModel>[];
final prevSubspaces = prevSpaceModel?.subspaceModels;
final newSubspaces = newSpaceModel.subspaceModels;
List<TagModelUpdate> tagUpdates = [];
final List<UpdateSubspaceTemplateModel> subspaceUpdates = [];
final List<SubspaceTemplateModel>? prevSubspaces =
prevSpaceModel?.subspaceModels;
final List<SubspaceTemplateModel>? newSubspaces =
newSpaceModel.subspaceModels;
tagUpdates =
processTagUpdates(prevSpaceModel?.tags, newSpaceModel.tags);
if (prevSubspaces != null || newSubspaces != null) {
if (prevSubspaces != null && newSubspaces != null) {
for (final prevSubspace in prevSubspaces) {
for (var prevSubspace in prevSubspaces) {
final existsInNew = newSubspaces
.any((subspace) => subspace.uuid == prevSubspace.uuid);
if (!existsInNew) {
@ -224,20 +232,20 @@ class CreateSpaceModelBloc
}
}
} else if (prevSubspaces != null && newSubspaces == null) {
for (final prevSubspace in prevSubspaces) {
for (var prevSubspace in prevSubspaces) {
subspaceUpdates.add(UpdateSubspaceTemplateModel(
action: Action.delete, uuid: prevSubspace.uuid));
}
}
if (newSubspaces != null) {
for (final newSubspace in newSubspaces) {
for (var newSubspace in newSubspaces) {
// Tag without UUID
if (newSubspace.uuid == null || newSubspace.uuid!.isEmpty) {
final tagUpdates = <TagModelUpdate>[];
if ((newSubspace.uuid == null || newSubspace.uuid!.isEmpty)) {
final List<TagModelUpdate> tagUpdates = [];
if (newSubspace.tags != null) {
for (final tag in newSubspace.tags!) {
for (var tag in newSubspace.tags!) {
tagUpdates.add(TagModelUpdate(
action: Action.add,
newTagUuid: tag.uuid == '' ? null : tag.uuid,
@ -255,14 +263,14 @@ class CreateSpaceModelBloc
if (prevSubspaces != null && newSubspaces != null) {
final newSubspaceMap = {
for (final subspace in newSubspaces) subspace.uuid: subspace
for (var subspace in newSubspaces) subspace.uuid: subspace
};
for (final prevSubspace in prevSubspaces) {
for (var prevSubspace in prevSubspaces) {
final newSubspace = newSubspaceMap[prevSubspace.uuid];
if (newSubspace != null) {
final tagSubspaceUpdates =
final List<TagModelUpdate> tagSubspaceUpdates =
processTagUpdates(prevSubspace.tags, newSubspace.tags);
subspaceUpdates.add(UpdateSubspaceTemplateModel(
action: Action.update,
@ -290,7 +298,7 @@ class CreateSpaceModelBloc
}
}
} catch (e) {
emit(const CreateSpaceModelError('Error creating space model'));
emit(CreateSpaceModelError('Error creating space model'));
}
});
}
@ -299,11 +307,11 @@ class CreateSpaceModelBloc
List<Tag>? prevTags,
List<Tag>? newTags,
) {
final tagUpdates = <TagModelUpdate>[];
final List<TagModelUpdate> tagUpdates = [];
final processedTags = <String?>{};
if (prevTags == null && newTags != null) {
for (final newTag in newTags) {
for (var newTag in newTags) {
tagUpdates.add(TagModelUpdate(
action: Action.add,
tag: newTag.tag,
@ -317,7 +325,7 @@ class CreateSpaceModelBloc
if (newTags != null || prevTags != null) {
// Case 1: Tags deleted
if (prevTags != null && newTags != null) {
for (final prevTag in prevTags) {
for (var prevTag in prevTags) {
final existsInNew =
newTags.any((newTag) => newTag.uuid == prevTag.uuid);
if (!existsInNew) {
@ -326,7 +334,7 @@ class CreateSpaceModelBloc
}
}
} else if (prevTags != null && newTags == null) {
for (final prevTag in prevTags) {
for (var prevTag in prevTags) {
tagUpdates
.add(TagModelUpdate(action: Action.delete, uuid: prevTag.uuid));
}
@ -336,7 +344,7 @@ class CreateSpaceModelBloc
if (newTags != null) {
final prevTagUuids = prevTags?.map((t) => t.uuid).toSet() ?? {};
for (final newTag in newTags) {
for (var newTag in newTags) {
// Tag without UUID
if ((newTag.uuid == null || !prevTagUuids.contains(newTag.uuid)) &&
!processedTags.contains(newTag.tag)) {
@ -352,9 +360,9 @@ class CreateSpaceModelBloc
// Case 3: Tags updated
if (prevTags != null && newTags != null) {
final newTagMap = {for (final tag in newTags) tag.uuid: tag};
final newTagMap = {for (var tag in newTags) tag.uuid: tag};
for (final prevTag in prevTags) {
for (var prevTag in prevTags) {
final newTag = newTagMap[prevTag.uuid];
if (newTag != null) {
tagUpdates.add(TagModelUpdate(
@ -373,7 +381,7 @@ class CreateSpaceModelBloc
String? _checkDuplicateModelName(List<String> allModels, String name) {
if (allModels.contains(name)) {
return 'Duplicate Model name';
return "Duplicate Model name";
}
return null;
}

View File

@ -16,7 +16,7 @@ class UpdateSpaceTemplate extends CreateSpaceModelEvent {
final SpaceTemplateModel spaceTemplate;
List<String>? allModels;
UpdateSpaceTemplate(this.spaceTemplate, this.allModels);
UpdateSpaceTemplate(this.spaceTemplate,this.allModels);
}
class CreateSpaceTemplate extends CreateSpaceModelEvent {
@ -36,7 +36,7 @@ class UpdateSpaceTemplateName extends CreateSpaceModelEvent {
final String name;
final List<String> allModels;
const UpdateSpaceTemplateName({required this.name, required this.allModels});
UpdateSpaceTemplateName({required this.name, required this.allModels});
@override
List<Object> get props => [name, allModels];
@ -45,19 +45,19 @@ class UpdateSpaceTemplateName extends CreateSpaceModelEvent {
class AddSubspacesToSpaceTemplate extends CreateSpaceModelEvent {
final List<SubspaceTemplateModel> subspaces;
const AddSubspacesToSpaceTemplate(this.subspaces);
AddSubspacesToSpaceTemplate(this.subspaces);
}
class AddTagsToSpaceTemplate extends CreateSpaceModelEvent {
final List<Tag> tags;
const AddTagsToSpaceTemplate(this.tags);
AddTagsToSpaceTemplate(this.tags);
}
class ValidateSpaceTemplateName extends CreateSpaceModelEvent {
final String name;
const ValidateSpaceTemplateName({required this.name});
ValidateSpaceTemplateName({required this.name});
}
class ModifySpaceTemplate extends CreateSpaceModelEvent {
@ -65,7 +65,7 @@ class ModifySpaceTemplate extends CreateSpaceModelEvent {
final SpaceTemplateModel updatedSpaceTemplate;
final Function(SpaceTemplateModel)? onUpdate;
const ModifySpaceTemplate(
ModifySpaceTemplate(
{required this.spaceTemplate,
required this.updatedSpaceTemplate,
this.onUpdate});

View File

@ -16,7 +16,7 @@ class CreateSpaceModelLoaded extends CreateSpaceModelState {
final SpaceTemplateModel space;
final String? errorMessage;
const CreateSpaceModelLoaded(this.space, {this.errorMessage});
CreateSpaceModelLoaded(this.space, {this.errorMessage});
@override
List<Object?> get props => [space, errorMessage];
@ -25,5 +25,5 @@ class CreateSpaceModelLoaded extends CreateSpaceModelState {
class CreateSpaceModelError extends CreateSpaceModelState {
final String message;
const CreateSpaceModelError(this.message);
CreateSpaceModelError(this.message);
}

View File

@ -21,21 +21,18 @@ class SpaceModelBloc extends Bloc<SpaceModelEvent, SpaceModelState> {
on<DeleteSpaceModel>(_onDeleteSpaceModel);
}
Future<void> _onCreateSpaceModel(
CreateSpaceModel event, Emitter<SpaceModelState> emit) async {
Future<void> _onCreateSpaceModel(CreateSpaceModel event, Emitter<SpaceModelState> emit) async {
final currentState = state;
if (currentState is SpaceModelLoaded) {
try {
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
final newSpaceModel = await api.getSpaceModel(
event.newSpaceModel.uuid ?? '', projectUuid);
final newSpaceModel = await api.getSpaceModel(event.newSpaceModel.uuid ?? '', projectUuid);
if (newSpaceModel != null) {
final updatedSpaceModels =
List<SpaceTemplateModel>.from(currentState.spaceModels)
..add(newSpaceModel);
final updatedSpaceModels = List<SpaceTemplateModel>.from(currentState.spaceModels)
..add(newSpaceModel);
emit(SpaceModelLoaded(spaceModels: updatedSpaceModels));
}
} catch (e) {
@ -44,15 +41,13 @@ class SpaceModelBloc extends Bloc<SpaceModelEvent, SpaceModelState> {
}
}
Future<void> _onUpdateSpaceModel(
UpdateSpaceModel event, Emitter<SpaceModelState> emit) async {
Future<void> _onUpdateSpaceModel(UpdateSpaceModel event, Emitter<SpaceModelState> emit) async {
final currentState = state;
if (currentState is SpaceModelLoaded) {
try {
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
final newSpaceModel =
await api.getSpaceModel(event.spaceModelUuid, projectUuid);
final newSpaceModel = await api.getSpaceModel(event.spaceModelUuid, projectUuid);
if (newSpaceModel != null) {
final updatedSpaceModels = currentState.spaceModels.map((model) {
return model.uuid == event.spaceModelUuid ? newSpaceModel : model;
@ -66,16 +61,14 @@ class SpaceModelBloc extends Bloc<SpaceModelEvent, SpaceModelState> {
}
}
Future<void> _onDeleteSpaceModel(
DeleteSpaceModel event, Emitter<SpaceModelState> emit) async {
Future<void> _onDeleteSpaceModel(DeleteSpaceModel event, Emitter<SpaceModelState> emit) async {
final currentState = state;
if (currentState is SpaceModelLoaded) {
try {
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
final deletedSuccessfully =
await api.deleteSpaceModel(event.spaceModelUuid, projectUuid);
final deletedSuccessfully = await api.deleteSpaceModel(event.spaceModelUuid, projectUuid);
if (deletedSuccessfully) {
final updatedSpaceModels = currentState.spaceModels

View File

@ -30,18 +30,19 @@ class SpaceTemplateModel extends Equatable {
return SpaceTemplateModel(
uuid: json['uuid'] ?? '',
createdAt: json['createdAt'] != null
? DateTime.tryParse(json['createdAt'])
? DateTime.tryParse(json['createdAt'])
: null,
internalId: internalId,
modelName: json['modelName'] ?? '',
subspaceModels: (json['subspaceModels'] as List<dynamic>?)
?.whereType<Map<String, dynamic>>()
.map(SubspaceTemplateModel.fromJson)
?.where((e) => e is Map<String, dynamic>)
.map((e) =>
SubspaceTemplateModel.fromJson(e as Map<String, dynamic>))
.toList() ??
[],
tags: (json['tags'] as List<dynamic>?)
?.whereType<Map<String, dynamic>>() // Validate type
.map(Tag.fromJson)
?.where((item) => item is Map<String, dynamic>) // Validate type
.map((item) => Tag.fromJson(item as Map<String, dynamic>))
.toList() ??
[],
);
@ -108,7 +109,7 @@ class UpdateSubspaceTemplateModel {
extension SpaceTemplateExtensions on SpaceTemplateModel {
List<String> listAllTagValues() {
final tagValues = <String>[];
final List<String> tagValues = [];
if (tags != null) {
tagValues.addAll(

View File

@ -18,10 +18,8 @@ class SpaceModelPage extends StatelessWidget {
final List<Tag> projectTags;
const SpaceModelPage(
{super.key,
this.products,
this.onSpaceModelsUpdated,
required this.projectTags});
{Key? key, this.products, this.onSpaceModelsUpdated, required this.projectTags})
: super(key: key);
@override
Widget build(BuildContext context) {
@ -79,8 +77,7 @@ class SpaceModelPage extends StatelessWidget {
}
// Render existing space model
final model = spaceModels[index];
final otherModel =
List<String>.from(allSpaceModelNames);
final otherModel = List<String>.from(allSpaceModelNames);
otherModel.remove(model.modelName);
return GestureDetector(
onTap: () {
@ -118,10 +115,8 @@ class SpaceModelPage extends StatelessWidget {
return Center(
child: Text(
'Error: ${state.message}',
style: Theme.of(context)
.textTheme
.bodySmall
?.copyWith(color: ColorsManager.warningRed),
style:
Theme.of(context).textTheme.bodySmall?.copyWith(color: ColorsManager.warningRed),
),
);
}
@ -131,7 +126,7 @@ class SpaceModelPage extends StatelessWidget {
}
double _calculateChildAspectRatio(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;
double screenWidth = MediaQuery.of(context).size.width;
if (screenWidth > 1600) {
return 1.5; // Decrease to make cards taller
}
@ -145,7 +140,7 @@ class SpaceModelPage extends StatelessWidget {
}
List<String> _getAllTagValues(List<SpaceTemplateModel> spaceModels) {
final allTags = <String>[];
final List<String> allTags = [];
for (final spaceModel in spaceModels) {
if (spaceModel.tags != null) {
allTags.addAll(spaceModel.listAllTagValues());
@ -155,7 +150,7 @@ class SpaceModelPage extends StatelessWidget {
}
List<String> _getAllSpaceModelName(List<SpaceTemplateModel> spaceModels) {
final names = <String>[];
final List<String> names = [];
for (final spaceModel in spaceModels) {
names.add(spaceModel.modelName);
}

View File

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:syncrow_web/utils/color_manager.dart';
class AddSpaceModelWidget extends StatelessWidget {
const AddSpaceModelWidget({super.key});
const AddSpaceModelWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {

View File

@ -9,12 +9,12 @@ class ButtonContentWidget extends StatelessWidget {
final bool disabled;
const ButtonContentWidget({
super.key,
Key? key,
this.icon,
required this.label,
this.svgAssets,
this.disabled = false,
});
}) : super(key: key);
@override
Widget build(BuildContext context) {

View File

@ -45,7 +45,7 @@ class ConfirmMergeDialog extends StatelessWidget {
elevation: 3,
),
child: Text(
'Cancel',
"Cancel",
style: Theme.of(context)
.textTheme
.bodyMedium
@ -66,7 +66,7 @@ class ConfirmMergeDialog extends StatelessWidget {
elevation: 3,
),
child: Text(
'Ok',
"Ok",
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w400,
fontSize: 16,

View File

@ -56,7 +56,7 @@ class ConfirmOverwriteDialog extends StatelessWidget {
elevation: 3,
),
child: Text(
'Cancel',
"Cancel",
style: Theme.of(context)
.textTheme
.bodyMedium
@ -86,7 +86,7 @@ class ConfirmOverwriteDialog extends StatelessWidget {
elevation: 3,
),
child: Text(
'Ok',
"Ok",
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w400,
fontSize: 16,

View File

@ -9,12 +9,13 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_event.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_state.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_event.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_state.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/subspace_model_create_widget.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/tag_chips_display_widget.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_event.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/subspace_model_create_widget.dart';
import 'package:syncrow_web/services/space_model_mang_api.dart';
import 'package:syncrow_web/utils/color_manager.dart';
@ -28,21 +29,22 @@ class CreateSpaceModelDialog extends StatelessWidget {
final List<Tag> projectTags;
const CreateSpaceModelDialog(
{super.key,
{Key? key,
this.products,
this.allTags,
this.spaceModel,
this.pageContext,
this.otherSpaceModels,
this.allSpaceModels,
required this.projectTags});
required this.projectTags})
: super(key: key);
@override
Widget build(BuildContext context) {
final spaceModelApi = SpaceModelManagementApi();
final SpaceModelManagementApi _spaceModelApi = SpaceModelManagementApi();
final screenWidth = MediaQuery.of(context).size.width;
final spaceNameController = TextEditingController(
final TextEditingController spaceNameController = TextEditingController(
text: spaceModel?.modelName ?? '',
);
@ -54,7 +56,7 @@ class CreateSpaceModelDialog extends StatelessWidget {
child: BlocProvider(
create: (_) {
final bloc = CreateSpaceModelBloc(
spaceModelApi,
_spaceModelApi,
);
if (spaceModel != null) {
bloc.add(UpdateSpaceTemplate(spaceModel!, otherSpaceModels));
@ -69,8 +71,7 @@ class CreateSpaceModelDialog extends StatelessWidget {
spaceNameController.addListener(() {
bloc.add(UpdateSpaceTemplateName(
name: spaceNameController.text,
allModels: otherSpaceModels ?? []));
name: spaceNameController.text, allModels: otherSpaceModels ?? []));
});
return bloc;
@ -88,9 +89,7 @@ class CreateSpaceModelDialog extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
Text(
spaceModel?.uuid == null
? 'Create New Space Model'
: 'Edit Space Model',
spaceModel?.uuid == null ? 'Create New Space Model' : 'Edit Space Model',
style: Theme.of(context)
.textTheme
.headlineLarge
@ -102,10 +101,8 @@ class CreateSpaceModelDialog extends StatelessWidget {
child: TextField(
controller: spaceNameController,
onChanged: (value) {
context.read<CreateSpaceModelBloc>().add(
UpdateSpaceTemplateName(
name: value,
allModels: otherSpaceModels ?? []));
context.read<CreateSpaceModelBloc>().add(UpdateSpaceTemplateName(
name: value, allModels: otherSpaceModels ?? []));
},
style: Theme.of(context)
.textTheme
@ -179,84 +176,55 @@ class CreateSpaceModelDialog extends StatelessWidget {
!isNameValid)
? null
: () {
final updatedSpaceTemplate =
updatedSpaceModel.copyWith(
modelName:
spaceNameController.text.trim(),
final updatedSpaceTemplate = updatedSpaceModel.copyWith(
modelName: spaceNameController.text.trim(),
);
if (updatedSpaceModel.uuid == null) {
context
.read<CreateSpaceModelBloc>()
.add(
context.read<CreateSpaceModelBloc>().add(
CreateSpaceTemplate(
spaceTemplate:
updatedSpaceTemplate,
spaceTemplate: updatedSpaceTemplate,
onCreate: (newModel) {
if (pageContext != null) {
pageContext!.read<SpaceModelBloc>().add(
CreateSpaceModel(newSpaceModel: newModel));
pageContext!
.read<SpaceModelBloc>()
.add(CreateSpaceModel(
newSpaceModel:
newModel));
pageContext!
.read<
SpaceManagementBloc>()
.add(
UpdateSpaceModelCache(
newModel));
.read<SpaceManagementBloc>()
.add(UpdateSpaceModelCache(newModel));
}
Navigator.of(context)
.pop(); // Close the dialog
Navigator.of(context).pop(); // Close the dialog
},
),
);
} else {
if (pageContext != null) {
final currentState = pageContext!
.read<SpaceModelBloc>()
.state;
if (currentState
is SpaceModelLoaded) {
final spaceModels =
List<SpaceTemplateModel>.from(
currentState.spaceModels);
final currentState =
pageContext!.read<SpaceModelBloc>().state;
if (currentState is SpaceModelLoaded) {
final spaceModels = List<SpaceTemplateModel>.from(
currentState.spaceModels);
final currentSpaceModel =
spaceModels
.cast<SpaceTemplateModel?>()
.firstWhere(
(sm) =>
sm?.uuid ==
updatedSpaceModel
.uuid,
final SpaceTemplateModel? currentSpaceModel =
spaceModels.cast<SpaceTemplateModel?>().firstWhere(
(sm) => sm?.uuid == updatedSpaceModel.uuid,
orElse: () => null,
);
if (currentSpaceModel != null) {
context
.read<CreateSpaceModelBloc>()
.add(ModifySpaceTemplate(
spaceTemplate:
currentSpaceModel,
updatedSpaceTemplate:
updatedSpaceTemplate,
spaceTemplate: currentSpaceModel,
updatedSpaceTemplate: updatedSpaceTemplate,
onUpdate: (newModel) {
if (pageContext !=
null) {
pageContext!
.read<
SpaceModelBloc>()
.add(UpdateSpaceModel(
if (pageContext != null) {
pageContext!.read<SpaceModelBloc>().add(
UpdateSpaceModel(
spaceModelUuid:
newModel.uuid ??
''));
newModel.uuid ?? ''));
pageContext!
.read<
SpaceManagementBloc>()
.add(UpdateSpaceModelCache(
newModel));
.read<SpaceManagementBloc>()
.add(UpdateSpaceModelCache(newModel));
}
Navigator.of(context)
.pop();
Navigator.of(context).pop();
}));
}
}
@ -265,11 +233,11 @@ class CreateSpaceModelDialog extends StatelessWidget {
},
backgroundColor: ColorsManager.secondaryColor,
borderRadius: 10,
foregroundColor: ((state.errorMessage != null &&
state.errorMessage != '') ||
!isNameValid)
? ColorsManager.whiteColorsWithOpacity
: ColorsManager.whiteColors,
foregroundColor:
((state.errorMessage != null && state.errorMessage != '') ||
!isNameValid)
? ColorsManager.whiteColorsWithOpacity
: ColorsManager.whiteColors,
child: const Text('OK'),
),
),

View File

@ -1,10 +1,9 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/dialog/linking_successful.dart';
class CustomLoadingIndicator extends StatefulWidget {
const CustomLoadingIndicator({super.key});
@override
_CustomLoadingIndicatorState createState() => _CustomLoadingIndicatorState();
}
@ -51,22 +50,22 @@ class _CustomLoadingIndicatorState extends State<CustomLoadingIndicator>
class LoadingPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
final Paint paint = Paint()
..strokeWidth = 5
..strokeCap = StrokeCap.round
..style = PaintingStyle.stroke;
final radius = size.width / 2;
final center = Offset(size.width / 2, size.height / 2);
final double radius = size.width / 2;
final Offset center = Offset(size.width / 2, size.height / 2);
for (var i = 0; i < 12; i++) {
final angle = (i * 30) * (pi / 180);
final startX = center.dx + radius * cos(angle);
final startY = center.dy + radius * sin(angle);
final endX = center.dx + (radius - 8) * cos(angle);
final endY = center.dy + (radius - 8) * sin(angle);
for (int i = 0; i < 12; i++) {
final double angle = (i * 30) * (pi / 180);
final double startX = center.dx + radius * cos(angle);
final double startY = center.dy + radius * sin(angle);
final double endX = center.dx + (radius - 8) * cos(angle);
final double endY = center.dy + (radius - 8) * sin(angle);
paint.color = Colors.blue.withValues(alpha: i / 12); // Gradient effect
paint.color = Colors.blue.withOpacity(i / 12); // Gradient effect
canvas.drawLine(Offset(startX, startY), Offset(endX, endY), paint);
}
}

View File

@ -6,7 +6,8 @@ import 'package:syncrow_web/utils/color_manager.dart';
class DeleteSpaceModelDialog extends StatelessWidget {
final VoidCallback onConfirmDelete;
const DeleteSpaceModelDialog({super.key, required this.onConfirmDelete});
const DeleteSpaceModelDialog({Key? key, required this.onConfirmDelete})
: super(key: key);
@override
Widget build(BuildContext context) {
@ -19,7 +20,7 @@ class DeleteSpaceModelDialog extends StatelessWidget {
backgroundColor: ColorsManager.whiteColors,
title: Center(
child: Text(
'Delete Space Model',
"Delete Space Model",
textAlign: TextAlign.center,
style: Theme.of(context)
.textTheme
@ -33,13 +34,13 @@ class DeleteSpaceModelDialog extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
Text(
'Are you sure you want to delete?',
"Are you sure you want to delete?",
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.headlineSmall,
),
const SizedBox(height: 15),
Text(
'The existing sub-spaces, devices, and routines will remain associated with the spaces, but the connection will be removed.',
"The existing sub-spaces, devices, and routines will remain associated with the spaces, but the connection will be removed.",
textAlign: TextAlign.center,
style: Theme.of(context)
.textTheme
@ -59,7 +60,7 @@ class DeleteSpaceModelDialog extends StatelessWidget {
onPressed: () {
Navigator.of(context).pop(); // Close dialog
},
label: 'Cancel',
label: "Cancel",
),
),
const SizedBox(width: 10),

View File

@ -47,9 +47,9 @@ class _LinkSpaceModelSpacesDialogState
Widget _buildDialogContent() {
widget.spaceModel.createdAt.toString();
final formattedDate =
String formattedDate =
DateFormat('yyyy-MM-dd').format(widget.spaceModel.createdAt!);
final formattedTime =
String formattedTime =
DateFormat('HH:mm:ss').format(widget.spaceModel.createdAt!);
return Expanded(
@ -70,7 +70,7 @@ class _LinkSpaceModelSpacesDialogState
children: [
const Center(
child: Text(
'Link Space Model to Spaces',
"Link Space Model to Spaces",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
@ -81,21 +81,22 @@ class _LinkSpaceModelSpacesDialogState
const Divider(),
const SizedBox(height: 16),
_buildDetailRow(
'Space model name:', widget.spaceModel.modelName),
"Space model name:", widget.spaceModel.modelName),
Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Row(
children: [
const Expanded(
child: Text(
'Creation date and time:',
style: TextStyle(fontWeight: FontWeight.bold),
"Creation date and time:",
style: const TextStyle(
fontWeight: FontWeight.bold),
),
),
const SizedBox(width: 8),
Expanded(
child: Text(
'$formattedDate $formattedTime',
"$formattedDate $formattedTime",
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black),
@ -106,14 +107,14 @@ class _LinkSpaceModelSpacesDialogState
),
// _buildDetailRow("Creation date and time:",
// widget.spaceModel.createdAt.toString()),
_buildDetailRow('Created by:', 'Admin'),
_buildDetailRow("Created by:", "Admin"),
const SizedBox(height: 12),
const Text(
'Link to:',
"Link to:",
style: TextStyle(fontWeight: FontWeight.bold),
),
const Text(
'Please select all the spaces where you would like to link the Routine.',
"Please select all the spaces where you would like to link the Routine.",
style: TextStyle(fontSize: 12, color: Colors.grey),
),
const SizedBox(height: 8),
@ -123,7 +124,7 @@ class _LinkSpaceModelSpacesDialogState
children: [
Expanded(
flex: 7,
child: ColoredBox(
child: Container(
color: ColorsManager.whiteColors,
child: SpaceTreeView(
isSide: true,
@ -169,7 +170,7 @@ class _LinkSpaceModelSpacesDialogState
),
),
),
child: _buildButton('Cancel', Colors.grey, () {
child: _buildButton("Cancel", Colors.grey, () {
Navigator.of(context).pop();
}),
),
@ -190,14 +191,14 @@ class _LinkSpaceModelSpacesDialogState
),
),
child: _buildButton(
'Confirm',
"Confirm",
ColorsManager.onSecondaryColor,
() {
final spaceModelBloc = context.read<LinkSpaceToModelBloc>();
if (!spaceModelBloc.hasSelectedSpaces) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Please select at least one space')),
content: Text("Please select at least one space")),
);
return;
} else {

View File

@ -62,7 +62,7 @@ class LinkingAttentionDialog extends StatelessWidget {
elevation: 3,
),
child: Text(
'Overwrite',
"Overwrite",
style: Theme.of(context)
.textTheme
.bodyMedium
@ -93,7 +93,7 @@ class LinkingAttentionDialog extends StatelessWidget {
elevation: 3,
),
child: Text(
'Merge',
"Merge",
style: Theme.of(context)
.textTheme
.bodyMedium

View File

@ -23,7 +23,7 @@ void showOverwriteDialog(
mainAxisSize: MainAxisSize.min,
children: [
const Text(
'Overwrite',
"Overwrite",
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
@ -32,13 +32,13 @@ void showOverwriteDialog(
),
const SizedBox(height: 15),
const Text(
'Are you sure you want to overwrite?',
"Are you sure you want to overwrite?",
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
textAlign: TextAlign.center,
),
const SizedBox(height: 5),
Text(
'Selected spaces already have linked space model / sub-spaces and devices',
"Selected spaces already have linked space model / sub-spaces and devices",
style: TextStyle(
fontSize: 14,
color: Colors.grey[600],
@ -61,7 +61,7 @@ void showOverwriteDialog(
elevation: 0,
),
child: const Text(
'Cancel',
"Cancel",
style: TextStyle(
fontSize: 16,
color: Colors.black,
@ -88,7 +88,7 @@ void showOverwriteDialog(
elevation: 3,
),
child: const Text(
'OK',
"OK",
style: TextStyle(
fontSize: 16,
color: Colors.white,

View File

@ -10,28 +10,28 @@ class DynamicProductWidget extends StatelessWidget {
final double maxHeight;
const DynamicProductWidget({
super.key,
Key? key,
required this.productTagCount,
required this.maxWidth,
required this.maxHeight,
});
}) : super(key: key);
@override
Widget build(BuildContext context) {
const itemSpacing = 8.0;
const lineSpacing = 8.0;
const textPadding = 16.0;
const itemHeight = 40.0;
const double itemSpacing = 8.0;
const double lineSpacing = 8.0;
const double textPadding = 16.0;
const double itemHeight = 40.0;
final productWidgets = <Widget>[];
var currentLineWidth = 0.0;
var currentHeight = itemHeight;
List<Widget> productWidgets = [];
double currentLineWidth = 0.0;
double currentHeight = itemHeight;
for (final product in productTagCount.entries) {
final prodType = product.key;
final count = product.value;
final String prodType = product.key;
final int count = product.value;
final textPainter = TextPainter(
final TextPainter textPainter = TextPainter(
text: TextSpan(
text: 'x$count',
style: Theme.of(context)
@ -42,7 +42,7 @@ class DynamicProductWidget extends StatelessWidget {
textDirection: TextDirection.ltr,
)..layout();
final itemWidth = textPainter.width + textPadding + 20;
final double itemWidth = textPainter.width + textPadding + 20;
if (currentLineWidth + itemWidth + itemSpacing > maxWidth) {
currentHeight += itemHeight + lineSpacing;

View File

@ -8,37 +8,38 @@ class DynamicRoomWidget extends StatelessWidget {
final double maxHeight;
const DynamicRoomWidget({
super.key,
Key? key,
required this.subspaceModels,
required this.maxWidth,
required this.maxHeight,
});
}) : super(key: key);
@override
Widget build(BuildContext context) {
const itemSpacing = 8.0;
const lineSpacing = 8.0;
const textPadding = 16.0;
const itemHeight = 30.0;
const double itemSpacing = 8.0;
const double lineSpacing = 8.0;
const double textPadding = 16.0;
const double itemHeight = 30.0;
final roomWidgets = <Widget>[];
var currentLineWidth = 0.0;
var currentHeight = itemHeight;
List<Widget> roomWidgets = [];
double currentLineWidth = 0.0;
double currentHeight = itemHeight;
for (final subspace in subspaceModels!) {
final textPainter = TextPainter(
final TextPainter textPainter = TextPainter(
text: TextSpan(
text: subspace.subspaceName,
style: Theme.of(context).textTheme.bodyMedium),
text: subspace.subspaceName,
style: Theme.of(context).textTheme.bodyMedium
),
textDirection: TextDirection.ltr,
)..layout();
final itemWidth = textPainter.width + textPadding;
final double itemWidth = textPainter.width + textPadding;
if (currentLineWidth + itemWidth + itemSpacing > maxWidth) {
currentHeight += itemHeight + lineSpacing;
if (currentHeight > maxHeight) {
roomWidgets.add(const RoomNameWidget(name: '...'));
roomWidgets.add(const RoomNameWidget(name: "..."));
break;
}
currentLineWidth = 0.0;

View File

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:syncrow_web/utils/color_manager.dart';
class EllipsisItemWidget extends StatelessWidget {
const EllipsisItemWidget({super.key});
const EllipsisItemWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -14,7 +14,7 @@ class EllipsisItemWidget extends StatelessWidget {
border: Border.all(color: ColorsManager.transparentColor),
),
child: Text(
'...',
"...",
style: Theme.of(context)
.textTheme
.bodySmall

View File

@ -7,10 +7,10 @@ class FlexibleItemWidget extends StatelessWidget {
final int count;
const FlexibleItemWidget({
super.key,
Key? key,
required this.prodType,
required this.count,
});
}) : super(key: key);
@override
Widget build(BuildContext context) {

View File

@ -4,7 +4,7 @@ import 'package:syncrow_web/utils/color_manager.dart';
class RoomNameWidget extends StatelessWidget {
final String name;
const RoomNameWidget({super.key, required this.name});
const RoomNameWidget({Key? key, required this.name}) : super(key: key);
@override
Widget build(BuildContext context) {

View File

@ -1,19 +1,19 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/svg.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/link_space_model/bloc/link_space_to_model_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/link_space_model/bloc/link_space_to_model_event.dart';
import 'package:syncrow_web/pages/spaces_management/link_space_model/bloc/link_space_to_model_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';
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_event.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/dialog/custom_loading_dialog.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/dialog/delete_space_model_dialog.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/dialog/link_space_model_spaces_dialog.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/dialog/linking_successful.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/dialog/overwrite_dialog.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/dialog/delete_space_model_dialog.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/dynamic_product_widget.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/dynamic_room_widget.dart';
import 'package:syncrow_web/utils/color_manager.dart';
@ -27,27 +27,27 @@ class SpaceModelCardWidget extends StatelessWidget with HelperResponsiveLayout {
final bool topActionsDisabled;
const SpaceModelCardWidget({
super.key,
Key? key,
required this.model,
this.pageContext,
this.topActionsDisabled = true,
});
}) : super(key: key);
@override
Widget build(BuildContext context) {
final productTagCount = <String, int>{};
final Map<String, int> productTagCount = {};
if (model.tags != null) {
for (final tag in model.tags!) {
for (var tag in model.tags!) {
final prodIcon = tag.product?.icon ?? 'Unknown';
productTagCount[prodIcon] = (productTagCount[prodIcon] ?? 0) + 1;
}
}
if (model.subspaceModels != null) {
for (final subspace in model.subspaceModels!) {
for (var subspace in model.subspaceModels!) {
if (subspace.tags != null) {
for (final tag in subspace.tags!) {
for (var tag in subspace.tags!) {
final prodIcon = tag.product?.icon ?? 'Unknown';
productTagCount[prodIcon] = (productTagCount[prodIcon] ?? 0) + 1;
}
@ -57,7 +57,7 @@ class SpaceModelCardWidget extends StatelessWidget with HelperResponsiveLayout {
return LayoutBuilder(
builder: (context, constraints) {
final showOnlyName = constraints.maxWidth < 250;
bool showOnlyName = constraints.maxWidth < 250;
return Container(
padding: const EdgeInsets.all(16.0),
decoration: BoxDecoration(
@ -65,7 +65,7 @@ class SpaceModelCardWidget extends StatelessWidget with HelperResponsiveLayout {
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: Colors.grey.withValues(alpha: 0.5),
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: const Offset(0, 3),
@ -81,12 +81,11 @@ class SpaceModelCardWidget extends StatelessWidget with HelperResponsiveLayout {
Expanded(
child: Text(
StringUtils.capitalizeFirstLetter(model.modelName),
style:
Theme.of(context).textTheme.headlineMedium?.copyWith(
color: ColorsManager.blackColor,
fontWeight: FontWeight.bold,
fontSize: isSmallScreenSize(context) ? 13 : 20,
),
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
color: ColorsManager.blackColor,
fontWeight: FontWeight.bold,
fontSize: isSmallScreenSize(context) ? 13 : 20,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
@ -101,15 +100,12 @@ class SpaceModelCardWidget extends StatelessWidget with HelperResponsiveLayout {
builder: (BuildContext dialogContext) {
return BlocProvider<LinkSpaceToModelBloc>(
create: (_) => LinkSpaceToModelBloc(),
child: BlocListener<LinkSpaceToModelBloc,
LinkSpaceToModelState>(
child: BlocListener<LinkSpaceToModelBloc, LinkSpaceToModelState>(
listenWhen: (previous, current) {
return previous != current;
},
listener: (context, state) {
final bloc =
BlocProvider.of<LinkSpaceToModelBloc>(
context);
final _bloc = BlocProvider.of<LinkSpaceToModelBloc>(context);
if (state is SpaceModelLoading) {
showDialog(
context: context,
@ -117,18 +113,14 @@ class SpaceModelCardWidget extends StatelessWidget with HelperResponsiveLayout {
builder: (BuildContext context) {
return Dialog(
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(
20)),
borderRadius: BorderRadius.circular(20)),
elevation: 10,
backgroundColor: Colors.white,
child: const Padding(
padding: EdgeInsets.symmetric(
vertical: 30,
horizontal: 50),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 30, horizontal: 50),
child: Column(
mainAxisSize:
MainAxisSize.min,
mainAxisSize: MainAxisSize.min,
children: [
CustomLoadingIndicator(),
],
@ -137,19 +129,14 @@ class SpaceModelCardWidget extends StatelessWidget with HelperResponsiveLayout {
);
},
);
} else if (state
is AlreadyHaveLinkedState) {
} else if (state is AlreadyHaveLinkedState) {
Navigator.of(dialogContext).pop();
showOverwriteDialog(
context, bloc, model);
} else if (state
is SpaceValidationSuccess) {
bloc.add(LinkSpaceModelEvent(
isOverWrite: false,
selectedSpaceMode: model.uuid));
showOverwriteDialog(context, _bloc, model);
} else if (state is SpaceValidationSuccess) {
_bloc.add(LinkSpaceModelEvent(
isOverWrite: false, selectedSpaceMode: model.uuid));
Future.delayed(
const Duration(seconds: 1), () {
Future.delayed(const Duration(seconds: 1), () {
Navigator.of(dialogContext).pop();
Navigator.of(dialogContext).pop();
Navigator.of(dialogContext).pop();
@ -157,29 +144,23 @@ class SpaceModelCardWidget extends StatelessWidget with HelperResponsiveLayout {
showDialog(
context: context,
builder:
(BuildContext dialogContext) {
builder: (BuildContext dialogContext) {
return const LinkingSuccessful();
},
).then((v) {
Future.delayed(
const Duration(seconds: 2), () {
Future.delayed(const Duration(seconds: 2), () {
Navigator.of(dialogContext).pop();
});
});
} else if (state
is SpaceModelLinkSuccess) {
} else if (state is SpaceModelLinkSuccess) {
Navigator.of(dialogContext).pop();
Navigator.of(dialogContext).pop();
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext
successDialogContext) {
Future.delayed(
const Duration(seconds: 2), () {
Navigator.of(successDialogContext)
.pop();
builder: (BuildContext successDialogContext) {
Future.delayed(const Duration(seconds: 2), () {
Navigator.of(successDialogContext).pop();
});
return const LinkingSuccessful();
@ -237,8 +218,7 @@ class SpaceModelCardWidget extends StatelessWidget with HelperResponsiveLayout {
),
),
),
if (productTagCount.isNotEmpty &&
model.subspaceModels != null)
if (productTagCount.isNotEmpty && model.subspaceModels != null)
Container(
width: 1.0,
color: ColorsManager.softGray,

View File

@ -5,9 +5,9 @@ class SubspaceChipWidget extends StatelessWidget {
final String subspace;
const SubspaceChipWidget({
super.key,
Key? key,
required this.subspace,
});
}) : super(key: key);
@override
Widget build(BuildContext context) {

View File

@ -1,9 +1,9 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/common/edit_chip.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
import 'package:syncrow_web/pages/spaces_management/create_subspace_model/views/create_subspace_model_dialog.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/button_content_widget.dart';
import 'package:syncrow_web/pages/spaces_management/create_subspace_model/views/create_subspace_model_dialog.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/subspace_name_label_widget.dart';
import 'package:syncrow_web/utils/color_manager.dart';
@ -15,11 +15,11 @@ class SubspaceModelCreate extends StatefulWidget {
final List<Tag> tags;
const SubspaceModelCreate({
super.key,
Key? key,
required this.subspaces,
this.onSpaceModelUpdate,
required this.tags,
});
}) : super(key: key);
@override
_SubspaceModelCreateState createState() => _SubspaceModelCreateState();
@ -117,9 +117,9 @@ class _SubspaceModelCreateState extends State<SubspaceModelCreate> {
.where((s) => !updatedIds.contains(s.internalId))
.toList();
final tagsToAppendToSpace = <Tag>[];
final List<Tag> tagsToAppendToSpace = [];
for (final s in deletedSubspaces) {
for (var s in deletedSubspaces) {
if (s.tags != null) {
tagsToAppendToSpace.addAll(s.tags!);
}

View File

@ -12,7 +12,7 @@ class SubspaceNameDisplayWidget extends StatefulWidget {
final bool Function(String updatedName) validateName;
const SubspaceNameDisplayWidget({
super.key,
Key? key,
required this.text,
this.textStyle,
this.backgroundColor = ColorsManager.whiteColors,
@ -21,7 +21,7 @@ class SubspaceNameDisplayWidget extends StatefulWidget {
this.borderRadius = const BorderRadius.all(Radius.circular(10)),
required this.onNameChanged,
required this.validateName,
});
}) : super(key: key);
@override
_SubspaceNameDisplayWidgetState createState() =>

View File

@ -50,8 +50,7 @@ class TagChipDisplay extends StatelessWidget {
Widget build(BuildContext context) {
final hasTags = spaceModel?.tags?.isNotEmpty ?? false;
final hasSubspaceTags =
spaceModel?.subspaceModels?.any((e) => e.tags?.isNotEmpty ?? false) ??
false;
spaceModel?.subspaceModels?.any((e) => e.tags?.isNotEmpty ?? false) ?? false;
if (hasTags || hasSubspaceTags) {
return Container(

View File

@ -13,7 +13,7 @@ class CenterBodyBloc extends Bloc<CenterBodyEvent, CenterBodyState> {
emit(SpaceModelState());
});
on<CommunitySelectedEvent>((event, emit) {
on<CommunitySelectedEvent>((event, emit) {
emit(CommunitySelectedState());
});
}

View File

@ -5,4 +5,4 @@ class CommunityStructureSelectedEvent extends CenterBodyEvent {}
class SpaceModelSelectedEvent extends CenterBodyEvent {}
class CommunitySelectedEvent extends CenterBodyEvent {}
class CommunitySelectedEvent extends CenterBodyEvent {}

View File

@ -2,13 +2,11 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_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/structure_selector/bloc/center_body_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/structure_selector/bloc/center_body_event.dart';
import 'package:syncrow_web/pages/spaces_management/structure_selector/bloc/center_body_state.dart';
import '../bloc/center_body_bloc.dart';
class CenterBodyWidget extends StatelessWidget {
const CenterBodyWidget({super.key});
@override
Widget build(BuildContext context) {
return BlocBuilder<CenterBodyBloc, CenterBodyState>(
@ -54,7 +52,7 @@ class CenterBodyWidget extends StatelessWidget {
.textTheme
.bodyLarge!
.color!
.withValues(alpha: 0.5),
.withOpacity(0.5),
),
),
),
@ -75,7 +73,7 @@ class CenterBodyWidget extends StatelessWidget {
// .textTheme
// .bodyLarge!
// .color!
// .withValues(alpha:0.5),
// .withOpacity(0.5),
// ),
// ),
// ),

View File

@ -1,4 +1,5 @@
import 'package:equatable/equatable.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/tag.dart';
@ -12,7 +13,7 @@ abstract class AddDeviceTypeModelEvent extends Equatable {
class UpdateProductCountEvent extends AddDeviceTypeModelEvent {
final SelectedProduct selectedProduct;
const UpdateProductCountEvent({required this.selectedProduct});
UpdateProductCountEvent({required this.selectedProduct});
@override
List<Object> get props => [selectedProduct];

View File

@ -2,10 +2,10 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.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/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/tag.dart';
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/views/assign_tag_models_dialog.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/helper/tag_helper.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/subspace_template_model.dart';
@ -80,8 +80,7 @@ class AddDeviceTypeModelWidget extends StatelessWidget {
const SizedBox(height: 16),
Expanded(
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 20.0),
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: ScrollableGridViewWidget(
isCreate: isCreate,
products: products,
@ -153,11 +152,10 @@ class AddDeviceTypeModelWidget extends StatelessWidget {
),
SizedBox(
width: 140,
child:
BlocBuilder<AddDeviceTypeModelBloc, AddDeviceModelState>(
child: BlocBuilder<AddDeviceTypeModelBloc, AddDeviceModelState>(
builder: (context, state) {
final isDisabled = state is AddDeviceModelLoaded &&
state.selectedProducts.isEmpty;
final isDisabled =
state is AddDeviceModelLoaded && state.selectedProducts.isEmpty;
return DefaultButton(
backgroundColor: ColorsManager.secondaryColor,
@ -170,15 +168,13 @@ class AddDeviceTypeModelWidget extends StatelessWidget {
: () async {
if (state is AddDeviceModelLoaded &&
state.selectedProducts.isNotEmpty) {
final initialTags =
TagHelper.generateInitialTags(
final initialTags = TagHelper.generateInitialTags(
spaceTagModels: spaceTagModels,
subspaces: subspaces,
);
final dialogTitle = initialTags.isNotEmpty
? 'Edit Device'
: 'Assign Tags';
final dialogTitle =
initialTags.isNotEmpty ? 'Edit Device' : 'Assign Tags';
Navigator.of(context).pop();
await showDialog<bool>(
context: context,

View File

@ -12,12 +12,13 @@ class ScrollableGridViewWidget extends StatelessWidget {
final List<SelectedProduct>? initialProductCounts;
final bool isCreate;
const ScrollableGridViewWidget(
{super.key,
required this.products,
required this.crossAxisCount,
this.initialProductCounts,
required this.isCreate});
const ScrollableGridViewWidget({
super.key,
required this.products,
required this.crossAxisCount,
this.initialProductCounts,
required this.isCreate
});
@override
Widget build(BuildContext context) {