You cannot 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 lines
3.1 KiB
Dart
85 lines
3.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/svg.dart';
|
|
|
|
extension WithContainer on Widget {
|
|
Widget get insideContainer => Container(color: Colors.white, padding: EdgeInsets.only(top: 16, bottom: 16, right: 21, left: 21), child: this);
|
|
|
|
Widget get expand => Expanded(child: this);
|
|
|
|
Widget get insideContainerTableRow => Container(color: Colors.white, padding: EdgeInsets.only(right: 5, left: 5), child: this);
|
|
}
|
|
|
|
class DefaultButton extends StatelessWidget {
|
|
final String text;
|
|
final VoidCallback? onPress;
|
|
final Color textColor;
|
|
final Color? color;
|
|
final Color? disabledColor;
|
|
final IconData? iconData;
|
|
final String? svgIcon;
|
|
final double? fontSize;
|
|
final bool isTextExpanded;
|
|
final int count;
|
|
|
|
DefaultButton(this.text, this.onPress, {this.color, this.isTextExpanded = true, this.svgIcon, this.disabledColor, this.count = 0, this.textColor = Colors.white, this.iconData, this.fontSize});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox(
|
|
height: 43,
|
|
width: double.infinity,
|
|
child: TextButton(
|
|
onPressed: onPress,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
if (iconData != null) Icon(iconData, color: textColor),
|
|
if (svgIcon != null) SvgPicture.asset(svgIcon!, color: textColor),
|
|
if (!isTextExpanded)
|
|
Padding(
|
|
padding: EdgeInsets.only(left: (iconData ?? svgIcon) != null ? 6 : 0),
|
|
child: Text(
|
|
text,
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(fontSize: fontSize ?? 16, fontWeight: FontWeight.w600, color: textColor, letterSpacing: -0.48),
|
|
),
|
|
),
|
|
if (isTextExpanded)
|
|
Expanded(
|
|
child: Text(
|
|
text,
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(fontSize: fontSize ?? 16, fontWeight: FontWeight.w600, color: textColor, letterSpacing: -0.48),
|
|
),
|
|
),
|
|
if (count > 0)
|
|
Align(
|
|
alignment: Alignment.topCenter,
|
|
child: Container(
|
|
margin: EdgeInsets.only(top: 6, bottom: 6),
|
|
padding: EdgeInsets.only(left: 5, right: 5),
|
|
alignment: Alignment.center,
|
|
height: 16,
|
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(10.0), color: Colors.white),
|
|
child: Text(
|
|
"$count",
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w700, color: Color(0xffD02127), letterSpacing: -0.6),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
style: TextButton.styleFrom(
|
|
backgroundColor: color ?? const Color(0xffD02127),
|
|
disabledForegroundColor: disabledColor,
|
|
disabledBackgroundColor: disabledColor,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(6),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|