diff --git a/lib/pages/dynamics/detail/view.dart b/lib/pages/dynamics/detail/view.dart index 38aec7954..3c9211946 100644 --- a/lib/pages/dynamics/detail/view.dart +++ b/lib/pages/dynamics/detail/view.dart @@ -63,8 +63,7 @@ class _DynamicDetailPageState extends State get _getImageCallback => _horizontalPreview ? (imgList, index) { - bool needReverse = - _fabAnimationCtr?.status.isForwardOrCompleted == true; + bool needReverse = _isFabVisible; if (needReverse) { _fabAnimationCtr?.reverse(); } @@ -195,8 +194,7 @@ class _DynamicDetailPageState extends State } else { ScaffoldState? scaffoldState = Scaffold.maybeOf(context); if (scaffoldState != null) { - bool needReverse = - _fabAnimationCtr?.status.isForwardOrCompleted == true; + bool needReverse = _isFabVisible; if (needReverse) { _fabAnimationCtr?.reverse(); } @@ -229,22 +227,28 @@ class _DynamicDetailPageState extends State void listener() { // 标题 - if (_dynamicDetailController.scrollController.offset > 55 && - !_visibleTitle) { - _visibleTitle = true; - _titleStreamC.add(true); - } else if (_dynamicDetailController.scrollController.offset <= 55 && - _visibleTitle) { - _visibleTitle = false; - _titleStreamC.add(false); + if (_dynamicDetailController.scrollController.positions.length == 1) { + if (_dynamicDetailController.scrollController.offset > 55 && + !_visibleTitle) { + _visibleTitle = true; + _titleStreamC.add(true); + } else if (_dynamicDetailController.scrollController.offset <= 55 && + _visibleTitle) { + _visibleTitle = false; + _titleStreamC.add(false); + } } // fab按钮 - final ScrollDirection direction = - _dynamicDetailController.scrollController.position.userScrollDirection; - if (direction == ScrollDirection.forward) { + final ScrollDirection direction1 = _dynamicDetailController + .scrollController.positions.first.userScrollDirection; + late final ScrollDirection direction2 = _dynamicDetailController + .scrollController.positions.last.userScrollDirection; + if (direction1 == ScrollDirection.forward || + direction2 == ScrollDirection.forward) { _showFab(); - } else if (direction == ScrollDirection.reverse) { + } else if (direction1 == ScrollDirection.reverse || + direction2 == ScrollDirection.reverse) { _hideFab(); } } @@ -384,6 +388,7 @@ class _DynamicDetailPageState extends State Expanded( flex: _ratio[0].toInt(), child: CustomScrollView( + controller: _dynamicDetailController.scrollController, physics: const AlwaysScrollableScrollPhysics(), slivers: [ SliverPadding( diff --git a/lib/pages/html/view.dart b/lib/pages/html/view.dart index 11cabd5fd..6cca11cc2 100644 --- a/lib/pages/html/view.dart +++ b/lib/pages/html/view.dart @@ -56,8 +56,7 @@ class _HtmlRenderPageState extends State get _getImageCallback => _horizontalPreview ? (imgList, index) { - bool needReverse = - fabAnimationCtr.status.isForwardOrCompleted == true; + bool needReverse = _isFabVisible; if (needReverse) { fabAnimationCtr.reverse(); } @@ -131,11 +130,15 @@ class _HtmlRenderPageState extends State // } // fab按钮 - final ScrollDirection direction = - _htmlRenderCtr.scrollController.position.userScrollDirection; - if (direction == ScrollDirection.forward) { + final ScrollDirection direction1 = + _htmlRenderCtr.scrollController.positions.first.userScrollDirection; + late final ScrollDirection direction2 = + _htmlRenderCtr.scrollController.positions.last.userScrollDirection; + if (direction1 == ScrollDirection.forward || + direction2 == ScrollDirection.forward) { _showFab(); - } else if (direction == ScrollDirection.reverse) { + } else if (direction1 == ScrollDirection.reverse || + direction2 == ScrollDirection.reverse) { _hideFab(); } } @@ -184,8 +187,7 @@ class _HtmlRenderPageState extends State } else { ScaffoldState? scaffoldState = Scaffold.maybeOf(context); if (scaffoldState != null) { - bool needReverse = - fabAnimationCtr.status.isForwardOrCompleted == true; + bool needReverse = _isFabVisible; if (needReverse) { fabAnimationCtr.reverse(); } @@ -337,9 +339,8 @@ class _HtmlRenderPageState extends State Expanded( flex: _ratio[0].toInt(), child: CustomScrollView( - controller: orientation == Orientation.portrait - ? _htmlRenderCtr.scrollController - : null, + controller: _htmlRenderCtr.scrollController, + physics: const AlwaysScrollableScrollPhysics(), slivers: [ SliverPadding( padding: orientation == Orientation.portrait @@ -402,6 +403,7 @@ class _HtmlRenderPageState extends State backgroundColor: Colors.transparent, body: CustomScrollView( controller: _htmlRenderCtr.scrollController, + physics: const AlwaysScrollableScrollPhysics(), slivers: [ SliverPadding( padding: EdgeInsets.only(right: padding / 4),