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

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,
),
),