diff --git a/CHANGELOG.md b/CHANGELOG.md index 98c27ba..e7786e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file. --- +## [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 ### 优化 @@ -36,75 +52,22 @@ All notable changes to this project will be documented in this file. --- - - -## [1.3.2] - 2026-03-30 - -### 新增 -- 📝 **诗词投稿功能** - - 新增投稿页面 `lib/views/profile/expand/manu-script.dart` - - 支持诗词收录申请,包含完整表单(参考语句、分类选择、诗人和标题、关键词、诗词介绍、人机验证) - - 实现相似度检测功能,防止重复提交 - - 平台字段自动获取设备类型并发送"设备类型 + Flutter"格式数据 - - 修改"去投稿"按钮跳转逻辑,文件:`lib/views/profile/profile_page.dart` - - - - ---- - -## [1.3.0] - 2026-03-29 - -### 新增 -- ⚡ **离线数据下载优化** - - 添加取消下载功能,支持中断下载过程 - - 下载过程中显示取消按钮,点击可立即停止 - - 优化下载状态显示,避免页面卡死 - - 取消下载时显示相应提示 - - 文件:`lib/views/profile/settings/offline-data.dart` - -### 优化 -- 🌐 **网络状态自动检测** - - 个人卡片加载时自动检测网络状态 - - 无网络时自动调整为离线状态 - - 避免网络异常导致的错误 - - 文件:`lib/views/profile/per_card.dart` - -### 修复 -- 🐛 **网络状态检测错误修复** - - 修复 `currentNetworkStatus` 不存在的错误 - - 修复 `NetworkStatus.offline` 不存在的错误 - - 使用正确的 `currentStatus` 和 `NetworkStatus.error` - - 文件:`lib/views/profile/per_card.dart` - -### 新增 -- 📊 **服务器信息显示** - - 在离线数据页面添加服务器信息卡片 - - 显示 API 地址、版本、频率限制等信息 - - 文件:`lib/views/profile/settings/offline-data.dart` - -### 优化 -- 📱 **离线数据下载功能增强** - - 新增下载类型选择:诗句和答题 - - 诗句数量选项:20、30、60、100条 - - 答题数量选项:20、50、80、100条 - - 100条下载需要加入用户体验计划 - - 实现下载一条写入一条的功能 - - 取消下载时保存已下载的数据 - - 实时更新缓存状态显示 - - 返回上一页时继续后台下载,不中断 - - 清空缓存时弹窗选择清空内容(诗句/答题/全部) - - 缓存状态同时显示诗句和答题数量 - - 文件:`lib/views/profile/settings/offline-data.dart` - - - ---- - ## 软件特性功能 ### 已开发完成 -- 🐛 **已知bug列表功能** - 从下到上弹出页面显示已知bug、解决方法和解决时间、支持下拉刷新和滚动查看、显示bug优先级和状态、提供详细解决方案描述、显示影响用户范围和时间信息 +- � **诗词卡片截图分享功能** - 主页点赞按钮上方添加悬浮分享按钮、点击生成诗词卡片高清图片并分享、使用RepaintBoundary和GlobalKey实现Widget截图、集成share_plus库实现跨平台分享、包含生成中/成功/失败提示 + - 优先级:4 +- 📜 **诗词投稿功能** - 新增投稿页面、支持诗词收录申请表单、包含参考语句/分类选择/诗人和标题/关键词/诗词介绍/人机验证、实现相似度检测防止重复提交、平台字段自动获取设备类型 + - 优先级:3 +- ⚡ **离线数据下载优化** - 添加取消下载功能、下载过程中显示取消按钮、优化下载状态显示避免页面卡死、取消下载时显示相应提示 + - 优先级:4 +- 🌐 **网络状态自动检测** - 个人卡片加载时自动检测网络状态、无网络时自动调整为离线状态、避免网络异常导致的错误 + - 优先级:3 +- 📊 **服务器信息显示** - 在离线数据页面添加服务器信息卡片、显示API地址/版本/频率限制等信息 + - 优先级:2 +- 📱 **离线数据下载功能增强** - 新增下载类型选择(诗句和答题)、诗句数量选项(20/30/60/100条)、答题数量选项(20/50/80/100条)、100条下载需加入用户体验计划、实现下载一条写入一条、取消下载时保存已下载数据、实时更新缓存状态、返回上一页继续后台下载、清空缓存时弹窗选择清空内容、缓存状态同时显示诗句和答题数量 + - 优先级:5 +- �� **已知bug列表功能** - 从下到上弹出页面显示已知bug、解决方法和解决时间、支持下拉刷新和滚动查看、显示bug优先级和状态、提供详细解决方案描述、显示影响用户范围和时间信息 - 📜 **投稿记录功能** - 投稿记录页面显示历史投稿列表、按时间倒序排列、支持展开查看详细信息、提供清空记录功能、投稿成功后自动保存到SharedPreferences、最多保存50条记录 - 🗳️ **投票功能完整实现** - 用户登录/注册、获取投票列表、投票详情、提交投票、投票结果展示、API服务基础URL修改、登录注册逻辑简化(只需用户名、默认密码123456、自动注册登录、设备标识)、投票页面调试功能、user_identifier增加Flutter后缀、setState调用安全修复(添加mounted检查)、投票登录状态持久化修复(添加Cookie管理器支持PHP Session认证) - 🎨 **个人卡片标签栏布局优化** - 将标签栏区域一分为二,左侧区域可以点击展开/收起个人卡片 diff --git a/android/build/reports/problems/problems-report.html b/android/build/reports/problems/problems-report.html new file mode 100644 index 0000000..b96f1cc --- /dev/null +++ b/android/build/reports/problems/problems-report.html @@ -0,0 +1,663 @@ + + + + + + + + + + + + + Gradle Configuration Cache + + + +
+ +
+ Loading... +
+ + + + + + diff --git a/lib/views/home/home_components.dart b/lib/views/home/home_components.dart index feacbf4..4034425 100644 --- a/lib/views/home/home_components.dart +++ b/lib/views/home/home_components.dart @@ -2,8 +2,13 @@ /// 功能: 诗词页面通用组件和工具函数 /// 介绍: 从 home_page.dart 和 home_part.dart 中提取的公共组件,用于代码复用和简化 +import 'dart:io'; +import 'dart:ui' as ui; import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:share_plus/share_plus.dart'; import '../../constants/app_constants.dart'; import '../../utils/http/poetry_api.dart'; import 'home-load.dart'; @@ -34,6 +39,84 @@ class LoadingWidget extends StatelessWidget { } } +/// 截图和分享工具类 +class ShareImageUtils { + /// 将 Widget 截图并分享 + static Future captureAndShare( + BuildContext context, + GlobalKey repaintKey, { + String? subject, + }) async { + try { + PoetryStateManager.showSnackBar( + context, + '正在生成图片...', + backgroundColor: AppConstants.primaryColor, + ); + + final boundary = + repaintKey.currentContext?.findRenderObject() + as RenderRepaintBoundary?; + if (boundary == null) { + if (context.mounted) { + PoetryStateManager.showSnackBar( + context, + '生成图片失败', + backgroundColor: AppConstants.errorColor, + ); + } + return; + } + + ui.Image image = await boundary.toImage(pixelRatio: 3.0); + ByteData? byteData = await image.toByteData( + format: ui.ImageByteFormat.png, + ); + + if (byteData == null) { + if (context.mounted) { + PoetryStateManager.showSnackBar( + context, + '生成图片失败', + backgroundColor: AppConstants.errorColor, + ); + } + return; + } + + Uint8List pngBytes = byteData.buffer.asUint8List(); + + final directory = await getTemporaryDirectory(); + final file = File( + '${directory.path}/poetry_${DateTime.now().millisecondsSinceEpoch}.png', + ); + await file.writeAsBytes(pngBytes); + + final result = await Share.shareXFiles([ + XFile(file.path), + ], subject: subject ?? '诗词分享'); + + if (result.status == ShareResultStatus.success) { + if (context.mounted) { + PoetryStateManager.showSnackBar( + context, + '分享成功!', + backgroundColor: AppConstants.successColor, + ); + } + } + } catch (e) { + if (context.mounted) { + PoetryStateManager.showSnackBar( + context, + '分享失败:${e.toString().substring(0, e.toString().length > 50 ? 50 : e.toString().length)}', + backgroundColor: AppConstants.errorColor, + ); + } + } + } +} + /// 错误状态组件 class CustomErrorWidget extends StatelessWidget { final String errorMessage; @@ -277,3 +360,112 @@ class CopyUtils { ); } } + +/// 悬浮分享按钮组件 +class FloatingShareButton extends StatelessWidget { + final VoidCallback onShare; + + const FloatingShareButton({super.key, required this.onShare}); + + @override + Widget build(BuildContext context) { + return Container( + width: 56, + height: 56, + decoration: BoxDecoration( + color: AppConstants.secondaryColor, + shape: BoxShape.circle, + boxShadow: [ + BoxShadow( + color: AppConstants.secondaryColor.withAlpha(76), + blurRadius: 8, + offset: const Offset(0, 4), + ), + ], + ), + child: Material( + color: Colors.transparent, + child: InkWell( + borderRadius: BorderRadius.circular(28), + onTap: () { + HapticFeedback.lightImpact(); + onShare(); + }, + child: const Center( + child: Icon(Icons.share, color: Colors.white, size: 28), + ), + ), + ), + ); + } +} + +/// 统计信息卡片组件 +class StatsCard extends StatelessWidget { + final PoetryData poetryData; + + const StatsCard({super.key, required this.poetryData}); + + @override + Widget build(BuildContext context) { + return Container( + margin: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(5), + blurRadius: 5, + offset: const Offset(0, 1), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + '统计信息', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + color: AppConstants.primaryColor, + ), + ), + const SizedBox(height: 12), + Row( + children: [ + _buildStatItem('今日', poetryData.hitsDay.toString()), + const SizedBox(width: 20), + _buildStatItem('本月', poetryData.hitsMonth.toString()), + const SizedBox(width: 20), + _buildStatItem('总计', poetryData.hitsTotal.toString()), + ], + ), + ], + ), + ); + } + + Widget _buildStatItem(String label, String value) { + return Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + value, + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + color: Colors.black87, + ), + ), + const SizedBox(height: 4), + Text(label, style: const TextStyle(fontSize: 12, color: Colors.grey)), + ], + ), + ); + } +} diff --git a/lib/views/home/home_page.dart b/lib/views/home/home_page.dart index 57625b2..aa86df5 100644 --- a/lib/views/home/home_page.dart +++ b/lib/views/home/home_page.dart @@ -39,6 +39,8 @@ class _HomePageState extends State late Animation _fadeAnimation; late Animation _slideAnimation; + final GlobalKey _repaintKey = GlobalKey(); + // 动态加载状态 bool _isLoadingNext = false; Map _sectionLoadingStates = { @@ -724,6 +726,15 @@ class _HomePageState extends State } } + Future _sharePoetryImage() async { + if (_poetryData == null) return; + await ShareImageUtils.captureAndShare( + context, + _repaintKey, + subject: _poetryData!.name, + ); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -773,6 +784,7 @@ class _HomePageState extends State keywordList: _keywordList, onTap: _loadNextPoetry, sectionLoadingStates: _sectionLoadingStates, + repaintKey: _repaintKey, ), const SizedBox(height: 160), // 为悬浮按钮留出更多空间 ], @@ -799,6 +811,12 @@ class _HomePageState extends State bottom: 32, child: FloatingNextButton(onNext: _loadNextPoetry), ), + // 悬浮分享按钮 - 右边上方 + Positioned( + right: 16, + bottom: 100, + child: FloatingShareButton(onShare: _sharePoetryImage), + ), // 悬浮点赞按钮 - 右边(仅在线状态显示) if (isOnline) Positioned( diff --git a/lib/views/home/home_part.dart b/lib/views/home/home_part.dart index bd29f8d..2737351 100644 --- a/lib/views/home/home_part.dart +++ b/lib/views/home/home_part.dart @@ -17,6 +17,7 @@ class PoetryCard extends StatefulWidget { final List keywordList; final VoidCallback? onTap; final Map? sectionLoadingStates; + final GlobalKey? repaintKey; const PoetryCard({ super.key, @@ -24,6 +25,7 @@ class PoetryCard extends StatefulWidget { required this.keywordList, this.onTap, this.sectionLoadingStates, + this.repaintKey, }); @override @@ -104,7 +106,7 @@ class _PoetryCardState extends State { @override Widget build(BuildContext context) { - return GestureDetector( + final card = GestureDetector( onTap: () { // 播放点击音效(不等待完成) AudioManager().playClickSound(); @@ -160,6 +162,11 @@ class _PoetryCardState extends State { ], ), ); + + if (widget.repaintKey != null) { + return RepaintBoundary(key: widget.repaintKey, child: card); + } + return card; } Widget _buildTimeBar() { diff --git a/lib/views/profile/components/pop-menu.dart b/lib/views/profile/components/pop-menu.dart index 13f0d93..125b309 100644 --- a/lib/views/profile/components/pop-menu.dart +++ b/lib/views/profile/components/pop-menu.dart @@ -21,9 +21,9 @@ class PopMenu extends StatelessWidget { static Future shareApp(BuildContext context) async { try { - const String shareText = '诗词学习App - 一款优雅的诗词学习应用,包含丰富的诗词内容和答题功能'; + const String shareText = '情景诗词App - 一款优雅的诗词学习应用,包含丰富的诗词内容和答题功能'; - final result = await Share.shareWithResult(shareText, subject: '诗词学习App'); + final result = await Share.shareWithResult(shareText, subject: '情景诗词App'); if (result.status == ShareResultStatus.success) { if (context.mounted) {