Repository navigation
Add Cupertino scrollbar - #13290
Add Cupertino scrollbar#13290
Conversation
1ec6aa2 to
2fc0f22
Compare
|
Rebased from upstream |
There was a problem hiding this comment.
Please run flutter analyze --dartdocs to catch new members that are missing documentation.
There was a problem hiding this comment.
Ah crap, thanks for catching. Added a bunch missing. Surprised it wasn't in travis.
There was a problem hiding this comment.
Would it make sense for this just to be a private member on the state?
There was a problem hiding this comment.
Material scrollbar actually draws with cupertino painter on iOS. Seems consistent with googlekit on iOS.
2fc0f22 to
f5693e9
Compare
|
Oops, didn't actually force push after rebasing. Pushed for real now. |
There was a problem hiding this comment.
you can remove this TODO (and the matching one on the other side), we're not likely to do this any time soon.
There was a problem hiding this comment.
This is easier to do now. Is it worth doing and reshaping the tree each time opacity comes in and out of = 0.0?
There was a problem hiding this comment.
I think we should just wait until we have a reason to do it.
There was a problem hiding this comment.
IMHO we really shouldn't make the original _ScrollbarPainter class public. It's a crazy class with crazy semantics (e.g. it's a custom painter but you have to dispose it).
There was a problem hiding this comment.
If I left 2 implementations in 2 separate files, it seems to alleviate your concern here and on the next comment. Do you prefer that approach? A bit copy paste-y I initially thought.
There was a problem hiding this comment.
It doesn't make any sense for a CustomPainter to have externally mutable state.
There was a problem hiding this comment.
Maybe that's too strong a statement. Let me say instead, it's very much contrary to how CustomPainter was intended to work.
There was a problem hiding this comment.
Seems like the existing custom painter in material already mutates the painter (when the inherited theme changes). I didn't see any class docs on CustomPainter on its desired immutability.
There was a problem hiding this comment.
false is wrong here. It should be comparing every constructor argument, and they should all be immutable fields, so that when you create a new instance of this custom painter, the painting logic knows whether it's different or not.
f5693e9 to
563a0a3
Compare
|
I did the refactor we talked about. Basically the ScrollbarPainter is mostly immutable minus opacity and scroll metrics. Moved animation, controller, timer out to the widget states. |
|
This is on my list to review, sorry I haven't gotten to it yet. |
| final ThemeData theme = Theme.of(context); | ||
| _currentPlatform = theme.platform; | ||
|
|
||
| if (_currentPlatform == TargetPlatform.iOS) { |
There was a problem hiding this comment.
here and in various other places: where you currently us an if to check the platform, use a switch so that the analyzer tells us if we missed handling a new platform when we add one
|
|
||
| /// A [CustomPainter] for painting scrollbars. | ||
| /// | ||
| /// Unlike [CustomPainter]s that sub-classes [CustomPainter] and only repaints |
| /// An opacity [Animation] that dictates the opacity of the thumb. | ||
| /// Changes in value of this [Listenable] will automatically trigger repaints. | ||
| /// Mustn't be null. | ||
| Animation<double> fadeoutOpacityAnimation; |
| /// | ||
| /// * the scroll position changes; and | ||
| /// * when the scrollbar fades away. | ||
| /// |
There was a problem hiding this comment.
These docs should talk about update() and how to use it
| assert(mainAxisMargin != null), | ||
| assert(crossAxisMargin != null), | ||
| assert(minLength != null) { | ||
| fadeoutOpacityAnimation.addListener(notifyListeners); |
There was a problem hiding this comment.
I think you need to override dispose() and call removeListener there.
Also, the docs need to talk about how it's important to call dispose() on this object when you're done with it.
There was a problem hiding this comment.
Added doc about needing to dispose.
ChangeNotifier.dispose already more or less does removeListener.
There was a problem hiding this comment.
How does ChangeNotifier know about fadeoutOpacityAnimation?
There was a problem hiding this comment.
ah you're right. Sorry, I mixed the 2 layers of listeners up.
|
Thanks for reviewing |
* Create CupertinoScrollbar * handle main axis margin * Adaptive material scrollbar and tests * Small tweaks * reapply changes on head * Docs * start * Refactored ScrollbarPainter to be more immutable * fix tests * fix bug: one animationcontroller pointed to multiple painters * some docs tweak * remove unused import * review * review * add dispose
Fixes #8774