JuiButton.secondary constructor

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

Implementation

JuiButton.secondary({
  Key? key,
  required String label,
  required VoidCallback? onPressed,
  VoidCallback? onLongPress,
  ButtonStyle? style,
  FocusNode? focusNode,
  bool autofocus = false,
  Clip clipBehavior = Clip.none,
  double width = double.infinity,
  Color? textColor = JuiColors.primaryColor,
  Color? backgroundColor = JuiColors.white,
  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) ? Colors.black.withOpacity(0.32) : textColor,
          ),
          backgroundColor: MaterialStateProperty.all<Color?>(
            (disabled == true || loading == true) ? const Color(0xFFD3D3D3) : backgroundColor,
          ),
          fixedSize: MaterialStateProperty.all<Size?>(Size(width, JuiBreakpoints.b48)),
          elevation: MaterialStateProperty.all<double>(0),
          shape: MaterialStateProperty.all<OutlinedBorder?>(
            RoundedRectangleBorder(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 (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),
            ],
          ),
        ),
      );