深色模式、首页设置页面和功能优化

This commit is contained in:
Developer
2026-04-02 07:06:55 +08:00
parent f0a62ed68b
commit 954d173329
88 changed files with 12157 additions and 7578 deletions

View File

@@ -2,10 +2,13 @@ import 'dart:ui';
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';
import '../../utils/http/poetry_api.dart';
import '../../services/get/theme_controller.dart';
import 'collect_notes.dart';
import 'liked_poetry_manager.dart';
@@ -37,6 +40,7 @@ class _AllListPageState extends State<AllListPage> {
List<UnifiedCard> _cards = [];
bool _isLoading = false;
StreamSubscription<NetworkEvent>? _networkSubscription;
final ThemeController _themeController = Get.find<ThemeController>();
@override
void initState() {
@@ -132,95 +136,129 @@ class _AllListPageState extends State<AllListPage> {
@override
Widget build(BuildContext context) {
if (_isLoading && _cards.isEmpty) {
return const Center(child: CircularProgressIndicator());
}
return Obx(() {
final isDark = _themeController.isDarkMode;
if (_cards.isEmpty) {
return _buildEmptyState();
}
if (_isLoading && _cards.isEmpty) {
return Center(
child: CircularProgressIndicator(
color: isDark ? Colors.white : AppConstants.primaryColor,
),
);
}
return RefreshIndicator(
onRefresh: _loadAllData,
child: ListView.separated(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 80),
itemCount: _cards.length + 1,
separatorBuilder: (context, index) {
if (index == _cards.length) return const SizedBox.shrink();
return Container(
height: 1,
color: Colors.black.withOpacity(0.1),
margin: const EdgeInsets.symmetric(vertical: 4),
);
},
itemBuilder: (context, index) {
if (index == _cards.length) {
return _buildBottomIndicator();
}
return _buildCard(_cards[index]);
},
),
);
if (_cards.isEmpty) {
return _buildEmptyState(isDark);
}
return RefreshIndicator(
onRefresh: _loadAllData,
child: ListView.separated(
// 添加底部内边距,让内容延伸到导航栏下方,实现玻璃效果
padding: EdgeInsets.fromLTRB(
16,
8,
16,
AppConfig.liquidGlassTotalHeight + 16,
),
itemCount: _cards.length + 1,
separatorBuilder: (context, index) {
if (index == _cards.length) return const SizedBox.shrink();
return Container(
height: 1,
color: isDark
? Colors.white.withValues(alpha: 0.1)
: Colors.black.withValues(alpha: 0.1),
margin: const EdgeInsets.symmetric(vertical: 4),
);
},
itemBuilder: (context, index) {
if (index == _cards.length) {
return _buildBottomIndicator(isDark);
}
return _buildCard(_cards[index], isDark);
},
),
);
});
}
Widget _buildBottomIndicator() {
Widget _buildBottomIndicator(bool isDark) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 24),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(width: 40, height: 1, color: Colors.grey[300]),
Container(
width: 40,
height: 1,
color: isDark ? Colors.grey[700] : Colors.grey[300],
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
'到底了',
style: TextStyle(fontSize: 12, color: Colors.grey[400]),
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.grey[500] : Colors.grey[400],
),
),
),
Container(width: 40, height: 1, color: Colors.grey[300]),
Container(
width: 40,
height: 1,
color: isDark ? Colors.grey[700] : Colors.grey[300],
),
],
),
);
}
// 构建空状态
Widget _buildEmptyState() {
Widget _buildEmptyState(bool isDark) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.inbox_outlined, size: 64, color: Colors.grey[400]),
Icon(
Icons.inbox_outlined,
size: 64,
color: isDark ? Colors.grey[600] : Colors.grey[400],
),
const SizedBox(height: 16),
Text(
'暂无收藏内容',
style: TextStyle(fontSize: 16, color: Colors.grey[600]),
style: TextStyle(
fontSize: 16,
color: isDark ? Colors.grey[400] : Colors.grey[600],
),
),
const SizedBox(height: 8),
Text(
'点赞诗词或创建笔记后将显示在这里',
style: TextStyle(fontSize: 14, color: Colors.grey[500]),
style: TextStyle(
fontSize: 14,
color: isDark ? Colors.grey[500] : Colors.grey[500],
),
),
],
),
);
}
// 根据类型构建卡片 - 使用策略模式
Widget _buildCard(UnifiedCard card) {
Widget _buildCard(UnifiedCard card, bool isDark) {
switch (card.type) {
case CardType.like:
return _buildLikeCard(card.data as PoetryData);
return _buildLikeCard(card.data as PoetryData, isDark);
case CardType.note:
return _buildNoteCard(card.data as Map<String, dynamic>);
return _buildNoteCard(card.data as Map<String, dynamic>, isDark);
}
}
// 构建点赞卡片 - 简洁紧凑样式
Widget _buildLikeCard(PoetryData poetry) {
Widget _buildLikeCard(PoetryData poetry, bool isDark) {
return Container(
margin: const EdgeInsets.only(bottom: 0),
decoration: BoxDecoration(
color: Colors.white,
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: AppConstants.primaryColor.withValues(alpha: 0.2),
@@ -228,7 +266,9 @@ class _AllListPageState extends State<AllListPage> {
),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.03),
color: isDark
? Colors.black.withValues(alpha: 0.2)
: Colors.black.withValues(alpha: 0.03),
blurRadius: 6,
offset: const Offset(0, 1),
),
@@ -237,23 +277,23 @@ class _AllListPageState extends State<AllListPage> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 顶部行:出处(左) + 标签(右)
Padding(
padding: const EdgeInsets.fromLTRB(10, 4, 0, 4),
child: Row(
children: [
// 出处 - 左上角
if (poetry.url.isNotEmpty)
Expanded(
child: Text(
poetry.url,
style: TextStyle(fontSize: 11, color: Colors.grey[600]),
style: TextStyle(
fontSize: 11,
color: isDark ? Colors.grey[400] : Colors.grey[600],
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
if (poetry.url.isEmpty) const Spacer(),
// 类型标识 - 右上角
Container(
padding: const EdgeInsets.symmetric(
horizontal: 8,
@@ -290,15 +330,14 @@ class _AllListPageState extends State<AllListPage> {
),
),
// 诗句内容
Padding(
padding: const EdgeInsets.fromLTRB(10, 4, 10, 4),
child: Text(
poetry.name,
style: const TextStyle(
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: Colors.black87,
color: isDark ? Colors.white : Colors.black87,
height: 1.3,
),
maxLines: 2,
@@ -306,7 +345,6 @@ class _AllListPageState extends State<AllListPage> {
),
),
// 操作按钮
Padding(
padding: const EdgeInsets.fromLTRB(8, 0, 8, 6),
child: Row(
@@ -332,11 +370,14 @@ class _AllListPageState extends State<AllListPage> {
icon: Icon(
Icons.note_add,
size: 14,
color: Colors.orange[700],
color: isDark ? Colors.orange[300] : Colors.orange[700],
),
label: Text(
'创建笔记',
style: TextStyle(fontSize: 12, color: Colors.orange[700]),
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.orange[300] : Colors.orange[700],
),
),
),
TextButton.icon(
@@ -344,11 +385,14 @@ class _AllListPageState extends State<AllListPage> {
icon: Icon(
Icons.favorite_border,
size: 14,
color: Colors.grey[600],
color: isDark ? Colors.grey[400] : Colors.grey[600],
),
label: Text(
'取消',
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.grey[400] : Colors.grey[600],
),
),
),
],
@@ -359,8 +403,7 @@ class _AllListPageState extends State<AllListPage> {
);
}
// 构建笔记卡片 - 紧凑阴影样式
Widget _buildNoteCard(Map<String, dynamic> note) {
Widget _buildNoteCard(Map<String, dynamic> note, bool isDark) {
final title = note['title'] as String? ?? '';
final content = note['content'] as String? ?? '';
final category = note['category'] as String? ?? '';
@@ -382,11 +425,13 @@ class _AllListPageState extends State<AllListPage> {
return Container(
margin: const EdgeInsets.only(bottom: 0),
decoration: BoxDecoration(
color: Colors.white,
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.06),
color: isDark
? Colors.black.withValues(alpha: 0.2)
: Colors.black.withValues(alpha: 0.06),
blurRadius: 8,
offset: const Offset(0, 2),
),
@@ -397,7 +442,6 @@ class _AllListPageState extends State<AllListPage> {
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 笔记内容
InkWell(
onTap: () => _handleNoteTap(note, isLocked),
borderRadius: BorderRadius.circular(10),
@@ -413,7 +457,7 @@ class _AllListPageState extends State<AllListPage> {
fontWeight: hasTitle
? FontWeight.w600
: FontWeight.normal,
color: Colors.black87,
color: isDark ? Colors.white : Colors.black87,
height: 1.4,
),
maxLines: 2,
@@ -426,7 +470,9 @@ class _AllListPageState extends State<AllListPage> {
'${note['charCount'] ?? displayText.length}',
style: TextStyle(
fontSize: 11,
color: Colors.grey[500],
color: isDark
? Colors.grey[400]
: Colors.grey[500],
),
),
if (hasCategory) ...[
@@ -437,14 +483,18 @@ class _AllListPageState extends State<AllListPage> {
vertical: 1,
),
decoration: BoxDecoration(
color: Colors.grey[200],
color: isDark
? Colors.grey[800]
: Colors.grey[200],
borderRadius: BorderRadius.circular(3),
),
child: Text(
category,
style: TextStyle(
fontSize: 9,
color: Colors.grey[600],
color: isDark
? Colors.grey[400]
: Colors.grey[600],
),
),
),
@@ -458,7 +508,6 @@ class _AllListPageState extends State<AllListPage> {
],
),
// 类型标识 - 右上角
Positioned(
top: 0,
right: 0,
@@ -477,31 +526,38 @@ class _AllListPageState extends State<AllListPage> {
Icon(
Icons.note_outlined,
size: 12,
color: Colors.orange[700],
color: isDark ? Colors.orange[300] : Colors.orange[700],
),
const SizedBox(width: 3),
Text(
'笔记',
style: TextStyle(
fontSize: 11,
color: Colors.orange[700],
color: isDark ? Colors.orange[300] : Colors.orange[700],
fontWeight: FontWeight.w500,
),
),
if (isPinned) ...[
const SizedBox(width: 6),
Icon(Icons.push_pin, size: 10, color: Colors.orange[700]),
Icon(
Icons.push_pin,
size: 10,
color: isDark ? Colors.orange[300] : Colors.orange[700],
),
],
if (isLocked) ...[
const SizedBox(width: 6),
Icon(Icons.lock, size: 10, color: Colors.orange[700]),
Icon(
Icons.lock,
size: 10,
color: isDark ? Colors.orange[300] : Colors.orange[700],
),
],
],
),
),
),
// 锁定遮罩
if (isLocked)
Positioned.fill(
child: GestureDetector(
@@ -511,7 +567,9 @@ class _AllListPageState extends State<AllListPage> {
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
child: Container(
color: Colors.white.withValues(alpha: 0.4),
color: (isDark ? Colors.black : Colors.white).withValues(
alpha: 0.4,
),
child: Center(
child: Row(
mainAxisSize: MainAxisSize.min,
@@ -519,14 +577,18 @@ class _AllListPageState extends State<AllListPage> {
Icon(
Icons.lock,
size: 16,
color: Colors.orange[700],
color: isDark
? Colors.orange[300]
: Colors.orange[700],
),
const SizedBox(width: 6),
Text(
'已锁定',
style: TextStyle(
fontSize: 13,
color: Colors.orange[700],
color: isDark
? Colors.orange[300]
: Colors.orange[700],
fontWeight: FontWeight.w500,
),
),

View File

@@ -1,9 +1,11 @@
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';
/// 时间: 2026-03-26
/// 功能: 笔记编辑页面
@@ -24,6 +26,7 @@ class _CollectNotesPageState extends State<CollectNotesPage> {
final TextEditingController _contentController = TextEditingController();
final FocusNode _titleFocusNode = FocusNode();
final FocusNode _contentFocusNode = FocusNode();
final ThemeController _themeController = Get.find<ThemeController>();
String? _currentNoteId;
DateTime? _lastSavedTime;
@@ -279,10 +282,10 @@ class _CollectNotesPageState extends State<CollectNotesPage> {
horizontal: 16,
),
decoration: BoxDecoration(
color: AppConstants.primaryColor.withOpacity(0.1),
color: AppConstants.primaryColor.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: AppConstants.primaryColor.withOpacity(0.3),
color: AppConstants.primaryColor.withValues(alpha: 0.3),
),
),
child: Row(
@@ -550,113 +553,146 @@ class _CollectNotesPageState extends State<CollectNotesPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0,
leading: IconButton(
icon: Icon(Icons.arrow_back, color: AppConstants.primaryColor),
onPressed: () => Navigator.of(context).pop(),
),
title: Text(
_currentNoteId == null ? '新建笔记' : '编辑笔记',
style: const TextStyle(
color: Colors.black87,
fontWeight: FontWeight.w600,
return Obx(() {
final isDark = _themeController.isDarkMode;
return Scaffold(
backgroundColor: isDark
? const Color(0xFF1A1A1A)
: Theme.of(context).scaffoldBackgroundColor,
appBar: AppBar(
backgroundColor: isDark ? const Color(0xFF2A2A2A) : Colors.white,
elevation: 0,
leading: IconButton(
icon: Icon(
Icons.arrow_back,
color: isDark ? Colors.white70 : AppConstants.primaryColor,
),
onPressed: () => Navigator.of(context).pop(),
),
),
actions: [
// 删除按钮(仅编辑时显示)
if (_currentNoteId != null)
title: Text(
_currentNoteId == null ? '新建笔记' : '编辑笔记',
style: TextStyle(
color: isDark ? Colors.white : Colors.black87,
fontWeight: FontWeight.w600,
),
),
actions: [
if (_currentNoteId != null)
IconButton(
icon: Icon(
Icons.delete_outline,
color: isDark ? Colors.red[300] : Colors.red[400],
),
onPressed: _showDeleteDialog,
tooltip: '删除笔记',
),
IconButton(
icon: Icon(Icons.delete_outline, color: Colors.red[400]),
onPressed: _showDeleteDialog,
tooltip: '删除笔记',
icon: Icon(
_isLocked ? Icons.lock : Icons.lock_outline,
color: _isLocked
? AppConstants.primaryColor
: (isDark ? Colors.grey[400] : Colors.grey[600]),
),
onPressed: _showPasswordDialog,
tooltip: _isLocked ? '修改密码' : '设置密码',
),
// 锁定按钮
IconButton(
icon: Icon(
_isLocked ? Icons.lock : Icons.lock_outline,
color: _isLocked ? AppConstants.primaryColor : Colors.grey[600],
IconButton(
icon: Icon(
_isPinned ? Icons.push_pin : Icons.push_pin_outlined,
color: _isPinned
? AppConstants.primaryColor
: (isDark ? Colors.grey[400] : Colors.grey[600]),
),
onPressed: _togglePin,
tooltip: _isPinned ? '取消置顶' : '置顶',
),
onPressed: _showPasswordDialog,
tooltip: _isLocked ? '修改密码' : '设置密码',
),
// 置顶按钮
IconButton(
icon: Icon(
_isPinned ? Icons.push_pin : Icons.push_pin_outlined,
color: _isPinned ? AppConstants.primaryColor : Colors.grey[600],
),
onPressed: _togglePin,
tooltip: _isPinned ? '取消置顶' : '置顶',
),
],
),
body: _isLoading
? const Center(child: CircularProgressIndicator())
: GestureDetector(
onTap: () {
// 点击非输入框区域取消焦点
_titleFocusNode.unfocus();
_contentFocusNode.unfocus();
},
child: Column(
children: [
_buildStatusBar(),
Expanded(
child: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
_buildTitleInput(),
const SizedBox(height: 16),
_buildContentInput(),
],
],
),
body: _isLoading
? Center(
child: CircularProgressIndicator(
color: isDark ? Colors.white : AppConstants.primaryColor,
),
)
: GestureDetector(
onTap: () {
_titleFocusNode.unfocus();
_contentFocusNode.unfocus();
},
child: Column(
children: [
_buildStatusBar(isDark),
Expanded(
child: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
_buildTitleInput(isDark),
const SizedBox(height: 16),
_buildContentInput(isDark),
],
),
),
),
),
],
],
),
),
),
);
);
});
}
Widget _buildStatusBar() {
Widget _buildStatusBar(bool isDark) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
color: Colors.grey[50],
color: isDark ? const Color(0xFF2A2A2A) : Colors.grey[50],
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
// 创建时间
Icon(Icons.add_circle_outline, size: 14, color: Colors.grey[500]),
Icon(
Icons.add_circle_outline,
size: 14,
color: isDark ? Colors.grey[400] : Colors.grey[500],
),
const SizedBox(width: 4),
Text(
_createTime != null ? '创建 ${_formatDate(_createTime!)}' : '新笔记',
style: TextStyle(fontSize: 12, color: Colors.grey[500]),
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.grey[400] : Colors.grey[500],
),
),
const SizedBox(width: 16),
// 保存时间
Icon(Icons.access_time, size: 14, color: Colors.grey[500]),
Icon(
Icons.access_time,
size: 14,
color: isDark ? Colors.grey[400] : Colors.grey[500],
),
const SizedBox(width: 4),
Text(
_lastSavedTime != null
? '保存 ${_formatDateTime(_lastSavedTime!)}'
: '未保存',
style: TextStyle(fontSize: 12, color: Colors.grey[500]),
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.grey[400] : Colors.grey[500],
),
),
const SizedBox(width: 16),
// 字数
Icon(Icons.text_fields, size: 14, color: Colors.grey[500]),
Icon(
Icons.text_fields,
size: 14,
color: isDark ? Colors.grey[400] : Colors.grey[500],
),
const SizedBox(width: 4),
Text(
'$_charCount',
style: TextStyle(fontSize: 12, color: Colors.grey[500]),
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.grey[400] : Colors.grey[500],
),
),
if (_isPinned) ...[
const SizedBox(width: 16),
@@ -740,23 +776,27 @@ class _CollectNotesPageState extends State<CollectNotesPage> {
);
}
Widget _buildTitleInput() {
Widget _buildTitleInput(bool isDark) {
return Row(
children: [
Expanded(
child: Container(
decoration: BoxDecoration(
color: Colors.white,
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: _titleFocusNode.hasFocus
? AppConstants.primaryColor.withValues(alpha: 0.5)
: Colors.grey.withValues(alpha: 0.2),
: (isDark
? Colors.grey[700]!
: Colors.grey.withValues(alpha: 0.2)),
width: 1.5,
),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.05),
color: isDark
? Colors.black.withValues(alpha: 0.2)
: Colors.black.withValues(alpha: 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
@@ -768,23 +808,30 @@ class _CollectNotesPageState extends State<CollectNotesPage> {
maxLines: 1,
decoration: InputDecoration(
hintText: '标题(可选)',
hintStyle: TextStyle(color: Colors.grey[400]),
hintStyle: TextStyle(
color: isDark ? Colors.grey[500] : Colors.grey[400],
),
border: InputBorder.none,
contentPadding: const EdgeInsets.all(16),
),
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: isDark ? Colors.white : Colors.black87,
),
),
),
),
const SizedBox(width: 12),
// 分类选择
Container(
decoration: BoxDecoration(
color: Colors.white,
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.05),
color: isDark
? Colors.black.withValues(alpha: 0.2)
: Colors.black.withValues(alpha: 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
@@ -797,7 +844,6 @@ class _CollectNotesPageState extends State<CollectNotesPage> {
: null,
onSelected: (value) async {
if (value == _customCategoryKey) {
// 弹出自定义分类输入框
await _showCustomCategoryDialog();
} else {
setState(() {
@@ -819,13 +865,17 @@ class _CollectNotesPageState extends State<CollectNotesPage> {
color: AppConstants.primaryColor,
),
if (category == _category) const SizedBox(width: 8),
Text(category),
Text(
category,
style: TextStyle(
color: isDark ? Colors.white : Colors.black87,
),
),
],
),
);
}).toList();
// 添加自定义分类选项
items.add(
PopupMenuItem(
value: _customCategoryKey,
@@ -843,9 +893,18 @@ class _CollectNotesPageState extends State<CollectNotesPage> {
_category != null &&
_category!.isNotEmpty)
const SizedBox(width: 8),
Icon(Icons.edit, size: 16, color: Colors.grey[600]),
Icon(
Icons.edit,
size: 16,
color: isDark ? Colors.grey[400] : Colors.grey[600],
),
const SizedBox(width: 8),
Text('自定义', style: TextStyle(color: Colors.grey[600])),
Text(
'自定义',
style: TextStyle(
color: isDark ? Colors.grey[400] : Colors.grey[600],
),
),
],
),
),
@@ -874,7 +933,7 @@ class _CollectNotesPageState extends State<CollectNotesPage> {
Icon(
Icons.arrow_drop_down,
size: 18,
color: Colors.grey[600],
color: isDark ? Colors.grey[400] : Colors.grey[600],
),
],
),
@@ -885,21 +944,25 @@ class _CollectNotesPageState extends State<CollectNotesPage> {
);
}
Widget _buildContentInput() {
Widget _buildContentInput(bool isDark) {
return Container(
constraints: const BoxConstraints(minHeight: 300),
decoration: BoxDecoration(
color: Colors.white,
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: _contentFocusNode.hasFocus
? AppConstants.primaryColor.withValues(alpha: 0.5)
: Colors.grey.withValues(alpha: 0.2),
: (isDark
? Colors.grey[700]!
: Colors.grey.withValues(alpha: 0.2)),
width: 1.5,
),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.05),
color: isDark
? Colors.black.withValues(alpha: 0.2)
: Colors.black.withValues(alpha: 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
@@ -912,11 +975,17 @@ class _CollectNotesPageState extends State<CollectNotesPage> {
minLines: 12,
decoration: InputDecoration(
hintText: '开始写笔记...',
hintStyle: TextStyle(color: Colors.grey[400]),
hintStyle: TextStyle(
color: isDark ? Colors.grey[500] : Colors.grey[400],
),
border: InputBorder.none,
contentPadding: const EdgeInsets.all(16),
),
style: const TextStyle(fontSize: 16, height: 1.5),
style: TextStyle(
fontSize: 16,
height: 1.5,
color: isDark ? Colors.white : Colors.black87,
),
),
);
}

View File

@@ -3,14 +3,18 @@
/// 介绍: 显示用户点赞的诗词列表,支持删除操作
/// 最新变化: 新增点赞足迹管理功能
library;
import 'dart:async' show StreamSubscription;
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:poes/controllers/history_controller.dart';
import '../../../constants/app_constants.dart';
import '../../../utils/http/poetry_api.dart';
import '../../../services/network_listener_service.dart';
import '../home/home_components.dart';
import '../../../services/get/theme_controller.dart';
import '../home/set/home_components.dart';
/// 点赞足迹页面
class FootprintPage extends StatefulWidget {
@@ -26,6 +30,7 @@ class _FootprintPageState extends State<FootprintPage>
bool _isLoading = false;
String _errorMessage = '';
StreamSubscription<NetworkEvent>? _networkSubscription;
final ThemeController _themeController = Get.find<ThemeController>();
@override
void initState() {
@@ -395,23 +400,30 @@ class _FootprintPageState extends State<FootprintPage>
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey[50],
appBar: AppBar(
title: const Text('点赞足迹'),
backgroundColor: AppConstants.primaryColor,
foregroundColor: Colors.white,
elevation: 0,
),
body: _buildBody(),
);
return Obx(() {
final isDark = _themeController.isDarkMode;
return Scaffold(
backgroundColor: isDark ? const Color(0xFF1A1A1A) : Colors.grey[50],
appBar: AppBar(
title: const Text('点赞足迹'),
backgroundColor: isDark
? const Color(0xFF2A2A2A)
: AppConstants.primaryColor,
foregroundColor: Colors.white,
elevation: 0,
),
body: _buildBody(isDark),
);
});
}
Widget _buildBody() {
Widget _buildBody(bool isDark) {
if (_isLoading) {
return const Center(
return Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(AppConstants.primaryColor),
valueColor: AlwaysStoppedAnimation<Color>(
isDark ? Colors.white : AppConstants.primaryColor,
),
),
);
}
@@ -421,11 +433,18 @@ class _FootprintPageState extends State<FootprintPage>
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.error_outline, size: 64, color: AppConstants.errorColor),
Icon(
Icons.error_outline,
size: 64,
color: isDark ? Colors.red[300] : AppConstants.errorColor,
),
const SizedBox(height: 16),
Text(
_errorMessage,
style: TextStyle(fontSize: 16, color: AppConstants.errorColor),
style: TextStyle(
fontSize: 16,
color: isDark ? Colors.red[300] : AppConstants.errorColor,
),
),
const SizedBox(height: 16),
ElevatedButton(
@@ -446,16 +465,26 @@ class _FootprintPageState extends State<FootprintPage>
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.favorite_border, size: 64, color: Colors.grey[400]),
Icon(
Icons.favorite_border,
size: 64,
color: isDark ? Colors.grey[600] : Colors.grey[400],
),
const SizedBox(height: 16),
Text(
'暂无点赞记录',
style: TextStyle(fontSize: 16, color: Colors.grey[600]),
style: TextStyle(
fontSize: 16,
color: isDark ? Colors.grey[400] : Colors.grey[600],
),
),
const SizedBox(height: 8),
Text(
'去主页点赞喜欢的诗词吧',
style: TextStyle(fontSize: 14, color: Colors.grey[500]),
style: TextStyle(
fontSize: 14,
color: isDark ? Colors.grey[500] : Colors.grey[500],
),
),
],
),
@@ -466,7 +495,6 @@ class _FootprintPageState extends State<FootprintPage>
onRefresh: _loadLikedPoetry,
child: Column(
children: [
// 添加不可点击的刷新按钮
if (_likedPoetryList.isNotEmpty) ...[
Container(
margin: const EdgeInsets.fromLTRB(16, 8, 16, 8),
@@ -475,21 +503,26 @@ class _FootprintPageState extends State<FootprintPage>
Icon(
Icons.refresh,
size: 20,
color: AppConstants.primaryColor,
color: isDark ? Colors.white70 : AppConstants.primaryColor,
),
const SizedBox(width: 8),
Text(
'下拉刷新列表',
style: TextStyle(
fontSize: 14,
color: AppConstants.primaryColor,
color: isDark
? Colors.white70
: AppConstants.primaryColor,
fontWeight: FontWeight.w500,
),
),
const Spacer(),
Text(
'${_likedPoetryList.length} 条记录',
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.grey[400] : Colors.grey[600],
),
),
],
),
@@ -501,7 +534,7 @@ class _FootprintPageState extends State<FootprintPage>
itemCount: _likedPoetryList.length,
itemBuilder: (context, index) {
final poetry = _likedPoetryList[index];
return _buildLikedPoetryCard(poetry);
return _buildLikedPoetryCard(poetry, isDark);
},
),
),
@@ -510,15 +543,17 @@ class _FootprintPageState extends State<FootprintPage>
);
}
Widget _buildLikedPoetryCard(PoetryData poetry) {
Widget _buildLikedPoetryCard(PoetryData poetry, bool isDark) {
return Container(
margin: const EdgeInsets.only(bottom: 16),
decoration: BoxDecoration(
color: Colors.white,
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.05),
color: isDark
? Colors.black.withValues(alpha: 0.2)
: Colors.black.withValues(alpha: 0.05),
blurRadius: 8,
offset: const Offset(0, 2),
),
@@ -527,15 +562,14 @@ class _FootprintPageState extends State<FootprintPage>
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// URL字段 (出处)
Padding(
padding: const EdgeInsets.fromLTRB(16, 16, 16, 8),
child: Text(
"出处: ${poetry.url}",
style: const TextStyle(
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.normal,
color: Colors.black,
color: isDark ? Colors.grey[400] : Colors.black,
fontStyle: FontStyle.italic,
),
overflow: TextOverflow.ellipsis,
@@ -543,7 +577,6 @@ class _FootprintPageState extends State<FootprintPage>
),
),
// Name字段 (精选诗句) - 与主页样式一致
Container(
width: double.infinity,
padding: const EdgeInsets.all(16),
@@ -596,10 +629,10 @@ class _FootprintPageState extends State<FootprintPage>
const SizedBox(height: 8),
Text(
poetry.name,
style: const TextStyle(
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Colors.black87,
color: isDark ? Colors.white : Colors.black87,
height: 1.4,
),
textAlign: TextAlign.center,
@@ -608,7 +641,6 @@ class _FootprintPageState extends State<FootprintPage>
),
),
// drtime字段 (原文)
if (poetry.drtime.isNotEmpty) ...[
const SizedBox(height: 12),
Padding(
@@ -617,15 +649,15 @@ class _FootprintPageState extends State<FootprintPage>
width: double.infinity,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: const Color(0xFFF8F8F8),
color: isDark ? Colors.grey[800] : const Color(0xFFF8F8F8),
borderRadius: BorderRadius.circular(8),
),
child: Text(
poetry.drtime,
style: const TextStyle(
style: TextStyle(
fontSize: 14,
height: 1.6,
color: Colors.black87,
color: isDark ? Colors.grey[300] : Colors.black87,
),
maxLines: 3,
overflow: TextOverflow.ellipsis,
@@ -634,7 +666,6 @@ class _FootprintPageState extends State<FootprintPage>
),
],
// 操作按钮
Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
child: Row(
@@ -645,8 +676,14 @@ class _FootprintPageState extends State<FootprintPage>
icon: const Icon(Icons.favorite_border, size: 18),
label: const Text('取消点赞'),
style: OutlinedButton.styleFrom(
foregroundColor: AppConstants.errorColor,
side: BorderSide(color: AppConstants.errorColor),
foregroundColor: isDark
? Colors.red[300]
: AppConstants.errorColor,
side: BorderSide(
color: isDark
? Colors.red[300]!
: AppConstants.errorColor,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),

View File

@@ -1,7 +1,7 @@
/// 时间: 2025-03-22
/// 功能: 点赞诗词管理器
/// 介绍: 管理点赞诗词的加载、显示、删除等操作
/// 最新变化: 从FavoritesPage分离出来的点赞管理逻辑
/// 最新变化: 从FavoritesPage分离出来的点赞管理逻辑,添加底部内边距适配液态玻璃导航栏
library liked_poetry_manager;
@@ -10,10 +10,11 @@ import 'dart:async' show StreamSubscription;
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import '../../../constants/app_constants.dart';
import '../../../config/app_config.dart';
import '../../../controllers/history_controller.dart';
import '../../../utils/http/poetry_api.dart';
import '../../../services/network_listener_service.dart';
import '../home/home_components.dart';
import '../home/set/home_components.dart';
/// 点赞诗词管理器
class LikedPoetryManager extends StatefulWidget {
@@ -453,7 +454,13 @@ class _LikedPoetryManagerState extends State<LikedPoetryManager>
return RefreshIndicator(
onRefresh: _loadLikedPoetry,
child: ListView.builder(
padding: const EdgeInsets.all(16),
// 添加底部内边距,让内容延伸到导航栏下方,实现玻璃效果
padding: EdgeInsets.only(
left: 16,
right: 16,
top: 16,
bottom: AppConfig.liquidGlassTotalHeight + 16,
),
itemCount: _likedPoetryList.length + 1,
itemBuilder: (context, index) {
if (index == _likedPoetryList.length) {

View File

@@ -2,10 +2,13 @@ import 'dart:async';
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';
import '../../services/network_listener_service.dart';
import '../../services/get/theme_controller.dart';
/// 时间: 2026-03-26
/// 功能: 本地笔记列表组件
@@ -23,6 +26,7 @@ class _LocalNotesListState extends State<LocalNotesList> {
List<Map<String, dynamic>> _notes = [];
bool _isLoadingNotes = false;
StreamSubscription<NetworkEvent>? _networkSubscription;
final ThemeController _themeController = Get.find<ThemeController>();
@override
void initState() {
@@ -72,71 +76,107 @@ class _LocalNotesListState extends State<LocalNotesList> {
@override
Widget build(BuildContext context) {
if (_isLoadingNotes && _notes.isEmpty) {
return const Center(child: CircularProgressIndicator());
}
return Obx(() {
final isDark = _themeController.isDarkMode;
if (_notes.isEmpty) {
return _buildEmptyNotes();
}
if (_isLoadingNotes && _notes.isEmpty) {
return Center(
child: CircularProgressIndicator(
color: isDark ? Colors.white : AppConstants.primaryColor,
),
);
}
return RefreshIndicator(
onRefresh: _loadNotes,
child: ListView.builder(
padding: const EdgeInsets.fromLTRB(16, 16, 16, 80),
itemCount: _notes.length + 1,
itemBuilder: (context, index) {
if (index == _notes.length) {
return _buildBottomIndicator();
}
final note = _notes[index];
return _buildNoteCard(note);
},
),
);
if (_notes.isEmpty) {
return _buildEmptyNotes(isDark);
}
return RefreshIndicator(
onRefresh: _loadNotes,
child: ListView.builder(
// 添加底部内边距,让内容延伸到导航栏下方,实现玻璃效果
padding: EdgeInsets.fromLTRB(
16,
16,
16,
AppConfig.liquidGlassTotalHeight + 16,
),
itemCount: _notes.length + 1,
itemBuilder: (context, index) {
if (index == _notes.length) {
return _buildBottomIndicator(isDark);
}
final note = _notes[index];
return _buildNoteCard(note, isDark);
},
),
);
});
}
Widget _buildBottomIndicator() {
Widget _buildBottomIndicator(bool isDark) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 24),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(width: 40, height: 1, color: Colors.grey[300]),
Container(
width: 40,
height: 1,
color: isDark ? Colors.grey[700] : Colors.grey[300],
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
'到底了',
style: TextStyle(fontSize: 12, color: Colors.grey[400]),
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.grey[500] : Colors.grey[400],
),
),
),
Container(width: 40, height: 1, color: Colors.grey[300]),
Container(
width: 40,
height: 1,
color: isDark ? Colors.grey[700] : Colors.grey[300],
),
],
),
);
}
// 构建空笔记状态
Widget _buildEmptyNotes() {
Widget _buildEmptyNotes(bool isDark) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.note_add_outlined, size: 64, color: Colors.grey[400]),
Icon(
Icons.note_add_outlined,
size: 64,
color: isDark ? Colors.grey[600] : Colors.grey[400],
),
const SizedBox(height: 16),
Text('暂无笔记', style: TextStyle(fontSize: 16, color: Colors.grey[600])),
Text(
'暂无笔记',
style: TextStyle(
fontSize: 16,
color: isDark ? Colors.grey[400] : Colors.grey[600],
),
),
const SizedBox(height: 8),
Text(
'点击右下角按钮创建新笔记',
style: TextStyle(fontSize: 14, color: Colors.grey[500]),
style: TextStyle(
fontSize: 14,
color: isDark ? Colors.grey[500] : Colors.grey[500],
),
),
],
),
);
}
// 构建笔记卡片
Widget _buildNoteCard(Map<String, dynamic> note) {
Widget _buildNoteCard(Map<String, dynamic> note, bool isDark) {
final title = note['title'] as String? ?? '';
final content = note['content'] as String? ?? '';
final timeStr = note['time'] as String? ?? '';
@@ -145,7 +185,6 @@ class _LocalNotesListState extends State<LocalNotesList> {
final isPinned = note['isPinned'] == true;
final isLocked = note['isLocked'] == true;
// 显示逻辑:有标题显示标题,无标题有分类显示分类,否则显示内容
String displayText;
bool hasTitle = title.isNotEmpty;
bool hasCategory = category.isNotEmpty && category != '未分类';
@@ -161,16 +200,20 @@ class _LocalNotesListState extends State<LocalNotesList> {
return Container(
margin: const EdgeInsets.only(bottom: 16),
decoration: BoxDecoration(
color: Colors.white,
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.08),
color: isDark
? Colors.black.withValues(alpha: 0.3)
: Colors.black.withValues(alpha: 0.08),
blurRadius: 12,
offset: const Offset(0, 4),
),
BoxShadow(
color: Colors.black.withValues(alpha: 0.04),
color: isDark
? Colors.black.withValues(alpha: 0.2)
: Colors.black.withValues(alpha: 0.04),
blurRadius: 6,
offset: const Offset(0, 2),
),
@@ -180,7 +223,6 @@ class _LocalNotesListState extends State<LocalNotesList> {
borderRadius: BorderRadius.circular(12),
child: Stack(
children: [
// 原始内容
InkWell(
onTap: () => _handleNoteTap(note, isLocked),
borderRadius: BorderRadius.circular(12),
@@ -189,42 +231,40 @@ class _LocalNotesListState extends State<LocalNotesList> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 顶部:创建时间、保存时间和置顶/锁定按钮
Row(
children: [
// 创建时间
if (createTimeStr.isNotEmpty) ...[
Icon(
Icons.add_circle_outline,
size: 12,
color: Colors.grey[400],
color: isDark ? Colors.grey[500] : Colors.grey[400],
),
const SizedBox(width: 2),
Text(
_formatDate(createTimeStr),
style: TextStyle(
fontSize: 10,
color: Colors.grey[400],
color: isDark
? Colors.grey[500]
: Colors.grey[400],
),
),
const SizedBox(width: 8),
],
// 保存时间
Icon(
Icons.access_time,
size: 12,
color: Colors.grey[400],
color: isDark ? Colors.grey[500] : Colors.grey[400],
),
const SizedBox(width: 2),
Text(
_formatDateTime(timeStr),
style: TextStyle(
fontSize: 10,
color: Colors.grey[400],
color: isDark ? Colors.grey[500] : Colors.grey[400],
),
),
const Spacer(),
// 分类标签
if (hasCategory)
Container(
padding: const EdgeInsets.symmetric(
@@ -246,7 +286,6 @@ class _LocalNotesListState extends State<LocalNotesList> {
),
),
if (hasCategory) const SizedBox(width: 8),
// 锁定图标
if (isLocked)
Container(
padding: const EdgeInsets.all(4),
@@ -256,7 +295,6 @@ class _LocalNotesListState extends State<LocalNotesList> {
color: AppConstants.primaryColor,
),
),
// 置顶按钮
GestureDetector(
onTap: () => _togglePin(note['id'] as String?),
child: Container(
@@ -268,14 +306,15 @@ class _LocalNotesListState extends State<LocalNotesList> {
size: 16,
color: isPinned
? AppConstants.primaryColor
: Colors.grey[400],
: (isDark
? Colors.grey[500]
: Colors.grey[400]),
),
),
),
],
),
const SizedBox(height: 12),
// 标题或内容
Text(
displayText,
style: TextStyle(
@@ -283,13 +322,12 @@ class _LocalNotesListState extends State<LocalNotesList> {
fontWeight: hasTitle
? FontWeight.w600
: FontWeight.normal,
color: Colors.black87,
color: isDark ? Colors.white : Colors.black87,
height: 1.5,
),
maxLines: 3,
overflow: TextOverflow.ellipsis,
),
// 底部:字数和删除按钮
const SizedBox(height: 12),
Row(
children: [
@@ -297,11 +335,10 @@ class _LocalNotesListState extends State<LocalNotesList> {
'${note['charCount'] ?? displayText.length}',
style: TextStyle(
fontSize: 12,
color: Colors.grey[400],
color: isDark ? Colors.grey[500] : Colors.grey[400],
),
),
const Spacer(),
// 删除按钮
GestureDetector(
onTap: () =>
_showDeleteNoteDialog(note['id'] as String?),
@@ -310,7 +347,9 @@ class _LocalNotesListState extends State<LocalNotesList> {
child: Icon(
Icons.delete_outline,
size: 18,
color: Colors.grey[400],
color: isDark
? Colors.grey[500]
: Colors.grey[400],
),
),
),
@@ -320,7 +359,6 @@ class _LocalNotesListState extends State<LocalNotesList> {
),
),
),
// 锁定时的毛玻璃遮罩
if (isLocked)
Positioned.fill(
child: GestureDetector(
@@ -330,29 +368,32 @@ class _LocalNotesListState extends State<LocalNotesList> {
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 8, sigmaY: 8),
child: Container(
color: Colors.white.withValues(alpha: 0.3),
color: (isDark ? Colors.black : Colors.white)
.withValues(alpha: 0.3),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
children: [
// 顶部时间信息
Row(
children: [
Icon(
Icons.access_time,
size: 12,
color: Colors.grey[600],
color: isDark
? Colors.grey[400]
: Colors.grey[600],
),
const SizedBox(width: 4),
Text(
_formatDateTime(timeStr),
style: TextStyle(
fontSize: 10,
color: Colors.grey[600],
color: isDark
? Colors.grey[400]
: Colors.grey[600],
),
),
const Spacer(),
// 删除按钮
GestureDetector(
onTap: () => _showDeleteNoteDialog(
note['id'] as String?,
@@ -362,14 +403,15 @@ class _LocalNotesListState extends State<LocalNotesList> {
child: Icon(
Icons.delete_outline,
size: 16,
color: Colors.grey[600],
color: isDark
? Colors.grey[400]
: Colors.grey[600],
),
),
),
],
),
const Spacer(),
// 中间锁定图标(左右结构)
Row(
mainAxisSize: MainAxisSize.min,
children: [
@@ -397,7 +439,9 @@ class _LocalNotesListState extends State<LocalNotesList> {
'点击输入密码访问',
style: TextStyle(
fontSize: 12,
color: Colors.grey[600],
color: isDark
? Colors.grey[400]
: Colors.grey[600],
),
),
],
@@ -405,14 +449,15 @@ class _LocalNotesListState extends State<LocalNotesList> {
],
),
const Spacer(),
// 底部字数
Row(
children: [
Text(
'${note['charCount'] ?? displayText.length}',
style: TextStyle(
fontSize: 10,
color: Colors.grey[600],
color: isDark
? Colors.grey[400]
: Colors.grey[600],
),
),
],