mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
updated blank structure
This commit is contained in:
@ -27,10 +27,25 @@ class SpaceManagementBloc extends Bloc<SpaceManagementEvent, SpaceManagementStat
|
|||||||
UpdateCommunityEvent event,
|
UpdateCommunityEvent event,
|
||||||
Emitter<SpaceManagementState> emit,
|
Emitter<SpaceManagementState> emit,
|
||||||
) async {
|
) async {
|
||||||
|
final previousState = state;
|
||||||
try {
|
try {
|
||||||
emit(SpaceManagementLoading());
|
emit(SpaceManagementLoading());
|
||||||
final success = await _api.updateCommunity(event.communityUuid, event.name);
|
final success = await _api.updateCommunity(event.communityUuid, event.name);
|
||||||
if (success) {
|
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());
|
add(LoadCommunityAndSpacesEvent());
|
||||||
} else {
|
} else {
|
||||||
emit(const SpaceManagementError('Failed to update the community.'));
|
emit(const SpaceManagementError('Failed to update the community.'));
|
||||||
@ -125,17 +140,16 @@ class SpaceManagementBloc extends Bloc<SpaceManagementEvent, SpaceManagementStat
|
|||||||
emit(SpaceManagementLoading());
|
emit(SpaceManagementLoading());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
CommunityModel? newCommunity = await _api.createCommunity(
|
CommunityModel? newCommunity = await _api.createCommunity(event.name, event.description);
|
||||||
event.name,
|
|
||||||
event.description
|
|
||||||
);
|
|
||||||
|
|
||||||
if (newCommunity != null) {
|
if (newCommunity != null) {
|
||||||
if (previousState is SpaceManagementLoaded) {
|
if (previousState is SpaceManagementLoaded) {
|
||||||
final updatedCommunities = List<CommunityModel>.from(previousState.communities)
|
final updatedCommunities = List<CommunityModel>.from(previousState.communities)
|
||||||
..add(newCommunity);
|
..add(newCommunity);
|
||||||
emit(SpaceManagementLoaded(
|
emit(SpaceManagementLoaded(
|
||||||
communities: updatedCommunities, products: _cachedProducts ?? []));
|
communities: updatedCommunities,
|
||||||
|
products: _cachedProducts ?? [],
|
||||||
|
selectedCommunity: newCommunity));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emit(const SpaceManagementError('Error creating community'));
|
emit(const SpaceManagementError('Error creating community'));
|
||||||
|
@ -16,9 +16,11 @@ class SpaceManagementLoading extends SpaceManagementState {}
|
|||||||
|
|
||||||
class SpaceManagementLoaded extends SpaceManagementState {
|
class SpaceManagementLoaded extends SpaceManagementState {
|
||||||
final List<CommunityModel> communities;
|
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 {
|
class SpaceCreationSuccess extends SpaceManagementState {
|
||||||
|
@ -56,6 +56,8 @@ class SpaceManagementPageState extends State<SpaceManagementPage> {
|
|||||||
);
|
);
|
||||||
if (selectedIndex != -1) {
|
if (selectedIndex != -1) {
|
||||||
selectedCommunity = state.communities[selectedIndex];
|
selectedCommunity = state.communities[selectedIndex];
|
||||||
|
} else if (state.selectedCommunity != null) {
|
||||||
|
selectedCommunity = state.selectedCommunity;
|
||||||
} else {
|
} else {
|
||||||
selectedCommunity = null;
|
selectedCommunity = null;
|
||||||
selectedSpace = null;
|
selectedSpace = null;
|
||||||
|
@ -109,7 +109,9 @@ class CommunityStructureHeader extends StatelessWidget {
|
|||||||
onPressed: onSave,
|
onPressed: onSave,
|
||||||
),
|
),
|
||||||
if (isSave) const SizedBox(width: 10),
|
if (isSave) const SizedBox(width: 10),
|
||||||
if (communityName != null && communityName != '')
|
/*
|
||||||
|
Commenting till finalize delete
|
||||||
|
if (communityName != null && communityName != '')
|
||||||
_buildButton(
|
_buildButton(
|
||||||
label: "Delete",
|
label: "Delete",
|
||||||
icon: SvgPicture.asset(
|
icon: SvgPicture.asset(
|
||||||
@ -119,6 +121,7 @@ class CommunityStructureHeader extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
onPressed: onDelete,
|
onPressed: onDelete,
|
||||||
),
|
),
|
||||||
|
*/
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,7 @@ abstract class ColorsManager {
|
|||||||
static const Color counterBackgroundColor = Color(0xCCF4F4F4);
|
static const Color counterBackgroundColor = Color(0xCCF4F4F4);
|
||||||
static const Color neutralGray = Color(0xFFE5E5E5);
|
static const Color neutralGray = Color(0xFFE5E5E5);
|
||||||
static const Color warningRed = Color(0xFFFF6465);
|
static const Color warningRed = Color(0xFFFF6465);
|
||||||
|
static const Color borderColor = Color(0xFFE5E5E5);
|
||||||
}
|
}
|
||||||
//background: #background: #5D5D5D;
|
//background: #background: #5D5D5D;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user