render method

dynamic render(
  1. BuildContext context,
  2. OwlnextInputState state
)

Implementation

render(BuildContext context, OwlnextInputState state) {
  if (state.widget.axis == Axis.vertical) {
    return Column(
      crossAxisAlignment: state.widget.verticalCrossAlignment ?? CrossAxisAlignment.start,
      mainAxisAlignment: state.widget.verticalMainAlignment ?? MainAxisAlignment.start,
      children: [
        if (state.widget.label != null && Artist().inputDecoration.floatingLabelBehavior != FloatingLabelBehavior.auto)
        SizedBox(
          child: Row(
            children: [
              if (state.widget.label != null)
              Expanded(
                child: Text(
                  "${state.widget.label ?? ''} ${state.widget.isMandatory == true ? "* " : ""}",
                  textAlign: TextAlign.left,
                  style: state.getLabelStyle
                ),
              ),
              if (state.widget.infoCallback != null)
              InkWell(
                child: MouseRegion(
                  cursor: SystemMouseCursors.click,
                  child: GestureDetector(
                    onTap: () {
                      state.widget.infoCallback!();
                    },
                    child: Container(
                      width: 17,
                      height: 17,
                      margin: const EdgeInsets.only(left: 12),
                      padding: const EdgeInsets.all(2),
                      decoration: BoxDecoration(
                        border: Border.all(
                          color: Theme.of(context).colorScheme.primary,
                        ),
                        borderRadius: BorderRadius.circular(100)
                      ),
                      child: Icon(
                        Icons.question_mark,
                        color: Theme.of(context).colorScheme.primary,
                        size: 10
                      )
                    )
                  )
                )
              )
            ]
          ),
        ),
        if (state.widget.label != null && Artist().inputDecoration.floatingLabelBehavior != FloatingLabelBehavior.auto)
        SizedBox(
          height: Artist().labelBottomSpace,
        ),
        Row(
          children: [
            Flexible(
              child: state.widget.isInsideList == true ?
                ConstrainedBox(
                  constraints: BoxConstraints(
                    maxWidth: state.widget.isExpanded == true ? double.infinity : Artist().maxInputWidth,
                  ),
                  child: generateForm(context, state.focusNode, state),
                ) :
                ConstrainedBox(
                  constraints: BoxConstraints(
                    minWidth: 250,
                    maxWidth: state.widget.isExpanded == true ? double.infinity : Artist().maxInputWidth,
                  ),
                  child: generateForm(context, state.focusNode, state)
                )
            ),
            if (state.widget.hasCopyToClipboard)
            Row(
              children: [
                const SizedBox(width: 12),
                InkWell(
                  onTap: state.handleCopyToClipBoard,
                  child: Icon(
                    Icons.copy,
                    color: Theme.of(context).colorScheme.primary,
                  )
                ),
              ],
            )
          ],
        ),
      ]
    );
  } else if (state.widget.axis == Axis.horizontal) {
    return Row(
      crossAxisAlignment: state.widget.minimumLines! > 1 ? CrossAxisAlignment.start : CrossAxisAlignment.center,
      children: [
        if (state.widget.label != null && Artist().inputDecoration.floatingLabelBehavior != FloatingLabelBehavior.auto)
        SizedBox(
          child: Row(
            children: [
              if (state.widget.label != null)
              SizedBox(
                width: Artist().horizontalLabelWidth,
                child: Text(
                  "${state.widget.label ?? ''} ${state.widget.isMandatory == true ? "* " : ""}",
                  textAlign: TextAlign.left,
                  style: state.getLabelStyle
                ),
              ),
              if (state.widget.infoCallback != null)
              InkWell(
                child: MouseRegion(
                  cursor: SystemMouseCursors.click,
                  child: GestureDetector(
                    onTap: () {
                      state.widget.infoCallback!();
                    },
                    child: Container(
                      width: 17,
                      height: 17,
                      margin: const EdgeInsets.only(left: 12),
                      padding: const EdgeInsets.all(2),
                      decoration: BoxDecoration(
                        border: Border.all(
                          color: Theme.of(context).colorScheme.primary,
                        ),
                        borderRadius: BorderRadius.circular(100)
                      ),
                      child: Icon(
                        Icons.question_mark,
                        color: Theme.of(context).colorScheme.primary,
                        size: 10
                      )
                    )
                  )
                )
              )
            ]
          ),
        ),
        if (state.widget.label != null && Artist().inputDecoration.floatingLabelBehavior != FloatingLabelBehavior.auto)
        SizedBox(
          width: Artist().labelBottomSpace,
        ),
        Flexible(
          child: ConstrainedBox(
            constraints: BoxConstraints(
              minWidth: 250,
              maxWidth: Artist().maxInputWidth,
            ),
            child: state.widget.isInsideList == true ?
              generateForm(context, state.focusNode, state)
              :
              generateForm(context, state.focusNode, state),
          )
        ),
        if (state.widget.hasCopyToClipboard)
        Row(
          children: [
            const SizedBox(width: 12),
            InkWell(
              onTap: state.handleCopyToClipBoard,
              child: Icon(
                Icons.copy,
                color: Theme.of(context).colorScheme.primary,
              )
            ),
          ],
        )
      ]
    );
  }
}