import 'package:auto_size_text/auto_size_text.dart';
import 'package:design/design.dart';
import 'package:guru_widgets/common/flexible_container.dart';
import 'package:guru_widgets/localizations/widgets_strings.dart';
import 'package:guru_widgets/theme/guru_theme.dart';

/// Created by Haoyi on 2023/6/7
/// 


class PurchaseButtonStyle {
  final List<BoxShadow>? shadows;
  final Color? color;
  final Gradient? gradient;
  final TextStyle? textStyle;

  const PurchaseButtonStyle({
    this.shadows,
    this.color,
    this.gradient,
    this.textStyle
  });
}


class PurchaseButton extends StatelessWidget {
  final Size size;
  final String? price;
  final PurchaseButtonStyle? buttonStyle;

  const PurchaseButton(this.size, this.price, {this.buttonStyle, super.key});

  @override
  Widget build(BuildContext context) {
    final appStrings = WidgetsStrings.get();
    return FlexibleContainer(
      width: size.width,
      height: size.height,
      radius: BorderRadius.circular(size.height * 0.5),
      alignment: Alignment.center,
      padding: const EdgeInsets.symmetric(horizontal: 8),
      shadows: buttonStyle?.shadows ?? [BoxShadow(color: Colors.black.withOpacity(0.5), offset: const Offset(0, 1))],
      color: buttonStyle?.color,
      gradient: buttonStyle?.gradient ?? const LinearGradient(
          begin: Alignment.topCenter,
          end: Alignment.bottomCenter,
          colors: [Color(0xFF04D56E), Color(0xFF08A658)]),
      child: AutoSizeText(
        price ?? appStrings.buy.toUpperCase(),
        minFontSize: 5,
        maxLines: 1,
        textAlign: TextAlign.center,
        style: buttonStyle?.textStyle ?? TextStyle(
            fontSize: 13,
            fontWeight: GuruTheme.fwSemiBold,
            color: Colors.white,
            shadows: [BoxShadow(offset: const Offset(0, 1), color: Colors.black.withOpacity(0.4))]),
      ),
    );
  }
}
