鸿蒙 api23
This commit is contained in:
@@ -3,7 +3,6 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../constants/app_constants.dart';
|
||||
import '../../config/app_config.dart';
|
||||
import '../../controllers/history_controller.dart';
|
||||
import '../../services/network_listener_service.dart';
|
||||
@@ -178,7 +177,7 @@ class AllListPageState extends State<AllListPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final favoritesController = Get.find<FavoritesController>();
|
||||
|
||||
|
||||
return Obx(() {
|
||||
final isDark = _themeController.isDarkMode;
|
||||
final themeColor = _themeController.currentThemeColor;
|
||||
@@ -198,7 +197,9 @@ class AllListPageState extends State<AllListPage> {
|
||||
|
||||
return RefreshIndicator(
|
||||
onRefresh: _loadAllData,
|
||||
child: isGridView ? _buildGridView(isDark, themeColor) : _buildListView(isDark, themeColor),
|
||||
child: isGridView
|
||||
? _buildGridView(isDark, themeColor)
|
||||
: _buildListView(isDark, themeColor),
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -364,7 +365,6 @@ class AllListPageState extends State<AllListPage> {
|
||||
Widget _buildGridNoteCard(Map<String, dynamic> note, bool isDark) {
|
||||
final title = note['title'] as String? ?? '';
|
||||
final content = note['content'] as String? ?? '';
|
||||
final category = note['category'] as String? ?? '';
|
||||
final isPinned = note['isPinned'] == true;
|
||||
final isLocked = note['isLocked'] == true;
|
||||
|
||||
@@ -421,14 +421,18 @@ class AllListPageState extends State<AllListPage> {
|
||||
Icon(
|
||||
Icons.note_outlined,
|
||||
size: 10,
|
||||
color: isDark ? Colors.orange[300] : Colors.orange[700],
|
||||
color: isDark
|
||||
? Colors.orange[300]
|
||||
: Colors.orange[700],
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
Text(
|
||||
'笔记',
|
||||
style: TextStyle(
|
||||
fontSize: 9,
|
||||
color: isDark ? Colors.orange[300] : Colors.orange[700],
|
||||
color: isDark
|
||||
? Colors.orange[300]
|
||||
: Colors.orange[700],
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
@@ -440,13 +444,17 @@ class AllListPageState extends State<AllListPage> {
|
||||
Icon(
|
||||
Icons.push_pin,
|
||||
size: 12,
|
||||
color: isDark ? Colors.orange[300] : Colors.orange[700],
|
||||
color: isDark
|
||||
? Colors.orange[300]
|
||||
: Colors.orange[700],
|
||||
),
|
||||
if (isLocked)
|
||||
Icon(
|
||||
Icons.lock,
|
||||
size: 12,
|
||||
color: isDark ? Colors.orange[300] : Colors.orange[700],
|
||||
color: isDark
|
||||
? Colors.orange[300]
|
||||
: Colors.orange[700],
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -471,9 +479,7 @@ class AllListPageState extends State<AllListPage> {
|
||||
'${note['charCount'] ?? displayText.length} 字',
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: isDark
|
||||
? Colors.grey[400]
|
||||
: Colors.grey[500],
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[500],
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -489,9 +495,8 @@ class AllListPageState extends State<AllListPage> {
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
|
||||
child: Container(
|
||||
color: (isDark ? Colors.black : Colors.white).withValues(
|
||||
alpha: 0.4,
|
||||
),
|
||||
color: (isDark ? Colors.black : Colors.white)
|
||||
.withValues(alpha: 0.4),
|
||||
child: Center(
|
||||
child: Icon(
|
||||
Icons.lock,
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../constants/app_constants.dart';
|
||||
import '../../controllers/history_controller.dart';
|
||||
import '../../services/network_listener_service.dart';
|
||||
import '../../services/get/theme_controller.dart';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/// 时间: 2025-03-22
|
||||
/// 功能: 点赞诗词管理器
|
||||
/// 介绍: 管理点赞诗词的加载、显示、删除等操作
|
||||
/// 最新变化: 从FavoritesPage分离出来的点赞管理逻辑,添加底部内边距适配液态玻璃导航栏
|
||||
/// 上次更新: 2026-04-18 修复详情刷新按钮显示开发中、支持深色模式
|
||||
|
||||
library liked_poetry_manager;
|
||||
|
||||
@@ -32,12 +32,11 @@ class LikedPoetryManager extends StatefulWidget {
|
||||
PoetryData poetry,
|
||||
) async {
|
||||
try {
|
||||
debugPrint(
|
||||
'DEBUG: LikedPoetryManager - 点击查看详情 - Poetry ID: ${poetry.id}',
|
||||
);
|
||||
final themeController = Get.find<ThemeController>();
|
||||
final isDark = themeController.isDarkMode;
|
||||
final themeColor = themeController.currentThemeColor;
|
||||
|
||||
final likedList = await HistoryController.getLikedHistory();
|
||||
debugPrint('DEBUG: LikedPoetryManager - 获取到 ${likedList.length} 条点赞记录');
|
||||
|
||||
Map<String, dynamic> poetryData;
|
||||
try {
|
||||
@@ -45,177 +44,216 @@ class LikedPoetryManager extends StatefulWidget {
|
||||
(item) => item['id'].toString() == poetry.id.toString(),
|
||||
orElse: () => poetry.toJson(),
|
||||
);
|
||||
debugPrint('DEBUG: LikedPoetryManager - 找到匹配的诗词数据');
|
||||
} catch (e) {
|
||||
debugPrint('DEBUG: LikedPoetryManager - 未找到匹配数据,使用当前poetry数据');
|
||||
poetryData = poetry.toJson();
|
||||
}
|
||||
|
||||
debugPrint(
|
||||
'DEBUG: LikedPoetryManager - 诗词数据字段: ${poetryData.keys.toList()}',
|
||||
);
|
||||
|
||||
if (context.mounted) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (context) => Container(
|
||||
height: MediaQuery.of(context).size.height * 0.8,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(20),
|
||||
topRight: Radius.circular(20),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 8),
|
||||
width: 40,
|
||||
height: 4,
|
||||
builder: (context) {
|
||||
return StatefulBuilder(
|
||||
builder: (context, setSheetState) {
|
||||
return Container(
|
||||
height: MediaQuery.of(context).size.height * 0.8,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[300],
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
color: isDark ? const Color(0xFF1E1E1E) : Colors.white,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(20),
|
||||
topRight: Radius.circular(20),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.article,
|
||||
color: AppConstants.primaryColor,
|
||||
size: 24,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text(
|
||||
'诗词详情',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 8),
|
||||
width: 40,
|
||||
height: 4,
|
||||
decoration: BoxDecoration(
|
||||
color: isDark ? Colors.grey[600] : Colors.grey[300],
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('开发中'),
|
||||
duration: Duration(seconds: 1),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.article, color: themeColor, size: 24),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'诗词详情',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: isDark ? Colors.white : Colors.black87,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Icon(
|
||||
Icons.refresh,
|
||||
color: Colors.grey[600],
|
||||
size: 20,
|
||||
const Spacer(),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
setSheetState(() {});
|
||||
try {
|
||||
final freshList =
|
||||
await HistoryController.getLikedHistory();
|
||||
final freshData = freshList.firstWhere(
|
||||
(item) =>
|
||||
item['id'].toString() ==
|
||||
poetry.id.toString(),
|
||||
orElse: () => poetryData,
|
||||
);
|
||||
setSheetState(() {
|
||||
poetryData = freshData;
|
||||
});
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: const Text('已刷新'),
|
||||
duration: const Duration(seconds: 1),
|
||||
backgroundColor: themeColor,
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('刷新失败: $e'),
|
||||
duration: const Duration(seconds: 1),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Icon(
|
||||
Icons.refresh,
|
||||
color: isDark
|
||||
? Colors.grey[400]
|
||||
: Colors.grey[600],
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
IconButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
icon: const Icon(Icons.close),
|
||||
color: isDark
|
||||
? Colors.grey[400]
|
||||
: Colors.grey[600],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildDetailCard(
|
||||
'精选诗句',
|
||||
poetryData['name'] ?? poetry.name,
|
||||
Icons.format_quote,
|
||||
themeColor,
|
||||
isDark,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
if (poetryData['liked_time'] != null) ...[
|
||||
Expanded(
|
||||
child: _buildDetailCard(
|
||||
'点赞时间',
|
||||
'${poetryData['liked_date'] ?? ''} ${poetryData['liked_time'] ?? ''}',
|
||||
Icons.favorite,
|
||||
Colors.orange,
|
||||
isDark,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (poetryData['keywords'] != null &&
|
||||
poetryData['keywords']
|
||||
.toString()
|
||||
.isNotEmpty) ...[
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: _buildDetailCard(
|
||||
'标签',
|
||||
poetryData['keywords'],
|
||||
Icons.local_offer,
|
||||
Colors.green,
|
||||
isDark,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
if (poetryData['alias'] != null &&
|
||||
poetryData['alias']
|
||||
.toString()
|
||||
.isNotEmpty) ...[
|
||||
Expanded(
|
||||
child: _buildDetailCard(
|
||||
'出处',
|
||||
poetryData['url'],
|
||||
Icons.link,
|
||||
Colors.teal,
|
||||
isDark,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (poetryData['url'] != null &&
|
||||
poetryData['url']
|
||||
.toString()
|
||||
.isNotEmpty) ...[
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: _buildDetailCard(
|
||||
'朝代',
|
||||
poetryData['alias'],
|
||||
Icons.history,
|
||||
Colors.blue,
|
||||
isDark,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
if (poetryData['introduce'] != null &&
|
||||
poetryData['introduce'].toString().isNotEmpty)
|
||||
_buildDetailCard(
|
||||
'译文/介绍',
|
||||
poetryData['introduce'],
|
||||
Icons.translate,
|
||||
themeColor,
|
||||
isDark,
|
||||
),
|
||||
if (poetryData['drtime'] != null &&
|
||||
poetryData['drtime'].toString().isNotEmpty)
|
||||
_buildDetailCard(
|
||||
'原文or赏析',
|
||||
poetryData['drtime'],
|
||||
Icons.menu_book,
|
||||
Colors.purple,
|
||||
isDark,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
IconButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
icon: const Icon(Icons.close),
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildDetailCard(
|
||||
'精选诗句',
|
||||
poetryData['name'] ?? poetry.name,
|
||||
Icons.format_quote,
|
||||
AppConstants.primaryColor,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
if (poetryData['liked_time'] != null) ...[
|
||||
Expanded(
|
||||
child: _buildDetailCard(
|
||||
'点赞时间',
|
||||
'${poetryData['liked_date'] ?? ''} ${poetryData['liked_time'] ?? ''}',
|
||||
Icons.favorite,
|
||||
Colors.orange,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (poetryData['keywords'] != null &&
|
||||
poetryData['keywords']
|
||||
.toString()
|
||||
.isNotEmpty) ...[
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: _buildDetailCard(
|
||||
'标签',
|
||||
poetryData['keywords'],
|
||||
Icons.local_offer,
|
||||
Colors.green,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
if (poetryData['alias'] != null &&
|
||||
poetryData['alias'].toString().isNotEmpty) ...[
|
||||
Expanded(
|
||||
child: _buildDetailCard(
|
||||
'出处',
|
||||
poetryData['url'],
|
||||
Icons.link,
|
||||
Colors.teal,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (poetryData['url'] != null &&
|
||||
poetryData['url'].toString().isNotEmpty) ...[
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: _buildDetailCard(
|
||||
'朝代',
|
||||
poetryData['alias'],
|
||||
Icons.history,
|
||||
Colors.blue,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
if (poetryData['introduce'] != null &&
|
||||
poetryData['introduce'].toString().isNotEmpty)
|
||||
_buildDetailCard(
|
||||
'译文/介绍',
|
||||
poetryData['introduce'],
|
||||
Icons.translate,
|
||||
AppConstants.primaryColor,
|
||||
),
|
||||
if (poetryData['drtime'] != null &&
|
||||
poetryData['drtime'].toString().isNotEmpty)
|
||||
_buildDetailCard(
|
||||
'原文or赏析',
|
||||
poetryData['drtime'],
|
||||
Icons.menu_book,
|
||||
Colors.purple,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -238,12 +276,15 @@ class LikedPoetryManager extends StatefulWidget {
|
||||
String content,
|
||||
IconData icon,
|
||||
Color accentColor,
|
||||
bool isDark,
|
||||
) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: accentColor.withValues(alpha: 0.05),
|
||||
color: isDark
|
||||
? accentColor.withValues(alpha: 0.12)
|
||||
: accentColor.withValues(alpha: 0.05),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: accentColor.withValues(alpha: 0.2), width: 1),
|
||||
),
|
||||
@@ -253,7 +294,9 @@ class LikedPoetryManager extends StatefulWidget {
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: accentColor.withValues(alpha: 0.1),
|
||||
color: isDark
|
||||
? accentColor.withValues(alpha: 0.18)
|
||||
: accentColor.withValues(alpha: 0.1),
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(12),
|
||||
topRight: Radius.circular(12),
|
||||
@@ -278,9 +321,9 @@ class LikedPoetryManager extends StatefulWidget {
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Text(
|
||||
content,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.black87,
|
||||
color: isDark ? Colors.white70 : Colors.black87,
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
/// 介绍: 显示系统公告列表,支持下拉刷新
|
||||
/// 最新变化: 添加底部"到底了"提示,防止被底部 tabs 遮住
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../constants/app_constants.dart';
|
||||
import '../../config/app_config.dart';
|
||||
import 'collect_notes.dart';
|
||||
import '../../controllers/history_controller.dart';
|
||||
@@ -157,7 +156,6 @@ class _LocalNotesListState extends State<LocalNotesList> {
|
||||
final title = note['title'] as String? ?? '';
|
||||
final content = note['content'] as String? ?? '';
|
||||
final timeStr = note['time'] as String? ?? '';
|
||||
final createTimeStr = note['createTime'] as String? ?? '';
|
||||
final category = note['category'] as String? ?? '';
|
||||
final isPinned = note['isPinned'] == true;
|
||||
final isLocked = note['isLocked'] == true;
|
||||
|
||||
Reference in New Issue
Block a user