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

Issue with animated height of sheet. #125

Open
izakfilmalter opened this issue Jan 27, 2025 · 1 comment
Open

Issue with animated height of sheet. #125

izakfilmalter opened this issue Jan 27, 2025 · 1 comment

Comments

@izakfilmalter
Copy link

I am trying to animate the bottom space in my true-sheet based on the state of the keyboard. When the keyboard is closed, I have it set to add marginBottom to my Animated.View for the bottom inset. When the keyboard opens, I animate that to 0 in sync with the keyboard animation. This happens correctly, but true-sheet is not updating the height of my sheet.

import { TrueSheet } from '@lodev09/react-native-true-sheet'
import { useRef } from 'react'
import { Pressable, Text, TextInput, View } from 'react-native'
import { useReanimatedKeyboardAnimation } from 'react-native-keyboard-controller'
import Animated, { interpolate, useAnimatedStyle } from 'react-native-reanimated'
import { useSafeAreaInsets } from 'react-native-safe-area-context'

export default function SettingsScreen() {
  const sheet = useRef<TrueSheet>(null)

  const { bottom } = useSafeAreaInsets()

  const { progress } = useReanimatedKeyboardAnimation()

  const animatedStyle = useAnimatedStyle(() => ({
    marginBottom: interpolate(progress.value, [0, 1], [bottom, 0]),
  }))

  // Present the sheet ✅
  const present = async () => {
    await sheet.current?.present()
    console.log('horray! sheet has been presented 💩')
  }

  // Dismiss the sheet ✅
  const dismiss = async () => {
    await sheet.current?.dismiss()
    console.log('Bye bye 👋')
  }

  return (
    <View>
      <Pressable onPress={present}>
        <Text>Present Sheet</Text>
      </Pressable>

      <TrueSheet ref={sheet} sizes={['auto']} cornerRadius={24} blurTint={'dark'}>
        <Animated.View className={'relative bg-background'} style={animatedStyle}>
          <View className={'p-4'}>
            <View className={'h-64'}></View>

            <TextInput />
          </View>

          <View className={'absolute top-[100%] right-0 left-0 h-32 bg-background'} />
        </Animated.View>
      </TrueSheet>
    </View>
  )
}
@lodev09
Copy link
Owner

lodev09 commented Jan 27, 2025

Unfortunately, TrueSheet doesn't have first class support for Reanimated.

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

No branches or pull requests

2 participants