album: fixed padding around scroll thumb

This commit is contained in:
Thibault Deckers 2019-09-13 20:33:57 +09:00
parent af7f5536ac
commit 5768b8a056
2 changed files with 30 additions and 18 deletions

View file

@ -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),

View file

@ -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<DraggableScrollbar> 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<DraggableScrollbar> 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,
),
),
),
)),
),
],
),
);