mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
formatted all files.
This commit is contained in:
@ -5,7 +5,6 @@ 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';
|
||||
@ -21,7 +20,7 @@ class CreateSpaceModelBloc
|
||||
try {
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
late SpaceTemplateModel spaceTemplate = event.spaceTemplate;
|
||||
late final spaceTemplate = event.spaceTemplate;
|
||||
|
||||
final tagBodyModels =
|
||||
spaceTemplate.tags?.map((tag) => tag.toTagBodyModel()).toList() ??
|
||||
@ -55,7 +54,7 @@ class CreateSpaceModelBloc
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
emit(CreateSpaceModelError('Error creating space model'));
|
||||
emit(const CreateSpaceModelError('Error creating space model'));
|
||||
}
|
||||
});
|
||||
|
||||
@ -65,14 +64,14 @@ class CreateSpaceModelBloc
|
||||
if (_space != null) {
|
||||
emit(CreateSpaceModelLoaded(_space!));
|
||||
} else {
|
||||
emit(CreateSpaceModelError("No space template found"));
|
||||
emit(const CreateSpaceModelError('No space template found'));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
on<UpdateSpaceTemplate>((event, emit) {
|
||||
_space = event.spaceTemplate;
|
||||
final String? errorMessage = _checkDuplicateModelName(
|
||||
final errorMessage = _checkDuplicateModelName(
|
||||
event.allModels ?? [], event.spaceTemplate.modelName);
|
||||
emit(CreateSpaceModelLoaded(_space!, errorMessage: errorMessage));
|
||||
});
|
||||
@ -94,9 +93,8 @@ 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,
|
||||
@ -108,7 +106,7 @@ class CreateSpaceModelBloc
|
||||
: tag;
|
||||
}) ??
|
||||
<Tag>[],
|
||||
...?matchingEventSubspace.tags?.where(
|
||||
...matchingEventSubspace.tags?.where(
|
||||
(e) =>
|
||||
subspace.tags
|
||||
?.every((t) => t.internalId != e.internalId) ??
|
||||
@ -127,9 +125,7 @@ class CreateSpaceModelBloc
|
||||
event.subspaces
|
||||
.where((e) =>
|
||||
updatedSubspaces.every((s) => s.internalId != e.internalId))
|
||||
.forEach((newSubspace) {
|
||||
updatedSubspaces.add(newSubspace);
|
||||
});
|
||||
.forEach(updatedSubspaces.add);
|
||||
|
||||
final updatedSpace =
|
||||
currentState.space.copyWith(subspaceModels: updatedSubspaces);
|
||||
@ -137,7 +133,7 @@ class CreateSpaceModelBloc
|
||||
emit(CreateSpaceModelLoaded(updatedSpace,
|
||||
errorMessage: currentState.errorMessage));
|
||||
} else {
|
||||
emit(CreateSpaceModelError("Space template not initialized"));
|
||||
emit(const CreateSpaceModelError('Space template not initialized'));
|
||||
}
|
||||
});
|
||||
|
||||
@ -163,14 +159,12 @@ class CreateSpaceModelBloc
|
||||
event.tags
|
||||
.where(
|
||||
(e) => updatedTags.every((t) => t.internalId != e.internalId))
|
||||
.forEach((e) {
|
||||
updatedTags.add(e);
|
||||
});
|
||||
.forEach(updatedTags.add);
|
||||
|
||||
emit(CreateSpaceModelLoaded(
|
||||
currentState.space.copyWith(tags: updatedTags)));
|
||||
} else {
|
||||
emit(CreateSpaceModelError("Space template not initialized"));
|
||||
emit(const CreateSpaceModelError('Space template not initialized'));
|
||||
}
|
||||
});
|
||||
|
||||
@ -180,12 +174,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 =
|
||||
@ -194,7 +188,7 @@ class CreateSpaceModelBloc
|
||||
emit(CreateSpaceModelLoaded(updatedSpaceModel));
|
||||
}
|
||||
} else {
|
||||
emit(CreateSpaceModelError("Space template not initialized"));
|
||||
emit(const CreateSpaceModelError('Space template not initialized'));
|
||||
}
|
||||
});
|
||||
|
||||
@ -211,19 +205,17 @@ class CreateSpaceModelBloc
|
||||
if (prevSpaceModel?.modelName != newSpaceModel.modelName) {
|
||||
spaceModelName = newSpaceModel.modelName;
|
||||
}
|
||||
List<TagModelUpdate> tagUpdates = [];
|
||||
final List<UpdateSubspaceTemplateModel> subspaceUpdates = [];
|
||||
final List<SubspaceTemplateModel>? prevSubspaces =
|
||||
prevSpaceModel?.subspaceModels;
|
||||
final List<SubspaceTemplateModel>? newSubspaces =
|
||||
newSpaceModel.subspaceModels;
|
||||
var tagUpdates = <TagModelUpdate>[];
|
||||
final subspaceUpdates = <UpdateSubspaceTemplateModel>[];
|
||||
final prevSubspaces = prevSpaceModel?.subspaceModels;
|
||||
final newSubspaces = newSpaceModel.subspaceModels;
|
||||
|
||||
tagUpdates =
|
||||
processTagUpdates(prevSpaceModel?.tags, newSpaceModel.tags);
|
||||
|
||||
if (prevSubspaces != null || newSubspaces != null) {
|
||||
if (prevSubspaces != null && newSubspaces != null) {
|
||||
for (var prevSubspace in prevSubspaces) {
|
||||
for (final prevSubspace in prevSubspaces) {
|
||||
final existsInNew = newSubspaces
|
||||
.any((subspace) => subspace.uuid == prevSubspace.uuid);
|
||||
if (!existsInNew) {
|
||||
@ -232,20 +224,20 @@ class CreateSpaceModelBloc
|
||||
}
|
||||
}
|
||||
} else if (prevSubspaces != null && newSubspaces == null) {
|
||||
for (var prevSubspace in prevSubspaces) {
|
||||
for (final prevSubspace in prevSubspaces) {
|
||||
subspaceUpdates.add(UpdateSubspaceTemplateModel(
|
||||
action: Action.delete, uuid: prevSubspace.uuid));
|
||||
}
|
||||
}
|
||||
|
||||
if (newSubspaces != null) {
|
||||
for (var newSubspace in newSubspaces) {
|
||||
for (final newSubspace in newSubspaces) {
|
||||
// Tag without UUID
|
||||
if ((newSubspace.uuid == null || newSubspace.uuid!.isEmpty)) {
|
||||
final List<TagModelUpdate> tagUpdates = [];
|
||||
if (newSubspace.uuid == null || newSubspace.uuid!.isEmpty) {
|
||||
final tagUpdates = <TagModelUpdate>[];
|
||||
|
||||
if (newSubspace.tags != null) {
|
||||
for (var tag in newSubspace.tags!) {
|
||||
for (final tag in newSubspace.tags!) {
|
||||
tagUpdates.add(TagModelUpdate(
|
||||
action: Action.add,
|
||||
newTagUuid: tag.uuid == '' ? null : tag.uuid,
|
||||
@ -263,14 +255,14 @@ class CreateSpaceModelBloc
|
||||
|
||||
if (prevSubspaces != null && newSubspaces != null) {
|
||||
final newSubspaceMap = {
|
||||
for (var subspace in newSubspaces) subspace.uuid: subspace
|
||||
for (final subspace in newSubspaces) subspace.uuid: subspace
|
||||
};
|
||||
|
||||
for (var prevSubspace in prevSubspaces) {
|
||||
for (final prevSubspace in prevSubspaces) {
|
||||
final newSubspace = newSubspaceMap[prevSubspace.uuid];
|
||||
|
||||
if (newSubspace != null) {
|
||||
final List<TagModelUpdate> tagSubspaceUpdates =
|
||||
final tagSubspaceUpdates =
|
||||
processTagUpdates(prevSubspace.tags, newSubspace.tags);
|
||||
subspaceUpdates.add(UpdateSubspaceTemplateModel(
|
||||
action: Action.update,
|
||||
@ -298,7 +290,7 @@ class CreateSpaceModelBloc
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
emit(CreateSpaceModelError('Error creating space model'));
|
||||
emit(const CreateSpaceModelError('Error creating space model'));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -307,11 +299,11 @@ class CreateSpaceModelBloc
|
||||
List<Tag>? prevTags,
|
||||
List<Tag>? newTags,
|
||||
) {
|
||||
final List<TagModelUpdate> tagUpdates = [];
|
||||
final tagUpdates = <TagModelUpdate>[];
|
||||
final processedTags = <String?>{};
|
||||
|
||||
if (prevTags == null && newTags != null) {
|
||||
for (var newTag in newTags) {
|
||||
for (final newTag in newTags) {
|
||||
tagUpdates.add(TagModelUpdate(
|
||||
action: Action.add,
|
||||
tag: newTag.tag,
|
||||
@ -325,7 +317,7 @@ class CreateSpaceModelBloc
|
||||
if (newTags != null || prevTags != null) {
|
||||
// Case 1: Tags deleted
|
||||
if (prevTags != null && newTags != null) {
|
||||
for (var prevTag in prevTags) {
|
||||
for (final prevTag in prevTags) {
|
||||
final existsInNew =
|
||||
newTags.any((newTag) => newTag.uuid == prevTag.uuid);
|
||||
if (!existsInNew) {
|
||||
@ -334,7 +326,7 @@ class CreateSpaceModelBloc
|
||||
}
|
||||
}
|
||||
} else if (prevTags != null && newTags == null) {
|
||||
for (var prevTag in prevTags) {
|
||||
for (final prevTag in prevTags) {
|
||||
tagUpdates
|
||||
.add(TagModelUpdate(action: Action.delete, uuid: prevTag.uuid));
|
||||
}
|
||||
@ -344,7 +336,7 @@ class CreateSpaceModelBloc
|
||||
if (newTags != null) {
|
||||
final prevTagUuids = prevTags?.map((t) => t.uuid).toSet() ?? {};
|
||||
|
||||
for (var newTag in newTags) {
|
||||
for (final newTag in newTags) {
|
||||
// Tag without UUID
|
||||
if ((newTag.uuid == null || !prevTagUuids.contains(newTag.uuid)) &&
|
||||
!processedTags.contains(newTag.tag)) {
|
||||
@ -360,9 +352,9 @@ class CreateSpaceModelBloc
|
||||
|
||||
// Case 3: Tags updated
|
||||
if (prevTags != null && newTags != null) {
|
||||
final newTagMap = {for (var tag in newTags) tag.uuid: tag};
|
||||
final newTagMap = {for (final tag in newTags) tag.uuid: tag};
|
||||
|
||||
for (var prevTag in prevTags) {
|
||||
for (final prevTag in prevTags) {
|
||||
final newTag = newTagMap[prevTag.uuid];
|
||||
if (newTag != null) {
|
||||
tagUpdates.add(TagModelUpdate(
|
||||
@ -381,7 +373,7 @@ class CreateSpaceModelBloc
|
||||
|
||||
String? _checkDuplicateModelName(List<String> allModels, String name) {
|
||||
if (allModels.contains(name)) {
|
||||
return "Duplicate Model name";
|
||||
return 'Duplicate Model name';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
UpdateSpaceTemplateName({required this.name, required this.allModels});
|
||||
const 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;
|
||||
|
||||
AddSubspacesToSpaceTemplate(this.subspaces);
|
||||
const AddSubspacesToSpaceTemplate(this.subspaces);
|
||||
}
|
||||
|
||||
class AddTagsToSpaceTemplate extends CreateSpaceModelEvent {
|
||||
final List<Tag> tags;
|
||||
|
||||
AddTagsToSpaceTemplate(this.tags);
|
||||
const AddTagsToSpaceTemplate(this.tags);
|
||||
}
|
||||
|
||||
class ValidateSpaceTemplateName extends CreateSpaceModelEvent {
|
||||
final String name;
|
||||
|
||||
ValidateSpaceTemplateName({required this.name});
|
||||
const ValidateSpaceTemplateName({required this.name});
|
||||
}
|
||||
|
||||
class ModifySpaceTemplate extends CreateSpaceModelEvent {
|
||||
@ -65,7 +65,7 @@ class ModifySpaceTemplate extends CreateSpaceModelEvent {
|
||||
final SpaceTemplateModel updatedSpaceTemplate;
|
||||
final Function(SpaceTemplateModel)? onUpdate;
|
||||
|
||||
ModifySpaceTemplate(
|
||||
const ModifySpaceTemplate(
|
||||
{required this.spaceTemplate,
|
||||
required this.updatedSpaceTemplate,
|
||||
this.onUpdate});
|
||||
|
@ -16,7 +16,7 @@ class CreateSpaceModelLoaded extends CreateSpaceModelState {
|
||||
final SpaceTemplateModel space;
|
||||
final String? errorMessage;
|
||||
|
||||
CreateSpaceModelLoaded(this.space, {this.errorMessage});
|
||||
const 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;
|
||||
|
||||
CreateSpaceModelError(this.message);
|
||||
const CreateSpaceModelError(this.message);
|
||||
}
|
||||
|
@ -21,18 +21,21 @@ 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) {
|
||||
@ -41,13 +44,15 @@ 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;
|
||||
@ -61,14 +66,16 @@ 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
|
||||
|
@ -30,19 +30,18 @@ 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>?)
|
||||
?.where((e) => e is Map<String, dynamic>)
|
||||
.map((e) =>
|
||||
SubspaceTemplateModel.fromJson(e as Map<String, dynamic>))
|
||||
?.whereType<Map<String, dynamic>>()
|
||||
.map(SubspaceTemplateModel.fromJson)
|
||||
.toList() ??
|
||||
[],
|
||||
tags: (json['tags'] as List<dynamic>?)
|
||||
?.where((item) => item is Map<String, dynamic>) // Validate type
|
||||
.map((item) => Tag.fromJson(item as Map<String, dynamic>))
|
||||
?.whereType<Map<String, dynamic>>() // Validate type
|
||||
.map(Tag.fromJson)
|
||||
.toList() ??
|
||||
[],
|
||||
);
|
||||
@ -109,7 +108,7 @@ class UpdateSubspaceTemplateModel {
|
||||
|
||||
extension SpaceTemplateExtensions on SpaceTemplateModel {
|
||||
List<String> listAllTagValues() {
|
||||
final List<String> tagValues = [];
|
||||
final tagValues = <String>[];
|
||||
|
||||
if (tags != null) {
|
||||
tagValues.addAll(
|
||||
|
@ -18,8 +18,10 @@ class SpaceModelPage extends StatelessWidget {
|
||||
final List<Tag> projectTags;
|
||||
|
||||
const SpaceModelPage(
|
||||
{Key? key, this.products, this.onSpaceModelsUpdated, required this.projectTags})
|
||||
: super(key: key);
|
||||
{super.key,
|
||||
this.products,
|
||||
this.onSpaceModelsUpdated,
|
||||
required this.projectTags});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -77,7 +79,8 @@ 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: () {
|
||||
@ -115,8 +118,10 @@ 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),
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -126,7 +131,7 @@ class SpaceModelPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
double _calculateChildAspectRatio(BuildContext context) {
|
||||
double screenWidth = MediaQuery.of(context).size.width;
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
if (screenWidth > 1600) {
|
||||
return 1.5; // Decrease to make cards taller
|
||||
}
|
||||
@ -140,7 +145,7 @@ class SpaceModelPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
List<String> _getAllTagValues(List<SpaceTemplateModel> spaceModels) {
|
||||
final List<String> allTags = [];
|
||||
final allTags = <String>[];
|
||||
for (final spaceModel in spaceModels) {
|
||||
if (spaceModel.tags != null) {
|
||||
allTags.addAll(spaceModel.listAllTagValues());
|
||||
@ -150,7 +155,7 @@ class SpaceModelPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
List<String> _getAllSpaceModelName(List<SpaceTemplateModel> spaceModels) {
|
||||
final List<String> names = [];
|
||||
final names = <String>[];
|
||||
for (final spaceModel in spaceModels) {
|
||||
names.add(spaceModel.modelName);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
class AddSpaceModelWidget extends StatelessWidget {
|
||||
const AddSpaceModelWidget({Key? key}) : super(key: key);
|
||||
const AddSpaceModelWidget({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -9,12 +9,12 @@ class ButtonContentWidget extends StatelessWidget {
|
||||
final bool disabled;
|
||||
|
||||
const ButtonContentWidget({
|
||||
Key? key,
|
||||
super.key,
|
||||
this.icon,
|
||||
required this.label,
|
||||
this.svgAssets,
|
||||
this.disabled = false,
|
||||
}) : super(key: key);
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -9,13 +9,12 @@ 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_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/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/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/services/space_model_mang_api.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
@ -29,22 +28,21 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
final List<Tag> projectTags;
|
||||
|
||||
const CreateSpaceModelDialog(
|
||||
{Key? key,
|
||||
{super.key,
|
||||
this.products,
|
||||
this.allTags,
|
||||
this.spaceModel,
|
||||
this.pageContext,
|
||||
this.otherSpaceModels,
|
||||
this.allSpaceModels,
|
||||
required this.projectTags})
|
||||
: super(key: key);
|
||||
required this.projectTags});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final SpaceModelManagementApi _spaceModelApi = SpaceModelManagementApi();
|
||||
final spaceModelApi = SpaceModelManagementApi();
|
||||
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
final TextEditingController spaceNameController = TextEditingController(
|
||||
final spaceNameController = TextEditingController(
|
||||
text: spaceModel?.modelName ?? '',
|
||||
);
|
||||
|
||||
@ -56,7 +54,7 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
child: BlocProvider(
|
||||
create: (_) {
|
||||
final bloc = CreateSpaceModelBloc(
|
||||
_spaceModelApi,
|
||||
spaceModelApi,
|
||||
);
|
||||
if (spaceModel != null) {
|
||||
bloc.add(UpdateSpaceTemplate(spaceModel!, otherSpaceModels));
|
||||
@ -71,7 +69,8 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
|
||||
spaceNameController.addListener(() {
|
||||
bloc.add(UpdateSpaceTemplateName(
|
||||
name: spaceNameController.text, allModels: otherSpaceModels ?? []));
|
||||
name: spaceNameController.text,
|
||||
allModels: otherSpaceModels ?? []));
|
||||
});
|
||||
|
||||
return bloc;
|
||||
@ -89,7 +88,9 @@ 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
|
||||
@ -101,8 +102,10 @@ 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
|
||||
@ -176,55 +179,84 @@ 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<SpaceManagementBloc>()
|
||||
.add(UpdateSpaceModelCache(newModel));
|
||||
.read<SpaceModelBloc>()
|
||||
.add(CreateSpaceModel(
|
||||
newSpaceModel:
|
||||
newModel));
|
||||
pageContext!
|
||||
.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 SpaceTemplateModel? currentSpaceModel =
|
||||
spaceModels.cast<SpaceTemplateModel?>().firstWhere(
|
||||
(sm) => sm?.uuid == updatedSpaceModel.uuid,
|
||||
final 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(
|
||||
spaceModelUuid:
|
||||
newModel.uuid ?? ''));
|
||||
if (pageContext !=
|
||||
null) {
|
||||
pageContext!
|
||||
.read<SpaceManagementBloc>()
|
||||
.add(UpdateSpaceModelCache(newModel));
|
||||
.read<
|
||||
SpaceModelBloc>()
|
||||
.add(UpdateSpaceModel(
|
||||
spaceModelUuid:
|
||||
newModel.uuid ??
|
||||
''));
|
||||
pageContext!
|
||||
.read<
|
||||
SpaceManagementBloc>()
|
||||
.add(UpdateSpaceModelCache(
|
||||
newModel));
|
||||
}
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context)
|
||||
.pop();
|
||||
}));
|
||||
}
|
||||
}
|
||||
@ -233,11 +265,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'),
|
||||
),
|
||||
),
|
||||
|
@ -1,9 +1,10 @@
|
||||
import 'dart:math';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/dialog/linking_successful.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CustomLoadingIndicator extends StatefulWidget {
|
||||
const CustomLoadingIndicator({super.key});
|
||||
|
||||
@override
|
||||
_CustomLoadingIndicatorState createState() => _CustomLoadingIndicatorState();
|
||||
}
|
||||
@ -50,22 +51,22 @@ class _CustomLoadingIndicatorState extends State<CustomLoadingIndicator>
|
||||
class LoadingPainter extends CustomPainter {
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final Paint paint = Paint()
|
||||
final paint = Paint()
|
||||
..strokeWidth = 5
|
||||
..strokeCap = StrokeCap.round
|
||||
..style = PaintingStyle.stroke;
|
||||
|
||||
final double radius = size.width / 2;
|
||||
final Offset center = Offset(size.width / 2, size.height / 2);
|
||||
final radius = size.width / 2;
|
||||
final center = Offset(size.width / 2, size.height / 2);
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
paint.color = Colors.blue.withOpacity(i / 12); // Gradient effect
|
||||
paint.color = Colors.blue.withValues(alpha: i / 12); // Gradient effect
|
||||
canvas.drawLine(Offset(startX, startY), Offset(endX, endY), paint);
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,7 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
||||
class DeleteSpaceModelDialog extends StatelessWidget {
|
||||
final VoidCallback onConfirmDelete;
|
||||
|
||||
const DeleteSpaceModelDialog({Key? key, required this.onConfirmDelete})
|
||||
: super(key: key);
|
||||
const DeleteSpaceModelDialog({super.key, required this.onConfirmDelete});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -20,7 +19,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
|
||||
@ -34,13 +33,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
|
||||
@ -60,7 +59,7 @@ class DeleteSpaceModelDialog extends StatelessWidget {
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(); // Close dialog
|
||||
},
|
||||
label: "Cancel",
|
||||
label: 'Cancel',
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
|
@ -47,9 +47,9 @@ class _LinkSpaceModelSpacesDialogState
|
||||
|
||||
Widget _buildDialogContent() {
|
||||
widget.spaceModel.createdAt.toString();
|
||||
String formattedDate =
|
||||
final formattedDate =
|
||||
DateFormat('yyyy-MM-dd').format(widget.spaceModel.createdAt!);
|
||||
String formattedTime =
|
||||
final 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,22 +81,21 @@ 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: const TextStyle(
|
||||
fontWeight: FontWeight.bold),
|
||||
'Creation date and time:',
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
"$formattedDate $formattedTime",
|
||||
'$formattedDate $formattedTime',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black),
|
||||
@ -107,14 +106,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),
|
||||
@ -124,7 +123,7 @@ class _LinkSpaceModelSpacesDialogState
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 7,
|
||||
child: Container(
|
||||
child: ColoredBox(
|
||||
color: ColorsManager.whiteColors,
|
||||
child: SpaceTreeView(
|
||||
isSide: true,
|
||||
@ -170,7 +169,7 @@ class _LinkSpaceModelSpacesDialogState
|
||||
),
|
||||
),
|
||||
),
|
||||
child: _buildButton("Cancel", Colors.grey, () {
|
||||
child: _buildButton('Cancel', Colors.grey, () {
|
||||
Navigator.of(context).pop();
|
||||
}),
|
||||
),
|
||||
@ -191,14 +190,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 {
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -10,28 +10,28 @@ class DynamicProductWidget extends StatelessWidget {
|
||||
final double maxHeight;
|
||||
|
||||
const DynamicProductWidget({
|
||||
Key? key,
|
||||
super.key,
|
||||
required this.productTagCount,
|
||||
required this.maxWidth,
|
||||
required this.maxHeight,
|
||||
}) : super(key: key);
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const double itemSpacing = 8.0;
|
||||
const double lineSpacing = 8.0;
|
||||
const double textPadding = 16.0;
|
||||
const double itemHeight = 40.0;
|
||||
const itemSpacing = 8.0;
|
||||
const lineSpacing = 8.0;
|
||||
const textPadding = 16.0;
|
||||
const itemHeight = 40.0;
|
||||
|
||||
List<Widget> productWidgets = [];
|
||||
double currentLineWidth = 0.0;
|
||||
double currentHeight = itemHeight;
|
||||
final productWidgets = <Widget>[];
|
||||
var currentLineWidth = 0.0;
|
||||
var currentHeight = itemHeight;
|
||||
|
||||
for (final product in productTagCount.entries) {
|
||||
final String prodType = product.key;
|
||||
final int count = product.value;
|
||||
final prodType = product.key;
|
||||
final count = product.value;
|
||||
|
||||
final TextPainter textPainter = TextPainter(
|
||||
final textPainter = TextPainter(
|
||||
text: TextSpan(
|
||||
text: 'x$count',
|
||||
style: Theme.of(context)
|
||||
@ -42,7 +42,7 @@ class DynamicProductWidget extends StatelessWidget {
|
||||
textDirection: TextDirection.ltr,
|
||||
)..layout();
|
||||
|
||||
final double itemWidth = textPainter.width + textPadding + 20;
|
||||
final itemWidth = textPainter.width + textPadding + 20;
|
||||
|
||||
if (currentLineWidth + itemWidth + itemSpacing > maxWidth) {
|
||||
currentHeight += itemHeight + lineSpacing;
|
||||
|
@ -8,38 +8,37 @@ class DynamicRoomWidget extends StatelessWidget {
|
||||
final double maxHeight;
|
||||
|
||||
const DynamicRoomWidget({
|
||||
Key? key,
|
||||
super.key,
|
||||
required this.subspaceModels,
|
||||
required this.maxWidth,
|
||||
required this.maxHeight,
|
||||
}) : super(key: key);
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const double itemSpacing = 8.0;
|
||||
const double lineSpacing = 8.0;
|
||||
const double textPadding = 16.0;
|
||||
const double itemHeight = 30.0;
|
||||
const itemSpacing = 8.0;
|
||||
const lineSpacing = 8.0;
|
||||
const textPadding = 16.0;
|
||||
const itemHeight = 30.0;
|
||||
|
||||
List<Widget> roomWidgets = [];
|
||||
double currentLineWidth = 0.0;
|
||||
double currentHeight = itemHeight;
|
||||
final roomWidgets = <Widget>[];
|
||||
var currentLineWidth = 0.0;
|
||||
var currentHeight = itemHeight;
|
||||
|
||||
for (final subspace in subspaceModels!) {
|
||||
final TextPainter textPainter = TextPainter(
|
||||
final 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 double itemWidth = textPainter.width + textPadding;
|
||||
final 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;
|
||||
|
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
class EllipsisItemWidget extends StatelessWidget {
|
||||
const EllipsisItemWidget({Key? key}) : super(key: key);
|
||||
const EllipsisItemWidget({super.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
|
||||
|
@ -7,10 +7,10 @@ class FlexibleItemWidget extends StatelessWidget {
|
||||
final int count;
|
||||
|
||||
const FlexibleItemWidget({
|
||||
Key? key,
|
||||
super.key,
|
||||
required this.prodType,
|
||||
required this.count,
|
||||
}) : super(key: key);
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -4,7 +4,7 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
||||
class RoomNameWidget extends StatelessWidget {
|
||||
final String name;
|
||||
|
||||
const RoomNameWidget({Key? key, required this.name}) : super(key: key);
|
||||
const RoomNameWidget({super.key, required this.name});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -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({
|
||||
Key? key,
|
||||
super.key,
|
||||
required this.model,
|
||||
this.pageContext,
|
||||
this.topActionsDisabled = true,
|
||||
}) : super(key: key);
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Map<String, int> productTagCount = {};
|
||||
final productTagCount = <String, int>{};
|
||||
|
||||
if (model.tags != null) {
|
||||
for (var tag in model.tags!) {
|
||||
for (final tag in model.tags!) {
|
||||
final prodIcon = tag.product?.icon ?? 'Unknown';
|
||||
productTagCount[prodIcon] = (productTagCount[prodIcon] ?? 0) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (model.subspaceModels != null) {
|
||||
for (var subspace in model.subspaceModels!) {
|
||||
for (final subspace in model.subspaceModels!) {
|
||||
if (subspace.tags != null) {
|
||||
for (var tag in subspace.tags!) {
|
||||
for (final 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) {
|
||||
bool showOnlyName = constraints.maxWidth < 250;
|
||||
final 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.withOpacity(0.5),
|
||||
color: Colors.grey.withValues(alpha: 0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: const Offset(0, 3),
|
||||
@ -81,11 +81,12 @@ 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,
|
||||
),
|
||||
@ -100,12 +101,15 @@ 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,
|
||||
@ -113,14 +117,18 @@ 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: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 30, horizontal: 50),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: 30,
|
||||
horizontal: 50),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisSize:
|
||||
MainAxisSize.min,
|
||||
children: [
|
||||
CustomLoadingIndicator(),
|
||||
],
|
||||
@ -129,14 +137,19 @@ 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();
|
||||
@ -144,23 +157,29 @@ 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();
|
||||
@ -218,7 +237,8 @@ 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,
|
||||
|
@ -5,9 +5,9 @@ class SubspaceChipWidget extends StatelessWidget {
|
||||
final String subspace;
|
||||
|
||||
const SubspaceChipWidget({
|
||||
Key? key,
|
||||
super.key,
|
||||
required this.subspace,
|
||||
}) : super(key: key);
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -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({
|
||||
Key? key,
|
||||
super.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 List<Tag> tagsToAppendToSpace = [];
|
||||
final tagsToAppendToSpace = <Tag>[];
|
||||
|
||||
for (var s in deletedSubspaces) {
|
||||
for (final s in deletedSubspaces) {
|
||||
if (s.tags != null) {
|
||||
tagsToAppendToSpace.addAll(s.tags!);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ class SubspaceNameDisplayWidget extends StatefulWidget {
|
||||
final bool Function(String updatedName) validateName;
|
||||
|
||||
const SubspaceNameDisplayWidget({
|
||||
Key? key,
|
||||
super.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() =>
|
||||
|
@ -50,7 +50,8 @@ 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(
|
||||
|
Reference in New Issue
Block a user