import 'package:auto_size_text/auto_size_text.dart';
import 'package:design/design.dart';
import 'package:guru_utils/audio/audio_effector.dart';
import 'package:guru_widgets/pages/settings/guru_settings_page.dart';
import 'package:guru_widgets/button/single_tap_widget.dart';
import 'package:guru_widgets/common/flexible_container.dart';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:guru_widgets/common/spacer.dart';
import 'package:guru_widgets/theme/guru_theme.dart';

import 'remove_ads_design_model.dart';

/// Created by Haoyi on 2022/9/14

class RemoveAdsCard extends StatelessWidget {
  final RemoveAdsCardDesignSpec cardSpec;
  final VoidCallback? onPurchase;
  final GlobalKey tipsKey = GlobalKey();

  RemoveAdsCard({ required this.cardSpec, this.onPurchase, Key? key})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    final textDirection = Directionality.of(Get.context!);
    return TapWidget(
      onTap: () {
        
      },
      child: FlexibleContainer(
        width: cardSpec.removeAdsSize.width,
        height: cardSpec.removeAdsSize.height,
        radius: cardSpec.removeAdsCardRadius,
        gradient: const LinearGradient(
            begin: Alignment.centerLeft,
            end: Alignment.centerRight,
            colors: [Color(0xFFFFB343), Color(0xFFFFDE7A)]),
        child: Stack(
          fit: StackFit.expand,
          children: [
            Positioned.directional(
                width: cardSpec.radialLightWidth,
                textDirection: textDirection,
                end: 0,
                top: 0,
                bottom: 0,
                child: Image.asset("assets/images/pic_radial_light.png", fit: BoxFit.fill)),
            Positioned.directional(
                textDirection: textDirection,
                end: cardSpec.removeAdsImageEndSpacing,
                top: cardSpec.removeAdsImageVerticalSpacing,
                bottom: cardSpec.removeAdsImageVerticalSpacing,
                child: Image.asset(
                  "assets/images/pic_remove_ads.png",
                  fit: BoxFit.fill,
                )),
            Positioned.directional(
                width: cardSpec.productDetailsWidth,
                textDirection: textDirection,
                start: 0,
                top: 0,
                bottom: 0,
                child: Padding(
                    padding: cardSpec.purchaseDetailsPadding,
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        SizedSpacer(height: cardSpec.productDetailsTopSpacing),
                        AutoSizeText(
                          'Remove Banner and Pop-up Ads',
                          maxLines: 2,
                          strutStyle: const StrutStyle(height: 1.1),
                          style: TextStyle(
                              fontSize: cardSpec.productDetailsFontSize,
                              fontWeight: GuruTheme.fwBold,
                              color: const Color(0xFF7E1E00)),
                        ),
                        SizedSpacer(height: cardSpec.purchaseButtonTopSpacing),
                        FlexibleContainer(
                          width: cardSpec.removeAdsPurchaseButtonSize.width,
                          height: cardSpec.removeAdsPurchaseButtonSize.height,
                          radius: cardSpec.purchaseButtonRadius,
                          alignment: Alignment.center,
                          padding: const EdgeInsets.symmetric(horizontal: 8),
                          shadows: [
                            BoxShadow(
                                color: Colors.black.withOpacity(0.5),
                                offset: cardSpec.purchaseButtonShadowOffset)
                          ],
                          gradient: const LinearGradient(
                              begin: Alignment.topCenter,
                              end: Alignment.bottomCenter,
                              colors: [Color(0xFF04D56E), Color(0xFF08A658)]),
                          child: AutoSizeText(
                            'test222',
                            minFontSize: 5,
                            maxLines: 1,
                            textAlign: TextAlign.center,
                            style: TextStyle(
                                fontSize: cardSpec.productDetailsFontSize,
                                fontWeight: GuruTheme.fwSemiBold,
                                color: Colors.white,
                                shadows: [
                                  BoxShadow(
                                      offset: cardSpec.productPriceTextShadowOffset,
                                      color: Colors.black.withOpacity(0.4))
                                ]),
                          ),
                        )
                      ],
                    ))),
            Positioned.directional(
                textDirection: textDirection,
                end: cardSpec.tipsSpacing,
                top: cardSpec.tipsSpacing,
                child: GestureDetector(
                  onTap: () {
                    
                  },
                  child: Image.asset("assets/images/ic_colorful_tips.png",
                      key: tipsKey, width: cardSpec.tipsSize, height: cardSpec.tipsSize),
                )),
          ],
        ),
      ),
    );
  }
}
