feat: 更新代码仓库全部修改
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
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
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../controllers/hi_menu_controller.dart';
|
||||
|
||||
class HIMenuBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut<HIMenuController>(
|
||||
() => HIMenuController(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:easy_refresh/easy_refresh.dart';
|
||||
import 'package:kaer_with_panels/app/utils/kr_log_util.dart';
|
||||
import '../../../services/api_service/kr_api.user.dart';
|
||||
import '../../../utils/kr_common_util.dart';
|
||||
import '../../../common/app_run_data.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:kaer_with_panels/app/services/kr_subscribe_service.dart';
|
||||
|
||||
class HIMenuController extends GetxController {
|
||||
/// 订阅服务
|
||||
final KRSubscribeService kr_subscribeService = KRSubscribeService();
|
||||
// 版本号
|
||||
final RxString kr_version = ''.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
_kr_getVersion();
|
||||
}
|
||||
|
||||
// 获取版本号
|
||||
Future<void> _kr_getVersion() async {
|
||||
final PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
kr_version.value = packageInfo.version;
|
||||
}
|
||||
}
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:easy_refresh/easy_refresh.dart';
|
||||
import 'package:flutter_html/flutter_html.dart';
|
||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||
import 'package:kaer_with_panels/app/widgets/hi_base_scaffold.dart';
|
||||
import '../../../routes/app_pages.dart';
|
||||
import '../controllers/hi_menu_controller.dart';
|
||||
import 'package:kaer_with_panels/app/widgets/kr_app_text_style.dart';
|
||||
import 'package:kaer_with_panels/app/localization/app_translations.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:kaer_with_panels/app/widgets/kr_local_image.dart';
|
||||
import 'package:kaer_with_panels/app/modules/kr_home/views/hi_subscription_corner_button.dart';
|
||||
import 'package:kaer_with_panels/app/common/app_run_data.dart';
|
||||
import 'package:kaer_with_panels/app/modules/hi_menu/widgets/hi_menu_list_item.dart';
|
||||
import 'package:kaer_with_panels/app/modules/hi_menu/widgets/user_info_card.dart';
|
||||
|
||||
class HIMenuView extends GetView<HIMenuController> {
|
||||
const HIMenuView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return HIBaseScaffold(
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(height: 60.h),
|
||||
Padding(
|
||||
// 5. 为整个区块设置左右 41.w 的内边距
|
||||
padding: EdgeInsets.symmetric(horizontal: 41.w),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min, // 让 Column 包裹内容
|
||||
children: [
|
||||
Obx(() {
|
||||
final account = KRAppRunData.getInstance().kr_account.value ?? '未登录';
|
||||
return UserInfoCard(
|
||||
controller: controller,
|
||||
userId: account,
|
||||
);
|
||||
}),
|
||||
|
||||
SizedBox(height: 10.h), // 卡片和菜单列表的间距
|
||||
|
||||
// ListView.separated 现在也会继承 Padding 的约束
|
||||
ListView.separated(
|
||||
shrinkWrap: true, // 让 ListView 高度自适应内容
|
||||
physics: const NeverScrollableScrollPhysics(), // 在 Stack 中,禁用其自身的滚动
|
||||
itemCount: _menuItems.length,
|
||||
// 渲染每一项
|
||||
itemBuilder: (context, index) {
|
||||
return MenuListItem(item: _menuItems[index]);
|
||||
},
|
||||
// 设置每一项之间的间距
|
||||
separatorBuilder: (context, index) {
|
||||
return SizedBox(height: 10.h);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// 版本号信息
|
||||
Obx((){
|
||||
// 1. 从 Obx 的回调函数中 return 一个 Widget
|
||||
return Positioned(
|
||||
bottom: 40.0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Text(
|
||||
'当前版本:${controller.kr_version.value}',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
// 2. 建议使用更稳定的颜色,避免主题切换时出现问题
|
||||
color: Theme.of(context).primaryColor,
|
||||
fontSize: 10.w,
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const List<MenuItem> _menuItems = [
|
||||
MenuItem(
|
||||
iconName: 'icon-1',
|
||||
title: '节点列表',
|
||||
route: Routes.HI_NODE_LIST,
|
||||
),
|
||||
MenuItem(
|
||||
iconName: 'icon-2',
|
||||
title: '消息中心',
|
||||
route: Routes.KR_MESSAGE,
|
||||
),
|
||||
MenuItem(
|
||||
iconName: 'icon-3',
|
||||
title: '常见问题',
|
||||
route: Routes.HI_HELP,
|
||||
),
|
||||
MenuItem(
|
||||
iconName: 'icon-4',
|
||||
title: '邀请好友',
|
||||
route: Routes.KR_INVITE,
|
||||
),
|
||||
MenuItem(
|
||||
iconName: 'icon-5',
|
||||
title: '在线客服',
|
||||
route: Routes.KR_CRISP,
|
||||
),
|
||||
];
|
||||
@@ -0,0 +1,80 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:kaer_with_panels/app/widgets/kr_local_image.dart';
|
||||
|
||||
// 1. 将 MenuItem 数据模型也移到这里,并设为公开
|
||||
class MenuItem {
|
||||
final String iconName;
|
||||
final String title;
|
||||
final String? route; // 路由地址
|
||||
final VoidCallback? onTap; // 或者是一个点击回调
|
||||
|
||||
const MenuItem({
|
||||
required this.iconName,
|
||||
required this.title,
|
||||
this.route,
|
||||
this.onTap,
|
||||
}) : assert(route != null || onTap != null,
|
||||
'Either route or onTap must be provided.');
|
||||
// 使用 assert 强制要求 route 和 onTap 至少提供一个
|
||||
}
|
||||
|
||||
// 2. MenuListItem 组件现在是这个文件的核心
|
||||
class MenuListItem extends StatelessWidget {
|
||||
const MenuListItem({
|
||||
super.key,
|
||||
required this.item,
|
||||
});
|
||||
|
||||
final MenuItem item;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// 优先处理 onTap 回调
|
||||
if (item.onTap != null) {
|
||||
item.onTap!();
|
||||
}
|
||||
// 如果没有 onTap,再处理 route 跳转
|
||||
else if (item.route != null) {
|
||||
Get.toNamed(item.route!);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
height: 50,
|
||||
padding: EdgeInsets.fromLTRB(20.w, 7, 18.w, 7),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).primaryColor, // 使用主题的主色作为背景
|
||||
borderRadius: BorderRadius.circular(1000.r), // 添加圆角
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
KrLocalImage(
|
||||
imageName: item.iconName,
|
||||
imageType: ImageType.svg,
|
||||
),
|
||||
SizedBox(width: 8.w),
|
||||
Expanded(
|
||||
child: Text(
|
||||
item.title,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 16.sp,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
KrLocalImage(
|
||||
imageName: 'arrow-right-icon',
|
||||
imageType: ImageType.svg,
|
||||
color: Colors.black,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
// 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,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user