Hide scroll handle for lists < 100 assets

This commit is contained in:
Matthias Rupp 2022-09-30 10:47:31 +02:00
parent 8440d9890c
commit dd71a53f5e

View file

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