premium_card.dart 8.03 KB
import 'package:doublefeel_flutter/app/modules/home/controllers/today_controller.dart';
import 'package:doublefeel_flutter/core/theme/app_theme.dart';
import 'package:doublefeel_flutter/l10n/l10n_extensions.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class PremiumCard extends StatelessWidget {
  const PremiumCard(
    this.controller, {
    super.key,
  });

  final TodayController controller;

  static const _accent = Color(0xFFFF773C);
  static const _proYellow = Color(0xFFFFDF51);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 165,
      margin: const EdgeInsets.only(bottom: 12),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(16),
        gradient: const LinearGradient(
          begin: Alignment.topCenter,
          end: Alignment.bottomCenter,
          colors: [Color(0xFFFFE8AE), Color(0xFFFFFAED), Colors.white],
          stops: [0, 0.5, 1],
        ),
        boxShadow: const [
          BoxShadow(
            color: Color(0x1A7E7E7E),
            offset: Offset(0, 4),
            blurRadius: 12,
          ),
        ],
      ),
      child: ClipRRect(
        borderRadius: BorderRadius.circular(16),
        child: Stack(
          children: [
            Positioned(
              top: 7,
              right: 12,
              child: Image.asset(
                'assets/images/today/ic_gift_box.png',
                width: 90,
                height: 98,
                fit: BoxFit.contain,
              ),
            ),
            Column(
              children: [
                Expanded(
                  child: Padding(
                    padding: const EdgeInsets.fromLTRB(20, 20, 104, 0),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(
                          l10n.annualMemberDiscounts,
                          style: TextStyle(
                            fontSize: 12,
                            fontWeight: FontWeight.w500,
                            color: context.colors.textPrimary,
                            height: 1.2,
                          ),
                        ),
                        const SizedBox(height: 4),
                        Row(
                          crossAxisAlignment: CrossAxisAlignment.end,
                          children: [
                            const Text(
                              '20%',
                              style: TextStyle(
                                fontSize: 32,
                                fontWeight: FontWeight.w700,
                                color: _accent,
                                height: 1,
                              ),
                            ),
                            const SizedBox(width: 4),
                            Padding(
                              padding: const EdgeInsets.only(bottom: 4),
                              child: Text(
                                l10n.specialOffers,
                                style: const TextStyle(
                                  fontSize: 16,
                                  fontWeight: FontWeight.w600,
                                  color: _accent,
                                  height: 1.2,
                                ),
                              ),
                            ),
                          ],
                        ),
                        const Spacer(),
                        Obx(() => controller.yearlyProductAppleInfo.value !=
                                    null &&
                                controller.yearlyProduct.value != null
                            ? Row(
                                children: [
                                  Text(
                                    l10n.currentPrice,
                                    style: TextStyle(
                                      fontSize: 12,
                                      fontWeight: FontWeight.w500,
                                      color: context.colors.textPrimary,
                                    ),
                                  ),
                                  const SizedBox(width: 6),
                                  Text(
                                    controller.displayPrice(),
                                    style: TextStyle(
                                      fontSize: 12,
                                      fontWeight: FontWeight.w500,
                                      color: context.colors.textPrimary,
                                    ),
                                  ),
                                  const SizedBox(width: 8),
                                  Text(
                                    l10n.originalPrice(
                                        controller.originDisplayPrice()),
                                    style: TextStyle(
                                      fontSize: 12,
                                      color: context.colors.textTertiary,
                                      decoration: TextDecoration.lineThrough,
                                      decorationColor:
                                          context.colors.textTertiary,
                                    ),
                                  ),
                                ],
                              )
                            : SizedBox()),
                        const SizedBox(height: 12),
                      ],
                    ),
                  ),
                ),
                const Divider(
                  height: 1,
                  thickness: 1,
                  color: Color(0xFFF3F3F3),
                  indent: 20,
                  endIndent: 20,
                ),
                Padding(
                  padding: const EdgeInsets.fromLTRB(20, 10, 16, 12),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      GestureDetector(
                        onTap: () => controller.toPremiumPage('今日-会员广告'),
                        behavior: HitTestBehavior.opaque,
                        child: Text(
                          context.l10n.allPlans,
                          style: const TextStyle(
                            fontSize: 12,
                            fontWeight: FontWeight.w500,
                            color: _accent,
                          ),
                        ),
                      ),
                      GestureDetector(
                        onTap: () => controller.toPremiumDiscoutPage('今日-会员广告'),
                        child: Container(
                          height: 28,
                          padding: const EdgeInsets.only(left: 12, right: 8),
                          decoration: BoxDecoration(
                            color: _proYellow,
                            borderRadius: BorderRadius.circular(23),
                          ),
                          child: Row(
                            mainAxisSize: MainAxisSize.min,
                            children: [
                              Text(
                                context.l10n.redeemOffer,
                                style: TextStyle(
                                  fontSize: 12,
                                  fontWeight: FontWeight.w500,
                                  color: context.colors.textPrimary,
                                ),
                              ),
                              const SizedBox(width: 2),
                              Image.asset(
                                'assets/images/today/premium_chevron.png',
                                width: 12,
                                height: 12,
                              ),
                            ],
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}