From 5ac7eb03018038271b635430fb3c728bc93370fa Mon Sep 17 00:00:00 2001 From: hannathkadher Date: Sun, 24 Nov 2024 02:28:28 +0400 Subject: [PATCH] updated blank structure --- .../bloc/space_management_bloc.dart | 24 +++++++++++++++---- .../bloc/space_management_state.dart | 6 +++-- .../view/spaces_management_page.dart | 2 ++ .../community_stricture_header_widget.dart | 5 +++- lib/utils/color_manager.dart | 1 + 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/lib/pages/spaces_management/bloc/space_management_bloc.dart b/lib/pages/spaces_management/bloc/space_management_bloc.dart index 913c4c92..74f76db2 100644 --- a/lib/pages/spaces_management/bloc/space_management_bloc.dart +++ b/lib/pages/spaces_management/bloc/space_management_bloc.dart @@ -27,10 +27,25 @@ class SpaceManagementBloc extends Bloc emit, ) async { + final previousState = state; try { emit(SpaceManagementLoading()); final success = await _api.updateCommunity(event.communityUuid, event.name); if (success) { + if (previousState is SpaceManagementLoaded) { + final updatedCommunities = List.from(previousState.communities); + for(var community in updatedCommunities){ + if(community.uuid == event.communityUuid){ + community.name = event.name; + break; + } + } + emit(SpaceManagementLoaded( + communities: updatedCommunities, + products: previousState.products, + selectedCommunity: previousState.selectedCommunity, + )); + } add(LoadCommunityAndSpacesEvent()); } else { emit(const SpaceManagementError('Failed to update the community.')); @@ -125,17 +140,16 @@ class SpaceManagementBloc extends Bloc.from(previousState.communities) ..add(newCommunity); emit(SpaceManagementLoaded( - communities: updatedCommunities, products: _cachedProducts ?? [])); + communities: updatedCommunities, + products: _cachedProducts ?? [], + selectedCommunity: newCommunity)); } } else { emit(const SpaceManagementError('Error creating community')); diff --git a/lib/pages/spaces_management/bloc/space_management_state.dart b/lib/pages/spaces_management/bloc/space_management_state.dart index 0e05b42e..0264d4e8 100644 --- a/lib/pages/spaces_management/bloc/space_management_state.dart +++ b/lib/pages/spaces_management/bloc/space_management_state.dart @@ -16,9 +16,11 @@ class SpaceManagementLoading extends SpaceManagementState {} class SpaceManagementLoaded extends SpaceManagementState { final List communities; - final List products; // Include products in the state + final List products; + CommunityModel? selectedCommunity; // Include products in the state - SpaceManagementLoaded({required this.communities, required this.products}); + SpaceManagementLoaded( + {required this.communities, required this.products, this.selectedCommunity}); } class SpaceCreationSuccess extends SpaceManagementState { diff --git a/lib/pages/spaces_management/view/spaces_management_page.dart b/lib/pages/spaces_management/view/spaces_management_page.dart index c2c9e8de..452a1657 100644 --- a/lib/pages/spaces_management/view/spaces_management_page.dart +++ b/lib/pages/spaces_management/view/spaces_management_page.dart @@ -56,6 +56,8 @@ class SpaceManagementPageState extends State { ); if (selectedIndex != -1) { selectedCommunity = state.communities[selectedIndex]; + } else if (state.selectedCommunity != null) { + selectedCommunity = state.selectedCommunity; } else { selectedCommunity = null; selectedSpace = null; diff --git a/lib/pages/spaces_management/widgets/community_stricture_header_widget.dart b/lib/pages/spaces_management/widgets/community_stricture_header_widget.dart index c1de16c1..cdbbf195 100644 --- a/lib/pages/spaces_management/widgets/community_stricture_header_widget.dart +++ b/lib/pages/spaces_management/widgets/community_stricture_header_widget.dart @@ -109,7 +109,9 @@ class CommunityStructureHeader extends StatelessWidget { onPressed: onSave, ), if (isSave) const SizedBox(width: 10), - if (communityName != null && communityName != '') + /* + Commenting till finalize delete + if (communityName != null && communityName != '') _buildButton( label: "Delete", icon: SvgPicture.asset( @@ -119,6 +121,7 @@ class CommunityStructureHeader extends StatelessWidget { ), onPressed: onDelete, ), + */ ], ); } diff --git a/lib/utils/color_manager.dart b/lib/utils/color_manager.dart index 2bc3fe66..709d4ac7 100644 --- a/lib/utils/color_manager.dart +++ b/lib/utils/color_manager.dart @@ -52,6 +52,7 @@ abstract class ColorsManager { static const Color counterBackgroundColor = Color(0xCCF4F4F4); static const Color neutralGray = Color(0xFFE5E5E5); static const Color warningRed = Color(0xFFFF6465); + static const Color borderColor = Color(0xFFE5E5E5); } //background: #background: #5D5D5D;