mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
@ -26,27 +26,27 @@ class LinkSpaceToModelBloc
|
||||
Future<void> _getSpaceIds(LinkSpaceModelSelectedIdsEvent event,
|
||||
Emitter<LinkSpaceToModelState> emit) async {
|
||||
try {
|
||||
final context = NavigationService.navigatorKey.currentContext!;
|
||||
final spaceBloc = context.read<SpaceTreeBloc>();
|
||||
spacesListIds.clear();
|
||||
for (final communityId in spaceBloc.state.selectedCommunities) {
|
||||
final spacesList =
|
||||
BuildContext context = NavigationService.navigatorKey.currentContext!;
|
||||
var spaceBloc = context.read<SpaceTreeBloc>();
|
||||
spacesListIds.clear();
|
||||
for (var communityId in spaceBloc.state.selectedCommunities) {
|
||||
List<String> spacesList =
|
||||
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
|
||||
spacesListIds.addAll(spacesList);
|
||||
spacesListIds.addAll(spacesList);
|
||||
}
|
||||
hasSelectedSpaces =
|
||||
spaceBloc.state.selectedCommunities.any((communityId) {
|
||||
final spacesList =
|
||||
List<String> spacesList =
|
||||
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
|
||||
return spacesList.isNotEmpty;
|
||||
});
|
||||
if (hasSelectedSpaces) {
|
||||
debugPrint('At least one space is selected.');
|
||||
debugPrint("At least one space is selected.");
|
||||
} else {
|
||||
debugPrint('No spaces selected.');
|
||||
debugPrint("No spaces selected.");
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('Error in _getSpaceIds: $e');
|
||||
debugPrint("Error in _getSpaceIds: $e");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,9 @@ abstract class LinkSpaceToModelState {
|
||||
class SpaceModelInitial extends LinkSpaceToModelState {}
|
||||
|
||||
class SpaceModelLoading extends LinkSpaceToModelState {}
|
||||
|
||||
class LinkSpaceModelLoading extends LinkSpaceToModelState {}
|
||||
|
||||
|
||||
class SpaceModelSelectedState extends LinkSpaceToModelState {
|
||||
final int selectedIndex;
|
||||
const SpaceModelSelectedState(this.selectedIndex);
|
||||
|
@ -15,11 +15,11 @@ class LinkSpaceModelDialog extends StatelessWidget {
|
||||
final List<SpaceTemplateModel> spaceModels;
|
||||
|
||||
const LinkSpaceModelDialog({
|
||||
super.key,
|
||||
Key? key,
|
||||
this.onSave,
|
||||
this.initialSelectedIndex,
|
||||
required this.spaceModels,
|
||||
});
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -39,10 +39,9 @@ class LinkSpaceModelDialog extends StatelessWidget {
|
||||
color: ColorsManager.textFieldGreyColor,
|
||||
width: MediaQuery.of(context).size.width * 0.7,
|
||||
height: MediaQuery.of(context).size.height * 0.6,
|
||||
child: BlocBuilder<LinkSpaceToModelBloc,
|
||||
LinkSpaceToModelState>(
|
||||
child: BlocBuilder<LinkSpaceToModelBloc, LinkSpaceToModelState>(
|
||||
builder: (context, state) {
|
||||
var selectedIndex = -1;
|
||||
int selectedIndex = -1;
|
||||
if (state is SpaceModelSelectedState) {
|
||||
selectedIndex = state.selectedIndex;
|
||||
}
|
||||
@ -73,9 +72,7 @@ class LinkSpaceModelDialog extends StatelessWidget {
|
||||
),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
child: SpaceModelCardWidget(
|
||||
model: model,
|
||||
),
|
||||
child: SpaceModelCardWidget(model: model,),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
Reference in New Issue
Block a user