Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-07-21 22:14:38 +08:00
parent dae8df840a
commit 43843ca721
10 changed files with 204 additions and 217 deletions

View File

@@ -1305,7 +1305,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
bool showIntro = true,
VoidCallback? onTap,
}) {
List<String> tabs = [
final tabs = [
if (showIntro)
videoDetailController.isFileSource ? '离线视频' : introText ?? '简介',
if (videoDetailController.showReply) '评论',
@@ -1322,53 +1322,61 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
);
}
final flag = !needIndicator || tabs.length == 1;
Widget tabBar() => TabBar(
labelColor: flag ? themeData.colorScheme.onSurface : null,
indicator: flag ? const BoxDecoration() : null,
padding: EdgeInsets.zero,
controller: videoDetailController.tabCtr,
labelStyle:
TabBarTheme.of(context).labelStyle?.copyWith(fontSize: 13) ??
const TextStyle(fontSize: 13),
labelPadding: const EdgeInsets.symmetric(horizontal: 10.0),
dividerColor: Colors.transparent,
dividerHeight: 0,
onTap: (value) {
void animToTop() {
if (onTap != null) {
onTap();
return;
Widget tabBar() {
final flag = !needIndicator || tabs.length == 1;
return TabBar(
padding: .zero,
dividerHeight: 0,
labelPadding: .zero,
dividerColor: Colors.transparent,
controller: videoDetailController.tabCtr,
indicator: flag ? const BoxDecoration() : null,
labelColor: flag ? themeData.colorScheme.onSurface : null,
labelStyle:
TabBarTheme.of(context).labelStyle?.copyWith(fontSize: 13) ??
const TextStyle(fontSize: 13),
onTap: (value) {
void animToTop() {
if (onTap != null) {
onTap();
return;
}
String text = tabs[value];
if (videoDetailController.isFileSource ||
text == '简介' ||
text == '相关视频') {
videoDetailController.introScrollCtr?.animToTop();
} else if (text.startsWith('评论')) {
_videoReplyController.animateToTop();
}
}
String text = tabs[value];
if (videoDetailController.isFileSource ||
text == '简介' ||
text == '相关视频') {
videoDetailController.introScrollCtr?.animToTop();
} else if (text.startsWith('评论')) {
_videoReplyController.animateToTop();
}
}
if (flag) {
animToTop();
} else if (!videoDetailController.tabCtr.indexIsChanging) {
animToTop();
}
},
tabs: tabs.map((text) {
if (text == '评论') {
return Obx(() {
final count = _videoReplyController.count.value;
if (flag) {
animToTop();
} else if (!videoDetailController.tabCtr.indexIsChanging) {
animToTop();
}
},
tabs: tabs.map((text) {
if (text == '评论') {
return Obx(() {
final count = _videoReplyController.count.value;
return Tab(
child: Text(
'评论${count == -1 ? '' : ' ${NumUtils.numFormat(count)}'}',
softWrap: false,
overflow: .visible,
),
);
});
} else {
return Tab(
text: '评论${count == -1 ? '' : ' ${NumUtils.numFormat(count)}'}',
child: Text(text, softWrap: false, overflow: .visible),
);
});
} else {
return Tab(text: text);
}
}).toList(),
);
}
}).toList(),
);
}
return DecoratedBox(
decoration: BoxDecoration(
@@ -1385,68 +1393,62 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
if (tabs.isEmpty)
const Spacer()
else
Flexible(
flex: tabs.length == 3 ? 2 : 1,
child: tabBar(),
Expanded(
child: Align(
alignment: .centerLeft,
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: 96.0 * tabs.length),
child: tabBar(),
),
),
),
Flexible(
flex: 1,
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
SizedBox(
height: 32,
child: TextButton(
style: const ButtonStyle(
padding: WidgetStatePropertyAll(EdgeInsets.zero),
),
onPressed: videoDetailController.showShootDanmakuSheet,
child: Text(
'发弹幕',
style: TextStyle(
fontSize: 12,
color: themeData.colorScheme.onSurfaceVariant,
),
),
),
),
SizedBox(
width: 38,
height: 38,
child: Obx(
() {
final ctr = videoDetailController.plPlayerController;
final enableShowDanmaku = ctr.enableShowDanmaku.value;
return IconButton(
onPressed: () {
final newVal = !enableShowDanmaku;
ctr.enableShowDanmaku.value = newVal;
if (!ctr.tempPlayerConf) {
GStorage.setting.put(
SettingBoxKey.enableShowDanmaku,
newVal,
);
}
},
icon: Icon(
size: 22,
enableShowDanmaku
? CustomIcons.dm_on
: CustomIcons.dm_off,
color: enableShowDanmaku
? themeData.colorScheme.secondary
: themeData.colorScheme.outline,
),
);
},
),
),
const SizedBox(width: 14),
],
SizedBox(
height: 32,
child: TextButton(
style: const ButtonStyle(
padding: WidgetStatePropertyAll(.zero),
),
onPressed: videoDetailController.showShootDanmakuSheet,
child: Text(
'发弹幕',
style: TextStyle(
fontSize: 12,
color: themeData.colorScheme.onSurfaceVariant,
),
),
),
),
SizedBox.square(
dimension: 38,
child: Obx(
() {
final ctr = videoDetailController.plPlayerController;
final enableShowDanmaku = ctr.enableShowDanmaku.value;
return IconButton(
onPressed: () {
final newVal = !enableShowDanmaku;
ctr.enableShowDanmaku.value = newVal;
if (!ctr.tempPlayerConf) {
GStorage.setting.put(
SettingBoxKey.enableShowDanmaku,
newVal,
);
}
},
icon: Icon(
size: 22,
enableShowDanmaku
? CustomIcons.dm_on
: CustomIcons.dm_off,
color: enableShowDanmaku
? themeData.colorScheme.secondary
: themeData.colorScheme.outline,
),
);
},
),
),
const SizedBox(width: 14),
],
),
),