| 1 | import "package:flutter/cupertino.dart"; |
| 2 | import "package:flutter/material.dart"; |
| 3 | |
| 4 | class NewPrimaryButton extends StatelessWidget { |
| 5 | const NewPrimaryButton({ |
| 6 | required this.onPressed, |
| 7 | required this.text, |
| 8 | required this.color, |
| 9 | required this.textColor, |
| 10 | this.image, |
| 11 | this.isLoading = false, |
| 12 | this.borderColor = Colors.transparent, |
| 13 | this.disabled = false, |
| 14 | super.key, |
| 15 | }); |
| 16 | |
| 17 | final VoidCallback onPressed; |
| 18 | final bool isLoading; |
| 19 | final bool disabled; |
| 20 | final Widget? image; |
| 21 | final Color color; |
| 22 | final Color textColor; |
| 23 | final Color borderColor; |
| 24 | final String text; |
| 25 | |
| 26 | @override |
| 27 | Widget build(BuildContext context) => SizedBox( |
| 28 | height: 52, |
| 29 | child: TextButton( |
| 30 | onPressed: disabled ? null : onPressed, |
| 31 | style: ButtonStyle( |
| 32 | backgroundColor: WidgetStateProperty.all( |
| 33 | disabled ? color.withAlpha(128) : color, |
| 34 | ), |
| 35 | shape: WidgetStateProperty.all<RoundedSuperellipseBorder>( |
| 36 | RoundedSuperellipseBorder( |
| 37 | borderRadius: BorderRadius.circular(18), |
| 38 | ), |
| 39 | ), |
| 40 | ), |
| 41 | child: Center( |
| 42 | child: isLoading |
| 43 | ? const CupertinoActivityIndicator() |
| 44 | : Row( |
| 45 | spacing: 10, |
| 46 | mainAxisSize: MainAxisSize.min, |
| 47 | children: <Widget>[ |
| 48 | if (image != null) image!, |
| 49 | Text( |
| 50 | text, |
| 51 | style: Theme.of(context).textTheme.bodyMedium?.copyWith( |
| 52 | fontSize: 14, |
| 53 | fontWeight: FontWeight.w600, |
| 54 | color: textColor, |
| 55 | ), |
| 56 | ), |
| 57 | ], |
| 58 | ), |
| 59 | ), |
| 60 | ), |
| 61 | ); |
| 62 | } |