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