fix: Hero导致videoPlayer渲染两次
This commit is contained in:
@ -187,120 +187,115 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
builder: (context, boxConstraints) {
|
builder: (context, boxConstraints) {
|
||||||
double maxWidth = boxConstraints.maxWidth;
|
double maxWidth = boxConstraints.maxWidth;
|
||||||
double maxHeight = boxConstraints.maxHeight;
|
double maxHeight = boxConstraints.maxHeight;
|
||||||
return Hero(
|
return Stack(
|
||||||
tag: videoDetailController.heroTag,
|
children: [
|
||||||
child: Stack(
|
FutureBuilder(
|
||||||
children: [
|
future: _futureBuilderFuture,
|
||||||
FutureBuilder(
|
builder: ((context, snapshot) {
|
||||||
future: _futureBuilderFuture,
|
if (snapshot.hasData &&
|
||||||
builder: ((context, snapshot) {
|
snapshot.data['status']) {
|
||||||
if (snapshot.hasData &&
|
return Obx(
|
||||||
snapshot.data['status']) {
|
() => !videoDetailController
|
||||||
return Obx(
|
.autoPlay.value
|
||||||
() => videoDetailController
|
? const SizedBox()
|
||||||
.autoPlay.value
|
: PLVideoPlayer(
|
||||||
? PLVideoPlayer(
|
controller: plPlayerController!,
|
||||||
|
headerControl: HeaderControl(
|
||||||
controller:
|
controller:
|
||||||
plPlayerController!,
|
plPlayerController,
|
||||||
headerControl: HeaderControl(
|
videoDetailCtr:
|
||||||
controller:
|
videoDetailController,
|
||||||
plPlayerController,
|
),
|
||||||
videoDetailCtr:
|
),
|
||||||
videoDetailController,
|
);
|
||||||
),
|
} else {
|
||||||
)
|
return const SizedBox();
|
||||||
: const SizedBox(),
|
}
|
||||||
);
|
}),
|
||||||
} else {
|
),
|
||||||
return const SizedBox();
|
|
||||||
}
|
Obx(
|
||||||
}),
|
() => Visibility(
|
||||||
),
|
visible:
|
||||||
Obx(
|
videoDetailController.isShowCover.value,
|
||||||
() => Visibility(
|
child: Positioned(
|
||||||
visible: videoDetailController
|
top: 0,
|
||||||
.isShowCover.value,
|
left: 0,
|
||||||
child: Positioned(
|
right: 0,
|
||||||
top: 0,
|
child: NetworkImgLayer(
|
||||||
left: 0,
|
type: 'emote',
|
||||||
right: 0,
|
src: videoDetailController
|
||||||
child: NetworkImgLayer(
|
.videoItem['pic'],
|
||||||
type: 'emote',
|
width: maxWidth,
|
||||||
src: videoDetailController
|
height: maxHeight,
|
||||||
.videoItem['pic'],
|
|
||||||
width: maxWidth,
|
|
||||||
height: maxHeight,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
|
||||||
/// 关闭自动播放时 手动播放
|
/// 关闭自动播放时 手动播放
|
||||||
Obx(
|
Obx(
|
||||||
() => Visibility(
|
() => Visibility(
|
||||||
visible: videoDetailController
|
visible: videoDetailController
|
||||||
.isShowCover.value &&
|
.isShowCover.value &&
|
||||||
videoDetailController
|
videoDetailController
|
||||||
.isEffective.value &&
|
.isEffective.value &&
|
||||||
!videoDetailController
|
!videoDetailController.autoPlay.value,
|
||||||
.autoPlay.value,
|
child: Stack(
|
||||||
child: Stack(
|
children: [
|
||||||
children: [
|
Positioned(
|
||||||
Positioned(
|
top: 0,
|
||||||
top: 0,
|
left: 0,
|
||||||
left: 0,
|
right: 0,
|
||||||
right: 0,
|
child: AppBar(
|
||||||
child: AppBar(
|
primary: false,
|
||||||
primary: false,
|
foregroundColor: Colors.white,
|
||||||
foregroundColor: Colors.white,
|
backgroundColor:
|
||||||
|
Colors.transparent,
|
||||||
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
tooltip: '稍后再看',
|
||||||
|
onPressed: () async {
|
||||||
|
var res = await UserHttp
|
||||||
|
.toViewLater(
|
||||||
|
bvid:
|
||||||
|
videoDetailController
|
||||||
|
.bvid);
|
||||||
|
SmartDialog.showToast(
|
||||||
|
res['msg']);
|
||||||
|
},
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.history_outlined),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 14)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
right: 12,
|
||||||
|
bottom: 10,
|
||||||
|
child: TextButton.icon(
|
||||||
|
style: ButtonStyle(
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
Colors.transparent,
|
MaterialStateProperty
|
||||||
actions: [
|
.resolveWith((states) {
|
||||||
IconButton(
|
return Theme.of(context)
|
||||||
tooltip: '稍后再看',
|
.colorScheme
|
||||||
onPressed: () async {
|
.primaryContainer;
|
||||||
var res = await UserHttp
|
}),
|
||||||
.toViewLater(
|
|
||||||
bvid:
|
|
||||||
videoDetailController
|
|
||||||
.bvid);
|
|
||||||
SmartDialog.showToast(
|
|
||||||
res['msg']);
|
|
||||||
},
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.history_outlined),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 14)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
onPressed: () => handlePlay(),
|
||||||
Positioned(
|
icon: const Icon(
|
||||||
right: 12,
|
Icons.play_circle_outline,
|
||||||
bottom: 10,
|
size: 20,
|
||||||
child: TextButton.icon(
|
|
||||||
style: ButtonStyle(
|
|
||||||
backgroundColor:
|
|
||||||
MaterialStateProperty
|
|
||||||
.resolveWith(
|
|
||||||
(states) {
|
|
||||||
return Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.primaryContainer;
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
onPressed: () => handlePlay(),
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.play_circle_outline,
|
|
||||||
size: 20,
|
|
||||||
),
|
|
||||||
label: const Text('Play'),
|
|
||||||
),
|
),
|
||||||
|
label: const Text('Play'),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
)),
|
],
|
||||||
),
|
)),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user