Bluesky app fork with some witchin' additions 💫

Improve consistency of floating button positioning (#1501)

authored by

Paul Frazee and committed by
GitHub
68dd3210 f5e9e4af

+17 -26
+8 -19
src/view/com/util/fab/FABInner.tsx
··· 6 6 import {useAnimatedValue} from 'lib/hooks/useAnimatedValue' 7 7 import {useStores} from 'state/index' 8 8 import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries' 9 - import {isWeb} from 'platform/detection' 9 + import {useSafeAreaInsets} from 'react-native-safe-area-context' 10 + import {clamp} from 'lib/numbers' 10 11 11 12 export interface FABProps 12 13 extends ComponentProps<typeof TouchableWithoutFeedback> { ··· 19 20 icon, 20 21 ...props 21 22 }: FABProps) { 23 + const insets = useSafeAreaInsets() 22 24 const {isTablet} = useWebMediaQueries() 23 25 const store = useStores() 24 26 const interp = useAnimatedValue(0) 25 27 React.useEffect(() => { 26 28 Animated.timing(interp, { 27 - toValue: store.shell.minimalShellMode ? 1 : 0, 29 + toValue: store.shell.minimalShellMode ? 0 : 1, 28 30 duration: 100, 29 31 useNativeDriver: true, 30 32 isInteraction: false, ··· 33 35 const transform = isTablet 34 36 ? undefined 35 37 : { 36 - transform: [{translateY: Animated.multiply(interp, 60)}], 38 + transform: [{translateY: Animated.multiply(interp, -44)}], 37 39 } 38 40 const size = isTablet ? styles.sizeLarge : styles.sizeRegular 41 + const right = isTablet ? 50 : 24 42 + const bottom = isTablet ? 50 : clamp(insets.bottom, 15, 60) + 15 39 43 return ( 40 44 <TouchableWithoutFeedback testID={testID} {...props}> 41 - <Animated.View 42 - style={[ 43 - styles.outer, 44 - size, 45 - isWeb && isTablet 46 - ? { 47 - right: 50, 48 - bottom: 50, 49 - } 50 - : { 51 - bottom: 114, 52 - }, 53 - transform, 54 - ]}> 45 + <Animated.View style={[styles.outer, size, {right, bottom}, transform]}> 55 46 <LinearGradient 56 47 colors={[gradients.blueLight.start, gradients.blueLight.end]} 57 48 start={{x: 0, y: 0}} ··· 78 69 outer: { 79 70 position: 'absolute', 80 71 zIndex: 1, 81 - right: 24, 82 - bottom: 94, 83 72 }, 84 73 inner: { 85 74 justifyContent: 'center',
+9 -7
src/view/com/util/load-latest/LoadLatestBtn.tsx
··· 3 3 import {observer} from 'mobx-react-lite' 4 4 import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' 5 5 import {useSafeAreaInsets} from 'react-native-safe-area-context' 6 - import {clamp} from 'lodash' 7 6 import {useStores} from 'state/index' 8 7 import {usePalette} from 'lib/hooks/usePalette' 9 8 import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries' 10 9 import {colors} from 'lib/styles' 11 10 import {HITSLOP_20} from 'lib/constants' 11 + import {isWeb} from 'platform/detection' 12 + import {clamp} from 'lib/numbers' 12 13 13 14 export const LoadLatestBtn = observer(function LoadLatestBtnImpl({ 14 15 onPress, ··· 22 23 }) { 23 24 const store = useStores() 24 25 const pal = usePalette('default') 25 - const {isDesktop, isTablet, isMobile} = useWebMediaQueries() 26 + const {isDesktop, isTablet} = useWebMediaQueries() 26 27 const safeAreaInsets = useSafeAreaInsets() 28 + const minMode = store.shell.minimalShellMode 29 + const bottom = isTablet 30 + ? 50 31 + : (minMode ? 16 : 60) + (isWeb ? 20 : clamp(safeAreaInsets.bottom, 15, 60)) 27 32 return ( 28 33 <TouchableOpacity 29 34 style={[ ··· 32 37 isTablet && styles.loadLatestTablet, 33 38 pal.borderDark, 34 39 pal.view, 35 - isMobile && 36 - !store.shell.minimalShellMode && { 37 - bottom: 60 + clamp(safeAreaInsets.bottom, 15, 30), 38 - }, 40 + {bottom}, 39 41 ]} 40 42 onPress={onPress} 41 43 hitSlop={HITSLOP_20} ··· 52 54 loadLatest: { 53 55 position: 'absolute', 54 56 left: 18, 55 - bottom: 35, 57 + bottom: 44, 56 58 borderWidth: 1, 57 59 width: 52, 58 60 height: 52,