mobile_skt/lib/widgets/gradient_button.dart

66 lines
2.2 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:loading_animation_widget/loading_animation_widget.dart';
import 'package:sk_base_mobile/app_theme.dart';
import 'package:sk_base_mobile/constants/constants.dart';
import 'package:sk_base_mobile/util/screen_adaper_util.dart';
class GradientButton extends StatelessWidget {
final VoidCallback? onPressed;
final bool isLoading;
final String buttonText;
final Icon? icon;
const GradientButton(
{super.key,
this.buttonText = TextEnum.createInventoryInOutBtnText,
this.onPressed,
this.icon,
this.isLoading = false});
@override
Widget build(BuildContext context) {
return SizedBox(
width: double.infinity,
child: ElevatedButton(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(AppTheme.primaryColor),
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(
EdgeInsets.symmetric(vertical: ScreenAdaper.height(10)),
),
minimumSize: MaterialStateProperty.all<Size>(
Size(double.infinity, ScreenAdaper.height(80))),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
2024-04-07 17:32:46 +08:00
borderRadius: BorderRadius.circular(10),
),
),
),
onPressed: onPressed ?? () => {},
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (icon != null) ...[
icon!,
SizedBox(
width: ScreenAdaper.width(10),
)
],
isLoading
? LoadingAnimationWidget.fourRotatingDots(
color: AppTheme.nearlyWhite,
size: ScreenAdaper.height(40),
)
: Text(
buttonText,
style: TextStyle(
color: AppTheme.nearlyWhite,
fontWeight: FontWeight.bold,
fontSize: ScreenAdaper.height(25),
),
)
]),
),
);
}
}