Hide scroll handle for lists < 100 assets
This commit is contained in:
parent
8440d9890c
commit
dd71a53f5e
1 changed files with 16 additions and 6 deletions
|
@ -136,10 +136,13 @@ class ImmichAssetGrid extends HookConsumerWidget {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final scrolling = useState(false);
|
||||
|
||||
final useDragScrolling = _assets.length > 100;
|
||||
|
||||
void dragScrolling(bool active) {
|
||||
scrolling.value = active;
|
||||
}
|
||||
|
@ -148,6 +151,17 @@ class ImmichAssetGrid extends HookConsumerWidget {
|
|||
return _itemBuilder(c, position, scrolling.value);
|
||||
}
|
||||
|
||||
final listWidget = ScrollablePositionedList.builder(
|
||||
itemBuilder: itemBuilder,
|
||||
itemPositionsListener: _itemPositionsListener,
|
||||
itemScrollController: _itemScrollController,
|
||||
itemCount: renderList.length,
|
||||
);
|
||||
|
||||
if (!useDragScrolling) {
|
||||
return listWidget;
|
||||
}
|
||||
|
||||
return DraggableScrollbar.semicircle(
|
||||
scrollStateListener: dragScrolling,
|
||||
itemPositionsListener: _itemPositionsListener,
|
||||
|
@ -157,11 +171,7 @@ class ImmichAssetGrid extends HookConsumerWidget {
|
|||
labelConstraints: const BoxConstraints(maxHeight: 28),
|
||||
scrollbarAnimationDuration: const Duration(seconds: 1),
|
||||
scrollbarTimeToFade: const Duration(seconds: 4),
|
||||
child: ScrollablePositionedList.builder(
|
||||
itemBuilder: itemBuilder,
|
||||
itemPositionsListener: _itemPositionsListener,
|
||||
itemScrollController: _itemScrollController,
|
||||
itemCount: renderList.length,
|
||||
));
|
||||
child: listWidget,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue