premium_card.dart 7.16 KB
import 'package:flutter/material.dart';

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

  final VoidCallback? onClaimTap;
  final VoidCallback? onAllPlansTap;

  static const _h1 = Color(0xFF0F0F11);
  static const _h3 = Color(0xFFB0B0B6);
  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/premium_gift_illustration.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: [
                        const Text(
                          '年度会员优惠',
                          style: TextStyle(
                            fontSize: 12,
                            fontWeight: FontWeight.w500,
                            color: _h1,
                            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),
                            const Padding(
                              padding: EdgeInsets.only(bottom: 4),
                              child: Text(
                                '优惠',
                                style: TextStyle(
                                  fontSize: 16,
                                  fontWeight: FontWeight.w600,
                                  color: _accent,
                                  height: 1.2,
                                ),
                              ),
                            ),
                          ],
                        ),
                        const Spacer(),
                        Row(
                          children: [
                            const Text(
                              '现价',
                              style: TextStyle(
                                fontSize: 12,
                                fontWeight: FontWeight.w500,
                                color: _h1,
                              ),
                            ),
                            const SizedBox(width: 6),
                            const Text(
                              '¥78.00/年',
                              style: TextStyle(
                                fontSize: 12,
                                fontWeight: FontWeight.w500,
                                color: _h1,
                              ),
                            ),
                            const SizedBox(width: 8),
                            Text(
                              '原价 ¥198/年',
                              style: TextStyle(
                                fontSize: 12,
                                color: _h3,
                                decoration: TextDecoration.lineThrough,
                                decorationColor: _h3,
                              ),
                            ),
                          ],
                        ),
                        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: onAllPlansTap,
                        behavior: HitTestBehavior.opaque,
                        child: const Text(
                          '全部方案',
                          style: TextStyle(
                            fontSize: 12,
                            fontWeight: FontWeight.w500,
                            color: _accent,
                          ),
                        ),
                      ),
                      GestureDetector(
                        onTap: onClaimTap,
                        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: [
                              const Text(
                                '领取优惠',
                                style: TextStyle(
                                  fontSize: 12,
                                  fontWeight: FontWeight.w500,
                                  color: _h1,
                                ),
                              ),
                              const SizedBox(width: 2),
                              Image.asset(
                                'assets/images/today/premium_chevron.png',
                                width: 12,
                                height: 12,
                              ),
                            ],
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}