diff --git a/lib/widgets/album/thumbnail_collection.dart b/lib/widgets/album/thumbnail_collection.dart index db5d2716c..30e140d93 100644 --- a/lib/widgets/album/thumbnail_collection.dart +++ b/lib/widgets/album/thumbnail_collection.dart @@ -45,6 +45,16 @@ class ThumbnailCollectionContent extends StatelessWidget { Widget build(BuildContext context) { final bottomInsets = MediaQuery.of(context).viewInsets.bottom; final sectionKeys = _sections.keys.toList(); + double topPadding = 0; + if (appBar != null) { + final topWidget = appBar; + if (topWidget is PreferredSizeWidget) { + topPadding = topWidget.preferredSize.height; + } else if (topWidget is SliverAppBar) { + topPadding = kToolbarHeight + (topWidget.bottom?.preferredSize?.height ?? 0.0); + } + } + return SafeArea( child: DraggableScrollbar.arrows( child: CustomScrollView( @@ -68,7 +78,7 @@ class ThumbnailCollectionContent extends StatelessWidget { ], ), controller: _scrollController, - padding: EdgeInsets.only(bottom: bottomInsets), + padding: EdgeInsets.only(top: topPadding, bottom: bottomInsets), labelTextBuilder: (double offset) => Text( "${offset ~/ 1}", style: TextStyle(color: Colors.blueGrey), diff --git a/lib/widgets/common/draggable_scrollbar.dart b/lib/widgets/common/draggable_scrollbar.dart index 7cae7feed..76ed1196c 100644 --- a/lib/widgets/common/draggable_scrollbar.dart +++ b/lib/widgets/common/draggable_scrollbar.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; /// TLAD: copied from https://pub.dev/packages/draggable_scrollbar 0.0.4 /// modified to allow any `ScrollView` as a child, not just `BoxScrollView` +/// modified to apply vertical padding when computing `barMaxScrollExtent` /// Build the Scroll Thumb and label using the current configuration typedef Widget ScrollThumbBuilder( @@ -343,7 +344,7 @@ class _DraggableScrollbarState extends State with TickerProv super.dispose(); } - double get barMaxScrollExtent => context.size.height - widget.heightScrollThumb; + double get barMaxScrollExtent => context.size.height - widget.heightScrollThumb - widget.padding.vertical; double get barMinScrollExtent => 0.0; @@ -374,24 +375,25 @@ class _DraggableScrollbarState extends State with TickerProv child: widget.child, ), RepaintBoundary( - child: GestureDetector( - onVerticalDragStart: _onVerticalDragStart, - onVerticalDragUpdate: _onVerticalDragUpdate, - onVerticalDragEnd: _onVerticalDragEnd, - child: Container( - alignment: Alignment.topRight, - margin: EdgeInsets.only(top: _barOffset), - padding: widget.padding, - child: widget.scrollThumbBuilder( - widget.backgroundColor, - _thumbAnimation, - _labelAnimation, - widget.heightScrollThumb, - labelText: labelText, - labelConstraints: widget.labelConstraints, + child: GestureDetector( + onVerticalDragStart: _onVerticalDragStart, + onVerticalDragUpdate: _onVerticalDragUpdate, + onVerticalDragEnd: _onVerticalDragEnd, + child: Container( + alignment: Alignment.topRight, + margin: EdgeInsets.only(top: _barOffset), + padding: widget.padding, + child: widget.scrollThumbBuilder( + widget.backgroundColor, + _thumbAnimation, + _labelAnimation, + widget.heightScrollThumb, + labelText: labelText, + labelConstraints: widget.labelConstraints, + ), ), ), - )), + ), ], ), );