showButtonPanelPopList static method

void showButtonPanelPopList(
  1. dynamic context,
  2. GlobalKey<State<StatefulWidget>> popKey, {
  3. List<String>? data,
  4. PopupDirection popDirection = PopupDirection.bottom,
  5. PopupListItemBuilder? itemBuilder,
  6. PopupListItemClick? onItemClick,
  7. VoidCallback? onDismiss,
})

带 itemBuilder 的 Popup List Window popKey 依附的组件和BrnPopUpWindow组件共同持有的GlobalKey data 要显示的文本数据列表 popDirection 箭头的方向 itemBuilder 自定义 item 构造方法 onItemClick item 点击回调 onItemClickInterceptor item 点击拦截回调 onDismiss popUpWindow消失回调

Implementation

static void showButtonPanelPopList(
  context,
  GlobalKey popKey, {
  List<String>? data,
  PopupDirection popDirection = PopupDirection.bottom,
  PopupListItemBuilder? itemBuilder,
  PopupListItemClick? onItemClick,
  VoidCallback? onDismiss,
}) {
  TextStyle textStyle = TextStyle(
      color: BaseThemeConfig.instance.getConfig().commonConfig.colorTextBase,
      fontSize: 16);
  double arrowHeight = 6.0;
  Color borderColor = const Color(0xffCCCCCC);
  Color backgroundColor = Colors.white;
  double offset = 4;
  double spaceMargin = -10;
  double minWidth = 100;
  double maxWidth = 150;
  double maxHeight = 200;
  double borderRadius = 4;
  bool hasCloseIcon = true;
  assert(popKey.currentContext != null &&
      popKey.currentContext!.findRenderObject() != null);
  if (popKey.currentContext == null ||
      popKey.currentContext!.findRenderObject() == null) return;
  Navigator.push(
      context,
      PhoenixPopupRoute(
          child: PopupWindow(
        context,
        arrowHeight: arrowHeight,
        popKey: popKey,
        textStyle: textStyle,
        backgroundColor: backgroundColor,
        isShowCloseIcon: hasCloseIcon,
        offset: offset,
        widget: PhoenixTools.isEmpty(data)
            ? Container(
                constraints:
                    BoxConstraints(maxWidth: maxWidth, maxHeight: maxHeight),
              )
            : Container(
                constraints:
                    BoxConstraints(maxWidth: maxWidth, maxHeight: maxHeight),
                child: SingleChildScrollView(
                  child: Container(
                    padding: const EdgeInsets.only(top: 6, bottom: 6),
                    child: Column(
                      children: _getItems(context, minWidth, maxWidth,
                          itemBuilder, textStyle, data!, (index, item) {
                        if (onItemClick != null) {
                          bool isIntercept = onItemClick(index, item);
                          if (isIntercept) return;
                        }
                        Navigator.pop(
                            context, {'index': index, 'item': item});
                      }),
                    ),
                  ),
                ),
              ),
        popDirection: popDirection,
        borderRadius: borderRadius,
        borderColor: borderColor,
        spaceMargin: spaceMargin,
      ))).then((result) {
    if (onDismiss != null) {
      onDismiss();
    }
  });
}