add status bar shadow
This commit is contained in:
@@ -23,6 +23,7 @@ import {LabelsOnMe} from '#/components/moderation/LabelsOnMe'
|
||||
import {ProfileHeaderAlerts} from '#/components/moderation/ProfileHeaderAlerts'
|
||||
import {GrowableAvatar} from './GrowableAvatar'
|
||||
import {GrowableBanner} from './GrowableBanner'
|
||||
import {StatusBarShadow} from './StatusBarShadow'
|
||||
|
||||
interface Props {
|
||||
profile: Shadow<AppBskyActorDefs.ProfileViewDetailed>
|
||||
@@ -101,6 +102,7 @@ let ProfileHeaderShell = ({
|
||||
<View
|
||||
pointerEvents={isIOS ? 'auto' : 'box-none'}
|
||||
style={[a.relative, {height: 150}]}>
|
||||
<StatusBarShadow />
|
||||
<GrowableBanner
|
||||
backButton={
|
||||
<>
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import Animated, {SharedValue, useAnimatedStyle} from 'react-native-reanimated'
|
||||
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||
import {LinearGradient} from 'expo-linear-gradient'
|
||||
|
||||
import {isIOS} from '#/platform/detection'
|
||||
import {usePagerHeaderContext} from '#/view/com/pager/PagerHeaderContext'
|
||||
import {atoms as a} from '#/alf'
|
||||
|
||||
const AnimatedLinearGradient = Animated.createAnimatedComponent(LinearGradient)
|
||||
|
||||
export function StatusBarShadow() {
|
||||
const {top: topInset} = useSafeAreaInsets()
|
||||
const pagerContext = usePagerHeaderContext()
|
||||
|
||||
if (isIOS && pagerContext) {
|
||||
const {scrollY} = pagerContext
|
||||
return <StatusBarShadowInnner scrollY={scrollY} />
|
||||
}
|
||||
|
||||
return (
|
||||
<LinearGradient
|
||||
colors={['rgba(0,0,0,0.5)', 'rgba(0,0,0,0)']}
|
||||
style={[
|
||||
a.absolute,
|
||||
a.z_10,
|
||||
{height: topInset, top: 0, left: 0, right: 0},
|
||||
]}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function StatusBarShadowInnner({scrollY}: {scrollY: SharedValue<number>}) {
|
||||
const {top: topInset} = useSafeAreaInsets()
|
||||
|
||||
const animatedStyle = useAnimatedStyle(() => {
|
||||
console.log(scrollY.get())
|
||||
return {
|
||||
transform: [
|
||||
{
|
||||
translateY: Math.min(0, scrollY.get()),
|
||||
},
|
||||
],
|
||||
}
|
||||
})
|
||||
|
||||
return (
|
||||
<AnimatedLinearGradient
|
||||
colors={['rgba(0,0,0,0.5)', 'rgba(0,0,0,0)']}
|
||||
style={[
|
||||
animatedStyle,
|
||||
a.absolute,
|
||||
a.z_10,
|
||||
{height: topInset, top: 0, left: 0, right: 0},
|
||||
]}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export function StatusBarShadow() {
|
||||
return null
|
||||
}
|
||||
@@ -9,7 +9,8 @@ export const PagerHeaderContext = React.createContext<{
|
||||
} | null>(null)
|
||||
|
||||
/**
|
||||
* Passes information about the
|
||||
* Passes information about the scroll position and header height down via
|
||||
* context for the pager header to consume.
|
||||
*
|
||||
* @platform ios, android
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user