mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-08-26 09:09:40 +00:00
49 lines
1.2 KiB
Dart
49 lines
1.2 KiB
Dart
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
|
import 'package:syncrow_app/features/app_layout/model/community_model.dart';
|
|
import 'package:syncrow_app/features/app_layout/model/space_model.dart';
|
|
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_bloc.dart';
|
|
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.dart';
|
|
|
|
abstract final class SceneBlocFactory {
|
|
static SceneBloc create({
|
|
required bool pageType,
|
|
required HomeCubit homeCubit,
|
|
}) {
|
|
final selectedSpace = homeCubit.selectedSpace;
|
|
final defaultSpace = SpaceModel(
|
|
id: '-1',
|
|
name: '',
|
|
community: Community(
|
|
uuid: '-1',
|
|
name: '',
|
|
),
|
|
);
|
|
|
|
final spaceId = selectedSpace?.id ?? defaultSpace.id;
|
|
final space = selectedSpace ?? defaultSpace;
|
|
final communityUuid =
|
|
selectedSpace?.community.uuid ?? defaultSpace.community.uuid;
|
|
|
|
final sceneBloc = SceneBloc();
|
|
|
|
sceneBloc.add(
|
|
LoadScenes(
|
|
spaceId,
|
|
space,
|
|
showInDevice: pageType,
|
|
),
|
|
);
|
|
|
|
if (!pageType) {
|
|
sceneBloc.add(
|
|
LoadAutomation(
|
|
spaceId,
|
|
communityUuid,
|
|
),
|
|
);
|
|
}
|
|
|
|
return sceneBloc;
|
|
}
|
|
}
|