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.
cloudsolutions-atoms/lib/new_views/common_widgets/app_filled_button.dart

74 lines
2.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:test_sa/extensions/context_extension.dart';
2 years ago
import 'package:test_sa/extensions/int_extensions.dart';
2 years ago
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/new_models/gas_refill_model.dart';
2 years ago
import 'package:test_sa/new_views/app_style/app_color.dart';
class AppFilledButton extends StatelessWidget {
final VoidCallback? onPressed;
final String label;
final bool maxWidth, loading;
final double? fontSize;
1 year ago
final bool showIcon;
final Widget? icon;
final Color? buttonColor;
final Color? textColor;
final bool showBorder;
final double radius;
final int height;
final bool disableButton;
2 years ago
1 year ago
const AppFilledButton(
{this.onPressed,
required this.label,
this.maxWidth = false,
this.showIcon = false,
this.icon,
this.fontSize,
this.loading = false,
this.height = 56,
this.showBorder = false,
this.disableButton = false,
this.buttonColor,
this.textColor,
this.radius = 10,
Key? key})
: super(key: key);
@override
Widget build(BuildContext context) {
2 years ago
return Container(
height: height.toScreenHeight,
2 years ago
width: maxWidth ? double.infinity : null,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: disableButton ?context.isDark ?AppColor.neutral20 :AppColor.neutral140 : (buttonColor ?? AppColor.blueStatus(context)),
border: showBorder ? Border.all(color: textColor ?? AppColor.background(context)) : null,
),
child: loading
? SizedBox(
width: 24.toScreenHeight,
height: 24.toScreenHeight,
1 year ago
child: CircularProgressIndicator(
color: textColor ?? AppColor.background(context),
strokeWidth: 2,
),
)
: showIcon && icon != null
? Row(mainAxisAlignment: MainAxisAlignment.center, children: [
1 year ago
icon!,
8.width,
label.heading6(context).custom(color: textColor ?? AppColor.background(context)),
])
: label.heading6(context).custom(
color: disableButton ? AppColor.neutral150 : (textColor ?? AppColor.background(context)),
align: TextAlign.center,
fontSize: fontSize ?? 16.toScreenWidth,
),
).onPress(disableButton ? null : (loading ? null : onPressed));
}
}