mirror of
https://github.com/immich-app/immich.git
synced 2024-11-28 09:33:27 +02:00
fix(mobile): scroll thumb is hidden behind the tab navigation bar (#12512)
* fix(mobile): scroll thumb is hidden behind the tab navigation bar * better variable names * fix rounding error
This commit is contained in:
parent
b3ef5fe6e7
commit
9323b69c61
@ -59,8 +59,6 @@ class DraggableScrollbar extends StatefulWidget {
|
|||||||
|
|
||||||
final Function(bool scrolling) scrollStateListener;
|
final Function(bool scrolling) scrollStateListener;
|
||||||
|
|
||||||
final double viewPortHeight;
|
|
||||||
|
|
||||||
DraggableScrollbar.semicircle({
|
DraggableScrollbar.semicircle({
|
||||||
super.key,
|
super.key,
|
||||||
Key? scrollThumbKey,
|
Key? scrollThumbKey,
|
||||||
@ -69,7 +67,6 @@ class DraggableScrollbar extends StatefulWidget {
|
|||||||
required this.controller,
|
required this.controller,
|
||||||
required this.itemPositionsListener,
|
required this.itemPositionsListener,
|
||||||
required this.scrollStateListener,
|
required this.scrollStateListener,
|
||||||
required this.viewPortHeight,
|
|
||||||
this.heightScrollThumb = 48.0,
|
this.heightScrollThumb = 48.0,
|
||||||
this.backgroundColor = Colors.white,
|
this.backgroundColor = Colors.white,
|
||||||
this.padding,
|
this.padding,
|
||||||
@ -254,7 +251,7 @@ class DraggableScrollbarState extends State<DraggableScrollbar>
|
|||||||
}
|
}
|
||||||
|
|
||||||
double get barMaxScrollExtent =>
|
double get barMaxScrollExtent =>
|
||||||
widget.viewPortHeight -
|
(context.size?.height ?? 0) -
|
||||||
widget.heightScrollThumb -
|
widget.heightScrollThumb -
|
||||||
(widget.heightOffset ?? 0);
|
(widget.heightOffset ?? 0);
|
||||||
|
|
||||||
@ -340,8 +337,8 @@ class DraggableScrollbarState extends State<DraggableScrollbar>
|
|||||||
_thumbAnimationController.forward();
|
_thumbAnimationController.forward();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemPos < maxItemCount) {
|
if (itemPosition < maxItemCount) {
|
||||||
_currentItem = itemPos;
|
_currentItem = itemPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
_fadeoutTimer?.cancel();
|
_fadeoutTimer?.cancel();
|
||||||
@ -365,25 +362,35 @@ class DraggableScrollbarState extends State<DraggableScrollbar>
|
|||||||
widget.scrollStateListener(true);
|
widget.scrollStateListener(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int get itemPos {
|
int get itemPosition {
|
||||||
int numberOfItems = widget.child.itemCount;
|
int numberOfItems = widget.child.itemCount;
|
||||||
return ((_barOffset / barMaxScrollExtent) * numberOfItems).toInt();
|
return ((_barOffset / barMaxScrollExtent) * numberOfItems).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _jumpToBarPos() {
|
void _jumpToBarPosition() {
|
||||||
if (itemPos > maxItemCount - 1) {
|
if (itemPosition > maxItemCount - 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentItem = itemPos;
|
_currentItem = itemPosition;
|
||||||
|
|
||||||
|
/// If the bar is at the bottom but the item position is still smaller than the max item count (due to rounding error)
|
||||||
|
/// jump to the end of the list
|
||||||
|
if (barMaxScrollExtent - _barOffset < 10 && itemPosition < maxItemCount) {
|
||||||
|
widget.controller.jumpTo(
|
||||||
|
index: maxItemCount,
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
widget.controller.jumpTo(
|
widget.controller.jumpTo(
|
||||||
index: itemPos,
|
index: itemPosition,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer? dragHaltTimer;
|
Timer? dragHaltTimer;
|
||||||
int lastTimerPos = 0;
|
int lastTimerPosition = 0;
|
||||||
|
|
||||||
void _onVerticalDragUpdate(DragUpdateDetails details) {
|
void _onVerticalDragUpdate(DragUpdateDetails details) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -400,8 +407,8 @@ class DraggableScrollbarState extends State<DraggableScrollbar>
|
|||||||
_barOffset = barMaxScrollExtent;
|
_barOffset = barMaxScrollExtent;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemPos != lastTimerPos) {
|
if (itemPosition != lastTimerPosition) {
|
||||||
lastTimerPos = itemPos;
|
lastTimerPosition = itemPosition;
|
||||||
dragHaltTimer?.cancel();
|
dragHaltTimer?.cancel();
|
||||||
widget.scrollStateListener(true);
|
widget.scrollStateListener(true);
|
||||||
|
|
||||||
@ -413,7 +420,7 @@ class DraggableScrollbarState extends State<DraggableScrollbar>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_jumpToBarPos();
|
_jumpToBarPosition();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -426,7 +433,7 @@ class DraggableScrollbarState extends State<DraggableScrollbar>
|
|||||||
});
|
});
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_jumpToBarPos();
|
_jumpToBarPosition();
|
||||||
_isDragInProcess = false;
|
_isDragInProcess = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -264,7 +264,6 @@ class ImmichAssetGridViewState extends ConsumerState<ImmichAssetGridView> {
|
|||||||
|
|
||||||
final child = (useDragScrolling && ModalRoute.of(context) != null)
|
final child = (useDragScrolling && ModalRoute.of(context) != null)
|
||||||
? DraggableScrollbar.semicircle(
|
? DraggableScrollbar.semicircle(
|
||||||
viewPortHeight: context.height,
|
|
||||||
scrollStateListener: dragScrolling,
|
scrollStateListener: dragScrolling,
|
||||||
itemPositionsListener: _itemPositionsListener,
|
itemPositionsListener: _itemPositionsListener,
|
||||||
controller: _itemScrollController,
|
controller: _itemScrollController,
|
||||||
|
Loading…
Reference in New Issue
Block a user