首页3个tab视频快速切换index边界问题修复
This commit is contained in:
parent
2ba610ca7f
commit
6291dbc55d
@ -1294,61 +1294,68 @@ class _AttentionModuleState extends State<AttentionModule> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
if (videoModuleController.videoPlayIndex.value < videoList.length)
|
||||
Text(
|
||||
'@${videoList[videoModuleController.videoPlayIndex.value]['nickname'] ?? '未知'}',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 16.0),
|
||||
),
|
||||
LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final text = videoList[videoModuleController.videoPlayIndex.value]['title'] ?? '未知';
|
||||
final span = TextSpan(
|
||||
text: text,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14.0),
|
||||
);
|
||||
final tp = TextPainter(
|
||||
text: span,
|
||||
maxLines: 3,
|
||||
textDirection: TextDirection.ltr,
|
||||
);
|
||||
tp.layout(maxWidth: constraints.maxWidth);
|
||||
final isOverflow = tp.didExceedMaxLines;
|
||||
) else
|
||||
Text(
|
||||
'@未知',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 16.0),
|
||||
),
|
||||
if (videoModuleController.videoPlayIndex.value < videoList.length)
|
||||
LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final text = videoList[videoModuleController.videoPlayIndex.value]['title'] ?? '未知';
|
||||
final span = TextSpan(
|
||||
text: text,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14.0),
|
||||
);
|
||||
final tp = TextPainter(
|
||||
text: span,
|
||||
maxLines: 3,
|
||||
textDirection: TextDirection.ltr,
|
||||
);
|
||||
tp.layout(maxWidth: constraints.maxWidth);
|
||||
final isOverflow = tp.didExceedMaxLines;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
text,
|
||||
maxLines: videoList[videoModuleController.videoPlayIndex.value]['expanded'] ? null : 3,
|
||||
overflow: videoList[videoModuleController.videoPlayIndex.value]['expanded']
|
||||
? TextOverflow.visible
|
||||
: TextOverflow.ellipsis,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14.0),
|
||||
),
|
||||
if (isOverflow)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6.0),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
videoList[videoModuleController.videoPlayIndex.value]['expanded'] =
|
||||
!videoList[videoModuleController.videoPlayIndex.value]['expanded'];
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
videoList[videoModuleController.videoPlayIndex.value]['expanded'] ? '收起' : '展开更多',
|
||||
textAlign: TextAlign.right,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
text,
|
||||
maxLines: videoList[videoModuleController.videoPlayIndex.value]['expanded'] ? null : 3,
|
||||
overflow: videoList[videoModuleController.videoPlayIndex.value]['expanded']
|
||||
? TextOverflow.visible
|
||||
: TextOverflow.ellipsis,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14.0),
|
||||
),
|
||||
if (isOverflow)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6.0),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
videoList[videoModuleController.videoPlayIndex.value]['expanded'] =
|
||||
!videoList[videoModuleController.videoPlayIndex.value]['expanded'];
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
videoList[videoModuleController.videoPlayIndex.value]['expanded'] ? '收起' : '展开更多',
|
||||
textAlign: TextAlign.right,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
)else
|
||||
SizedBox()
|
||||
],
|
||||
)),
|
||||
Positioned(
|
||||
|
@ -1299,61 +1299,70 @@ class _FriendModuleState extends State<FriendModule> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'@${videoList[videoModuleController.videoPlayIndex.value]['nickname'] ?? '未知'}',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 16.0),
|
||||
),
|
||||
LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final text = videoList[videoModuleController.videoPlayIndex.value]['title'] ?? '未知';
|
||||
final span = TextSpan(
|
||||
text: text,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14.0),
|
||||
);
|
||||
final tp = TextPainter(
|
||||
text: span,
|
||||
maxLines: 3,
|
||||
textDirection: TextDirection.ltr,
|
||||
);
|
||||
tp.layout(maxWidth: constraints.maxWidth);
|
||||
final isOverflow = tp.didExceedMaxLines;
|
||||
if (videoModuleController.videoPlayIndex.value < videoList.length)
|
||||
Text(
|
||||
'@${videoList[videoModuleController.videoPlayIndex.value]['nickname'] ?? '未知'}',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 16.0),
|
||||
)
|
||||
else
|
||||
Text(
|
||||
'@未知',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 16.0),
|
||||
),
|
||||
// 对下面的 LayoutBuilder 也需要同样的检查
|
||||
if (videoModuleController.videoPlayIndex.value < videoList.length)
|
||||
LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final text = videoList[videoModuleController.videoPlayIndex.value]['title'] ?? '未知';
|
||||
final span = TextSpan(
|
||||
text: text,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14.0),
|
||||
);
|
||||
final tp = TextPainter(
|
||||
text: span,
|
||||
maxLines: 3,
|
||||
textDirection: TextDirection.ltr,
|
||||
);
|
||||
tp.layout(maxWidth: constraints.maxWidth);
|
||||
final isOverflow = tp.didExceedMaxLines;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
text,
|
||||
maxLines: videoList[videoModuleController.videoPlayIndex.value]['expanded'] ? null : 3,
|
||||
overflow: videoList[videoModuleController.videoPlayIndex.value]['expanded']
|
||||
? TextOverflow.visible
|
||||
: TextOverflow.ellipsis,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14.0),
|
||||
),
|
||||
if (isOverflow)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6.0),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
videoList[videoModuleController.videoPlayIndex.value]['expanded'] =
|
||||
!videoList[videoModuleController.videoPlayIndex.value]['expanded'];
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
videoList[videoModuleController.videoPlayIndex.value]['expanded'] ? '收起' : '展开更多',
|
||||
textAlign: TextAlign.right,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
text,
|
||||
maxLines: videoList[videoModuleController.videoPlayIndex.value]['expanded'] ? null : 3,
|
||||
overflow: videoList[videoModuleController.videoPlayIndex.value]['expanded']
|
||||
? TextOverflow.visible
|
||||
: TextOverflow.ellipsis,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14.0),
|
||||
),
|
||||
if (isOverflow)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6.0),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
videoList[videoModuleController.videoPlayIndex.value]['expanded'] =
|
||||
!videoList[videoModuleController.videoPlayIndex.value]['expanded'];
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
videoList[videoModuleController.videoPlayIndex.value]['expanded'] ? '收起' : '展开更多',
|
||||
textAlign: TextAlign.right,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
)else
|
||||
SizedBox()
|
||||
],
|
||||
)),
|
||||
Positioned(
|
||||
|
@ -1300,60 +1300,67 @@ class _RecommendModuleState extends State<RecommendModule> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'@${videoList[videoModuleController.videoPlayIndex.value]['nickname'] ?? '未知'}',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 16.0),
|
||||
),
|
||||
LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final text = videoList[videoModuleController.videoPlayIndex.value]['title'] ?? '未知';
|
||||
final span = TextSpan(
|
||||
text: text,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14.0),
|
||||
);
|
||||
final tp = TextPainter(
|
||||
text: span,
|
||||
maxLines: 3,
|
||||
textDirection: TextDirection.ltr,
|
||||
);
|
||||
tp.layout(maxWidth: constraints.maxWidth);
|
||||
final isOverflow = tp.didExceedMaxLines;
|
||||
if (videoModuleController.videoPlayIndex.value < videoList.length)
|
||||
Text(
|
||||
'@${videoList[videoModuleController.videoPlayIndex.value]['nickname'] ?? '未知'}',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 16.0),
|
||||
) else
|
||||
Text(
|
||||
'@未知',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 16.0),
|
||||
),
|
||||
if (videoModuleController.videoPlayIndex.value < videoList.length)
|
||||
LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final text = videoList[videoModuleController.videoPlayIndex.value]['title'] ?? '未知';
|
||||
final span = TextSpan(
|
||||
text: text,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14.0),
|
||||
);
|
||||
final tp = TextPainter(
|
||||
text: span,
|
||||
maxLines: 3,
|
||||
textDirection: TextDirection.ltr,
|
||||
);
|
||||
tp.layout(maxWidth: constraints.maxWidth);
|
||||
final isOverflow = tp.didExceedMaxLines;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
text,
|
||||
maxLines: videoList[videoModuleController.videoPlayIndex.value]['expanded'] ? null : 3,
|
||||
overflow:
|
||||
videoList[videoModuleController.videoPlayIndex.value]['expanded'] ? TextOverflow.visible : TextOverflow.ellipsis,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14.0),
|
||||
),
|
||||
if (isOverflow)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6.0),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
videoList[videoModuleController.videoPlayIndex.value]['expanded'] =
|
||||
!videoList[videoModuleController.videoPlayIndex.value]['expanded'];
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
videoList[videoModuleController.videoPlayIndex.value]['expanded'] ? '收起' : '展开更多',
|
||||
textAlign: TextAlign.right,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
text,
|
||||
maxLines: videoList[videoModuleController.videoPlayIndex.value]['expanded'] ? null : 3,
|
||||
overflow:
|
||||
videoList[videoModuleController.videoPlayIndex.value]['expanded'] ? TextOverflow.visible : TextOverflow.ellipsis,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14.0),
|
||||
),
|
||||
if (isOverflow)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6.0),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
videoList[videoModuleController.videoPlayIndex.value]['expanded'] =
|
||||
!videoList[videoModuleController.videoPlayIndex.value]['expanded'];
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
videoList[videoModuleController.videoPlayIndex.value]['expanded'] ? '收起' : '展开更多',
|
||||
textAlign: TextAlign.right,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
)else
|
||||
SizedBox()
|
||||
],
|
||||
)),
|
||||
Positioned(
|
||||
|
Loading…
x
Reference in New Issue
Block a user