关怀模式
This commit is contained in:
@@ -14,6 +14,8 @@ import '../../../config/app_config.dart';
|
||||
import '../../../controllers/history_controller.dart';
|
||||
import '../../../utils/http/poetry_api.dart';
|
||||
import '../../../services/network_listener_service.dart';
|
||||
import '../../../services/get/theme_controller.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../home/set/home_components.dart';
|
||||
|
||||
/// 点赞诗词管理器
|
||||
@@ -295,6 +297,7 @@ class _LikedPoetryManagerState extends State<LikedPoetryManager>
|
||||
bool _isLoading = false;
|
||||
String _errorMessage = '';
|
||||
StreamSubscription<NetworkEvent>? _networkSubscription;
|
||||
final ThemeController _themeController = Get.find<ThemeController>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -393,14 +396,21 @@ class _LikedPoetryManagerState extends State<LikedPoetryManager>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return _buildLikedPoetryList();
|
||||
return Obx(() {
|
||||
return _buildLikedPoetryList();
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildLikedPoetryList() {
|
||||
final themeColor = _themeController.currentThemeColor;
|
||||
final isDark = _themeController.isDarkMode;
|
||||
|
||||
if (_isLoading) {
|
||||
return const Center(
|
||||
return Center(
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: AlwaysStoppedAnimation<Color>(AppConstants.primaryColor),
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
isDark ? Colors.white : themeColor,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -420,7 +430,7 @@ class _LikedPoetryManagerState extends State<LikedPoetryManager>
|
||||
ElevatedButton(
|
||||
onPressed: _loadLikedPoetry,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppConstants.primaryColor,
|
||||
backgroundColor: themeColor,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
child: const Text('重试'),
|
||||
@@ -435,16 +445,26 @@ class _LikedPoetryManagerState extends State<LikedPoetryManager>
|
||||
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],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -464,44 +484,61 @@ class _LikedPoetryManagerState extends State<LikedPoetryManager>
|
||||
itemCount: _likedPoetryList.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == _likedPoetryList.length) {
|
||||
return _buildBottomIndicator();
|
||||
return _buildBottomIndicator(isDark);
|
||||
}
|
||||
final poetry = _likedPoetryList[index];
|
||||
return _buildLikedPoetryCard(poetry);
|
||||
return _buildLikedPoetryCard(poetry, themeColor, 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 _buildLikedPoetryCard(PoetryData poetry) {
|
||||
Widget _buildLikedPoetryCard(
|
||||
PoetryData poetry,
|
||||
Color themeColor,
|
||||
bool isDark,
|
||||
) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.03),
|
||||
color: isDark
|
||||
? Colors.black.withValues(alpha: 0.3)
|
||||
: Colors.black.withValues(alpha: 0.03),
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 1),
|
||||
),
|
||||
@@ -519,15 +556,15 @@ class _LikedPoetryManagerState extends State<LikedPoetryManager>
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
AppConstants.primaryColor.withValues(alpha: 0.1),
|
||||
AppConstants.primaryColor.withValues(alpha: 0.05),
|
||||
themeColor.withValues(alpha: 0.1),
|
||||
themeColor.withValues(alpha: 0.05),
|
||||
],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
border: Border.all(
|
||||
color: AppConstants.primaryColor.withValues(alpha: 0.2),
|
||||
color: themeColor.withValues(alpha: 0.2),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
@@ -537,18 +574,14 @@ class _LikedPoetryManagerState extends State<LikedPoetryManager>
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.format_quote,
|
||||
color: AppConstants.primaryColor,
|
||||
size: 14,
|
||||
),
|
||||
Icon(Icons.format_quote, color: themeColor, size: 14),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'精选诗句',
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppConstants.primaryColor,
|
||||
color: themeColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -556,10 +589,10 @@ class _LikedPoetryManagerState extends State<LikedPoetryManager>
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
poetry.name,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87,
|
||||
color: isDark ? Colors.white : Colors.black87,
|
||||
height: 1.2,
|
||||
),
|
||||
),
|
||||
@@ -573,7 +606,10 @@ class _LikedPoetryManagerState extends State<LikedPoetryManager>
|
||||
padding: const EdgeInsets.fromLTRB(8, 4, 8, 2),
|
||||
child: Text(
|
||||
"出处:${poetry.url}",
|
||||
style: TextStyle(fontSize: 11, color: Colors.grey[600]),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[600],
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
@@ -613,7 +649,7 @@ class _LikedPoetryManagerState extends State<LikedPoetryManager>
|
||||
icon: const Icon(Icons.visibility, size: 14),
|
||||
label: const Text('查看详情', style: TextStyle(fontSize: 12)),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppConstants.primaryColor,
|
||||
backgroundColor: themeColor,
|
||||
foregroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
|
||||
Reference in New Issue
Block a user