2024-03-20 09:37:20 +08:00
|
|
|
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';
|
2024-04-09 08:31:17 +08:00
|
|
|
import 'package:sk_base_mobile/widgets/core/sk_ink.dart';
|
2024-03-20 09:37:20 +08:00
|
|
|
|
|
|
|
class GradientButton extends StatelessWidget {
|
2024-03-20 10:37:52 +08:00
|
|
|
final VoidCallback? onPressed;
|
|
|
|
final bool isLoading;
|
|
|
|
final String buttonText;
|
2024-04-03 13:45:34 +08:00
|
|
|
final Icon? icon;
|
2024-04-09 08:31:17 +08:00
|
|
|
final BorderRadiusGeometry? borderRadius;
|
2024-03-20 10:37:52 +08:00
|
|
|
const GradientButton(
|
2024-03-20 09:37:20 +08:00
|
|
|
{super.key,
|
|
|
|
this.buttonText = TextEnum.createInventoryInOutBtnText,
|
|
|
|
this.onPressed,
|
2024-04-03 13:45:34 +08:00
|
|
|
this.icon,
|
2024-04-09 08:31:17 +08:00
|
|
|
this.borderRadius,
|
2024-03-20 09:37:20 +08:00
|
|
|
this.isLoading = false});
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-04-09 08:31:17 +08:00
|
|
|
return SkInk(
|
|
|
|
onTap: onPressed ?? () {},
|
|
|
|
gradient: const LinearGradient(
|
|
|
|
colors: [AppTheme.primaryColorLight, AppTheme.primaryColor]),
|
|
|
|
child: SizedBox(
|
|
|
|
height: ScreenAdaper.height(80),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
if (icon != null) ...[
|
|
|
|
icon!,
|
|
|
|
SizedBox(
|
|
|
|
width: ScreenAdaper.width(10),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
isLoading
|
|
|
|
? LoadingAnimationWidget.fourRotatingDots(
|
2024-04-03 13:45:34 +08:00
|
|
|
color: AppTheme.nearlyWhite,
|
2024-04-09 08:31:17 +08:00
|
|
|
size: ScreenAdaper.height(40),
|
|
|
|
)
|
|
|
|
: Text(
|
|
|
|
buttonText,
|
|
|
|
style: TextStyle(
|
|
|
|
color: AppTheme.nearlyWhite,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: ScreenAdaper.height(25),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
])),
|
2024-03-20 09:37:20 +08:00
|
|
|
);
|
2024-04-09 08:31:17 +08:00
|
|
|
|
|
|
|
// ElevatedButton(
|
|
|
|
// style: ButtonStyle(
|
|
|
|
// backgroundColor:
|
|
|
|
// MaterialStateProperty.all<Color>(AppTheme.primaryColor),
|
|
|
|
// minimumSize: MaterialStateProperty.all<Size>(
|
|
|
|
// Size(double.infinity, ScreenAdaper.height(80))),
|
|
|
|
// shape: MaterialStateProperty.all<RoundedRectangleBorder>(
|
|
|
|
// RoundedRectangleBorder(
|
|
|
|
// borderRadius: borderRadius ?? BorderRadius.circular(10),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// onPressed: onPressed ?? () => {},
|
|
|
|
// child: Text(
|
|
|
|
// buttonText,
|
|
|
|
// style: TextStyle(
|
|
|
|
// color: AppTheme.nearlyWhite,
|
|
|
|
// fontWeight: FontWeight.bold,
|
|
|
|
// fontSize: ScreenAdaper.height(25),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// 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),
|
|
|
|
// ),
|
|
|
|
// )
|
|
|
|
// ]),
|
|
|
|
// );
|
2024-03-20 09:37:20 +08:00
|
|
|
}
|
|
|
|
}
|