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,82 +31,90 @@ class SpaceModelCardWidget extends StatelessWidget {
} }
} }
return Container( return LayoutBuilder(
padding: const EdgeInsets.all(16.0), builder: (context, constraints) {
decoration: BoxDecoration( bool showOnlyName = constraints.maxWidth < 250;
color: Colors.white, return Container(
borderRadius: BorderRadius.circular(10), padding: const EdgeInsets.all(16.0),
boxShadow: [ decoration: BoxDecoration(
BoxShadow( color: Colors.white,
color: Colors.grey.withOpacity(0.5), borderRadius: BorderRadius.circular(10),
spreadRadius: 2, boxShadow: [
blurRadius: 5, BoxShadow(
offset: const Offset(0, 3), color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: const Offset(0, 3),
),
],
), ),
], child: Column(
), crossAxisAlignment: CrossAxisAlignment.start,
child: Column( children: [
crossAxisAlignment: CrossAxisAlignment.start, Text(
children: [ model.modelName,
Text( style: Theme.of(context).textTheme.headlineMedium?.copyWith(
model.modelName, color: Colors.black,
style: Theme.of(context).textTheme.headlineMedium?.copyWith( fontWeight: FontWeight.bold,
color: Colors.black, ),
fontWeight: FontWeight.bold, maxLines: 1,
), overflow: TextOverflow.ellipsis,
maxLines: 1, ),
overflow: TextOverflow.ellipsis, if (!showOnlyName) ...[
), const SizedBox(height: 10),
const SizedBox(height: 10),
Expanded(
child: Row(
children: [
// Left Container
Expanded( Expanded(
flex: 1, // Distribute space proportionally child: Row(
child: Container( children: [
padding: const EdgeInsets.all(8.0), // Left Container
child: LayoutBuilder( Expanded(
builder: (context, constraints) { flex: 1, // Distribute space proportionally
return Align( child: Container(
alignment: Alignment.topLeft, padding: const EdgeInsets.all(8.0),
child: DynamicRoomWidget( child: LayoutBuilder(
subspaceModels: model.subspaceModels, builder: (context, constraints) {
maxWidth: constraints.maxWidth, return Align(
maxHeight: constraints.maxHeight, alignment: Alignment.topLeft,
child: DynamicRoomWidget(
subspaceModels: model.subspaceModels,
maxWidth: constraints.maxWidth,
maxHeight: constraints.maxHeight,
),
);
},
), ),
); ),
}, ),
), if (productTagCount.isNotEmpty &&
model.subspaceModels != null)
Container(
width: 1.0,
color: ColorsManager.softGray,
margin: const EdgeInsets.symmetric(vertical: 6.0),
),
Expanded(
flex: 1, // Distribute space proportionally
child: Container(
padding: const EdgeInsets.all(8.0),
child: LayoutBuilder(
builder: (context, constraints) {
return Align(
alignment: Alignment.topLeft,
child: DynamicProductWidget(
productTagCount: productTagCount,
maxWidth: constraints.maxWidth,
maxHeight: constraints.maxHeight));
},
),
),
),
],
), ),
), ),
if (productTagCount.isNotEmpty && model.subspaceModels != null) ]
Container( ],
width: 1.0,
color: ColorsManager.softGray,
margin: const EdgeInsets.symmetric(vertical: 6.0),
),
Expanded(
flex: 1, // Distribute space proportionally
child: Container(
padding: const EdgeInsets.all(8.0),
child: LayoutBuilder(
builder: (context, constraints) {
return Align(
alignment: Alignment.topLeft,
child: DynamicProductWidget(
productTagCount: productTagCount,
maxWidth: constraints.maxWidth,
maxHeight: constraints.maxHeight));
},
),
),
),
],
),
), ),
], );
), },
); );
} }
} }