opt: 视频详情页Hero动画

This commit is contained in:
guozhigq
2024-05-26 15:48:28 +08:00
parent fa0c870f54
commit 979346233f

View File

@ -534,11 +534,10 @@ class _VideoDetailPageState extends State<VideoDetailPage>
Scaffold( Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
key: vdCtr.scaffoldKey, key: vdCtr.scaffoldKey,
backgroundColor: Colors.black,
appBar: PreferredSize( appBar: PreferredSize(
preferredSize: const Size.fromHeight(0), preferredSize: const Size.fromHeight(0),
child: AppBar( child: AppBar(
backgroundColor: Colors.transparent, backgroundColor: Colors.black,
elevation: 0, elevation: 0,
), ),
), ),
@ -568,8 +567,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
} }
return SliverAppBar( return SliverAppBar(
automaticallyImplyLeading: false, automaticallyImplyLeading: false,
// 假装使用一个非空变量避免Obx检测不到而罢工 pinned: true,
pinned: vdCtr.autoPlay.value,
elevation: 0, elevation: 0,
scrolledUnderElevation: 0, scrolledUnderElevation: 0,
forceElevated: innerBoxIsScrolled, forceElevated: innerBoxIsScrolled,
@ -577,47 +575,42 @@ class _VideoDetailPageState extends State<VideoDetailPage>
backgroundColor: Colors.black, backgroundColor: Colors.black,
flexibleSpace: FlexibleSpaceBar( flexibleSpace: FlexibleSpaceBar(
background: PopScope( background: PopScope(
canPop: plPlayerController?.isFullScreen.value != canPop:
true, plPlayerController?.isFullScreen.value != true,
onPopInvoked: (bool didPop) { onPopInvoked: (bool didPop) {
if (plPlayerController?.isFullScreen.value == if (plPlayerController?.isFullScreen.value ==
true) { true) {
plPlayerController! plPlayerController!
.triggerFullScreen(status: false); .triggerFullScreen(status: false);
} }
if (MediaQuery.of(context).orientation == if (MediaQuery.of(context).orientation ==
Orientation.landscape) { Orientation.landscape) {
verticalScreen(); verticalScreen();
} }
}, },
child: LayoutBuilder( child: Hero(
builder: (BuildContext context, tag: heroTag,
BoxConstraints boxConstraints) { child: Stack(
return Stack( children: <Widget>[
children: <Widget>[ if (isShowing) videoPlayerPanel,
if (isShowing)
Padding(
padding: EdgeInsets.only(top: 0),
child: videoPlayerPanel,
),
/// 关闭自动播放时 手动播放 /// 关闭自动播放时 手动播放
Obx( Obx(
() => Visibility( () => Visibility(
visible: !vdCtr.autoPlay.value && visible: !vdCtr.autoPlay.value &&
vdCtr.isShowCover.value, vdCtr.isShowCover.value,
child: Positioned( child: Positioned(
top: 0, top: 0,
left: 0, left: 0,
right: 0, right: 0,
child: handlePlayPanel(), child: handlePlayPanel(),
),
),
), ),
], ),
); ),
}, ],
)), ),
),
),
), ),
); );
}, },
@ -636,55 +629,51 @@ class _VideoDetailPageState extends State<VideoDetailPage>
: pinnedHeaderHeight; : pinnedHeaderHeight;
}, },
onlyOneScrollInBody: true, onlyOneScrollInBody: true,
body: ColoredBox( body: Column(
key: Key(heroTag), children: [
color: Theme.of(context).colorScheme.background, tabbarBuild(),
child: Column( Expanded(
children: [ child: TabBarView(
tabbarBuild(), controller: vdCtr.tabCtr,
Expanded( children: <Widget>[
child: TabBarView( Builder(
controller: vdCtr.tabCtr, builder: (BuildContext context) {
children: <Widget>[ return CustomScrollView(
Builder( key: const PageStorageKey<String>('简介'),
builder: (BuildContext context) { slivers: <Widget>[
return CustomScrollView( if (vdCtr.videoType == SearchType.video) ...[
key: const PageStorageKey<String>('简介'), VideoIntroPanel(bvid: vdCtr.bvid),
slivers: <Widget>[ ] else if (vdCtr.videoType ==
if (vdCtr.videoType == SearchType.video) ...[ SearchType.media_bangumi) ...[
VideoIntroPanel(bvid: vdCtr.bvid), Obx(() =>
] else if (vdCtr.videoType == BangumiIntroPanel(cid: vdCtr.cid.value)),
SearchType.media_bangumi) ...[
Obx(() => BangumiIntroPanel(
cid: vdCtr.cid.value)),
],
SliverToBoxAdapter(
child: Divider(
indent: 12,
endIndent: 12,
color: Theme.of(context)
.dividerColor
.withOpacity(0.06),
),
),
if (vdCtr.videoType == SearchType.video &&
vdCtr.enableRelatedVideo)
const RelatedVideoPanel(),
], ],
); SliverToBoxAdapter(
}, child: Divider(
indent: 12,
endIndent: 12,
color: Theme.of(context)
.dividerColor
.withOpacity(0.06),
),
),
if (vdCtr.videoType == SearchType.video &&
vdCtr.enableRelatedVideo)
const RelatedVideoPanel(),
],
);
},
),
Obx(
() => VideoReplyPanel(
bvid: vdCtr.bvid,
oid: vdCtr.oid.value,
), ),
Obx( )
() => VideoReplyPanel( ],
bvid: vdCtr.bvid,
oid: vdCtr.oid.value,
),
)
],
),
), ),
], ),
), ],
), ),
), ),
), ),