selectFeedFrontWidget function

Widget selectFeedFrontWidget(
  1. BuildContext context,
  2. AppModel app,
  3. StorageConditionsModel? containerStorageConditions,
  4. FeedFrontModel? feedFront,
  5. dynamic selectedCallback(
    1. dynamic selected
    ),
)

Implementation

Widget selectFeedFrontWidget(
    BuildContext context,
    AppModel app,
    StorageConditionsModel? containerStorageConditions,
    FeedFrontModel? feedFront,
    Function(dynamic selected) selectedCallback) {
  return SelectWidget<FeedFrontModel>(
      app: app,
      currentlySelected: feedFront,
      title: 'Feed Front',
      selectTitle: 'Select feed front',
      displayItemFunction: (item) =>
          text(app, context, item.documentID + ' ' + (item.description ?? '?')),
      blocProviderProvider: () => BlocProvider<FeedFrontListBloc>(
            create: (context) => FeedFrontListBloc(
              eliudQuery: getComponentSelectorQuery(0, app.documentID),
              feedFrontRepository: feedFrontRepository(appId: app.documentID)!,
            )..add(LoadFeedFrontList()),
          ),
      blocBuilder: (contentsLoaded, contentsNotLoaded) {
        return BlocBuilder<FeedFrontListBloc, FeedFrontListState>(
            builder: (context, state) {
          if ((state is FeedFrontListLoaded) && (state.values != null)) {
            return contentsLoaded(context, state.values!);
          } else {
            return contentsNotLoaded(
              context,
            );
          }
        });
      },
      addCallback: () {
        addComponent(context, app, 'feedFronts', (_, __) {});
      },
      deleteCallback: null,
      updateCallback: (item) {
        updateComponent(
            context, app, 'feedFronts', item.documentID, (_, __) {});
      },
      selectedCallback: selectedCallback,
      changePrivilegeEventCallback:
          (BuildContext newContext, int privilegeLevel) {
        BlocProvider.of<FeedFrontListBloc>(newContext).add(FeedFrontChangeQuery(
            newQuery:
                getComponentSelectorQuery(privilegeLevel, app.documentID)));
      },
      containerPrivilege: containerStorageConditions == null ||
              containerStorageConditions.privilegeLevelRequired == null
          ? 0
          : containerStorageConditions.privilegeLevelRequired!.index);
}