import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getx_scaffold/common/index.dart';
import 'package:ln_jq_app/common/login_util.dart';

class MallRulePage extends StatelessWidget {
  const MallRulePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color.fromRGBO(64, 199, 154, 1),
      appBar: AppBar(
        backgroundColor: Colors.transparent,
        elevation: 0,
        leading: IconButton(
          icon: const Icon(Icons.arrow_back_ios, color: Colors.white, size: 20),
          onPressed: () => Get.back(),
        ),
      ),
      body: Stack(
        children: [
          // 顶部装饰图
          Positioned(
            top: 30,
            right: Get.width * 0.15,
            child: LoginUtil.getAssImg("rule_bg@2x"),
          ),
          Container(
            margin: const EdgeInsets.fromLTRB(20, 100, 20, 20),
            padding: const EdgeInsets.all(24),
            width: double.infinity,
            decoration: BoxDecoration(
              image: DecorationImage(
                image: AssetImage('assets/images/rule_bg_1@2x.png'),
                fit: BoxFit.fill,
              ),
            ),
            child: SingleChildScrollView(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  const Text(
                    '积分获取规则',
                    style: TextStyle(
                      fontSize: 22,
                      fontWeight: FontWeight.bold,
                      color: Color(0xFF2C3E50),
                    ),
                  ),
                  const SizedBox(height: 30),
                  _buildRuleItem(
                    icon: 'tips_1@2x',
                    title: '每日首次签到积分规则',
                    content: '每日首签，立得 1 积分',
                  ),
                  _buildRuleItem(
                    icon: 'tips_2@2x',
                    title: '每日预约加氢积分规则',
                    content: '每日前 2 次预约加氢，各得 1 积分',
                  ),
                  _buildRuleItem(
                    icon: 'tips_3@2x',
                    title: '连续签到累计赠分规则',
                    content: '连续签到 3 天赠 2 积分，7 天赠 5 积分',
                  ),
                  _buildRuleItem(
                    icon: 'tips_4@2x',
                    title: '连续签到周期及断签重置规则',
                    content: '7 天为一个签到周期，中途断签则重新从第 1 天计算',
                  ),
                  _buildRuleItem(
                    icon: 'tips_5@2x',
                    title: '积分使用规则',
                    content:
                        '积分有效期3个月。个人账户内累计的所有有效积分，可在平台积分商城中，用于兑换商城内上架的各类商品、权益或服务，兑换时将按照商品标注的积分值扣除对应积分，积分兑换后不支持撤销、退换，商品兑换规则以积分商城内公示为准。',
                  ),
                  const SizedBox(height: 40),
                  const Center(
                    child: Text(
                      '本活动最终解释权归官方所有，如有疑问可咨询客服。',
                      style: TextStyle(color: Color(0xFF999999), fontSize: 12),
                    ),
                  ),
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildRuleItem({
    required String icon,
    required String title,
    required String content,
  }) {
    return Padding(
      padding: const EdgeInsets.only(bottom: 24),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              LoginUtil.getAssImg(icon),
              const SizedBox(width: 8),
              Text(
                title,
                style: TextStyle(
                  fontSize: 15.sp,
                  fontWeight: FontWeight.bold,
                  color: Color(0xFF333333),
                ),
              ),
            ],
          ),
          const SizedBox(height: 6),
          Padding(
            padding: const EdgeInsets.only(left: 0),
            child: Text(
              content,
              style: TextStyle(fontSize: 13.sp, color: Color(0xFF666666), height: 1.5),
            ),
          ),
        ],
      ),
    );
  }
}
