showLinePop static method

void showLinePop(
  1. BuildContext context, {
  2. bool isShowBg = false,
  3. _ClickCallBack? clickCallback,
})

显示带线带背景 pop

Implementation

static void showLinePop(BuildContext context,
    {bool isShowBg = false, _ClickCallBack? clickCallback}) {
  // 带线
  Widget _buildMenuLineCell(dataArr) {
    return ListView.separated(
      itemCount: dataArr.length,
      padding: const EdgeInsets.all(0.0),
      physics: const NeverScrollableScrollPhysics(),
      itemBuilder: (BuildContext context, int index) {
        return Material(
            color: _bgColor,
            child: InkWell(
                onTap: () {
                  Navigator.pop(context);
                  if (clickCallback != null) {
                    clickCallback(index, _listData[index]['text']);
                  }
                },
                child: SizedBox(
                  height: _cellHeight,
                  child: Row(
                    children: <Widget>[
                      const SizedBox(width: 25),
                      Image.asset(dataArr[index]['icon'],
                          width: _imgWH, height: _imgWH, color: Colors.white),
                      const SizedBox(width: 12),
                      Text(dataArr[index]['text'],
                          style: const TextStyle(
                              color: Colors.white, fontSize: _fontSize))
                    ],
                  ),
                )));
      },
      separatorBuilder: (context, index) {
        return const Divider(
          height: .1,
          indent: 50,
          endIndent: 0,
          color: Color(0xFFE6E6E6),
        );
      },
    );
  }

  Widget _menusView(dataArr) {
    var cellH = dataArr.length * _cellHeight;
    var navH = VScreenUtils.navigationBarHeight;
    if (isShowBg == true) {
      navH = navH - VScreenUtils.topSafeHeight;
    } else {
      navH = navH - 10;
    }
    return Positioned(
      right: 10,
      top: navH,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.end,
        children: <Widget>[
          Image.asset('assets/images/popMenus/ic_menu_up_arrow.png',
              width: 28, height: 5),
          ClipRRect(
              borderRadius: BorderRadius.circular(5),
              child: Container(
                  color: _bgColor,
                  width: 160,
                  height: cellH,
                  child: _buildMenuLineCell(dataArr)))
        ],
      ),
    );
  }

  if (isShowBg == true) {
    // 带背景
    showDialog(
        context: context,
        barrierDismissible: false,
        builder: (context) {
          return _BasePopMenus(child: _menusView(_listData));
        });
  } else {
    Navigator.of(context)
        .push(DialogRouter(_BasePopMenus(child: _menusView(_listData))));
  }
}