Compare commits

...

2 Commits

Author SHA1 Message Date
Developer
b081f09895 屏幕常亮 2026-03-31 21:59:07 +08:00
Developer
c897f50817 细节优化 2026-03-31 20:15:16 +08:00
14 changed files with 1076 additions and 670 deletions

View File

@@ -1,158 +1,13 @@
# Changelog # Changelog
All notable changes to this project will be documented in this file. ## 1.0.1
--- ### Added
- 添加了支持 OpenHarmony 平台的 wakelock_plus 库
- 依赖版本wakelock_plus (git: https://gitcode.com/openharmony-sig/fluttertpc_wakelock_plus.git, ref: br_v1.4.0_ohos)
## [1.3.9] - 2026-03-31 ## 1.0.0
### 新增 ### Initial Release
- 🆔 **UDID 设备信息显示** - 项目初始化
- 在应用信息页面的设备信息列表中添加 UDID 显示 - 基础功能实现
- 使用 `flutter_udid` 库获取跨平台设备唯一标识
- 支持点击复制 UDID 功能,带主题色 SnackBar 提示
- 将 AppInfoPage 从 StatelessWidget 改为 StatefulWidget
- 添加 `_loadUdid()` 方法异步加载 UDID
- 在技术栈卡片中添加 flutter_udid 说明
- 在开源协议对话框中添加 flutter_udid 条目
- 涉及文件:
- `lib/views/profile/app-info.dart` - 添加 UDID 获取和显示
### 升级
- 📦 **flutter_udid 库升级至 4.1.2**
- 升级本地 flutter_udid 包到最新版本 4.1.2
- Android 平台:更新 Gradle 到 8.5.0Kotlin 到 2.0.21,使用新的 FlutterPlugin API
- iOS 平台:替换 SAMKeychain 为 KeychainAccess支持 iOS 13.0+
- MacOS 平台:使用 KeychainAccess 和 IOKit 获取硬件 UUID
- HarmonyOS 平台:保持 3.0.0 版本,使用 OAID 获取设备标识
- 解决 Gradle 依赖冲突jcenter 废弃问题)
- 统一 JVM 目标版本为 17
- 涉及文件:
- `packages/flutter_udid/pubspec.yaml` - 更新版本和平台配置
- `packages/flutter_udid/android/build.gradle` - 更新 Gradle 和 Kotlin 版本
- `packages/flutter_udid/android/src/main/kotlin/.../FlutterUdidPlugin.kt` - 更新插件 API
- `packages/flutter_udid/ios/flutter_udid.podspec` - 更新依赖和部署目标
- `packages/flutter_udid/ios/Classes/SwiftFlutterUdidPlugin.swift` - 更新 KeychainAccess
- `packages/flutter_udid/macos/Classes/FlutterUdidPlugin.swift` - 更新实现
### 新增
- 👥 **QQ 交流群卡片**
- 在了解我们页面的"官方网站"卡片下方添加 QQ 群卡片
- 群号显示271129018
- 点击群号可复制到剪贴板
- 蓝色主题色Icons.group
- 提示"💡 点击群号可复制"
- 涉及文件:
- `lib/views/profile/settings/learn-us.dart` - 添加 QQ 群卡片
---
## [1.3.8] - 2026-03-31
### 新增
- 🎛️ **隐藏次要按钮功能**
- 在功能设置页面添加"隐藏次要按钮"开关
- 开启后隐藏主页的"上一条"和"分享"悬浮按钮
- 默认关闭,状态保存到 SharedPreferences
- 使用 `SecondaryButtonsManager` 单例管理状态
- 实时响应开关状态变化,无需重启应用
- 涉及文件:
- `lib/views/profile/settings/app_fun.dart` - 添加开关和状态管理
- `lib/views/home/home-load.dart` - 添加 SecondaryButtonsManager 管理类
- `lib/views/home/home_page.dart` - 使用 ValueListenableBuilder 监听状态变化
---
## [1.3.7] - 2026-03-31
### 新增
- 📸 **诗词卡片截图分享功能**
- 在主页点赞按钮上方添加悬浮分享按钮,使用 📤 icon
- 点击按钮可将当前诗词卡片生成高清图片并分享
- 使用 `RepaintBoundary``GlobalKey` 实现 Widget 截图
- 集成 `share_plus` 库实现跨平台图片分享
- 包含生成中、成功、失败的用户提示
- 涉及文件:
- `lib/views/home/home_components.dart` - 添加 ShareImageUtils 工具类和 FloatingShareButton 组件
- `lib/views/home/home_page.dart` - 添加截图 Key 和分享按钮布局
- `lib/views/home/home_part.dart` - 添加 RepaintBoundary 支持截图
---
## [1.3.6] - 2026-03-31
### 优化
- 🏷️ **文件重命名与统一**
-`sqlite_storage_controller.dart` 重命名为 `shared_preferences_storage_controller.dart`
- 将类名 `SQLiteStorageController` 重命名为 `SharedPreferencesStorageController`
- 更新所有引用该文件的导入语句和类名调用
- 涉及文件:
- `lib/main.dart`
- `lib/controllers/history_controller.dart`
- `lib/views/profile/profile_page.dart`
- `lib/views/profile/level/poetry.dart`
- `lib/views/profile/level/distinguish.dart`
- 保持功能不变,仅统一命名规范
---
## [1.3.5] - 2026-03-30
### 新增
- 📜 **投稿记录功能**
- 新增投稿记录页面 `lib/views/profile/expand/tougao.dart`
- 显示历史投稿记录列表,按时间倒序排列
- 支持展开查看详细信息(分类、诗人和标题、关键词、平台、介绍)
- 提供清空所有记录功能(带确认提示)
- 修改 `lib/views/profile/expand/manu-script.dart`
- 在AppBar添加历史记录图标按钮点击跳转至记录页面
- 投稿成功后自动保存记录到SharedPreferences
- 最多保存50条记录超出时自动删除最早的记录
---
## 软件特性功能
### 已开发完成
- 🎛️ **隐藏次要按钮功能** - 在功能设置页面添加开关、开启后隐藏主页的"上一条"和"分享"悬浮按钮、默认关闭、状态保存到SharedPreferences、使用SecondaryButtonsManager单例管理、实时响应开关状态变化无需重启
- 优先级3
- 📸 **诗词卡片截图分享功能** - 主页点赞按钮上方添加悬浮分享按钮、点击生成诗词卡片高清图片并分享、使用RepaintBoundary和GlobalKey实现Widget截图、集成share_plus库实现跨平台分享、包含生成中/成功/失败提示
- 优先级4
- 📜 **诗词投稿功能** - 新增投稿页面、支持诗词收录申请表单、包含参考语句/分类选择/诗人和标题/关键词/诗词介绍/人机验证、实现相似度检测防止重复提交、平台字段自动获取设备类型
- 优先级3
-**离线数据下载优化** - 添加取消下载功能、下载过程中显示取消按钮、优化下载状态显示避免页面卡死、取消下载时显示相应提示
- 优先级4
- 🌐 **网络状态自动检测** - 个人卡片加载时自动检测网络状态、无网络时自动调整为离线状态、避免网络异常导致的错误
- 优先级3
- 📊 **服务器信息显示** - 在离线数据页面添加服务器信息卡片、显示API地址/版本/频率限制等信息
- 优先级2
- 📱 **离线数据下载功能增强** - 新增下载类型选择诗句和答题、诗句数量选项20/30/60/100条、答题数量选项20/50/80/100条、100条下载需加入用户体验计划、实现下载一条写入一条、取消下载时保存已下载数据、实时更新缓存状态、返回上一页继续后台下载、清空缓存时弹窗选择清空内容、缓存状态同时显示诗句和答题数量
- 优先级5
- <20><> **已知bug列表功能** - 从下到上弹出页面显示已知bug、解决方法和解决时间、支持下拉刷新和滚动查看、显示bug优先级和状态、提供详细解决方案描述、显示影响用户范围和时间信息
- 📜 **投稿记录功能** - 投稿记录页面显示历史投稿列表、按时间倒序排列、支持展开查看详细信息、提供清空记录功能、投稿成功后自动保存到SharedPreferences、最多保存50条记录
- 🗳️ **投票功能完整实现** - 用户登录/注册、获取投票列表、投票详情、提交投票、投票结果展示、API服务基础URL修改、登录注册逻辑简化只需用户名、默认密码123456、自动注册登录、设备标识、投票页面调试功能、user_identifier增加Flutter后缀、setState调用安全修复添加mounted检查、投票登录状态持久化修复添加Cookie管理器支持PHP Session认证
- 🎨 **个人卡片标签栏布局优化** - 将标签栏区域一分为二,左侧区域可以点击展开/收起个人卡片
- 🎲 **题目随机化功能** - 进入答题页面时调用 fetch 接口获取新题,使用 Fisher-Yates 算法打乱题目 ID 顺序
- 💬 **答对答错反馈信息修复** - 当 API 返回的提示信息为空时,自行添加提示内容
- 📚 **App 自行管理题目 ID** - 实现题目 ID 管理逻辑,不再随机生成
- 🔧 **API 接口路径和参数最终修复** - 确认 API 路径,调整随机题目 ID 范围
- 🔧 **API 接口路径和参数修复** - 修复 API 路径和参数,使用正确的新 API 接口
- 🐛 **HttpResponse 处理修复** - 修复 HttpResponse 对象处理方式,使用正确的属性访问
- 🔧 **API 请求参数更新** - 根据新的 API 文档更新所有请求参数
- 📊 **个人页面统计数字动态化** - 从SharedPreferences读取真实的答题统计数据
- 📝 **记录页显示问题修复** - 修复答题记录页面显示未知题目和标签的问题
- 📋 **答题统计弹窗功能** - 显示详细的答题统计数据支持复制发送给AI评估
- 📝 **诗词答题功能** - 完整的答题页面,支持题目加载、答案提交、提示获取
- 🕐 **中国十二时辰制时间显示** - 时间显示改为十二时辰(子丑寅卯辰巳午未申酉戌亥)
- 🌤️ **天气功能集成** - 集成天气API获取城市、天气状态和温度
- 📚 **朝代信息显示** - 在诗人名称左侧添加朝代信息显示
- 🎨 **卡片样式优化** - 经典和现代样式颜色统一,毛玻璃样式优化
- 🐛 **卡片设置页面重复打开问题修复** - 使用 router.replaceUrl 替换当前页面,避免堆叠
- 📐 **2x2卡片布局优化** - 移除天气按钮组件,保留城市名称显示
- 🌐 **离线模式支持** - 新增 `OfflineDataManager` 类管理离线数据加载、离线状态时从本地缓存加载诗句、在线状态时从网络加载、支持循环加载本地缓存的诗句、离线模式下隐藏点赞按钮、无缓存时显示网络错误提示、优化数据加载逻辑
- 🔄 **个人卡片在线/离线状态切换** - 在个人卡片tips卡片内添加在线状态开关、开关状态保存到SharedPreferences、关闭后切换为离线状态、支持点击tips卡片切换祝福语功能、优化开关布局、状态切换时显示气泡消息提示
### 开发进度
- 🏗️ **HarmonyOS桌面小组件** - 开发中包含2x2布局、天气显示、诗句展示等功能
- 优先级3
getx 进入

