import 'package:flutter/material.dart'; import 'package:qadirneyriz/config/config.dart'; // ignore: must_be_immutable class CustomButton extends StatelessWidget { CustomButton({ super.key, this.onPressed, required this.hieght, this.fontSize = 16, this.width, this.isCircle = false, this.color, this.topLeftRadius = 20, this.topRightRadius = 20, this.bottomLeftRadius = 20, this.bottomRightRadius = 20, this.fontWeight, this.gradient, this.textColor = Colors.white, required this.text, }); double? width; double hieght; String text; bool isCircle; final Gradient? gradient; double? fontSize; Color? color; Color textColor; FontWeight? fontWeight; final double topLeftRadius; final double topRightRadius; final double bottomLeftRadius; final double bottomRightRadius; void Function()? onPressed; @override Widget build(BuildContext context) { return Container( width: width, height: hieght, decoration: BoxDecoration( gradient: gradient, borderRadius: isCircle ? null // اگر دکمه دایره باشد، از borderRadius استفاده نمی‌شود : BorderRadius.only( topLeft: Radius.circular(topLeftRadius), topRight: Radius.circular(topRightRadius), bottomLeft: Radius.circular(bottomLeftRadius), bottomRight: Radius.circular(bottomRightRadius), ), ), child: ElevatedButton( onPressed: onPressed, style: ElevatedButton.styleFrom( backgroundColor: gradient == null ? color ?? config.ui.mainGreen : Colors.transparent, shadowColor: (gradient != null) ? Colors.transparent : null, shape: isCircle == false ? RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(topLeftRadius), topRight: Radius.circular(topRightRadius), bottomLeft: Radius.circular(bottomLeftRadius), bottomRight: Radius.circular(bottomRightRadius), ), ) : const CircleBorder(), ), child: Text( text, style: TextStyle( fontSize: fontSize, fontWeight: fontWeight, color: textColor, ), ), ), ); } }