Giter VIP home page Giter VIP logo

Comments (5)

joseortiz9 avatar joseortiz9 commented on September 9, 2024 3

@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.

izakfilmalter avatar izakfilmalter commented on September 9, 2024 1

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.

Shystee avatar Shystee commented on September 9, 2024

Can you share the implementation? @joseortiz9

from react-navigation-bottom-sheet.

izakfilmalter avatar izakfilmalter commented on September 9, 2024

Ya would love to know what you did.

from react-navigation-bottom-sheet.

joseortiz9 avatar joseortiz9 commented on September 9, 2024

thanks @mtzfactory for the fix!

from react-navigation-bottom-sheet.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.