experiment with different drawer style

This commit is contained in:
Samuel Newman
2025-11-07 21:51:27 +02:00
parent 9583c310b9
commit 9be229e3fd
2 changed files with 86 additions and 62 deletions
+25 -1
View File
@@ -1,5 +1,7 @@
import React, {type ComponentProps, type JSX} from 'react' import React, {type ComponentProps, type JSX} from 'react'
import {Linking, ScrollView, TouchableOpacity, View} from 'react-native' import {Linking, ScrollView, TouchableOpacity, View} from 'react-native'
import {useDrawerProgress} from 'react-native-drawer-layout'
import Animated, {interpolate, useAnimatedStyle} from 'react-native-reanimated'
import {useSafeAreaInsets} from 'react-native-safe-area-context' import {useSafeAreaInsets} from 'react-native-safe-area-context'
import {msg, Plural, plural, Trans} from '@lingui/macro' import {msg, Plural, plural, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
@@ -13,7 +15,7 @@ import {getTabState, TabState} from '#/lib/routes/helpers'
import {type NavigationProp} from '#/lib/routes/types' import {type NavigationProp} from '#/lib/routes/types'
import {sanitizeHandle} from '#/lib/strings/handles' import {sanitizeHandle} from '#/lib/strings/handles'
import {colors} from '#/lib/styles' import {colors} from '#/lib/styles'
import {isWeb} from '#/platform/detection' import {isIOS, isWeb} from '#/platform/detection'
import {emitSoftReset} from '#/state/events' import {emitSoftReset} from '#/state/events'
import {useKawaiiMode} from '#/state/preferences/kawaii' import {useKawaiiMode} from '#/state/preferences/kawaii'
import {useUnreadNotifications} from '#/state/queries/notifications/unread' import {useUnreadNotifications} from '#/state/queries/notifications/unread'
@@ -263,8 +265,10 @@ let DrawerContent = ({}: React.PropsWithoutRef<{}>): React.ReactNode => {
<View <View
testID="drawer" testID="drawer"
style={[a.flex_1, a.border_r, t.atoms.bg, t.atoms.border_contrast_low]}> style={[a.flex_1, a.border_r, t.atoms.bg, t.atoms.border_contrast_low]}>
<AnimatedDrawerContent>
<ScrollView <ScrollView
style={[a.flex_1]} style={[a.flex_1]}
showsVerticalScrollIndicator={false}
contentContainerStyle={[ contentContainerStyle={[
{ {
paddingTop: Math.max( paddingTop: Math.max(
@@ -327,12 +331,32 @@ let DrawerContent = ({}: React.PropsWithoutRef<{}>): React.ReactNode => {
onPressFeedback={onPressFeedback} onPressFeedback={onPressFeedback}
onPressHelp={onPressHelp} onPressHelp={onPressHelp}
/> />
</AnimatedDrawerContent>
</View> </View>
) )
} }
DrawerContent = React.memo(DrawerContent) DrawerContent = React.memo(DrawerContent)
export {DrawerContent} export {DrawerContent}
const AnimatedDrawerContent = isIOS ? DrawerProgressAnimation : View
function DrawerProgressAnimation({children}: {children: React.ReactNode}) {
const drawerProgress = useDrawerProgress()
const animatedStyle = useAnimatedStyle(() => {
const progress = drawerProgress.get()
return {
opacity: progress,
transform: [{scale: interpolate(progress, [0, 1], [0.9, 1])}],
}
})
return (
<Animated.View style={[a.flex_1, animatedStyle]}>{children}</Animated.View>
)
}
let DrawerFooter = ({ let DrawerFooter = ({
onPressFeedback, onPressFeedback,
onPressHelp, onPressHelp,
+1 -1
View File
@@ -178,7 +178,7 @@ function DrawerLayout({children}: {children: React.ReactNode}) {
swipeEdgeWidth={winDim.width} swipeEdgeWidth={winDim.width}
swipeMinVelocity={100} swipeMinVelocity={100}
swipeMinDistance={10} swipeMinDistance={10}
drawerType={isIOS ? 'slide' : 'front'} drawerType={isIOS ? 'back' : 'front'}
overlayStyle={{ overlayStyle={{
backgroundColor: select(t.name, { backgroundColor: select(t.name, {
light: 'rgba(0, 57, 117, 0.1)', light: 'rgba(0, 57, 117, 0.1)',