Use dimensions hook
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
|||||||
useRef,
|
useRef,
|
||||||
useState,
|
useState,
|
||||||
} from 'react'
|
} from 'react'
|
||||||
import {Dimensions, View} from 'react-native'
|
import {useWindowDimensions, View} from 'react-native'
|
||||||
import Animated, {Easing, ZoomIn} from 'react-native-reanimated'
|
import Animated, {Easing, ZoomIn} from 'react-native-reanimated'
|
||||||
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||||
|
|
||||||
@@ -185,6 +185,7 @@ function Bubble({
|
|||||||
}) {
|
}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const insets = useSafeAreaInsets()
|
const insets = useSafeAreaInsets()
|
||||||
|
const dimensions = useWindowDimensions()
|
||||||
const [bubbleMeasurements, setBubbleMeasurements] = useState<
|
const [bubbleMeasurements, setBubbleMeasurements] = useState<
|
||||||
| {
|
| {
|
||||||
width: number
|
width: number
|
||||||
@@ -203,7 +204,7 @@ function Bubble({
|
|||||||
tipLeft: 0,
|
tipLeft: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
const {width: ww, height: wh} = Dimensions.get('window')
|
const {width: ww, height: wh} = dimensions
|
||||||
const maxTop = insets.top
|
const maxTop = insets.top
|
||||||
const maxBottom = wh - insets.bottom
|
const maxBottom = wh - insets.bottom
|
||||||
const {width: cw, height: ch} = bubbleMeasurements
|
const {width: cw, height: ch} = bubbleMeasurements
|
||||||
@@ -273,7 +274,7 @@ function Bubble({
|
|||||||
tipTop,
|
tipTop,
|
||||||
tipLeft,
|
tipLeft,
|
||||||
}
|
}
|
||||||
}, [position, targetMeasurements, bubbleMeasurements, insets])
|
}, [position, targetMeasurements, bubbleMeasurements, insets, dimensions])
|
||||||
|
|
||||||
const requestCloseWrapped = useCallback(() => {
|
const requestCloseWrapped = useCallback(() => {
|
||||||
setBubbleMeasurements(undefined)
|
setBubbleMeasurements(undefined)
|
||||||
|
|||||||
Reference in New Issue
Block a user