-
Notifications
You must be signed in to change notification settings - Fork 28.7k
iOS 13 scrollbar #35829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS 13 scrollbar #35829
Conversation
…tructure for switching
f604dea
to
70b0801
Compare
bab14a5
to
7d6329c
Compare
17452ce
to
7d467f0
Compare
…ve ScrollController passed in
7d467f0
to
e2a4af8
Compare
@justinmc I was just playing around with the scrollbar and comparing it to the native one. I managed to get the feel very close by removing the drag from the right gesture and adding a |
@Kavantix I'm able to get the drag-from-right thing in the iOS 13 simulator, but it seems a little harder to activate than it is in Flutter now. I don't have an iOS 13 device at the moment to try it on. Maybe we could make it more strict. There are a few words mentioned about it in a Reddit thread. You seem to be right that the long press threshold is shorter. Something like a Would you mind opening an issue for these two points? That way anyone else having this problem can find your workaround and add to the discussion. |
Thanks I appreciate it! |
Hello, guys just trying this draggable scrollbar implementation in my flutter 1.9 stable upgrade but the draggable scrollbar is not working. Could it be that it is not yet available on the stable channel? |
@Chimba123 It looks like this should be in >1.8.4, so your version looks good. Did you enable the feature properly? See the code block in the description up top that shows you how to enable this. For now it's not automatic. |
@justinmc I did exactly that but it cannot find the controller in the PrimaryScrollView wrapping |
Try this gist containing a full demo app that I know should work: https://gist.github.com/justinmc/3c58cb125644b230fe66832b0ea541c2 |
@justinmc "final ScrollController scrollController = ScrollController();" was the key thanks it works appreciate it |
No problem! |
Then another issue, how do we use this functionality in a CustomScrollView Widget with a linear list of scrolling widgets? |
@justinmc my problem is like this (snippet below) Widget build(BuildContext context) {
return CupertinoPageScaffold(
child: CustomScrollView(
slivers: <Widget>[
SliverPersistentHeader(
delegate: MyNav(),
pinned: true,
floating: false,
),
SliverList(),
],
),
);
}
} I have a navbar if I use that method in the link the scrollbar scrolls above the navbar, I want it under |
@justinmc I have found a way just wrap it in a SliverToBoxAdapter and set the media constraints of the containing widget like below @override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
child: CustomScrollView(
slivers: <Widget>[
SliverPersistentHeader(
delegate: MyNav(),
pinned: true,
floating: false,
),
SliverToBoxAdapter(
child: Container(
height: MediaQuery.of(context).size.height,
width:MediaQuery.of(context).size.width,
child: PrimaryScrollController(
controller: scrollController,
child: CupertinoScrollbar(
controller: scrollController,
child: MediaQuery.removePadding(
context: context,
removeTop: true,
child: Container()
),
),
),
),
),
],
),
);
}
} |
Ok good to hear you got it, thanks for following up. I will edit your comments for formatting really quick. |
@justinmc Hi. Could u add a property to set the |
Could you get the same outcome by removing the scrollbar from the widget tree? Like: if (_showScrollbar) {
return Scrollbar(
child: MyListView(),
);
}
return MyListView(); |
Hi @justinmc, This PR has been really helpful. I tried it with two ScrollViews. One vertical, other Horizontal, like
So, Vertical scroll drag works well. But, when I tried horizontal, it automatically switches to the vertical scroll. Is there a way to solve this? (I have tried it on windows app). |
@SahajRana Does it work without the CupertinoScrollbar? I believe you can't get bidirectional scrolling to work with this approach. If you can post a full minimal app that reproduces the problem I can take a closer look. |
Description
This PR implements iOS 13's draggable scrollbar. It can be activated by long pressing on the scrollbar or dragging in from the right on top of the scrollbar.
Related Issues
Closes #35127
Tests
I test dragging the scrollbar with long press and drag from right in packages/flutter/test/cupertino/scrollbar_test.dart.
Usage
I struggled to come up with a nice way for developers to use this feature, because by default, Flutter has no scrollbars. You must wrap your scrollable widget in a
Scrollbar
orCupertinoScrollbar
to get one, but then these scrollbar widgets have no command over the scroll position.The solution I ended up using requires a
ScrollController
to be passed in, like this: