From c173df934d5bb4de29189df838acc2aafe4f6d24 Mon Sep 17 00:00:00 2001 From: hannathkadher Date: Wed, 29 Jan 2025 12:24:12 +0400 Subject: [PATCH] added all tags --- .../widgets/community_structure_widget.dart | 12 ++ .../widgets/dialogs/create_space_dialog.dart | 6 +- .../space_model/view/space_model_page.dart | 8 +- .../widgets/space_model_card_widget.dart | 148 +++++++++--------- 4 files changed, 98 insertions(+), 76 deletions(-) diff --git a/lib/pages/spaces_management/all_spaces/widgets/community_structure_widget.dart b/lib/pages/spaces_management/all_spaces/widgets/community_structure_widget.dart index 7699dede..3a208a0d 100644 --- a/lib/pages/spaces_management/all_spaces/widgets/community_structure_widget.dart +++ b/lib/pages/spaces_management/all_spaces/widgets/community_structure_widget.dart @@ -295,6 +295,7 @@ class _CommunityStructureAreaState extends State { return CreateSpaceDialog( products: widget.products, spaceModels: widget.spaceModels, + allTags: _getAllTagValues(spaces), parentSpace: parentIndex != null ? spaces[parentIndex] : null, onCreateSpace: (String name, String icon, @@ -354,6 +355,7 @@ class _CommunityStructureAreaState extends State { tags: widget.selectedSpace?.tags, subspaces: widget.selectedSpace?.subspaces, isEdit: true, + allTags: _getAllTagValues(spaces), onCreateSpace: (String name, String icon, List selectedProducts, @@ -745,4 +747,14 @@ class _CommunityStructureAreaState extends State { duplicateRecursive(space, space.position, duplicatedParent); } } + + List _getAllTagValues(List spaces) { + final List allTags = []; + for (final space in spaces) { + if (space.tags != null) { + allTags.addAll(space.listAllTagValues()); + } + } + return allTags; + } } diff --git a/lib/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart b/lib/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart index eee8a25c..405ccd92 100644 --- a/lib/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart +++ b/lib/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart @@ -39,6 +39,7 @@ class CreateSpaceDialog extends StatefulWidget { final List? spaceModels; final List? subspaces; final List? tags; + final List? allTags; const CreateSpaceDialog( {super.key, @@ -49,6 +50,7 @@ class CreateSpaceDialog extends StatefulWidget { this.icon, this.isEdit = false, this.editSpace, + this.allTags, this.selectedProducts = const [], this.spaceModels, this.subspaces, @@ -628,7 +630,7 @@ class CreateSpaceDialogState extends State { spaceName: name, products: products, subspaces: subspaces, - allTags: [], + allTags: widget.allTags, onSave: (selectedSpaceTags, selectedSubspaces) { setState(() { tags = selectedSpaceTags; @@ -660,7 +662,7 @@ class CreateSpaceDialogState extends State { subspaces: subspaces, spaceTags: tags, isCreate: true, - allTags: [], + allTags: widget.allTags, initialSelectedProducts: TagHelper.createInitialSelectedProductsForTags( tags, subspaces), diff --git a/lib/pages/spaces_management/space_model/view/space_model_page.dart b/lib/pages/spaces_management/space_model/view/space_model_page.dart index ec6d54a0..b1fce7a1 100644 --- a/lib/pages/spaces_management/space_model/view/space_model_page.dart +++ b/lib/pages/spaces_management/space_model/view/space_model_page.dart @@ -112,14 +112,14 @@ class SpaceModelPage extends StatelessWidget { double _calculateChildAspectRatio(BuildContext context) { double screenWidth = MediaQuery.of(context).size.width; if (screenWidth > 1600) { - return 2; + return 1.5; // Decrease to make cards taller } if (screenWidth > 1200) { - return 3; + return 2.0; } else if (screenWidth > 800) { - return 3.5; + return 2.5; } else { - return 4.0; + return 3.0; } } diff --git a/lib/pages/spaces_management/space_model/widgets/space_model_card_widget.dart b/lib/pages/spaces_management/space_model/widgets/space_model_card_widget.dart index df0fba4f..0056c96f 100644 --- a/lib/pages/spaces_management/space_model/widgets/space_model_card_widget.dart +++ b/lib/pages/spaces_management/space_model/widgets/space_model_card_widget.dart @@ -31,82 +31,90 @@ class SpaceModelCardWidget extends StatelessWidget { } } - return Container( - padding: const EdgeInsets.all(16.0), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: const Offset(0, 3), + return LayoutBuilder( + builder: (context, constraints) { + bool showOnlyName = constraints.maxWidth < 250; + return Container( + padding: const EdgeInsets.all(16.0), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: const Offset(0, 3), + ), + ], ), - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - model.modelName, - style: Theme.of(context).textTheme.headlineMedium?.copyWith( - color: Colors.black, - fontWeight: FontWeight.bold, - ), - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - const SizedBox(height: 10), - Expanded( - child: Row( - children: [ - // Left Container + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + model.modelName, + style: Theme.of(context).textTheme.headlineMedium?.copyWith( + color: Colors.black, + fontWeight: FontWeight.bold, + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + if (!showOnlyName) ...[ + const SizedBox(height: 10), 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: DynamicRoomWidget( - subspaceModels: model.subspaceModels, - maxWidth: constraints.maxWidth, - maxHeight: constraints.maxHeight, + child: Row( + children: [ + // Left Container + 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: 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)); - }, - ), - ), - ), - ], - ), + ] + ], ), - ], - ), + ); + }, ); } }