95 lines
2.8 KiB
Dart
95 lines
2.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:onufitness/utils/helper_function.dart';
|
|
|
|
class CustomSubmitButton extends StatelessWidget {
|
|
final String text;
|
|
final VoidCallback onPressed;
|
|
final Color backgroundColor;
|
|
final Color textColor;
|
|
final double? fontSize;
|
|
final double? height;
|
|
final double? width;
|
|
final double? borderRadius;
|
|
final FontWeight? fontWeight;
|
|
final EdgeInsetsGeometry? padding;
|
|
final BorderSide? borderSide;
|
|
final TextStyle? textStyle;
|
|
final Widget? icon;
|
|
final bool isLoading;
|
|
final bool isDisable;
|
|
final Widget? suffix;
|
|
const CustomSubmitButton({
|
|
super.key,
|
|
required this.text,
|
|
required this.onPressed,
|
|
this.backgroundColor = Colors.black,
|
|
this.textColor = Colors.white,
|
|
this.fontSize,
|
|
this.height,
|
|
this.borderRadius,
|
|
this.fontWeight,
|
|
this.padding,
|
|
this.borderSide,
|
|
this.textStyle,
|
|
this.icon,
|
|
this.suffix,
|
|
this.isLoading = false,
|
|
this.width,
|
|
this.isDisable = false,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox(
|
|
width: width ?? double.infinity,
|
|
height: height ?? (isTablet ? 65.h : 50.h),
|
|
child: ElevatedButton(
|
|
onPressed: isDisable || isLoading ? null : onPressed,
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: backgroundColor,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(
|
|
borderRadius ?? (isTablet ? 35.r : 30.r),
|
|
),
|
|
side: borderSide ?? BorderSide.none,
|
|
),
|
|
padding:
|
|
padding ??
|
|
EdgeInsets.symmetric(horizontal: isTablet ? 24.w : 16.w),
|
|
),
|
|
child:
|
|
isLoading
|
|
? SizedBox(
|
|
width: 24.w,
|
|
height: 24.w,
|
|
child: CircularProgressIndicator(
|
|
color: textColor,
|
|
strokeWidth: 2.5,
|
|
),
|
|
)
|
|
: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
if (icon != null) icon!,
|
|
if (icon != null) SizedBox(width: 10.w),
|
|
Text(
|
|
text,
|
|
style:
|
|
textStyle ??
|
|
TextStyle(
|
|
fontSize: (fontSize ?? (isTablet ? 20.sp : 16.sp)),
|
|
fontWeight: fontWeight ?? FontWeight.w600,
|
|
color: textColor,
|
|
),
|
|
),
|
|
if (suffix != null) SizedBox(width: 5.w),
|
|
if (suffix != null) suffix!,
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|