Comments (5)
@izakfilmalter seems lit! we can refactor it to work with this library. I will try to create a PR soon, thanks!
from react-navigation-bottom-sheet.
I have the following patch to BottomSheetView to get dynamic snap points working. I don't know if there are performance issues with this, but everything should work.
You will need a Provider to pass handleContentLayout
to your modal
import { createContext } from 'react'
import { LayoutChangeEvent } from 'react-native'
export const NavigationContext = createContext<{
handleContentLayout?: (event: LayoutChangeEvent) => void
}>({})
Patch:
patches/@th3rdwave+react-navigation-bottom-sheet+0.2.2.patch
diff --git a/node_modules/@th3rdwave/react-navigation-bottom-sheet/src/BottomSheetView.tsx b/node_modules/@th3rdwave/react-navigation-bottom-sheet/src/BottomSheetView.tsx
index a83edbe..d25e296 100644
--- a/node_modules/@th3rdwave/react-navigation-bottom-sheet/src/BottomSheetView.tsx
+++ b/node_modules/@th3rdwave/react-navigation-bottom-sheet/src/BottomSheetView.tsx
@@ -2,6 +2,7 @@ import {
BottomSheetModal,
BottomSheetModalProps,
BottomSheetModalProvider,
+ useBottomSheetDynamicSnapPoints,
} from '@gorhom/bottom-sheet';
import { ParamListBase, useTheme } from '@react-navigation/native';
import * as React from 'react';
@@ -12,6 +13,7 @@ import type {
BottomSheetNavigationProp,
BottomSheetNavigationState,
} from './types';
+import { NavigationContext } from '@krewsocial/krew/Navigation/NavigationContext'
type BottomSheetModalScreenProps = BottomSheetModalProps & {
navigation: BottomSheetNavigationProp<ParamListBase>;
@@ -20,14 +22,24 @@ type BottomSheetModalScreenProps = BottomSheetModalProps & {
function BottomSheetModalScreen({
navigation,
index,
+ snapPoints = DEFAULT_SNAP_POINTS,
+ children,
...props
}: BottomSheetModalScreenProps) {
const ref = React.useRef<BottomSheetModal>(null);
const lastIndexRef = React.useRef(index);
+ const {
+ animatedHandleHeight,
+ animatedSnapPoints,
+ animatedContentHeight,
+ handleContentLayout,
+ } = useBottomSheetDynamicSnapPoints(snapPoints as Array<string | number>)
+
// Present on mount.
React.useEffect(() => {
ref.current?.present();
+
}, []);
const isMounted = React.useRef(true);
@@ -62,13 +74,21 @@ function BottomSheetModalScreen({
}, [navigation]);
return (
- <BottomSheetModal
- ref={ref}
- index={index}
- onChange={onChange}
- onDismiss={onDismiss}
- {...props}
- />
+
+ <BottomSheetModal
+ ref={ref}
+ index={index}
+ onChange={onChange}
+ onDismiss={onDismiss}
+ snapPoints={animatedSnapPoints}
+ handleHeight={animatedHandleHeight}
+ contentHeight={animatedContentHeight}
+ {...props}
+ >
+ <NavigationContext.Provider value={{handleContentLayout}}>
+ {children}
+ </NavigationContext.Provider>
+ </BottomSheetModal>
);
}
Modal:
export const Modal = () => {
const { handleContentLayout } = useContext(NavigationContext)
return (
<BottomSheetView
style={{ height: 100 }}
onLayout={handleContentLayout}
>
<Content1>Hangout Feedback</Content1>
</BottomSheetView>
)
}
from react-navigation-bottom-sheet.
Can you share the implementation? @joseortiz9
from react-navigation-bottom-sheet.
Ya would love to know what you did.
from react-navigation-bottom-sheet.
thanks @mtzfactory for the fix!
from react-navigation-bottom-sheet.
Related Issues (19)
- A property "headerShown" is NOT controlling the screen header visibility
- Closing all open modals. HOT 1
- Chrome Debugger problem
- footerComponent props is not rendering
- Android: Swipe-to-close doesn't work
- Panning down a screen with open keyboard throws an error
- How to style the sheet?
- Issue with new 0.2.4 version and centralized views not running to the bottom of the sheet HOT 1
- BottomSheetScrollView doesn't work! HOT 12
- Doesn't seems to work with BottomSheetFlatList HOT 1
- How to render backdrop above react navigation header
- When you QUICKLY press the back button "<" in android, it does not close all the BottomSheet.
- Unexpected error while trying to run the official example
- Cannot use `presentation: 'fullScreenModal` ? HOT 1
- Keyboard Configuration are not working HOT 1
- Lack of stackBehavior property
- BottomSheetScrollView doesn't work! HOT 1
- Functionality for rendering a single modal over a stack HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-navigation-bottom-sheet.