Skip to content
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

Snapping #16

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft

Snapping #16

wants to merge 12 commits into from

Conversation

RareScrap
Copy link
Contributor

Issue #14

  • Extracted defaults

@onebone
Copy link
Owner

onebone commented Nov 14, 2021

@RareScrap I have scanned your code so far, I have some possible options that can deal with the difficulties you have pointed at #14.

For scroll strategies other than ExitUntilCollapsed, they need to modify offsetY which is a member of CollapsingToolbarScaffoldState. The cause derives from the fact that snap behavior is actually a feature of CollapsingToolbarScaffold. I expect the problem would be fixed if you move the snapping methods to ScaffoldState.

And for interrupting animation with user inputs, I think it may be solved by utilizing MutatePriority though it may need some extra researches.

@onebone onebone added the feature New feature or request label Nov 16, 2021
@RareScrap
Copy link
Contributor Author

Thank you for your review. I was little busy last weekend. Will done with PR at this weekend.

@onebone
Copy link
Owner

onebone commented Nov 25, 2021

Great!

…rScaffoldState

+ Defaults naming refactoring
+ TODOs added
@RareScrap
Copy link
Contributor Author

There are many TODOs that require your attension. Please comment on each of them so we can discuss them.

@onebone
Copy link
Owner

onebone commented Dec 2, 2021

Thank you for reminding, I will review it until this weekend!

}
}

// TODO: Is there a better solution rather OptIn ExperimentalToolbarApi?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What makes it bother you??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't decide what to use: @ExperimentalToolbarApi or @OptIn(ExperimentalToolbarApi::class). I suppose that @ExperimentalToolbarApi is using for public animation methods and @OptIn(ExperimentalToolbarApi::class) safe to use in internal methods but I'm not sure.

What are you think? Why you using @ExperimentalToolbarApi at all?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expierence

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expierence

Sorry, I don't understand you. What exactly do you mean by this?

lib/src/main/java/me/onebone/toolbar/SnapStrategy.kt Outdated Show resolved Hide resolved
RareScrap and others added 9 commits December 23, 2021 22:03
- when toolbar is expanded or collapsed fully, do not perform snap (as it is not needed), this is the case, when progress == 0 or 1
- this improves performance and fixes a bug with horizontal scrolling in the CollapsingToolbarScaffold content
Add check whether snap to perform snap
@ChristopherKlammt
Copy link

@onebone what are the plans for merging this PR?

@RareScrap
Copy link
Contributor Author

There is a bug in it. I will describe it tomorrow.

Copy link

@Marx6 Marx6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coded

}
}

// TODO: Is there a better solution rather OptIn ExperimentalToolbarApi?
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expierence

}

// TODO: Is there a better solution rather OptIn ExperimentalToolbarApi?
@OptIn(ExperimentalToolbarApi::class)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expandOffset and collapseOffset are experimental because it is subject to change their behavior or surface anytime. Meantime, performSnap is private and we don't have to be warned by this potential change so I think it would be sufficient.

@@ -76,15 +67,15 @@ fun AppBarContainer(
modifier: Modifier = Modifier,
scrollStrategy: ScrollStrategy,
/** The state of a connected collapsing toolbar */
collapsingToolbarState: CollapsingToolbarState,
collapsingToolbarScaffoldState: CollapsingToolbarScaffoldState,
content: @Composable AppbarContainerScope.() -> Unit
) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert contract(i.e. parameter or behavior) changes in AppBarContainer.kt as it is in maintenance mode and thus should not be changed until it is removed!

return left
}

// TODO: A strange jump in snap speed is often observed
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bug I mentioned. You can see a strange expanding before the snap will applied. This sometimes works even in wrong direction. Look at the demonstration GIF:

When I release the finger you can see that snapping is moving in wrong direction (to top) before it finally snap to full size.

I tried to debug it and I suppose that a bug is in implementation of EnterAlwaysCollapsedNestedScrollConnection#onPostScroll() method. Unfortunately I don't know how NestedScrollConnection and math in EnterAlwaysCollapsedNestedScrollConnection work. I will be glad if you help me with it. Try to build an example app and reproduce this bug.

@onebone onebone linked an issue Jan 23, 2022 that may be closed by this pull request
@RareScrap
Copy link
Contributor Author

Sorry guys, I was too busy to done with it but now I have some time :)

@jkwiecien
Copy link

Rooting for that snapping guys! :)

@GIGAMOLE
Copy link

GIGAMOLE commented May 8, 2023

Hi, I created a newer version of the snapping feature here: #83

PR contains the recorded gifs and you can test it by yourself. For me, it seems like everything is working fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Snap on release
9 participants