关怀模式
This commit is contained in:
@@ -4,8 +4,10 @@
|
||||
/// 最新变化: 2026-04-02 支持深色模式
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../../constants/app_constants.dart';
|
||||
import '../../../services/get/theme_controller.dart';
|
||||
import '../../../utils/http/poetry_api.dart';
|
||||
import '../../../utils/audio_manager.dart';
|
||||
import 'set/home_components.dart';
|
||||
@@ -106,6 +108,8 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isDark = widget.isDark;
|
||||
final themeController = Get.find<ThemeController>();
|
||||
final themeColor = themeController.currentThemeColor;
|
||||
final card = GestureDetector(
|
||||
onTap: () {
|
||||
AudioManager().playClickSound();
|
||||
@@ -129,16 +133,16 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_buildTimeBar(isDark),
|
||||
_buildTimeBar(isDark, themeColor),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_buildTitleSection(isDark),
|
||||
_buildTitleSection(isDark, themeColor),
|
||||
if (widget.poetryData.drtime.isNotEmpty) ...[
|
||||
_buildContentSection(context, isDark),
|
||||
_buildContentSection(context, isDark, themeColor),
|
||||
const SizedBox(height: 3),
|
||||
],
|
||||
Align(
|
||||
@@ -157,27 +161,27 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppConstants.primaryColor,
|
||||
color: themeColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
Icons.format_quote,
|
||||
color: AppConstants.primaryColor,
|
||||
color: themeColor,
|
||||
size: 14,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildNameSection(isDark),
|
||||
_buildNameSection(isDark, themeColor),
|
||||
const SizedBox(height: 12),
|
||||
if (widget.keywordList.isNotEmpty) ...[
|
||||
_buildKeywordSection(isDark),
|
||||
_buildKeywordSection(isDark, themeColor),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
if (widget.poetryData.introduce.isNotEmpty) ...[
|
||||
_buildIntroductionSection(context, isDark),
|
||||
_buildIntroductionSection(context, isDark, themeColor),
|
||||
],
|
||||
],
|
||||
),
|
||||
@@ -185,7 +189,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
],
|
||||
),
|
||||
),
|
||||
_buildCopyTip(isDark),
|
||||
_buildCopyTip(isDark, themeColor),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -196,7 +200,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
return card;
|
||||
}
|
||||
|
||||
Widget _buildTimeBar(bool isDark) {
|
||||
Widget _buildTimeBar(bool isDark, Color themeColor) {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
@@ -209,10 +213,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
AppConstants.primaryColor.withAlpha(204),
|
||||
AppConstants.primaryColor,
|
||||
],
|
||||
colors: [themeColor.withAlpha(204), themeColor],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
@@ -251,7 +252,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCopyTip(bool isDark) {
|
||||
Widget _buildCopyTip(bool isDark, Color themeColor) {
|
||||
if (!_globalTipsEnabled || !_showCopyTip) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
@@ -264,11 +265,11 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: AppConstants.primaryColor,
|
||||
color: themeColor,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppConstants.primaryColor.withAlpha(76),
|
||||
color: themeColor.withAlpha(76),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
@@ -296,7 +297,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTitleSection(bool isDark) {
|
||||
Widget _buildTitleSection(bool isDark, Color themeColor) {
|
||||
final isLoading = widget.sectionLoadingStates?['title'] ?? false;
|
||||
|
||||
return SizedBox(
|
||||
@@ -321,7 +322,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
AppConstants.primaryColor,
|
||||
themeColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -357,7 +358,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildNameSection(bool isDark) {
|
||||
Widget _buildNameSection(bool isDark, Color themeColor) {
|
||||
final isLoading = widget.sectionLoadingStates?['name'] ?? false;
|
||||
|
||||
return Container(
|
||||
@@ -368,25 +369,20 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
gradient: LinearGradient(
|
||||
colors: isDark
|
||||
? [const Color(0xFF2A2A2A), const Color(0xFF252525)]
|
||||
: [
|
||||
AppConstants.primaryColor.withAlpha(26),
|
||||
AppConstants.primaryColor.withAlpha(13),
|
||||
],
|
||||
: [themeColor.withAlpha(26), themeColor.withAlpha(13)],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: isDark
|
||||
? Colors.grey[700]!
|
||||
: AppConstants.primaryColor.withAlpha(51),
|
||||
color: isDark ? Colors.grey[700]! : themeColor.withAlpha(51),
|
||||
width: 1,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: isDark
|
||||
? Colors.black.withAlpha(40)
|
||||
: AppConstants.primaryColor.withAlpha(26),
|
||||
: themeColor.withAlpha(26),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
@@ -412,7 +408,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
AppConstants.primaryColor,
|
||||
themeColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -456,7 +452,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
return text;
|
||||
}
|
||||
|
||||
Widget _buildKeywordSection(bool isDark) {
|
||||
Widget _buildKeywordSection(bool isDark, Color themeColor) {
|
||||
final isLoading = widget.sectionLoadingStates?['keywords'] ?? false;
|
||||
|
||||
return Column(
|
||||
@@ -475,7 +471,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
AppConstants.primaryColor,
|
||||
themeColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -513,18 +509,14 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: isDark
|
||||
? AppConstants.secondaryColor.withAlpha(
|
||||
40,
|
||||
)
|
||||
: AppConstants.secondaryColor.withAlpha(
|
||||
26,
|
||||
),
|
||||
? themeColor.withAlpha(40)
|
||||
: themeColor.withAlpha(26),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
keyword,
|
||||
style: TextStyle(
|
||||
color: AppConstants.secondaryColor,
|
||||
color: themeColor,
|
||||
fontSize: 12,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
@@ -550,14 +542,14 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: isDark
|
||||
? AppConstants.primaryColor.withAlpha(40)
|
||||
: AppConstants.primaryColor.withAlpha(26),
|
||||
? themeColor.withAlpha(40)
|
||||
: themeColor.withAlpha(26),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
widget.poetryData.alias,
|
||||
style: TextStyle(
|
||||
color: AppConstants.primaryColor,
|
||||
color: themeColor,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
@@ -604,7 +596,11 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildContentSection(BuildContext context, bool isDark) {
|
||||
Widget _buildContentSection(
|
||||
BuildContext context,
|
||||
bool isDark,
|
||||
Color themeColor,
|
||||
) {
|
||||
final isLoading = widget.sectionLoadingStates?['content'] ?? false;
|
||||
|
||||
return Builder(
|
||||
@@ -622,7 +618,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
decoration: BoxDecoration(
|
||||
color: isDark
|
||||
? Colors.grey[800]!.withAlpha(80)
|
||||
: AppConstants.primaryColor.withAlpha(20),
|
||||
: themeColor.withAlpha(20),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: isLoading
|
||||
@@ -635,9 +631,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
AppConstants.primaryColor,
|
||||
),
|
||||
valueColor: AlwaysStoppedAnimation<Color>(themeColor),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
@@ -659,9 +653,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: isDark
|
||||
? Colors.grey[300]
|
||||
: AppConstants.primaryColor,
|
||||
color: isDark ? Colors.grey[300] : themeColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
@@ -680,7 +672,11 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildIntroductionSection(BuildContext context, bool isDark) {
|
||||
Widget _buildIntroductionSection(
|
||||
BuildContext context,
|
||||
bool isDark,
|
||||
Color themeColor,
|
||||
) {
|
||||
final isLoading = widget.sectionLoadingStates?['introduction'] ?? false;
|
||||
|
||||
return Builder(
|
||||
@@ -710,9 +706,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
AppConstants.primaryColor,
|
||||
),
|
||||
valueColor: AlwaysStoppedAnimation<Color>(themeColor),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
Reference in New Issue
Block a user