深色模式、首页设置页面和功能优化
This commit is contained in:
@@ -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),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user