buildNormalInput method

Widget buildNormalInput(
  1. BuildContext context
)

Implementation

Widget buildNormalInput(BuildContext context) {
  var cardStyleDecoration = _getCardStylePreDecoration(context);
  var hasLeftWidget =
      leftLabel != null || leftIcon != null || (required ?? false);
  return Stack(
    alignment: Alignment.bottomCenter,
    children: [
      Container(
        alignment: Alignment.centerLeft,
        color: (cardStyleDecoration != null || decoration != null)
            ? null
            : backgroundColor,
        decoration: cardStyleDecoration ?? decoration,
        child: Row(
          crossAxisAlignment: additionInfo != ''
              ? CrossAxisAlignment.start
              : CrossAxisAlignment.center,
          children: <Widget>[
            Visibility(
              visible: hasLeftWidget,
              child: const SizedBox(
                width: 16,
              ),
            ),
            SizedBox(
              width: leftInfoWidth,
              child: Row(
                children: [
                  Visibility(
                    visible: leftIcon != null,
                    child: leftIcon ?? const SizedBox.shrink(),
                  ),
                  Visibility(
                    visible: leftLabel != null,
                    child: Container(
                      constraints: const BoxConstraints(maxWidth: 81),
                      padding: EdgeInsets.only(
                          left: leftIcon != null ? 4 : 0,
                          top: getInputPadding(),
                          bottom: getInputPadding()),
                      child: Column(
                        children: [
                          TDText(
                            leftLabel,
                            maxLines: 2,
                            style: leftLabelStyle,
                            font: TDTheme.of(context).fontBodyLarge,
                            fontWeight: FontWeight.w400,
                          ),
                        ],
                      ),
                    ),
                  ),
                  Visibility(
                    visible: labelWidget != null,
                    child: labelWidget ?? const SizedBox.shrink(),
                  ),
                  Visibility(
                      visible: required ?? false,
                      child: Padding(
                        padding: const EdgeInsets.only(left: 4.0),
                        child: TDText(
                          '*',
                          maxLines: 1,
                          style: TextStyle(
                              color: TDTheme.of(context).errorColor6),
                          font: TDTheme.of(context).fontBodyLarge,
                          fontWeight: FontWeight.w400,
                        ),
                      )),
                ],
              ),
            ),
            Expanded(
              flex: 1,
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  TDInputView(
                    textStyle: textStyle ??
                        TextStyle(color: TDTheme.of(context).fontGyColor1),
                    readOnly: readOnly,
                    autofocus: autofocus,
                    obscureText: obscureText,
                    onEditingComplete: onEditingComplete,
                    onSubmitted: onSubmitted,
                    hintText: hintText,
                    inputType: inputType,
                    onChanged: onChanged,
                    inputFormatters: inputFormatters ?? [LengthLimitingTextInputFormatter(maxNum)],
                    inputDecoration: inputDecoration,
                    maxLines: maxLines,
                    focusNode: focusNode,
                    isCollapsed: true,
                    textAlign: contentAlignment,
                    hintTextStyle: hintTextStyle ??
                        TextStyle(color: TDTheme.of(context).fontGyColor3),
                    cursorColor: cursorColor,
                    textInputBackgroundColor: textInputBackgroundColor,
                    controller: controller,
                    contentPadding: contentPadding ??
                        EdgeInsets.only(
                            left: 16,
                            right: 16,
                            bottom: additionInfo != '' ? 4 : getInputPadding(),
                            top: getInputPadding()),
                  ),
                  Visibility(
                    child: Padding(
                      padding: EdgeInsets.only(
                          left: 16, bottom: getInputPadding()),
                      child: TDText(
                        additionInfo,
                        font: TDTheme.of(context).fontBodySmall,
                        textColor: additionInfoColor ??
                            TDTheme.of(context).fontGyColor3,
                      ),
                    ),
                    visible: additionInfo != '',
                  )
                ],
              ),
            ),
            Visibility(
              visible: controller != null && controller!.text.isNotEmpty && needClear,
              child: GestureDetector(
                child: Container(
                  margin: EdgeInsets.only(left: 17.5, right: 16, top: additionInfo != '' ? getInputPadding() : 0),
                  child: Icon(
                    TDIcons.close_circle_filled,
                    color: clearBtnColor ?? TDTheme.of(context).fontGyColor3,
                  ),
                ),
                onTap: onClearTap
              ),
              replacement: Visibility(
                visible: rightBtn != null,
                child: GestureDetector(
                  onTap: onBtnTap,
                  child: Container(
                    margin: EdgeInsets.only(left: 17.5, right: 16, top: additionInfo != '' ? getInputPadding() : 0),
                    child: rightBtn,
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
      Visibility(
        visible: type != TDInputType.cardStyle,
        child: const TDDivider(
          margin: EdgeInsets.only(
            left: 16,
          ),
        ),
      ),
    ],
  );
}