Make shell hide/show animation smoother (#1683)
* Make shell hide/show animation smoother * Also animate "load latest"zio/stable
parent
c2a1cf4e56
commit
997918547c
|
@ -7,21 +7,22 @@ export function useMinimalShellMode() {
|
||||||
const store = useStores()
|
const store = useStores()
|
||||||
const minimalShellInterp = useAnimatedValue(0)
|
const minimalShellInterp = useAnimatedValue(0)
|
||||||
const footerMinimalShellTransform = {
|
const footerMinimalShellTransform = {
|
||||||
transform: [{translateY: Animated.multiply(minimalShellInterp, 100)}],
|
opacity: Animated.subtract(1, minimalShellInterp),
|
||||||
|
transform: [{translateY: Animated.multiply(minimalShellInterp, 50)}],
|
||||||
}
|
}
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (store.shell.minimalShellMode) {
|
if (store.shell.minimalShellMode) {
|
||||||
Animated.timing(minimalShellInterp, {
|
Animated.timing(minimalShellInterp, {
|
||||||
toValue: 1,
|
toValue: 1,
|
||||||
duration: 100,
|
duration: 150,
|
||||||
useNativeDriver: true,
|
useNativeDriver: true,
|
||||||
isInteraction: false,
|
isInteraction: false,
|
||||||
}).start()
|
}).start()
|
||||||
} else {
|
} else {
|
||||||
Animated.timing(minimalShellInterp, {
|
Animated.timing(minimalShellInterp, {
|
||||||
toValue: 0,
|
toValue: 0,
|
||||||
duration: 100,
|
duration: 150,
|
||||||
useNativeDriver: true,
|
useNativeDriver: true,
|
||||||
isInteraction: false,
|
isInteraction: false,
|
||||||
}).start()
|
}).start()
|
||||||
|
|
|
@ -24,13 +24,14 @@ export const FeedsTabBar = observer(function FeedsTabBarImpl(
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
Animated.timing(interp, {
|
Animated.timing(interp, {
|
||||||
toValue: store.shell.minimalShellMode ? 1 : 0,
|
toValue: store.shell.minimalShellMode ? 1 : 0,
|
||||||
duration: 100,
|
duration: 150,
|
||||||
useNativeDriver: true,
|
useNativeDriver: true,
|
||||||
isInteraction: false,
|
isInteraction: false,
|
||||||
}).start()
|
}).start()
|
||||||
}, [interp, store.shell.minimalShellMode])
|
}, [interp, store.shell.minimalShellMode])
|
||||||
const transform = {
|
const transform = {
|
||||||
transform: [{translateY: Animated.multiply(interp, -100)}],
|
opacity: Animated.subtract(1, interp),
|
||||||
|
transform: [{translateY: Animated.multiply(interp, -50)}],
|
||||||
}
|
}
|
||||||
|
|
||||||
const brandBlue = useColorSchemeStyle(s.brandBlue, s.blue3)
|
const brandBlue = useColorSchemeStyle(s.brandBlue, s.blue3)
|
||||||
|
|
|
@ -10,6 +10,10 @@ import {colors} from 'lib/styles'
|
||||||
import {HITSLOP_20} from 'lib/constants'
|
import {HITSLOP_20} from 'lib/constants'
|
||||||
import {isWeb} from 'platform/detection'
|
import {isWeb} from 'platform/detection'
|
||||||
import {clamp} from 'lib/numbers'
|
import {clamp} from 'lib/numbers'
|
||||||
|
import Animated, {useAnimatedStyle, withTiming} from 'react-native-reanimated'
|
||||||
|
|
||||||
|
const AnimatedTouchableOpacity =
|
||||||
|
Animated.createAnimatedComponent(TouchableOpacity)
|
||||||
|
|
||||||
export const LoadLatestBtn = observer(function LoadLatestBtnImpl({
|
export const LoadLatestBtn = observer(function LoadLatestBtnImpl({
|
||||||
onPress,
|
onPress,
|
||||||
|
@ -30,15 +34,18 @@ export const LoadLatestBtn = observer(function LoadLatestBtnImpl({
|
||||||
? 50
|
? 50
|
||||||
: (minMode || isDesktop ? 16 : 60) +
|
: (minMode || isDesktop ? 16 : 60) +
|
||||||
(isWeb ? 20 : clamp(safeAreaInsets.bottom, 15, 60))
|
(isWeb ? 20 : clamp(safeAreaInsets.bottom, 15, 60))
|
||||||
|
const animatedStyle = useAnimatedStyle(() => ({
|
||||||
|
bottom: withTiming(bottom, {duration: 150}),
|
||||||
|
}))
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity
|
<AnimatedTouchableOpacity
|
||||||
style={[
|
style={[
|
||||||
styles.loadLatest,
|
styles.loadLatest,
|
||||||
isDesktop && styles.loadLatestDesktop,
|
isDesktop && styles.loadLatestDesktop,
|
||||||
isTablet && styles.loadLatestTablet,
|
isTablet && styles.loadLatestTablet,
|
||||||
pal.borderDark,
|
pal.borderDark,
|
||||||
pal.view,
|
pal.view,
|
||||||
{bottom},
|
animatedStyle,
|
||||||
]}
|
]}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
hitSlop={HITSLOP_20}
|
hitSlop={HITSLOP_20}
|
||||||
|
@ -47,7 +54,7 @@ export const LoadLatestBtn = observer(function LoadLatestBtnImpl({
|
||||||
accessibilityHint="">
|
accessibilityHint="">
|
||||||
<FontAwesomeIcon icon="angle-up" color={pal.colors.text} size={19} />
|
<FontAwesomeIcon icon="angle-up" color={pal.colors.text} size={19} />
|
||||||
{showIndicator && <View style={[styles.indicator, pal.borderDark]} />}
|
{showIndicator && <View style={[styles.indicator, pal.borderDark]} />}
|
||||||
</TouchableOpacity>
|
</AnimatedTouchableOpacity>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue