JuiButton.ghost constructor

JuiButton.ghost({
  1. Key? key,
  2. required String label,
  3. required VoidCallback? onPressed,
  4. Widget? icon,
  5. VoidCallback? onLongPress,
  6. ButtonStyle? style,
  7. FocusNode? focusNode,
  8. bool autofocus = false,
  9. Clip clipBehavior = Clip.none,
  10. double width = double.infinity,
  11. Color? textColor = JuiColors.primaryColor,
  12. Color? backgroundColor = Colors.transparent,
  13. bool showBorder = true,
  14. bool? disabled,
  15. bool? loading,
})

Implementation

JuiButton.ghost({
  Key? key,
  required String label,
  required VoidCallback? onPressed,
  Widget? icon,
  VoidCallback? onLongPress,
  ButtonStyle? style,
  FocusNode? focusNode,
  bool autofocus = false,
  Clip clipBehavior = Clip.none,
  double width = double.infinity,
  Color? textColor = JuiColors.primaryColor,
  Color? backgroundColor = Colors.transparent,
  bool showBorder = true,
  bool? disabled,
  bool? loading,
}) : super(
        key: key,
        onPressed: (disabled == true || loading == true) ? null : onPressed,
        onLongPress: (disabled == true || loading == true) ? null : onLongPress,
        style: ButtonStyle(
          foregroundColor: MaterialStateProperty.all<Color?>(
            (disabled == true || loading == true) ? JuiColors.gray.shade300 : textColor,
          ),
          backgroundColor: MaterialStateProperty.all<Color?>(backgroundColor),
          overlayColor: MaterialStateProperty.all<Color?>(textColor?.withOpacity(0.1)),
          fixedSize: MaterialStateProperty.all<Size?>(Size(width, JuiBreakpoints.b48)),
          elevation: MaterialStateProperty.all<double>(0),
          shape: MaterialStateProperty.all<OutlinedBorder?>(
            RoundedRectangleBorder(
              side: BorderSide(
                color: showBorder
                    ? ((disabled == true || loading == true)
                        ? Colors.black.withOpacity(0.32)
                        : JuiColors.primaryColor)
                    : Colors.transparent,
                width: 1.0.r,
              ),
              borderRadius: BorderRadius.circular(JuiBreakpoints.b24),
            ),
          ),
        ),
        focusNode: focusNode,
        autofocus: autofocus,
        clipBehavior: clipBehavior,
        child: Padding(
          padding: EdgeInsets.symmetric(vertical: JuiBreakpoints.b12),
          child: Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              if (icon != null) SizedBox(width: JuiBreakpoints.b8),
              if (loading == true)
                SizedBox(
                  width: JuiBreakpoints.b16,
                  height: JuiBreakpoints.b16,
                  child: CircularProgressIndicator(
                    strokeWidth: 2.0.r,
                    color: Colors.black.withOpacity(0.32),
                  ),
                ),
              if (loading == true) SizedBox(width: JuiBreakpoints.b16),
              Text(
                label,
                style: const TextStyle().regularSemiBold(
                    color: (disabled == true || loading == true)
                        ? Colors.black.withOpacity(0.32)
                        : textColor),
              ),
              if (loading == true) SizedBox(width: JuiBreakpoints.b32),
            ],
          ),
        ),
      );