added all tags

This commit is contained in:
hannathkadher
2025-01-29 12:24:12 +04:00
parent e4262d08a5
commit c173df934d
4 changed files with 98 additions and 76 deletions

View File

@ -295,6 +295,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
return CreateSpaceDialog( return CreateSpaceDialog(
products: widget.products, products: widget.products,
spaceModels: widget.spaceModels, spaceModels: widget.spaceModels,
allTags: _getAllTagValues(spaces),
parentSpace: parentIndex != null ? spaces[parentIndex] : null, parentSpace: parentIndex != null ? spaces[parentIndex] : null,
onCreateSpace: (String name, onCreateSpace: (String name,
String icon, String icon,
@ -354,6 +355,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
tags: widget.selectedSpace?.tags, tags: widget.selectedSpace?.tags,
subspaces: widget.selectedSpace?.subspaces, subspaces: widget.selectedSpace?.subspaces,
isEdit: true, isEdit: true,
allTags: _getAllTagValues(spaces),
onCreateSpace: (String name, onCreateSpace: (String name,
String icon, String icon,
List<SelectedProduct> selectedProducts, List<SelectedProduct> selectedProducts,
@ -745,4 +747,14 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
duplicateRecursive(space, space.position, duplicatedParent); duplicateRecursive(space, space.position, duplicatedParent);
} }
} }
List<String> _getAllTagValues(List<SpaceModel> spaces) {
final List<String> allTags = [];
for (final space in spaces) {
if (space.tags != null) {
allTags.addAll(space.listAllTagValues());
}
}
return allTags;
}
} }

View File

@ -39,6 +39,7 @@ class CreateSpaceDialog extends StatefulWidget {
final List<SpaceTemplateModel>? spaceModels; final List<SpaceTemplateModel>? spaceModels;
final List<SubspaceModel>? subspaces; final List<SubspaceModel>? subspaces;
final List<Tag>? tags; final List<Tag>? tags;
final List<String>? allTags;
const CreateSpaceDialog( const CreateSpaceDialog(
{super.key, {super.key,
@ -49,6 +50,7 @@ class CreateSpaceDialog extends StatefulWidget {
this.icon, this.icon,
this.isEdit = false, this.isEdit = false,
this.editSpace, this.editSpace,
this.allTags,
this.selectedProducts = const [], this.selectedProducts = const [],
this.spaceModels, this.spaceModels,
this.subspaces, this.subspaces,
@ -628,7 +630,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
spaceName: name, spaceName: name,
products: products, products: products,
subspaces: subspaces, subspaces: subspaces,
allTags: [], allTags: widget.allTags,
onSave: (selectedSpaceTags, selectedSubspaces) { onSave: (selectedSpaceTags, selectedSubspaces) {
setState(() { setState(() {
tags = selectedSpaceTags; tags = selectedSpaceTags;
@ -660,7 +662,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
subspaces: subspaces, subspaces: subspaces,
spaceTags: tags, spaceTags: tags,
isCreate: true, isCreate: true,
allTags: [], allTags: widget.allTags,
initialSelectedProducts: initialSelectedProducts:
TagHelper.createInitialSelectedProductsForTags( TagHelper.createInitialSelectedProductsForTags(
tags, subspaces), tags, subspaces),

View File

@ -112,14 +112,14 @@ class SpaceModelPage extends StatelessWidget {
double _calculateChildAspectRatio(BuildContext context) { double _calculateChildAspectRatio(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width; double screenWidth = MediaQuery.of(context).size.width;
if (screenWidth > 1600) { if (screenWidth > 1600) {
return 2; return 1.5; // Decrease to make cards taller
} }
if (screenWidth > 1200) { if (screenWidth > 1200) {
return 3; return 2.0;
} else if (screenWidth > 800) { } else if (screenWidth > 800) {
return 3.5; return 2.5;
} else { } else {
return 4.0; return 3.0;
} }
} }

View File

@ -31,6 +31,9 @@ class SpaceModelCardWidget extends StatelessWidget {
} }
} }
return LayoutBuilder(
builder: (context, constraints) {
bool showOnlyName = constraints.maxWidth < 250;
return Container( return Container(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
decoration: BoxDecoration( decoration: BoxDecoration(
@ -57,6 +60,7 @@ class SpaceModelCardWidget extends StatelessWidget {
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
if (!showOnlyName) ...[
const SizedBox(height: 10), const SizedBox(height: 10),
Expanded( Expanded(
child: Row( child: Row(
@ -80,7 +84,8 @@ class SpaceModelCardWidget extends StatelessWidget {
), ),
), ),
), ),
if (productTagCount.isNotEmpty && model.subspaceModels != null) if (productTagCount.isNotEmpty &&
model.subspaceModels != null)
Container( Container(
width: 1.0, width: 1.0,
color: ColorsManager.softGray, color: ColorsManager.softGray,
@ -105,8 +110,11 @@ class SpaceModelCardWidget extends StatelessWidget {
], ],
), ),
), ),
]
], ],
), ),
); );
},
);
} }
} }