hi-client/lib/app/modules/hi_menu/widgets/user_info_card.dart
speakeloudest f42a481452
Some checks failed
Build Android APK / 编译 libcore.aar (push) Has been cancelled
Build Android APK / 编译 Android APK (release) (push) Has been cancelled
Build Android APK / 创建 GitHub Release (push) Has been cancelled
Build Multi-Platform / 编译 libcore (Android) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (Windows) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (macOS) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (Linux) (push) Has been cancelled
Build Multi-Platform / 构建 Android APK (push) Has been cancelled
Build Multi-Platform / 构建 Windows (push) Has been cancelled
Build Multi-Platform / 构建 macOS (push) Has been cancelled
Build Multi-Platform / 构建 Linux (push) Has been cancelled
Build Multi-Platform / 创建 Release (push) Has been cancelled
Build Windows / build (push) Has been cancelled
feat: 更新代码仓库全部修改
2025-10-30 04:47:53 -07:00

127 lines
4.6 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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';
/// 用户信息展示卡片 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(7.w, 4, 18.w, 4),
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.circular(35.5.r),
border: Border.all(
color: Colors.white,
width: 2.0, // 👇 核心改动: 将边框宽度设置为 2.0
),
),
child: Row(
children: [
CircleAvatar(
radius: 18.r,
backgroundColor: Colors.white,
child: KrLocalImage(
imageName: 'hi-home-logo',
imageType: ImageType.svg,
width: 16.w,
height: 16.h,
),
),
SizedBox(width: 12.w),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'ID: $userId',
style: TextStyle(
color: Colors.white,
fontSize: 14.sp,
fontWeight: FontWeight.bold,
),
),
Obx(() {
final currentSubscribe =
controller.kr_subscribeService.kr_currentSubscribe.value;
String expiryText;
if (currentSubscribe == null) {
expiryText = '尚未购买套餐';
} else {
final now = DateTime.now();
DateTime? expireDateTime;
try {
expireDateTime =
DateTime.parse(currentSubscribe.expireTime);
} catch (e) {
expireDateTime = null;
}
if (expireDateTime == null) {
expiryText = '套餐信息无效';
} else if (expireDateTime.isBefore(now)) {
final formattedExpireDate =
'${expireDateTime.year}/${expireDateTime.month.toString().padLeft(2, '0')}/${expireDateTime.day.toString().padLeft(2, '0')}';
expiryText = '已于 $formattedExpireDate 到期';
} else {
final year = expireDateTime.year;
final month = expireDateTime.month.toString().padLeft(2, '0');
final day = expireDateTime.day.toString().padLeft(2, '0');
final hour = expireDateTime.hour.toString().padLeft(2, '0');
final minute = expireDateTime.minute.toString().padLeft(2, '0');
final second = expireDateTime.second.toString().padLeft(2, '0');
// 2. 拼接成最终的字符串
final formattedDateTime = '$year/$month/$day $hour:$minute:$second';
expiryText = '到期时间:$formattedDateTime';
}
}
return Text(
expiryText,
style: TextStyle(
color: Colors.white,
fontSize: 12.sp,
),
);
}),
],
),
),
SizedBox(width: 8.w),
const KrLocalImage(
imageName: 'arrow-right-icon',
imageType: ImageType.svg,
color: Colors.white,
),
],
),
),
);
}
}