From da5c2148ad332e1c02015302934859217c5af7d1 Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Wed, 5 Mar 2025 13:42:35 +0800 Subject: [PATCH] opt: horizontal image view Signed-off-by: bggRGjQaUbCoE --- lib/pages/dynamics/detail/view.dart | 25 ++++++++++++++----------- lib/pages/html/view.dart | 25 ++++++++++++++----------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/lib/pages/dynamics/detail/view.dart b/lib/pages/dynamics/detail/view.dart index 3c921194..6cae8ede 100644 --- a/lib/pages/dynamics/detail/view.dart +++ b/lib/pages/dynamics/detail/view.dart @@ -49,6 +49,7 @@ class _DynamicDetailPageState extends State // 回复类型 late int replyType; bool _isFabVisible = true; + bool? _imageStatus; int oid = 0; int? opusId; bool isOpusId = false; @@ -63,9 +64,10 @@ class _DynamicDetailPageState extends State get _getImageCallback => _horizontalPreview ? (imgList, index) { - bool needReverse = _isFabVisible; - if (needReverse) { - _fabAnimationCtr?.reverse(); + _imageStatus = true; + bool isFabVisible = _isFabVisible; + if (isFabVisible) { + _hideFab(); } final ctr = AnimationController( vsync: this, @@ -81,9 +83,10 @@ class _DynamicDetailPageState extends State imgList, index, (value) async { - if (needReverse) { - needReverse = false; - _fabAnimationCtr?.forward(); + _imageStatus = null; + if (isFabVisible) { + isFabVisible = false; + _showFab(); } if (value == false) { await ctr.reverse(); @@ -194,9 +197,9 @@ class _DynamicDetailPageState extends State } else { ScaffoldState? scaffoldState = Scaffold.maybeOf(context); if (scaffoldState != null) { - bool needReverse = _isFabVisible; - if (needReverse) { - _fabAnimationCtr?.reverse(); + bool isFabVisible = _isFabVisible; + if (isFabVisible) { + _hideFab(); } scaffoldState.showBottomSheet( backgroundColor: Colors.transparent, @@ -206,8 +209,8 @@ class _DynamicDetailPageState extends State child: replyReplyPage( false, () { - if (needReverse) { - _fabAnimationCtr?.forward(); + if (isFabVisible && _imageStatus != true) { + _showFab(); } }, ), diff --git a/lib/pages/html/view.dart b/lib/pages/html/view.dart index 6cca11cc..c77439ed 100644 --- a/lib/pages/html/view.dart +++ b/lib/pages/html/view.dart @@ -44,6 +44,7 @@ class _HtmlRenderPageState extends State late String dynamicType; late int type; bool _isFabVisible = true; + bool? _imageStatus; late AnimationController fabAnimationCtr; late final List _ratio = GStorage.dynamicDetailRatio; @@ -56,9 +57,10 @@ class _HtmlRenderPageState extends State get _getImageCallback => _horizontalPreview ? (imgList, index) { - bool needReverse = _isFabVisible; - if (needReverse) { - fabAnimationCtr.reverse(); + _imageStatus = true; + bool isFabVisible = _isFabVisible; + if (isFabVisible) { + _hideFab(); } final ctr = AnimationController( vsync: this, @@ -74,9 +76,10 @@ class _HtmlRenderPageState extends State imgList, index, (value) async { - if (needReverse) { - needReverse = false; - fabAnimationCtr.forward(); + _imageStatus = null; + if (isFabVisible) { + isFabVisible = false; + _showFab(); } if (value == false) { await ctr.reverse(); @@ -187,9 +190,9 @@ class _HtmlRenderPageState extends State } else { ScaffoldState? scaffoldState = Scaffold.maybeOf(context); if (scaffoldState != null) { - bool needReverse = _isFabVisible; - if (needReverse) { - fabAnimationCtr.reverse(); + bool isFabVisible = _isFabVisible; + if (isFabVisible) { + _hideFab(); } scaffoldState.showBottomSheet( backgroundColor: Colors.transparent, @@ -199,8 +202,8 @@ class _HtmlRenderPageState extends State child: replyReplyPage( false, () { - if (needReverse) { - fabAnimationCtr.forward(); + if (isFabVisible && _imageStatus != true) { + _showFab(); } }, ),