-
-
Notifications
You must be signed in to change notification settings - Fork 741
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
Automatically auto adjusting content WITH dynamic snap points #1418
Comments
@karimcambridge Hey, if you set the string 'CONTENT_HEIGHT' as the initial snap point, the component will use it as a placeholder value to add calculated snap points based on the content. You don't need to manually set snap points based on the app state. Like this: And then pass |
Hello. I tried that at first, it’s buggy. And that also doesn’t achieve having “multiple snap points” |
For example @maximus986 this is with CONTENT_HEIGHT. This makes no sense for my UX. I want it to have 2 'DYNAMIC` snap points My custom solution (with 2 snappoints) The issue with my solution is that it only works when you double save on simulator, doesn't work otherwise because of how the hooks work i guess. So my suggestion is for actual dynamic snap points that you can change based on some variable. Not just automatically calculated bottom sheet height, which is what that feature is actually doing. |
My solution so far is to place the highest snappoint first like this
But it seems like this only works on initial render, like e.g setup. Whether or not you use Thus when the user tries to close the sheet, it will go to the smaller snappoint but with a higher index. I hope y’all get what i'm trying to explain here. |
I have been able to achieve this with a small hack. In the // BottomSheet.tsx
import RNBottomSheet, { useBottomSheetDynamicSnapPoints } from '@gorhom/bottom-sheet';
export const BottomSheet: React.FC = () => {
const initialSnapPoints = useMemo(() => [75, 'CONTENT_HEIGHT'], []);
const {
animatedHandleHeight,
animatedSnapPoints,
animatedContentHeight,
handleContentLayout,
} = useBottomSheetDynamicSnapPoints(initialSnapPoints);
return (
<RNBottomSheet
index={1}
snapPoints={animatedSnapPoints}
handleHeight={animatedHandleHeight}
contentHeight={animatedContentHeight}
>
<StuffWithDynamicContent />
</RNBottomSheet>
);
}; // StuffWithDynamicContent.tsx
import { useBottomSheet } from '@gorhom/bottom-sheet';
export const StuffWithDynamicContent: React.FC = () => {
const { snapToIndex } = useBottomSheet();
return (
<View
onLayout={() => { // resnap to the same index that corresponds to CONTENT_HEIGHT
setTimeout(() => {
snapToIndex(1);
}, 50); // needed tiny timout to make sure dynamic content fully rendered
}}
>
// dynamic content here
</View>
);
}; When the children of the |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
This issue was closed because it has been stalled for 5 days with no activity. |
Let's not close this. |
Feature Request
So my main app screen as various 'states', where lets say there are 4 states and each state needs different dynamic content in the bottom sheet and have different snap points. I'm trying to figure out how to achieve this. Think rideshare applications.
Why it is needed
More adjustability, better UX.
Possible implementation
Not sure
Code sample
This is my current code, how I’m handling the situation currently:
So here's the issue, I can't have real dynamic snappoints? I'd like when the app is in state
actionTypes.ride.request.DRIVER
, that the bottom sheet be able to open to a certain position (seeinitialSnapPoints
) but then when it’s in other states, nada.Suggestions:
Not sure how to solve this, but if it’s possible already, let me know, else let's talk.
The text was updated successfully, but these errors were encountered: