mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
updated blank structure
This commit is contained in:
@ -27,10 +27,25 @@ class SpaceManagementBloc extends Bloc<SpaceManagementEvent, SpaceManagementStat
|
||||
UpdateCommunityEvent event,
|
||||
Emitter<SpaceManagementState> 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<CommunityModel>.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<SpaceManagementEvent, SpaceManagementStat
|
||||
emit(SpaceManagementLoading());
|
||||
|
||||
try {
|
||||
CommunityModel? newCommunity = await _api.createCommunity(
|
||||
event.name,
|
||||
event.description
|
||||
);
|
||||
CommunityModel? newCommunity = await _api.createCommunity(event.name, event.description);
|
||||
|
||||
if (newCommunity != null) {
|
||||
if (previousState is SpaceManagementLoaded) {
|
||||
final updatedCommunities = List<CommunityModel>.from(previousState.communities)
|
||||
..add(newCommunity);
|
||||
emit(SpaceManagementLoaded(
|
||||
communities: updatedCommunities, products: _cachedProducts ?? []));
|
||||
communities: updatedCommunities,
|
||||
products: _cachedProducts ?? [],
|
||||
selectedCommunity: newCommunity));
|
||||
}
|
||||
} else {
|
||||
emit(const SpaceManagementError('Error creating community'));
|
||||
|
@ -16,9 +16,11 @@ class SpaceManagementLoading extends SpaceManagementState {}
|
||||
|
||||
class SpaceManagementLoaded extends SpaceManagementState {
|
||||
final List<CommunityModel> communities;
|
||||
final List<ProductModel> products; // Include products in the state
|
||||
final List<ProductModel> 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 {
|
||||
|
@ -56,6 +56,8 @@ class SpaceManagementPageState extends State<SpaceManagementPage> {
|
||||
);
|
||||
if (selectedIndex != -1) {
|
||||
selectedCommunity = state.communities[selectedIndex];
|
||||
} else if (state.selectedCommunity != null) {
|
||||
selectedCommunity = state.selectedCommunity;
|
||||
} else {
|
||||
selectedCommunity = null;
|
||||
selectedSpace = null;
|
||||
|
@ -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,
|
||||
),
|
||||
*/
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user