selectShopWidget function

Widget selectShopWidget(
  1. BuildContext context,
  2. AppModel app,
  3. StorageConditionsModel? containerStorageConditions,
  4. ShopModel? shop,
  5. dynamic selectedCallback(
    1. dynamic selected
    ),
)

Implementation

Widget selectShopWidget(
    BuildContext context,
    AppModel app,
    StorageConditionsModel? containerStorageConditions,
    ShopModel? shop,
    Function(dynamic selected) selectedCallback) {
  return SelectWidget<ShopModel>(
      app: app,
      currentlySelected: shop,
      title: 'Shop',
      selectTitle: 'Select shop',
      displayItemFunction: (item) =>
          text(app, context, item.documentID + ' ' + (item.description ?? '?')),
      blocProviderProvider: () => BlocProvider<ShopListBloc>(
            create: (context) => ShopListBloc(
              eliudQuery: getComponentSelectorQuery(0, app.documentID),
              shopRepository: shopRepository(appId: app.documentID)!,
            )..add(LoadShopList()),
          ),
      blocBuilder: (contentsLoaded, contentsNotLoaded) {
        return BlocBuilder<ShopListBloc, ShopListState>(
            builder: (context, state) {
          if ((state is ShopListLoaded) && (state.values != null)) {
            return contentsLoaded(context, state.values!);
          } else {
            return contentsNotLoaded(
              context,
            );
          }
        });
      },
      selectedCallback: selectedCallback,
      addCallback: () => ShopDashboard.addShop(app, context),
      deleteCallback: null,
      updateCallback: (item) => ShopDashboard.updateShop(app, context, item),
      changePrivilegeEventCallback: (BuildContext context, int privilegeLevel) {
        BlocProvider.of<ShopListBloc>(context).add(ShopChangeQuery(
            newQuery:
                getComponentSelectorQuery(privilegeLevel, app.documentID)));
      },
      containerPrivilege: containerStorageConditions == null ||
              containerStorageConditions.privilegeLevelRequired == null
          ? 0
          : containerStorageConditions.privilegeLevelRequired!.index);
}