buildTitle method

Widget buildTitle(
  1. BuildContext context,
  2. List<FixedExtentScrollController> controllers
)

Implementation

Widget buildTitle(BuildContext context, List<FixedExtentScrollController> controllers) {
  return Container(
    padding:
        EdgeInsets.only(left: leftPadding ?? 16, right: rightPadding ?? 16),
    height: getTitleHeight(),
    child: Row(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        // 左边按钮
        GestureDetector(
            onTap: () {
              if (onCancel != null) {
                onCancel!([
                  for (var i = 0; i < controllers.length; i++)
                    controllers[i].selectedItem
                ]);
              }
              Navigator.of(context).pop();
            },
            behavior: HitTestBehavior.opaque,
            child: TDText(
              '取消',
              style: leftTextStyle?? TextStyle(
                fontSize: TDTheme.of(context).fontBodyLarge!.size,
                color: TDTheme.of(context).fontGyColor2
              ),
            )),

        // 中间title
        Expanded(
          child: title == null
              ? Container()
              : Center(
                  child: TDText(
                    title,
                    style: centerTextStyle ?? TextStyle(
                      fontSize: TDTheme.of(context).fontTitleLarge!.size,
                      fontWeight: FontWeight.w600,
                      color: TDTheme.of(context).fontGyColor1
                    ),
                  ),
                ),
        ),

        // 右边按钮
        GestureDetector(
          onTap: () {
            if (onConfirm != null) {
              onConfirm!([
                for (var i = 0; i < controllers.length; i++)
                  controllers[i].selectedItem
              ]);
            }
            Navigator.of(context).pop();
          },
          behavior: HitTestBehavior.opaque,
          child: TDText(
            '确定',
            style: rightTextStyle?? TextStyle(
                fontSize: TDTheme.of(context).fontBodyLarge!.size,
                color: TDTheme.of(context).brandNormalColor
            ),
          ),
        ),
      ],
    ),
  );
}