layoutHoc function

dynamic layoutHoc ({@required GlobalKey<State<StatefulWidget>> scaleKey, GlobalKey<State<StatefulWidget>> fadeInKey, @required List<Widget> children, @required Color maskColor, @required WeDialogModel model, Function onMaskCLick })

Implementation

layoutHoc({
  //缩放-key
  @required GlobalKey scaleKey,
  //淡入-key
  GlobalKey fadeInKey,
  //显示视图
  @required List<Widget> children,
  //蒙版颜色
  @required Color maskColor,
  //显示样式
  @required WeDialogModel model,
  //蒙版点击
  Function onMaskCLick,
}) {
  List<Widget> childs = [
    Padding(
      padding: EdgeInsets.only(left: 37.0, right: 37.0),
      child: Scale(
        key: scaleKey,
        begin: 0.85,
        end: 1.0,
        child: Material(
          color: Colors.white,
          borderRadius: BorderRadius.all(Radius.circular(5.0)),
          child: Padding(
            padding: EdgeInsets.only(top: boxPadding - 4),
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: children,
            ),
          ),
        ),
      ),
    )
  ];

  if (model == WeDialogModel.overlay) {
    childs.insert(
        0,
        Positioned(
          top: 0,
          right: 0,
          bottom: 0,
          left: 0,
          child: GestureDetector(
            onTap: onMaskCLick,
            child: DecoratedBox(decoration: BoxDecoration(color: maskColor)),
          ),
        ));
  }

  final Widget child = Stack(
    alignment: Alignment.center,
    children: childs,
  );

  if (model == WeDialogModel.dialog) {
    return child;
  }

  return FadeIn(key: fadeInKey, duration: 150, child: child);
}