View File

@@ -9,6 +9,11 @@
# packages, and plugins designed to encourage good coding practices. # packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml include: package:flutter_lints/flutter.yaml
# 排除 packages 文件夹的分析
analyzer:
exclude:
- packages/**
linter: linter:
# The lint rules applied to this project can be customized in the # The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml` # section below to disable rules from the `package:flutter_lints/flutter.yaml`

View File

@@ -117,88 +117,90 @@ class _ActiveSearchPageState extends State<ActiveSearchPage>
children: [ children: [
// 自定义标题栏 // 自定义标题栏
if (isInTabBarView) if (isInTabBarView)
Container( SafeArea(
height: 56, child: Container(
padding: const EdgeInsets.symmetric(horizontal: 16), height: 56,
color: Colors.white, padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row( color: Colors.white,
children: [ child: Row(
// 返回按钮 children: [
//todo // 返回按钮
IconButton( //todo
icon: const Icon(Icons.arrow_back, color: Colors.black87), IconButton(
onPressed: () { icon: const Icon(Icons.arrow_back, color: Colors.black87),
// 检查是否可以返回,避免黑屏 onPressed: () {
if (Navigator.of(context).canPop()) { // 检查是否可以返回,避免黑屏
Navigator.of(context).pop(); if (Navigator.of(context).canPop()) {
} else { Navigator.of(context).pop();
// 如果无法返回(如在 TabBarView 中),跳转到主页 } else {
Navigator.of(context).pushReplacement( // 如果无法返回(如在 TabBarView 中),跳转到主页
MaterialPageRoute( Navigator.of(context).pushReplacement(
builder: (_) => const MainNavigation(), MaterialPageRoute(
), builder: (_) => const MainNavigation(),
); ),
} );
}, }
tooltip: '返回上一页', },
), tooltip: '返回上一页',
// 标题 ),
Expanded( // 标题
child: Row( Expanded(
children: [ child: Row(
const Icon( children: [
Icons.travel_explore, const Icon(
size: 20, Icons.travel_explore,
color: Colors.black87, size: 20,
),
const SizedBox(width: 8),
const Text(
'诗词搜索',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: Colors.black87, color: Colors.black87,
), ),
), const SizedBox(width: 8),
], const Text(
), '诗词搜索',
), style: TextStyle(
// 更多按钮 fontSize: 18,
IconButton( fontWeight: FontWeight.w600,
icon: const Icon(Icons.more_vert, color: Colors.black87), color: Colors.black87,
onPressed: () { ),
// 更多按钮的点击事件
showModalBottomSheet(
context: context,
builder: (context) => Container(
padding: const EdgeInsets.all(16),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
leading: const Icon(Icons.history),
title: const Text('搜索历史'),
onTap: () {
Navigator.pop(context);
// 实现搜索历史功能
},
),
ListTile(
leading: const Icon(Icons.settings),
title: const Text('搜索设置'),
onTap: () {
Navigator.pop(context);
// 实现搜索设置功能
},
),
],
), ),
), ],
); ),
}, ),
tooltip: '更多', // 更多按钮
), IconButton(
], icon: const Icon(Icons.more_vert, color: Colors.black87),
onPressed: () {
// 更多按钮的点击事件
showModalBottomSheet(
context: context,
builder: (context) => Container(
padding: const EdgeInsets.all(16),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
leading: const Icon(Icons.history),
title: const Text('搜索历史(开发中)'),
onTap: () {
Navigator.pop(context);
// 实现搜索历史功能
},
),
ListTile(
leading: const Icon(Icons.settings),
title: const Text('搜索设置(开发中)'),
onTap: () {
Navigator.pop(context);
// 实现搜索设置功能
},
),
],
),
),
);
},
tooltip: '更多',
),
],
),
), ),
), ),
// 搜索内容区域 // 搜索内容区域
@@ -209,9 +211,9 @@ class _ActiveSearchPageState extends State<ActiveSearchPage>
Padding( Padding(
padding: EdgeInsets.fromLTRB( padding: EdgeInsets.fromLTRB(
AppConstants.pageHorizontalPadding, AppConstants.pageHorizontalPadding,
isInTabBarView ? 16 : 8, isInTabBarView ? 8 : 4,
AppConstants.pageHorizontalPadding, AppConstants.pageHorizontalPadding,
8, 4,
), ),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -256,10 +258,9 @@ class _ActiveSearchPageState extends State<ActiveSearchPage>
onChanged: (_) => setState(() {}), onChanged: (_) => setState(() {}),
), ),
), ),
const SizedBox(height: 8),
Wrap( Wrap(
spacing: 8, spacing: 4,
runSpacing: 8, runSpacing: 4,
crossAxisAlignment: WrapCrossAlignment.center, crossAxisAlignment: WrapCrossAlignment.center,
children: [ children: [
const Text('', style: TextStyle(fontSize: 13)), const Text('', style: TextStyle(fontSize: 13)),

View File

@@ -141,8 +141,38 @@ class _PoetryCardState extends State<PoetryCard> {
_buildTitleSection(), _buildTitleSection(),
if (widget.poetryData.drtime.isNotEmpty) ...[ if (widget.poetryData.drtime.isNotEmpty) ...[
_buildContentSection(context), _buildContentSection(context),
const SizedBox(height: 16), const SizedBox(height: 3),
], ],
// 精选诗句标签 - 放在缝隙位置
Align(
alignment: Alignment.centerRight,
child: Container(
margin: EdgeInsets.zero,
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 2,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'精选诗句',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
color: AppConstants.primaryColor,
),
),
const SizedBox(width: 4),
Icon(
Icons.format_quote,
color: AppConstants.primaryColor,
size: 14,
),
],
),
),
),
_buildNameSection(), _buildNameSection(),
const SizedBox(height: 12), const SizedBox(height: 12),
if (widget.keywordList.isNotEmpty) ...[ if (widget.keywordList.isNotEmpty) ...[
@@ -333,7 +363,7 @@ class _PoetryCardState extends State<PoetryCard> {
return Container( return Container(
width: double.infinity, width: double.infinity,
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
margin: const EdgeInsets.only(bottom: 8), margin: EdgeInsets.zero,
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
colors: [ colors: [
@@ -359,27 +389,6 @@ class _PoetryCardState extends State<PoetryCard> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row(
children: [
Icon(
Icons.format_quote,
color: AppConstants.primaryColor,
size: 20,
),
const SizedBox(width: 8),
Expanded(
child: Text(
'精选诗句',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
color: AppConstants.primaryColor,
),
),
),
],
),
const SizedBox(height: 8),
GestureDetector( GestureDetector(
onLongPress: () => onLongPress: () =>
CopyUtils.showCopyDialog(context, widget.poetryData.name, '诗词'), CopyUtils.showCopyDialog(context, widget.poetryData.name, '诗词'),
@@ -409,7 +418,7 @@ class _PoetryCardState extends State<PoetryCard> {
), ),
) )
: Text( : Text(
widget.poetryData.name, _formatPoetryText(widget.poetryData.name),
style: const TextStyle( style: const TextStyle(
fontSize: 22, fontSize: 22,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@@ -424,6 +433,22 @@ class _PoetryCardState extends State<PoetryCard> {
); );
} }
String _formatPoetryText(String text) {
// 检查文本长度(文字+符号)
if (text.length < 10) {
return text; // 小于10个字不换行
}
// 找到第一个逗号的位置
final commaIndex = text.indexOf('');
if (commaIndex != -1) {
// 在第一个逗号处添加换行
return text.replaceFirst('', '\n');
}
return text; // 没有逗号,保持原样
}
Widget _buildKeywordSection() { Widget _buildKeywordSection() {
final isLoading = widget.sectionLoadingStates?['keywords'] ?? false; final isLoading = widget.sectionLoadingStates?['keywords'] ?? false;
@@ -441,7 +466,7 @@ class _PoetryCardState extends State<PoetryCard> {
children: [ children: [
SizedBox( SizedBox(
width: 16, width: 16,
height: 16, height: 8,
child: CircularProgressIndicator( child: CircularProgressIndicator(
strokeWidth: 2, strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>( valueColor: AlwaysStoppedAnimation<Color>(
@@ -449,7 +474,7 @@ class _PoetryCardState extends State<PoetryCard> {
), ),
), ),
), ),
const SizedBox(width: 8), const SizedBox(width: 4),
Text( Text(
'关键词加载中...', '关键词加载中...',
style: TextStyle( style: TextStyle(

View File

@@ -140,7 +140,7 @@ class _AppInfoPageState extends State<AppInfoPage> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const Text( const Text(
'Poes', '情景诗词',
style: TextStyle( style: TextStyle(
fontSize: 26, fontSize: 26,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@@ -149,7 +149,7 @@ class _AppInfoPageState extends State<AppInfoPage> {
), ),
const SizedBox(height: 6), const SizedBox(height: 6),
Text( Text(
'情景诗词 · 应用信息', 'Poes · 应用信息',
style: TextStyle( style: TextStyle(
fontSize: 13, fontSize: 13,
color: Colors.white.withValues(alpha: 0.85), color: Colors.white.withValues(alpha: 0.85),
@@ -178,9 +178,27 @@ class _AppInfoPageState extends State<AppInfoPage> {
), ),
const SizedBox(width: 6), const SizedBox(width: 6),
const Text( const Text(
'版本 1.2', '框架 1.3',
style: TextStyle(fontSize: 12, color: Colors.white), style: TextStyle(fontSize: 12, color: Colors.white),
), ),
const SizedBox(width: 8),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 2,
),
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.2),
borderRadius: BorderRadius.circular(4),
),
child: const Text(
'软件版本 1.5',
style: TextStyle(
fontSize: 10,
color: Colors.white,
),
),
),
], ],
), ),
), ),
@@ -231,10 +249,34 @@ class _AppInfoPageState extends State<AppInfoPage> {
), ),
), ),
const Divider(height: 1), const Divider(height: 1),
_buildInfoItem('Flutter', '跨平台UI框架', Icons.flutter_dash), // 2x2 网格布局展示技术栈
_buildInfoItem('Dart', '编程语言', Icons.code), Padding(
_buildInfoItem('shared_preferences', '本地存储', Icons.storage), padding: const EdgeInsets.all(16),
_buildInfoItem('flutter_udid', '设备唯一标识', Icons.perm_identity), child: GridView.count(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
crossAxisCount: 2,
mainAxisSpacing: 12,
crossAxisSpacing: 12,
childAspectRatio: 2.2,
children: [
_buildTechStackItem(
'Flutter',
'跨平台UI框架',
Icons.flutter_dash,
Colors.blue,
),
_buildTechStackItem('Dart', '编程语言', Icons.code, Colors.teal),
_buildTechStackItem('SP', '本地存储', Icons.storage, Colors.orange),
_buildTechStackItem(
'dio',
'网络处理',
Icons.network_check,
Colors.purple,
),
],
),
),
], ],
), ),
); );
@@ -335,12 +377,12 @@ class _AppInfoPageState extends State<AppInfoPage> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const Text( const Text(
'开源协议', '开源框架',
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500), style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
), ),
const SizedBox(height: 2), const SizedBox(height: 2),
Text( Text(
'BSD 3-Clause License', 'Flutter SDK',
style: TextStyle(fontSize: 12, color: Colors.grey[500]), style: TextStyle(fontSize: 12, color: Colors.grey[500]),
), ),
], ],
@@ -823,6 +865,59 @@ class _AppInfoPageState extends State<AppInfoPage> {
); );
} }
// 2x2 网格技术栈项
Widget _buildTechStackItem(
String title,
String value,
IconData icon,
Color color,
) {
return Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: color.withAlpha(20),
borderRadius: BorderRadius.circular(12),
border: Border.all(color: color.withAlpha(50), width: 1),
),
child: Row(
children: [
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: color.withAlpha(30),
borderRadius: BorderRadius.circular(8),
),
child: Icon(icon, size: 20, color: color),
),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
title,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: color,
),
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 2),
Text(
value,
style: TextStyle(fontSize: 11, color: Colors.grey[600]),
overflow: TextOverflow.ellipsis,
),
],
),
),
],
),
);
}
Widget _buildInfoItem(String title, String value, IconData icon) { Widget _buildInfoItem(String title, String value, IconData icon) {
return Padding( return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),

View File

@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:share_plus/share_plus.dart'; import 'package:share_plus/share_plus.dart';
import '../../../constants/app_constants.dart'; import '../../../constants/app_constants.dart';
import 'package:wakelock_plus/wakelock_plus.dart';
class PopMenu extends StatelessWidget { class PopMenu extends StatelessWidget {
final VoidCallback? onRefresh; final VoidCallback? onRefresh;
@@ -41,6 +42,46 @@ class PopMenu extends StatelessWidget {
} }
} }
static Future<void> toggleScreenWake(BuildContext context) async {
try {
// 检查当前状态
final bool isEnabled = await WakelockPlus.enabled;
// 切换状态
if (isEnabled) {
await WakelockPlus.disable();
if (context.mounted) {
ScaffoldMessenger.of(
context,
).showSnackBar(const SnackBar(content: Text('屏幕常亮已关闭')));
}
} else {
await WakelockPlus.enable();
if (context.mounted) {
ScaffoldMessenger.of(
context,
).showSnackBar(const SnackBar(content: Text('屏幕常亮已开启')));
}
}
} catch (e) {
if (context.mounted) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text('提示'),
content: const Text('该设备不支持屏幕常亮功能'),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('确定'),
),
],
),
);
}
}
}
static void show( static void show(
BuildContext context, { BuildContext context, {
VoidCallback? onRefresh, VoidCallback? onRefresh,
@@ -89,9 +130,9 @@ class PopMenu extends StatelessWidget {
}), }),
_buildBottomSheetItem( _buildBottomSheetItem(
context, context,
'扫描二维码', '屏幕常亮',
Icons.qr_code_scanner, Icons.screen_lock_rotation,
onScanQr, () => toggleScreenWake(context),
), ),
_buildBottomSheetItem(context, '夜间模式', Icons.dark_mode, onDarkMode), _buildBottomSheetItem(context, '夜间模式', Icons.dark_mode, onDarkMode),
const SizedBox(height: 20), const SizedBox(height: 20),

View File

@@ -7,10 +7,10 @@ import '../../constants/app_constants.dart';
import '../../services/network_listener_service.dart'; import '../../services/network_listener_service.dart';
import 'guide/tongji.dart'; import 'guide/tongji.dart';
/// 时间: 2026-03-25 /// 时间: 2026-03-31
/// 功能: 个人信息卡片组件 /// 功能: 个人信息卡片组件
/// 介绍: 可收起/张开的个人信息卡片,支持下拉张开,上滑收起 /// 介绍: 可收起/张开的个人信息卡片,支持下拉张开,上滑收起
/// 最新变化: 优化动画效果,添加毛玻璃背景,修复布局问题 /// 最新变化: 重新设计为苹果风格,优化动画效果,改进布局结构,提升用户体验
class PersonalCard extends StatefulWidget { class PersonalCard extends StatefulWidget {
final Map<String, dynamic> userData; final Map<String, dynamic> userData;
@@ -18,14 +18,16 @@ class PersonalCard extends StatefulWidget {
final ValueChanged<bool>? onExpandChanged; final ValueChanged<bool>? onExpandChanged;
final int currentPage; final int currentPage;
final ValueChanged<int>? onPageChanged; final ValueChanged<int>? onPageChanged;
final VoidCallback? onAvatarTap;
const PersonalCard({ const PersonalCard({
super.key, super.key,
required this.userData, required this.userData,
this.isExpanded, this.isExpanded,
this.onExpandChanged, this.onExpandChanged,
this.currentPage = 1, this.currentPage = 0,
this.onPageChanged, this.onPageChanged,
this.onAvatarTap,
}); });
@override @override
@@ -36,6 +38,8 @@ class PersonalCardState extends State<PersonalCard> {
late bool _isExpanded; late bool _isExpanded;
late String _currentTip; late String _currentTip;
bool _isOnline = true; bool _isOnline = true;
bool _isEditingNickname = false;
late TextEditingController _nicknameController;
// 累计数据 // 累计数据
int _totalViews = 0; int _totalViews = 0;
@@ -47,10 +51,19 @@ class PersonalCardState extends State<PersonalCard> {
super.initState(); super.initState();
_isExpanded = widget.isExpanded ?? false; _isExpanded = widget.isExpanded ?? false;
_currentTip = _getRandomTip(); _currentTip = _getRandomTip();
_nicknameController = TextEditingController(
text: widget.userData['nickname'] ?? '诗词爱好者',
);
_loadOnlineStatus(); _loadOnlineStatus();
_loadTotalStats(); _loadTotalStats();
} }
@override
void dispose() {
_nicknameController.dispose();
super.dispose();
}
Future<void> _loadTotalStats() async { Future<void> _loadTotalStats() async {
final views = await StatisticsManager().getTotalViews(); final views = await StatisticsManager().getTotalViews();
final likes = await StatisticsManager().getTotalLikes(); final likes = await StatisticsManager().getTotalLikes();
@@ -213,37 +226,54 @@ class PersonalCardState extends State<PersonalCard> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GestureDetector( return Container(
behavior: HitTestBehavior.translucent, margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Container( decoration: BoxDecoration(
decoration: BoxDecoration( borderRadius: BorderRadius.circular(20),
gradient: LinearGradient( boxShadow: [
colors: [ BoxShadow(
AppConstants.primaryColor.withValues(alpha: 0.95), color: Colors.black.withOpacity(0.1),
AppConstants.primaryColor.withValues(alpha: 0.9), blurRadius: 10,
AppConstants.primaryColor.withValues(alpha: 0.85), offset: const Offset(0, 2),
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
), ),
), ],
child: AnimatedContainer( ),
duration: const Duration(milliseconds: 400), child: ClipRRect(
curve: Curves.easeInOut, borderRadius: BorderRadius.circular(20),
padding: _isExpanded child: Container(
? const EdgeInsets.all(16) decoration: BoxDecoration(
: const EdgeInsets.symmetric(horizontal: 20, vertical: 12), gradient: LinearGradient(
height: _isExpanded ? null : 72, colors: [
child: Stack( AppConstants.primaryColor.withOpacity(0.95),
children: [ AppConstants.primaryColor.withOpacity(0.85),
// 毛玻璃效果层(在文字按钮下层,背景色上层) ],
BackdropFilter( begin: Alignment.topLeft,
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5), end: Alignment.bottomRight,
child: Container(color: Colors.transparent), ),
),
child: GestureDetector(
onTap: _toggleExpand,
behavior: HitTestBehavior.opaque,
child: AnimatedContainer(
duration: AppConstants.animationDurationMedium,
curve: Curves.easeOut,
padding: _isExpanded
? const EdgeInsets.all(20)
: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: Stack(
children: [
// 毛玻璃效果层
BackdropFilter(
filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10),
child: Container(color: Colors.transparent),
),
// 内容层
_isExpanded
? _buildExpandedContent()
: _buildCollapsedContent(),
],
), ),
// 内容层(在毛玻璃效果上层) ),
_isExpanded ? _buildExpandedContent() : _buildCollapsedContent(),
],
), ),
), ),
), ),
@@ -253,105 +283,168 @@ class PersonalCardState extends State<PersonalCard> {
Widget _buildCollapsedContent() { Widget _buildCollapsedContent() {
return Row( return Row(
children: [ children: [
// 左侧区域:可点击展开/收起 // 头像
Expanded(
child: GestureDetector(
onTap: _toggleExpand,
child: Row(
children: [
// 头像在左边
AnimatedContainer(
duration: const Duration(milliseconds: 400),
curve: Curves.easeInOut,
child: Stack(
children: [
CircleAvatar(
radius: 24,
backgroundColor: Colors.white,
child: Text(
widget.userData['avatar'] ?? '👤',
style: const TextStyle(fontSize: 18),
),
),
Positioned(
bottom: 0,
right: 0,
child: Container(
width: 16,
height: 16,
decoration: BoxDecoration(
color: _isOnline
? AppConstants.successColor
: Colors.red,
border: Border.all(color: Colors.white, width: 2),
borderRadius: BorderRadius.circular(8),
),
child: Icon(
_isOnline ? Icons.check : Icons.close,
color: Colors.white,
size: 10,
),
),
),
],
),
),
const SizedBox(width: 12),
// 名称和签名
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Text(
widget.userData['nickname'] ?? '诗词爱好者',
style: const TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.bold,
),
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 4),
Text(
widget.userData['signature'] ?? '人生如诗,岁月如歌',
style: const TextStyle(
color: Colors.white70,
fontSize: 12,
),
overflow: TextOverflow.ellipsis,
),
],
),
),
],
),
),
),
const SizedBox(width: 12),
// 右侧区域:标签栏,不可触发展开/收起
GestureDetector( GestureDetector(
behavior: HitTestBehavior.opaque, onTap: widget.onAvatarTap,
onTap: () {}, child: Stack(
child: Row(
children: [ children: [
_buildTabLabel(0, '卡片'), Container(
_buildTabLabel(1, '设置'), width: 48,
_buildTabLabel(2, '更多'), height: 48,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 4,
offset: const Offset(0, 2),
),
],
),
child: Center(
child: Text(
widget.userData['avatar'] ?? '👤',
style: const TextStyle(fontSize: 32),
),
),
),
// 在线状态指示器
Positioned(
bottom: 0,
right: 0,
child: Container(
width: 16,
height: 16,
decoration: BoxDecoration(
color: _isOnline ? AppConstants.successColor : Colors.red,
border: Border.all(color: Colors.white, width: 2),
borderRadius: BorderRadius.circular(8),
),
),
),
], ],
), ),
), ),
const SizedBox(width: 16),
// 名称和签名
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
widget.userData['nickname'] ?? '诗词爱好者',
style: const TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.bold,
),
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 4),
Text(
widget.userData['signature'] ?? '人生如诗,岁月如歌',
style: const TextStyle(color: Colors.white70, fontSize: 14),
overflow: TextOverflow.ellipsis,
),
],
),
),
// 页面切换提示
Row(
children: [
// 选项提示
Container(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Row(
children: [
_buildCollapsedTabLabel(0, '卡片'),
const SizedBox(width: 12),
_buildCollapsedTabLabel(1, '设置'),
const SizedBox(width: 12),
_buildCollapsedTabLabel(2, '更多'),
],
),
),
// 滑动指示箭头
Container(
padding: const EdgeInsets.all(8),
child: Row(
children: [
AnimatedRotation(
turns: _isExpanded ? 0.5 : 0,
duration: AppConstants.animationDurationMedium,
child: const Icon(
Icons.keyboard_arrow_down,
color: Colors.white,
size: 20,
),
),
const SizedBox(width: 4),
const Icon(Icons.swap_horiz, color: Colors.white70, size: 16),
],
),
),
],
),
], ],
); );
} }
Widget _buildExpandedContent() { Widget _buildExpandedContent() {
return Column( return Column(
mainAxisSize: MainAxisSize.min,
children: [ children: [
// 头部信息
Row( Row(
children: [ children: [
// 头像
GestureDetector(
onTap: widget.onAvatarTap,
child: Stack(
children: [
Container(
width: 64,
height: 64,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 6,
offset: const Offset(0, 3),
),
],
),
child: Center(
child: Text(
widget.userData['avatar'] ?? '👤',
style: const TextStyle(fontSize: 40),
),
),
),
// 在线状态指示器
Positioned(
bottom: 2,
right: 2,
child: Container(
width: 20,
height: 20,
decoration: BoxDecoration(
color: _isOnline
? AppConstants.successColor
: Colors.red,
border: Border.all(color: Colors.white, width: 2),
borderRadius: BorderRadius.circular(10),
),
),
),
],
),
),
const SizedBox(width: 16),
// 个人信息
Expanded( Expanded(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@@ -359,29 +452,84 @@ class PersonalCardState extends State<PersonalCard> {
// 昵称和等级 // 昵称和等级
Row( Row(
children: [ children: [
Text( Expanded(
widget.userData['nickname'] ?? '诗词爱好者', child: _isEditingNickname
style: const TextStyle( ? TextField(
color: Colors.white, controller: _nicknameController,
fontSize: 16, style: const TextStyle(
fontWeight: FontWeight.bold, color: AppConstants.primaryColor,
fontSize: 18,
fontWeight: FontWeight.bold,
),
decoration: const InputDecoration(
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
hintText: '输入昵称',
hintStyle: TextStyle(
color: AppConstants.primaryColor,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
onSubmitted: (value) {
setState(() {
widget.userData['nickname'] = value;
_isEditingNickname = false;
});
},
)
: GestureDetector(
onTap: () {
setState(() {
_isEditingNickname = true;
_nicknameController.text =
widget.userData['nickname'] ?? '诗词爱好者';
});
},
child: Text(
widget.userData['nickname'] ?? '诗词爱好者',
style: const TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.bold,
decoration: TextDecoration.underline,
),
),
),
),
const SizedBox(width: 8),
GestureDetector(
onTap: () {
setState(() {
_isEditingNickname = !_isEditingNickname;
if (_isEditingNickname) {
_nicknameController.text =
widget.userData['nickname'] ?? '诗词爱好者';
}
});
},
child: Icon(
_isEditingNickname ? Icons.check : Icons.edit,
color: Colors.white70,
size: 18,
), ),
), ),
const SizedBox(width: 6), const SizedBox(width: 8),
Container( Container(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 6, horizontal: 8,
vertical: 2, vertical: 2,
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.2), color: Colors.white.withOpacity(0.2),
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(12),
), ),
child: Text( child: Text(
widget.userData['level'] ?? 'Lv.1', widget.userData['level'] ?? 'Lv.1',
style: const TextStyle( style: const TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 10, fontSize: 12,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
), ),
), ),
@@ -394,200 +542,139 @@ class PersonalCardState extends State<PersonalCard> {
widget.userData['signature'] ?? '人生如诗,岁月如歌', widget.userData['signature'] ?? '人生如诗,岁月如歌',
style: const TextStyle( style: const TextStyle(
color: Colors.white70, color: Colors.white70,
fontSize: 12, fontSize: 14,
height: 1.2, height: 1.3,
), ),
maxLines: 2, maxLines: 2,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
const SizedBox(height: 10),
// 累计统计卡片
Container(
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 10,
),
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.15),
borderRadius: BorderRadius.circular(12),
),
child: Column(
children: [
Text(
'累计',
style: const TextStyle(
color: Colors.white70,
fontSize: 11,
),
),
const SizedBox(height: 8),
Row(
mainAxisSize: MainAxisSize.min,
children: [
_buildStatItem('浏览', _totalViews),
const SizedBox(width: 16),
_buildStatItem('点赞', _totalLikes),
const SizedBox(width: 16),
_buildStatItem('答题', _totalQuestions),
],
),
],
),
),
], ],
), ),
), ),
const SizedBox(width: 10), ],
// 头像在右边 ),
AnimatedContainer( const SizedBox(height: 10),
duration: const Duration(milliseconds: 400), // 统计数据卡片
curve: Curves.easeInOut, Container(
child: Stack( width: double.infinity,
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.1),
borderRadius: BorderRadius.circular(16),
),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [ children: [
CircleAvatar( _buildStatItem('浏览', _totalViews),
radius: 36, Container(
backgroundColor: Colors.white, width: 1,
child: Text( height: 40,
widget.userData['avatar'] ?? '👤', color: Colors.white.withOpacity(0.2),
style: const TextStyle(fontSize: 20),
),
), ),
Positioned( _buildStatItem('点赞', _totalLikes),
bottom: 0, Container(
right: 0, width: 1,
child: Container( height: 40,
width: 18, color: Colors.white.withOpacity(0.2),
height: 18,
decoration: BoxDecoration(
color: _isOnline
? AppConstants.successColor
: Colors.red,
border: Border.all(color: Colors.white, width: 2),
borderRadius: BorderRadius.circular(9),
),
child: Icon(
_isOnline ? Icons.check : Icons.close,
color: Colors.white,
size: 10,
),
),
), ),
_buildStatItem('答题', _totalQuestions),
], ],
), ),
],
),
),
const SizedBox(height: 8),
// 祝福语卡片
GestureDetector(
onTap: () {
HapticFeedback.lightImpact();
_showRandomTip();
},
child: Container(
width: double.infinity,
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 4,
offset: const Offset(0, 2),
),
],
), ),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
'💡 $_currentTip',
style: const TextStyle(
color: AppConstants.primaryColor,
fontSize: 14,
fontWeight: FontWeight.w600,
height: 1.3,
),
maxLines: 2,
),
),
const SizedBox(width: 12),
// 在线状态开关
Switch(
value: _isOnline,
onChanged: (value) {
_toggleOnlineStatus();
},
activeColor: AppConstants.primaryColor,
inactiveTrackColor: Colors.grey.shade300,
inactiveThumbColor: Colors.grey,
),
],
),
),
),
const SizedBox(height: 16),
// 页面标签
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_buildTabLabel(0, '卡片', Icons.credit_card),
const SizedBox(width: 32),
_buildTabLabel(1, '设置', Icons.settings),
const SizedBox(width: 32),
_buildTabLabel(2, '更多', Icons.more_horiz),
], ],
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
// 操作按钮 - 文本祝福语 // 页面指示器
Row( Container(
children: [ height: 3,
Expanded( margin: const EdgeInsets.symmetric(horizontal: 40),
child: GestureDetector( decoration: BoxDecoration(
onTap: () { color: Colors.white.withOpacity(0.2),
HapticFeedback.lightImpact(); borderRadius: BorderRadius.circular(1.5),
_showRandomTip(); ),
}, child: Stack(
child: Container( children: [
padding: const EdgeInsets.symmetric( AnimatedContainer(
horizontal: 16, duration: AppConstants.animationDurationMedium,
vertical: 12, curve: Curves.easeOut,
), width: (MediaQuery.of(context).size.width - 160) / 3,
decoration: BoxDecoration( height: 3,
color: Colors.white, decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12), color: Colors.white,
boxShadow: [ borderRadius: BorderRadius.circular(1.5),
BoxShadow( ),
color: Colors.black.withValues(alpha: 0.1), margin: EdgeInsets.only(
blurRadius: 4, left:
offset: const Offset(0, 2), ((MediaQuery.of(context).size.width - 160) / 3) *
), widget.currentPage,
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
'💡:$_currentTip',
style: const TextStyle(
color: AppConstants.primaryColor,
fontSize: 14,
fontWeight: FontWeight.w600,
),
textAlign: TextAlign.left,
maxLines: 3,
),
),
const SizedBox(width: 12),
// 在线状态开关
Switch(
value: _isOnline,
onChanged: (value) {
_toggleOnlineStatus();
},
activeColor: AppConstants.primaryColor,
inactiveTrackColor: Colors.grey.shade300,
inactiveThumbColor: Colors.grey,
),
],
),
), ),
), ),
), ],
],
),
// 标签栏
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {},
child: Container(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Row(
children: [
// 页面指示器
Expanded(
child: Container(
height: 3,
margin: const EdgeInsets.symmetric(horizontal: 20),
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.3),
borderRadius: BorderRadius.circular(2),
),
child: Stack(
children: [
// 背景条
Container(
height: 3,
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.3),
borderRadius: BorderRadius.circular(2),
),
),
// 滑动指示器
AnimatedContainer(
duration: const Duration(milliseconds: 300),
width: MediaQuery.of(context).size.width / 3 - 40,
height: 3,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(2),
),
margin: EdgeInsets.only(
left:
(MediaQuery.of(context).size.width / 3 - 40) *
widget.currentPage,
),
),
],
),
),
),
// 页面标签
_buildTabLabel(0, '卡片'),
_buildTabLabel(1, '设置'),
_buildTabLabel(2, '更多'),
],
),
), ),
), ),
], ],
@@ -601,7 +688,7 @@ class PersonalCardState extends State<PersonalCard> {
value.toString(), value.toString(),
style: const TextStyle( style: const TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 16, fontSize: 18,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
@@ -614,8 +701,34 @@ class PersonalCardState extends State<PersonalCard> {
); );
} }
Widget _buildTabLabel(int index, String label) { Widget _buildTabLabel(int index, String label, IconData icon) {
// === 单个页面标签:可点击切换到对应页面 === final isSelected = widget.currentPage == index;
return GestureDetector(
onTap: () {
widget.onPageChanged?.call(index);
},
child: Column(
children: [
Icon(
icon,
color: isSelected ? Colors.white : Colors.white70,
size: 20,
),
const SizedBox(height: 4),
Text(
label,
style: TextStyle(
color: isSelected ? Colors.white : Colors.white70,
fontSize: 12,
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
),
),
],
),
);
}
Widget _buildCollapsedTabLabel(int index, String label) {
final isSelected = widget.currentPage == index; final isSelected = widget.currentPage == index;
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
@@ -623,28 +736,19 @@ class PersonalCardState extends State<PersonalCard> {
}, },
child: Container( child: Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
child: Column( decoration: BoxDecoration(
mainAxisSize: MainAxisSize.min, color: isSelected
children: [ ? Colors.white.withOpacity(0.2)
Icon( : Colors.transparent,
index == 0 borderRadius: BorderRadius.circular(12),
? Icons.credit_card ),
: index == 1 child: Text(
? Icons.settings label,
: Icons.more_horiz, style: TextStyle(
color: isSelected ? Colors.white : Colors.white70, color: isSelected ? Colors.white : Colors.white70,
size: 16, fontSize: 12,
), fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
const SizedBox(height: 2), ),
Text(
label,
style: TextStyle(
color: isSelected ? Colors.white : Colors.white70,
fontSize: 10,
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
),
),
],
), ),
), ),
); );

View File

@@ -4,6 +4,7 @@
/// 最新变化: 重新设计布局,实现朋友圈风格的个人页面 /// 最新变化: 重新设计布局,实现朋友圈风格的个人页面
import 'dart:convert'; import 'dart:convert';
import 'dart:math' show Random;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@@ -66,6 +67,30 @@ class _ProfilePageState extends State<ProfilePage>
int _todayQuestions = 0; int _todayQuestions = 0;
int _todayLikes = 0; int _todayLikes = 0;
// 可爱的emoji列表
final List<String> _avatars = [
'👤',
'😊',
'🎉',
'🌟',
'🔥',
'💎',
'🌈',
'🦋',
'🌸',
'🐱',
'🐶',
'🐼',
'🐨',
'🐵',
'🦄',
'🐸',
'🐹',
'🐰',
'🦊',
'🐻',
];
// 模拟用户数据 // 模拟用户数据
final Map<String, dynamic> _userData = { final Map<String, dynamic> _userData = {
'avatar': '👤', // 使用emoji代替网络图片 'avatar': '👤', // 使用emoji代替网络图片
@@ -81,6 +106,14 @@ class _ProfilePageState extends State<ProfilePage>
'views': 3560, 'views': 3560,
}; };
// 更换头像
void _changeAvatar() {
final random = Random();
setState(() {
_userData['avatar'] = _avatars[random.nextInt(_avatars.length)];
});
}
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@@ -307,6 +340,7 @@ class _ProfilePageState extends State<ProfilePage>
); );
} }
}, },
onAvatarTap: _changeAvatar,
); );
} }
@@ -395,43 +429,43 @@ class _ProfilePageState extends State<ProfilePage>
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
// === 互动统计卡片 === // === 互动统计卡片 ===
if (!_isStatsHidden) Container(
Container( width: double.infinity,
width: double.infinity, padding: const EdgeInsets.all(20),
padding: const EdgeInsets.all(20), decoration: BoxDecoration(
decoration: BoxDecoration( color: Colors.white,
color: Colors.white, borderRadius: BorderRadius.circular(16),
borderRadius: BorderRadius.circular(16), boxShadow: [
boxShadow: [ BoxShadow(
BoxShadow( color: Colors.black.withValues(alpha: 0.08),
color: Colors.black.withValues(alpha: 0.08), blurRadius: 10,
blurRadius: 10, offset: const Offset(0, 2),
offset: const Offset(0, 2), ),
), ],
], ),
), child: Column(
child: Column( crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, children: [
children: [ Row(
Row( children: [
children: [ Icon(
Icon( Icons.analytics_outlined,
Icons.analytics_outlined, color: AppConstants.primaryColor,
size: 20,
),
const SizedBox(width: 8),
Text(
'诗词挑战',
style: TextStyle(
color: AppConstants.primaryColor, color: AppConstants.primaryColor,
size: 20, fontSize: 16,
fontWeight: FontWeight.bold,
), ),
const SizedBox(width: 8), ),
Text( ],
'诗词挑战', ),
style: TextStyle( const SizedBox(height: 16),
color: AppConstants.primaryColor, if (!_isStatsHidden)
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
],
),
const SizedBox(height: 16),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [ children: [
@@ -439,35 +473,42 @@ class _ProfilePageState extends State<ProfilePage>
_buildInteractionItem('本周答题', '$_weekQuestions'), _buildInteractionItem('本周答题', '$_weekQuestions'),
_buildInteractionItem('答对次数', '$_correctAnswers'), _buildInteractionItem('答对次数', '$_correctAnswers'),
], ],
), )
const SizedBox(height: 16), else
SizedBox( Center(
width: double.infinity, child: Padding(
child: ElevatedButton( padding: const EdgeInsets.symmetric(vertical: 16),
onPressed: () { child: Text(
Navigator.push( '数据已隐藏',
context, style: TextStyle(color: Colors.grey[500], fontSize: 14),
MaterialPageRoute(
builder: (_) => const PoetryLevelPage(),
),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: AppConstants.primaryColor,
padding: const EdgeInsets.symmetric(vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: const Text(
'开始诗词答题',
style: TextStyle(fontSize: 16),
), ),
), ),
), ),
], const SizedBox(height: 16),
), SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const PoetryLevelPage(),
),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: AppConstants.primaryColor,
padding: const EdgeInsets.symmetric(vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: const Text('开始诗词答题', style: TextStyle(fontSize: 16)),
),
),
],
), ),
),
], ],
), ),
); );
@@ -872,7 +913,7 @@ class _ProfilePageState extends State<ProfilePage>
context, context,
onRefresh: () => refreshData(), onRefresh: () => refreshData(),
onEdit: () => _showSnackBar('编辑资料'), onEdit: () => _showSnackBar('编辑资料'),
onScanQr: () => _showSnackBar('扫描二维码'), onScanQr: () => _showSnackBar('了解软件功能'),
onDarkMode: () => _showSnackBar('夜间模式'), onDarkMode: () => _showSnackBar('夜间模式'),
onSettings: () { onSettings: () {
Future.delayed(const Duration(milliseconds: 100), () { Future.delayed(const Duration(milliseconds: 100), () {

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import '../../../constants/app_constants.dart'; import '../../../constants/app_constants.dart';
import '../../../utils/audio_manager.dart'; import '../../../utils/audio_manager.dart';
@@ -371,9 +372,66 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
), ),
trailing: Icon(Icons.chevron_right, color: Colors.grey[400]), trailing: Icon(Icons.chevron_right, color: Colors.grey[400]),
onTap: () { onTap: () {
Navigator.push( // 显示对话框提示鸿蒙设备设置方法
context, showDialog(
MaterialPageRoute(builder: (context) => const WidgetsPage()), context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Row(
children: [
Icon(Icons.info_outline, color: AppConstants.primaryColor),
const SizedBox(width: 8),
const Text('桌面卡片设置'),
],
),
content: const Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'鸿蒙设备请在桌面端设置:',
style: TextStyle(fontWeight: FontWeight.bold),
),
SizedBox(height: 8),
Text('1. 长按桌面空白处'),
Text('2. 选择「情景诗词」卡片'),
Text('3. 添加后点击桌面卡片即可设置'),
Text('4. 后续版本支持在应用内设置卡片'),
SizedBox(height: 12),
Text(
'注意:该页面设置对鸿蒙设备不生效',
style: TextStyle(color: Colors.orange, fontSize: 12),
),
],
),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
// 返回桌面
SystemNavigator.pop();
},
child: const Text('前往桌面'),
),
ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const WidgetsPage(),
),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: AppConstants.primaryColor,
foregroundColor: Colors.white,
),
child: const Text('仍要进入'),
),
],
);
},
); );
}, },
); );

View File

@@ -422,7 +422,7 @@ class LearnUsPage extends StatelessWidget {
), ),
const SizedBox(height: 4), const SizedBox(height: 4),
Text( Text(
'专注诗词文化传播', '专注文字文化领域',
style: TextStyle(fontSize: 13, color: Colors.grey[600]), style: TextStyle(fontSize: 13, color: Colors.grey[600]),
), ),
], ],
@@ -431,6 +431,53 @@ class LearnUsPage extends StatelessWidget {
], ],
), ),
), ),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Row(
children: [
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.blue.withValues(alpha: 0.1),
Colors.blue.withValues(alpha: 0.05),
],
),
borderRadius: BorderRadius.circular(8),
),
child: const Center(
child: Icon(Icons.email, color: Colors.blue, size: 20),
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'商务合作&侵权申诉&联系我们',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 2),
const Text(
'2821981550@qq.com',
style: TextStyle(
fontSize: 13,
color: Colors.blue,
decoration: TextDecoration.underline,
),
),
],
),
),
],
),
),
], ],
), ),
); );

View File

@@ -60,6 +60,58 @@ class _AppDiyPageState extends State<AppDiyPage> {
super.initState(); super.initState();
_loadSettings(); _loadSettings();
_startScrolling(); _startScrolling();
// 延迟显示开发中提示对话框
WidgetsBinding.instance.addPostFrameCallback((_) {
_showDevNoticeDialog();
});
}
// 显示开发中提示对话框
void _showDevNoticeDialog() {
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
title: Row(
children: [
Icon(Icons.construction, color: AppConstants.primaryColor),
const SizedBox(width: 8),
const Text('开发中'),
],
),
content: const Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'个性化设置开发中',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
),
SizedBox(height: 12),
Text('• 当前设置仅当前页面生效'),
Text('• 后续版本将陆续支持'),
Text('• 可提前预览主题风格设置'),
SizedBox(height: 12),
Text(
'感谢您的耐心等待!',
style: TextStyle(color: Colors.grey, fontSize: 12),
),
],
),
actions: [
ElevatedButton(
onPressed: () => Navigator.of(context).pop(),
style: ElevatedButton.styleFrom(
backgroundColor: AppConstants.primaryColor,
foregroundColor: Colors.white,
),
child: const Text('我知道了'),
),
],
);
},
);
} }
@override @override
@@ -217,6 +269,13 @@ class _AppDiyPageState extends State<AppDiyPage> {
}); });
}, icon: Icons.navigation), }, icon: Icons.navigation),
_buildSwitchItem('转场动画', _enableAnimation, (value) {
setState(() {
// _enableAnimation = value;
_saveSettings();
});
}, icon: Icons.track_changes),
// 设计风格 // 设计风格
_buildSection('设计风格'), _buildSection('设计风格'),
_buildDesignStyleCard(), _buildDesignStyleCard(),

View File

@@ -8,15 +8,19 @@ import Foundation
import audioplayers_darwin import audioplayers_darwin
import device_info_plus import device_info_plus
import flutter_udid import flutter_udid
import package_info_plus
import path_provider_foundation import path_provider_foundation
import share_plus import share_plus
import shared_preferences_foundation import shared_preferences_foundation
import wakelock_plus
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin")) AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
FlutterUdidPlugin.register(with: registry.registrar(forPlugin: "FlutterUdidPlugin")) FlutterUdidPlugin.register(with: registry.registrar(forPlugin: "FlutterUdidPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin"))
} }

View File

@@ -1,6 +1,14 @@
# Generated by pub # Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile # See https://dart.dev/tools/pub/glossary#lockfile
packages: packages:
args:
dependency: transitive
description:
name: args
sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.7.0"
async: async:
dependency: transitive dependency: transitive
description: description:
@@ -145,6 +153,14 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.9" version: "1.0.9"
dbus:
dependency: transitive
description:
name: dbus
sha256: d0c98dcd4f5169878b6cf8f6e0a52403a9dff371a3e2f019697accbf6f44a270
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.7.12"
device_info_plus: device_info_plus:
dependency: transitive dependency: transitive
description: description:
@@ -335,6 +351,22 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.6" version: "1.0.6"
package_info_plus:
dependency: transitive
description:
name: package_info_plus
sha256: "468c26b4254ab01979fa5e4a98cb343ea3631b9acee6f21028997419a80e1a20"
url: "https://pub.flutter-io.cn"
source: hosted
version: "9.0.1"
package_info_plus_platform_interface:
dependency: transitive
description:
name: package_info_plus_platform_interface
sha256: "202a487f08836a592a6bd4f901ac69b3a8f146af552bbd14407b6b41e1c3f086"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.2.1"
path: path:
dependency: transitive dependency: transitive
description: description:
@@ -401,6 +433,14 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.3.0" version: "2.3.0"
petitparser:
dependency: transitive
description:
name: petitparser
sha256: "91bd59303e9f769f108f8df05e371341b15d59e995e6806aefab827b58336675"
url: "https://pub.flutter-io.cn"
source: hosted
version: "7.0.2"
platform: platform:
dependency: transitive dependency: transitive
description: description:
@@ -654,6 +694,23 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "15.0.2" version: "15.0.2"
wakelock_plus:
dependency: "direct main"
description:
path: wakelock_plus
ref: "br_v1.4.0_ohos"
resolved-ref: "75ac1ceb51510c507eb2c71a24ea34c4982b87bd"
url: "https://gitcode.com/openharmony-sig/fluttertpc_wakelock_plus.git"
source: git
version: "1.4.0"
wakelock_plus_platform_interface:
dependency: transitive
description:
name: wakelock_plus_platform_interface
sha256: "036deb14cd62f558ca3b73006d52ce049fabcdcb2eddfe0bf0fe4e8a943b5cf2"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.0"
web: web:
dependency: transitive dependency: transitive
description: description:
@@ -686,6 +743,14 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
xml:
dependency: transitive
description:
name: xml
sha256: "971043b3a0d3da28727e40ed3e0b5d18b742fa5a68665cca88e74b7876d5e025"
url: "https://pub.flutter-io.cn"
source: hosted
version: "6.6.1"
sdks: sdks:
dart: ">=3.9.2 <4.0.0" dart: ">=3.9.2 <4.0.0"
flutter: ">=3.35.0" flutter: ">=3.35.0"

View File

@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts # In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix. # of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1 version: 1.0.1+2
environment: environment:
sdk: ^3.9.2 sdk: ^3.9.2
@@ -48,10 +48,16 @@ dependencies:
path: packages/audioplayers path: packages/audioplayers
flutter_udid: flutter_udid:
path: packages/flutter_udid path: packages/flutter_udid
share_plus: share_plus:
path: packages/flutter_plus_plugins/packages/share_plus/share_plus path: packages/flutter_plus_plugins/packages/share_plus/share_plus
wakelock_plus:
git:
url: https://gitcode.com/openharmony-sig/fluttertpc_wakelock_plus.git
ref: br_v1.4.0_ohos
path: wakelock_plus
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: