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

Add option to StretchingSheetPhysics to limit stretchable direction #159

Closed
fujidaiti opened this issue Jun 4, 2024 · 6 comments · Fixed by #171
Closed

Add option to StretchingSheetPhysics to limit stretchable direction #159

fujidaiti opened this issue Jun 4, 2024 · 6 comments · Fixed by #171
Assignees
Labels
feature request New feature or request P1
Milestone

Comments

@fujidaiti
Copy link
Owner

fujidaiti commented Jun 4, 2024

Hi @habibasseiss,

When the screen gets pulled up, I don't think it's a matter of giving the background a color, instead the physics could "attach" to the bottom to prevent showing the parent screen.

Thanks for the suggestion! I agree with this idea and so I will add an option to StretchingSheetPhysics to limit the directions in which the sheet can stretch.

// Does not work in the current version
DraggableSheet(
  physics: StretchingSheetPhysics(
  // This disables the stretching effect when overdragging upward
    direction: StretchingBehaviorDIrection.downward,
  ),
);

Originally posted by @fujidaiti in #157 (comment)

@fujidaiti fujidaiti self-assigned this Jun 4, 2024
@fujidaiti fujidaiti added feature request New feature or request P1 labels Jun 4, 2024
@fujidaiti fujidaiti added this to the v1 milestone Jun 4, 2024
@appinteractive
Copy link

Is there also a way to specify the max stretch distance?

@mark8044
Copy link

mark8044 commented Jun 4, 2024

Would it be a hard stop when pulling up, or still give a Bouncing effect?

@habibasseiss
Copy link

habibasseiss commented Jun 4, 2024

I'd love to have max stretch like @appinteractive suggested. In the native sheet, the stretch stops at the reduced parent page limits.

Here's the behavior of a basic sheet in SwiftUI:

swiftui-sheet.mp4

Source code: https://gist.github.com/habibasseiss/d14c375c40b6a543a8043d2aedc00c36

Having that in addition to the sheet attaching the bottom would be amazing!

@fujidaiti
Copy link
Owner Author

fujidaiti commented Jun 5, 2024

@appinteractive

Is there also a way to specify the max stretch distance?

StretchingSheetPhysics.stretchingRange could be used for this purpose. It determines how many pixels the sheet can be overdragged. (Sorry for the lack of documentation, I'll try to get it done before the first stable release.)

// Overdragging is disabled.
StretchingSheetPhysics(stretchingRange: const Extent.pixels(0));

// The sheet can be overdragged by ±100 pixels.
StretchingSheetPhysics(stretchingRange: const Extent.pixels(100));

// The sheet can be overdragged by ±10% of the sheet height.
StretchingSheetPhysics(stretchingRange: const Extent.proportional(0.1));

I think it would be nice to allow this property to be set for each direction.

@appinteractive
Copy link

I think it would be nice to allow this property to be set for each direction.

That's a great idea!

@fujidaiti
Copy link
Owner Author

fujidaiti commented Jun 11, 2024

I'd love to have max stretch like @appinteractive suggested. In the native sheet, the stretch stops at the reduced parent page limits. ... Having that in addition to the sheet attaching the bottom would be amazing!

I think another effort is needed to achieve this behavior...
I have created an issue (#169) to track this topic, so please follow up if interested.

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

Successfully merging a pull request may close this issue.

4 participants