From 91ecc7d18b3f4ea703e824d5920278b98bbe2e20 Mon Sep 17 00:00:00 2001 From: BrightDV <92821484+BrightDV@users.noreply.github.com> Date: Fri, 13 Oct 2023 21:50:59 +0200 Subject: [PATCH] [home] bump hidable to add custom visibility algorithm --- lib/api/article_parts.dart | 4 ++-- lib/api/news.dart | 1 - lib/helpers/bottom_navigation_bar.dart | 23 +++++++++++++++++++++++ pubspec.yaml | 2 +- story_view/lib/widgets/story_view.dart | 1 - 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/lib/api/article_parts.dart b/lib/api/article_parts.dart index b2769e63..14356390 100644 --- a/lib/api/article_parts.dart +++ b/lib/api/article_parts.dart @@ -1462,7 +1462,7 @@ class WidgetsList extends StatelessWidget { // related articles - kIsWeb && false + kIsWeb ? Stack( alignment: Alignment.center, children: [ @@ -1556,7 +1556,7 @@ class WidgetsList extends StatelessWidget { child: ListView.builder( scrollDirection: Axis.horizontal, controller: scrollController, - physics: PagingScrollPhysics( + physics: const PagingScrollPhysics( itemDimension: 300, ), itemCount: article.relatedArticles.length, diff --git a/lib/api/news.dart b/lib/api/news.dart index d17c7402..a7bf72fb 100644 --- a/lib/api/news.dart +++ b/lib/api/news.dart @@ -19,7 +19,6 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:ui'; import 'package:better_player/better_player.dart'; import 'package:boxbox/Screens/circuit.dart'; diff --git a/lib/helpers/bottom_navigation_bar.dart b/lib/helpers/bottom_navigation_bar.dart index bf79288f..6d53eec1 100644 --- a/lib/helpers/bottom_navigation_bar.dart +++ b/lib/helpers/bottom_navigation_bar.dart @@ -26,6 +26,7 @@ import 'package:boxbox/Screens/standings.dart'; import 'package:boxbox/helpers/news_feed_widget.dart'; import 'package:flutter/foundation.dart' show kIsWeb; import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:hidable/hidable.dart'; import 'package:hive_flutter/hive_flutter.dart'; @@ -63,6 +64,23 @@ class _MainBottomNavigationBarState extends State { setState(() {}); } + // ref: https://github.com/insolite-dev/hidable/issues/26#issuecomment-1752105018 + double customHidableVisibility( + ScrollPosition position, double currentVisibility) { + const double deltaFactor = 0.04; + + // scrolls down + if (position.userScrollDirection == ScrollDirection.reverse) { + return (currentVisibility - deltaFactor).clamp(0, 1); + } + + // scrolls up + if (position.userScrollDirection == ScrollDirection.forward) { + return (currentVisibility + deltaFactor).clamp(0, 1); + } + return currentVisibility; + } + @override Widget build(BuildContext context) { int themeMode = @@ -312,6 +330,11 @@ class _MainBottomNavigationBarState extends State { ) : Hidable( controller: scrollController, + visibility: (position, currentVisibility) => + customHidableVisibility( + position, + currentVisibility, + ), child: BottomNavigationBar( type: BottomNavigationBarType.fixed, backgroundColor: useDarkMode diff --git a/pubspec.yaml b/pubspec.yaml index 167f1f52..c1f79271 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -45,7 +45,7 @@ dependencies: fluttertoast: ^8.2.1 font_awesome_flutter: ^10.2.1 geojson_vi: ^2.0.7 - hidable: ^1.0.5 + hidable: ^1.0.6 hive: ^2.1.0 hive_flutter: ^1.1.0 html: ^0.15.4 diff --git a/story_view/lib/widgets/story_view.dart b/story_view/lib/widgets/story_view.dart index 63331230..1489c0d0 100644 --- a/story_view/lib/widgets/story_view.dart +++ b/story_view/lib/widgets/story_view.dart @@ -1,6 +1,5 @@ import 'dart:async'; import 'dart:math'; -import 'dart:ui'; import 'package:collection/collection.dart' show IterableExtension; import 'package:flutter/material.dart';