// lib/app/modules/hi_menu/widgets/user_info_card.dart

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:kaer_with_panels/app/modules/hi_menu/controllers/hi_menu_controller.dart';
import 'package:kaer_with_panels/app/routes/app_pages.dart';
import 'package:kaer_with_panels/app/widgets/kr_local_image.dart';
import 'package:kaer_with_panels/app/widgets/kr_subscription_expiry_text.dart';

/// 用户信息展示卡片 Widget
///
/// 显示用户头像、ID和套餐到期时间，并提供点击跳转到套餐页面的功能。
class UserInfoCard extends StatelessWidget {
  const UserInfoCard({
    super.key,
    required this.controller,
    required this.userId,
  });

  final HIMenuController controller;
  final String userId;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        // 点击后用户页面
        Get.toNamed(Routes.HI_USER_INFO);
      },
      // 让整个卡片的透明区域也能响应点击
      behavior: HitTestBehavior.opaque,
      child: Container(
        padding: EdgeInsets.fromLTRB(5, 4, 18, 4),
        decoration: BoxDecoration(
          color: Colors.transparent,
          borderRadius: BorderRadius.circular(35.5),
          border: Border.all(
            color: Colors.white,
            width: 2.0, // 👇 核心改动: 将边框宽度设置为 2.0
          ),
        ),
        child: Row(
          children: [
            CircleAvatar(
              radius: 18,
              backgroundColor: Colors.white,
              child: KrLocalImage(
                imageName: 'hi-home-logo',
                imageType: ImageType.svg,
                width: 16,
                height: 16,
              ),
            ),
            SizedBox(width: 12),
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text(
                    userId,
                    overflow: TextOverflow.ellipsis,
                    maxLines: 1,
                    style: TextStyle(
                      color: Colors.white,
                      fontSize: 14.sp,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                  KRSubscriptionExpiryText(
                    expireTimeProvider: () => controller.kr_subscribeService
                        .kr_currentSubscribe.value?.expireTime,
                  ),
                ],
              ),
            ),
            SizedBox(width: 8.w),
            const KrLocalImage(
              imageName: 'arrow-right-icon',
              imageType: ImageType.svg,
              color: Colors.white,
            ),
          ],
        ),
      ),
    );
  }
}
