showPopListWindow static method

void showPopListWindow(
  1. dynamic context,
  2. GlobalKey<State<StatefulWidget>> popKey, {
  3. List<String>? data,
  4. PopupDirection popDirection = PopupDirection.bottom,
  5. double offset = 0,
  6. double? arrowOffset,
  7. PopupListItemClick? onItemClick,
  8. VoidCallback? onDismiss,
})

显示Popup List Window popKey 依附的组件和BrnPopUpWindow组件共同持有的GlobalKey data 要显示的文本数据列表 popDirection 箭头的方向 offset 距离targetView偏移量 onItemClick item 点击回调 onItemClickInterceptor item 点击拦截回调 onDismiss popUpWindow消失回调

Implementation

static void showPopListWindow(context, GlobalKey popKey,
    {List<String>? data,
    PopupDirection popDirection = PopupDirection.bottom,
    double offset = 0,
    double? arrowOffset,
    PopupListItemClick? onItemClick,
    VoidCallback? onDismiss}) {
  assert(popKey.currentContext != null &&
      popKey.currentContext!.findRenderObject() != null);
  if (popKey.currentContext == null ||
      popKey.currentContext!.findRenderObject() == null) return;

  double arrowHeight = 6.0;
  double borderRadius = 4;
  double spaceMargin = 0;
  double minWidth = 100;
  double maxWidth = 150;
  double maxHeight = 200;
  Color borderColor =
      BaseThemeConfig.instance.getConfig().commonConfig.dividerColorBase;
  Color backgroundColor = Colors.white;
  TextStyle textStyle = TextStyle(
      color: BaseThemeConfig.instance.getConfig().commonConfig.colorTextBase,
      fontSize: 14);
  bool hasCloseIcon = true;

  Navigator.push(
    context,
    PhoenixPopupRoute(
      child: PopupWindow(
        context,
        arrowHeight: arrowHeight,
        popKey: popKey,
        textStyle: textStyle,
        backgroundColor: backgroundColor,
        arrowOffset: arrowOffset,
        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, null, textStyle, data!,
                          (index, item) {
                        if (onItemClick != null) {
                          bool isIntercept = onItemClick(index, item);
                          if (isIntercept) return;
                        }
                        Navigator.pop(context);
                      }),
                    ),
                  ),
                ),
              ),
        popDirection: popDirection,
        borderRadius: borderRadius,
        borderColor: borderColor,
        spaceMargin: spaceMargin,
      ),
    ),
  ).then((result) {
    if (onDismiss != null) {
      onDismiss();
    }
  });
}