You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

85 regels
2.4 KiB

  1. import 'package:flutter/material.dart';
  2. import 'package:qadirneyriz/config/config.dart';
  3. // ignore: must_be_immutable
  4. class CustomButton extends StatelessWidget {
  5. CustomButton({
  6. super.key,
  7. this.onPressed,
  8. required this.hieght,
  9. this.fontSize = 16,
  10. this.width,
  11. this.isCircle = false,
  12. this.color,
  13. this.topLeftRadius = 20,
  14. this.topRightRadius = 20,
  15. this.bottomLeftRadius = 20,
  16. this.bottomRightRadius = 20,
  17. this.fontWeight,
  18. this.gradient,
  19. this.textColor = Colors.white,
  20. required this.text,
  21. });
  22. double? width;
  23. double hieght;
  24. String text;
  25. bool isCircle;
  26. final Gradient? gradient;
  27. double? fontSize;
  28. Color? color;
  29. Color textColor;
  30. FontWeight? fontWeight;
  31. final double topLeftRadius;
  32. final double topRightRadius;
  33. final double bottomLeftRadius;
  34. final double bottomRightRadius;
  35. void Function()? onPressed;
  36. @override
  37. Widget build(BuildContext context) {
  38. return Container(
  39. width: width,
  40. height: hieght,
  41. decoration: BoxDecoration(
  42. gradient: gradient,
  43. borderRadius: isCircle
  44. ? null // اگر دکمه دایره باشد، از borderRadius استفاده نمی‌شود
  45. : BorderRadius.only(
  46. topLeft: Radius.circular(topLeftRadius),
  47. topRight: Radius.circular(topRightRadius),
  48. bottomLeft: Radius.circular(bottomLeftRadius),
  49. bottomRight: Radius.circular(bottomRightRadius),
  50. ),
  51. ),
  52. child: ElevatedButton(
  53. onPressed: onPressed,
  54. style: ElevatedButton.styleFrom(
  55. backgroundColor: gradient == null
  56. ? color ?? config.ui.mainGreen
  57. : Colors.transparent,
  58. shadowColor: (gradient != null) ? Colors.transparent : null,
  59. shape: isCircle == false
  60. ? RoundedRectangleBorder(
  61. borderRadius: BorderRadius.only(
  62. topLeft: Radius.circular(topLeftRadius),
  63. topRight: Radius.circular(topRightRadius),
  64. bottomLeft: Radius.circular(bottomLeftRadius),
  65. bottomRight: Radius.circular(bottomRightRadius),
  66. ),
  67. )
  68. : const CircleBorder(),
  69. ),
  70. child: Text(
  71. text,
  72. style: TextStyle(
  73. fontSize: fontSize,
  74. fontWeight: fontWeight,
  75. color: textColor,
  76. ),
  77. ),
  78. ),
  79. );
  80. }
  81. }