Something went wrong. Try again.
Mirror — see github.com/blacksky-algorithms/blacksky.community
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091import {type ComponentProps, type JSX} from 'react'import { type GestureResponderEvent, type Pressable, type StyleProp, StyleSheet, type ViewStyle,} from 'react-native'import Animated from 'react-native-reanimated'import {useSafeAreaInsets} from 'react-native-safe-area-context'
import {PressableScale} from '#/lib/custom-animations/PressableScale'import {useHaptics} from '#/lib/haptics'import {useMinimalShellFabTransform} from '#/lib/hooks/useMinimalShellTransform'import {clamp} from '#/lib/numbers'import {atoms as a, ios, useBreakpoints, useTheme} from '#/alf'import {IS_WEB} from '#/env'
export interface FABProps extends ComponentProps<typeof Pressable> { testID?: string icon: JSX.Element style?: StyleProp<ViewStyle>}
export function FABInner({testID, icon, onPress, style, ...props}: FABProps) { const insets = useSafeAreaInsets() const {gtMobile} = useBreakpoints() const t = useTheme() const playHaptic = useHaptics() const fabMinimalShellTransform = useMinimalShellFabTransform()
const size = gtMobile ? styles.sizeLarge : styles.sizeRegular
const tabletSpacing = gtMobile ? {right: 50, bottom: 50} : {right: 24, bottom: clamp(insets.bottom, 15, 60) + 15}
return ( <Animated.View style={[ styles.outer, size, tabletSpacing, !gtMobile && fabMinimalShellTransform, ]}> <PressableScale testID={testID} onPressIn={ios(() => playHaptic('Light'))} onPress={evt => { onPress?.(evt) playHaptic('Light') }} onLongPress={ios((evt: GestureResponderEvent) => { onPress?.(evt) playHaptic('Heavy') })} targetScale={0.9} style={[ a.rounded_full, size, {backgroundColor: t.palette.primary_500}, a.align_center, a.justify_center, style, ]} {...props}> {icon} </PressableScale> </Animated.View> )}
const styles = StyleSheet.create({ sizeRegular: { width: 56, height: 56, borderRadius: 30, }, sizeLarge: { width: 70, height: 70, borderRadius: 35, }, outer: { // @ts-ignore web-only position: IS_WEB ? 'fixed' : 'absolute', zIndex: 1, cursor: 'pointer', },})