ref(android): Cleanup and optimization for scroll view classes#10202
ref(android): Cleanup and optimization for scroll view classes#10202CatchABus wants to merge 9 commits intoNativeScript:mainfrom
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 38cded4. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch ✅ Successfully ran 2 targetsSent with 💌 from NxCloud. |
|
@CatchABus I really like those changes. Looks much cleaner and efficient (all relying on NestedScrollView original behavior). |
Thank you very much! I've marked it as draft for now because iOS has center alignment as default so I'll look more into this. |
|
@CatchABus and we can't have the child of the scrollview default android alignment set to center? That way it would not be a breaking change |
|
@farfromrefug I did a bit of work about that here: 462b993 It uses the gravity defaults we already had and applies result to scroll views until built-in layout is completed. In cases where scrollview nested layout has a fixed height but its children overlap, center alignment has still got different results but I think old behaviour was also different than that of iOS. I believe this PR needs testing with more scenarios. Also, we should consider if it was less of a trouble to keep copies of those classes like we did before. |
462b993 to
f651443
Compare
|
@CatchABus This looks great, but I am a little confused, does it contain a breaking change ? I do see differences in vertical alignment. ( Centering Vertically) |
I'm trying to imitate old layout behaviour as much as possible but patch might still be lacking few things. |
|
New plain typescript app, wrap stackLayout in ScrollView i.e. <Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo">
<ActionBar title="My App" icon="" />
<ScrollView >
<StackLayout class="p-20">
<Label text="Tap the button" class="h1 text-center" />
<Button text="TAP" tap="{{ onTap }}" class="-primary" />
<Label text="{{ message }}" class="h2 text-center" textWrap="true" />
</StackLayout>
</ScrollView>
</Page> |
|
@jcassidyav I committed 2 fixes, one of which solves the problem you described. New changes have caused one of |
|
@CatchABus Another odd one, when a scroll view is used inside a @nativescript-community/ui-material-tabs , it no longer scrolls. No errors it just won't respond to a touch to scroll it. e.g. https://stackblitz.com/edit/nativescript-stackblitz-templates-dgf6vd?file=app/main-page.xml |
|
@farfromrefug @jcassidyav I close this in favor of #10213 . Layout rework gave me trouble because of how it currently works in {N} so I focused solely on exception fix. |


PR Checklist
What is the current behavior?
NativeScript scroll views are currently inheriting android
NestedScrollViewandHorizontalScrollViewclasses. This results in NativeScript horizontal and vertical scrollviews containing features that are already implemented by those classes mentioned above.In addition, scroll view saved state has stopped working because of conflict problems. See #10200
What is the new behavior?
This patch gets rid of obsolete code and fixes open issue at the same time.
On top of that, scroll view classes will now call superclass
onLayoutwhich handles saved state restoration too.@farfromrefug Your opinion is very important on this one.
Fixes/Closes #10200.