细节优化
This commit is contained in:
@@ -141,8 +141,38 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
_buildTitleSection(),
|
||||
if (widget.poetryData.drtime.isNotEmpty) ...[
|
||||
_buildContentSection(context),
|
||||
const SizedBox(height: 16),
|
||||
const SizedBox(height: 3),
|
||||
],
|
||||
// 精选诗句标签 - 放在缝隙位置
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Container(
|
||||
margin: EdgeInsets.zero,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 2,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'精选诗句',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppConstants.primaryColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
Icons.format_quote,
|
||||
color: AppConstants.primaryColor,
|
||||
size: 14,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildNameSection(),
|
||||
const SizedBox(height: 12),
|
||||
if (widget.keywordList.isNotEmpty) ...[
|
||||
@@ -333,7 +363,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(16),
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
margin: EdgeInsets.zero,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
@@ -359,27 +389,6 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.format_quote,
|
||||
color: AppConstants.primaryColor,
|
||||
size: 20,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'精选诗句',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppConstants.primaryColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
GestureDetector(
|
||||
onLongPress: () =>
|
||||
CopyUtils.showCopyDialog(context, widget.poetryData.name, '诗词'),
|
||||
@@ -409,7 +418,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
widget.poetryData.name,
|
||||
_formatPoetryText(widget.poetryData.name),
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -424,6 +433,22 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
);
|
||||
}
|
||||
|
||||
String _formatPoetryText(String text) {
|
||||
// 检查文本长度(文字+符号)
|
||||
if (text.length < 10) {
|
||||
return text; // 小于10个字,不换行
|
||||
}
|
||||
|
||||
// 找到第一个逗号的位置
|
||||
final commaIndex = text.indexOf(',');
|
||||
if (commaIndex != -1) {
|
||||
// 在第一个逗号处添加换行
|
||||
return text.replaceFirst(',', ',\n');
|
||||
}
|
||||
|
||||
return text; // 没有逗号,保持原样
|
||||
}
|
||||
|
||||
Widget _buildKeywordSection() {
|
||||
final isLoading = widget.sectionLoadingStates?['keywords'] ?? false;
|
||||
|
||||
@@ -441,7 +466,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
height: 8,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
@@ -449,7 +474,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'关键词加载中...',
|
||||
style: TextStyle(
|
||||
|
||||
Reference in New Issue
Block a user