mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-08-25 18:29:39 +00:00
Integrate CommunitiesTreeSelectionBloc into CreateSpaceButton to handle space selection upon successful space creation. Update community state in CommunitiesBloc to reflect new space addition, enhancing user experience and maintainability.
This commit is contained in:
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/models/community_model.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/models/community_model.dart';
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/bloc/communities_bloc.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/bloc/communities_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/communities_tree_selection_bloc/communities_tree_selection_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/helpers/space_details_dialog_helper.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/helpers/space_details_dialog_helper.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
@ -31,11 +32,17 @@ class _CreateSpaceButtonState extends State<CreateSpaceButton> {
|
|||||||
communityUuid: widget.community.uuid,
|
communityUuid: widget.community.uuid,
|
||||||
onSuccess: (updatedSpaceModel) {
|
onSuccess: (updatedSpaceModel) {
|
||||||
final newCommunity = widget.community.copyWith(
|
final newCommunity = widget.community.copyWith(
|
||||||
spaces: [updatedSpaceModel, ...widget.community.spaces],
|
spaces: [...widget.community.spaces, updatedSpaceModel],
|
||||||
);
|
);
|
||||||
context.read<CommunitiesBloc>().add(
|
context.read<CommunitiesBloc>().add(
|
||||||
CommunitiesUpdateCommunity(newCommunity),
|
CommunitiesUpdateCommunity(newCommunity),
|
||||||
);
|
);
|
||||||
|
context.read<CommunitiesTreeSelectionBloc>().add(
|
||||||
|
SelectSpaceEvent(
|
||||||
|
space: updatedSpaceModel,
|
||||||
|
community: newCommunity,
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
child: MouseRegion(
|
child: MouseRegion(
|
||||||
|
Reference in New Issue
Block a user