rm gesture

This commit is contained in:
Hailey
2024-06-23 12:47:57 -07:00
parent 29368acec1
commit 94cb6ea709
5 changed files with 142 additions and 213 deletions
@@ -1,28 +0,0 @@
import React from 'react'
import {Gesture, GestureDetector} from 'react-native-gesture-handler'
import {runOnJS} from 'react-native-reanimated'
export function BackGestureDetector({
onBack,
children,
}: {
onBack: () => void
children: React.ReactNode
}) {
const swipeGesture = Gesture.Pan()
.maxPointers(1)
.onEnd(({translationX, translationY, velocityX}) => {
if (
// Make sure it isn't a scrollview
translationX > translationY &&
translationY <= 10 &&
translationX >= 25 &&
// Shouldn't be a really slow swipe
velocityX >= 300
) {
runOnJS(onBack)()
}
})
return <GestureDetector gesture={swipeGesture}>{children}</GestureDetector>
}
@@ -1,11 +0,0 @@
import React from 'react'
export function BackGestureDetector({
onBack: _onBack,
children,
}: {
onBack: () => void
children: React.ReactNode
}) {
return children
}
+1 -15
View File
@@ -2,16 +2,13 @@ import React from 'react'
import {View} from 'react-native' import {View} from 'react-native'
import {msg, Trans} from '@lingui/macro' import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {useNavigation} from '@react-navigation/native'
import {NavigationProp} from 'lib/routes/types'
import {useProfileQuery} from 'state/queries/profile' import {useProfileQuery} from 'state/queries/profile'
import {useSession} from 'state/session' import {useSession} from 'state/session'
import {useWizardState} from '#/screens/StarterPack/Wizard/State' import {useWizardState} from '#/screens/StarterPack/Wizard/State'
import {atoms as a, useTheme} from '#/alf' import {atoms as a, useTheme} from '#/alf'
import * as TextField from '#/components/forms/TextField' import * as TextField from '#/components/forms/TextField'
import {StarterPack} from '#/components/icons/StarterPack' import {StarterPack} from '#/components/icons/StarterPack'
import {BackGestureDetector} from '#/components/StarterPack/Wizard/BackGestureDetector'
import {ScreenTransition} from '#/components/StarterPack/Wizard/ScreenTransition' import {ScreenTransition} from '#/components/StarterPack/Wizard/ScreenTransition'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
@@ -19,7 +16,6 @@ export function StepDetails() {
const {_} = useLingui() const {_} = useLingui()
const t = useTheme() const t = useTheme()
const [state, dispatch] = useWizardState() const [state, dispatch] = useWizardState()
const navigation = useNavigation<NavigationProp>()
const {currentAccount} = useSession() const {currentAccount} = useSession()
const {data: currentProfile} = useProfileQuery({ const {data: currentProfile} = useProfileQuery({
@@ -28,14 +24,6 @@ export function StepDetails() {
}) })
return ( return (
<BackGestureDetector
onBack={() => {
if (navigation.canGoBack()) {
navigation.goBack()
} else {
navigation.navigate('Home')
}
}}>
<ScreenTransition direction={state.transitionDirection}> <ScreenTransition direction={state.transitionDirection}>
<View style={[a.px_xl, a.gap_xl, a.mt_4xl]}> <View style={[a.px_xl, a.gap_xl, a.mt_4xl]}>
<View style={[a.gap_md, a.align_center, a.px_md, a.mb_md]}> <View style={[a.gap_md, a.align_center, a.px_md, a.mb_md]}>
@@ -63,8 +51,7 @@ export function StepDetails() {
value={state.name} value={state.name}
onChangeText={text => dispatch({type: 'SetName', name: text})} onChangeText={text => dispatch({type: 'SetName', name: text})}
/> />
<TextField.SuffixText <TextField.SuffixText label={_(`${state.name?.length} out of 50`)}>
label={_(`${state.name?.length} out of 50`)}>
<Text style={[t.atoms.text_contrast_medium]}> <Text style={[t.atoms.text_contrast_medium]}>
{state.name?.length ?? 0}/50 {state.name?.length ?? 0}/50
</Text> </Text>
@@ -93,6 +80,5 @@ export function StepDetails() {
</View> </View>
</View> </View>
</ScreenTransition> </ScreenTransition>
</BackGestureDetector>
) )
} }
+3 -12
View File
@@ -17,7 +17,6 @@ import {useWizardState} from '#/screens/StarterPack/Wizard/State'
import {atoms as a, useTheme} from '#/alf' import {atoms as a, useTheme} from '#/alf'
import {useThrottledValue} from '#/components/hooks/useThrottledValue' import {useThrottledValue} from '#/components/hooks/useThrottledValue'
import {Loader} from '#/components/Loader' import {Loader} from '#/components/Loader'
import {BackGestureDetector} from '#/components/StarterPack/Wizard/BackGestureDetector'
import {ScreenTransition} from '#/components/StarterPack/Wizard/ScreenTransition' import {ScreenTransition} from '#/components/StarterPack/Wizard/ScreenTransition'
import {WizardFeedCard} from '#/components/StarterPack/Wizard/WizardListCard' import {WizardFeedCard} from '#/components/StarterPack/Wizard/WizardListCard'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
@@ -68,10 +67,7 @@ export function StepFeeds({moderationOpts}: {moderationOpts: ModerationOpts}) {
} }
return ( return (
<BackGestureDetector onBack={() => dispatch({type: 'Back'})}> <ScreenTransition style={[a.flex_1]} direction={state.transitionDirection}>
<ScreenTransition
style={[a.flex_1]}
direction={state.transitionDirection}>
<View style={[a.border_b, t.atoms.border_contrast_medium]}> <View style={[a.border_b, t.atoms.border_contrast_medium]}>
<View style={[a.my_sm, a.px_md, {height: 40}]}> <View style={[a.my_sm, a.px_md, {height: 40}]}>
<SearchInput <SearchInput
@@ -91,9 +87,7 @@ export function StepFeeds({moderationOpts}: {moderationOpts: ModerationOpts}) {
!query && !screenReaderEnabled ? () => fetchNextPage() : undefined !query && !screenReaderEnabled ? () => fetchNextPage() : undefined
} }
onEndReachedThreshold={2} onEndReachedThreshold={2}
renderScrollComponent={props => ( renderScrollComponent={props => <KeyboardAwareScrollView {...props} />}
<KeyboardAwareScrollView {...props} />
)}
keyboardShouldPersistTaps="handled" keyboardShouldPersistTaps="handled"
containWeb={true} containWeb={true}
sideBorders={false} sideBorders={false}
@@ -111,15 +105,12 @@ export function StepFeeds({moderationOpts}: {moderationOpts: ModerationOpts}) {
a.mt_lg, a.mt_lg,
a.leading_snug, a.leading_snug,
]}> ]}>
<Trans> <Trans>No feeds found. Try searching for something else.</Trans>
No feeds found. Try searching for something else.
</Trans>
</Text> </Text>
)} )}
</View> </View>
} }
/> />
</ScreenTransition> </ScreenTransition>
</BackGestureDetector>
) )
} }
@@ -13,7 +13,6 @@ import {List} from 'view/com/util/List'
import {useWizardState} from '#/screens/StarterPack/Wizard/State' import {useWizardState} from '#/screens/StarterPack/Wizard/State'
import {atoms as a, useTheme} from '#/alf' import {atoms as a, useTheme} from '#/alf'
import {Loader} from '#/components/Loader' import {Loader} from '#/components/Loader'
import {BackGestureDetector} from '#/components/StarterPack/Wizard/BackGestureDetector'
import {ScreenTransition} from '#/components/StarterPack/Wizard/ScreenTransition' import {ScreenTransition} from '#/components/StarterPack/Wizard/ScreenTransition'
import {WizardProfileCard} from '#/components/StarterPack/Wizard/WizardListCard' import {WizardProfileCard} from '#/components/StarterPack/Wizard/WizardListCard'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
@@ -55,10 +54,7 @@ export function StepProfiles({
} }
return ( return (
<BackGestureDetector onBack={() => dispatch({type: 'Back'})}> <ScreenTransition style={[a.flex_1]} direction={state.transitionDirection}>
<ScreenTransition
style={[a.flex_1]}
direction={state.transitionDirection}>
<View style={[a.border_b, t.atoms.border_contrast_medium]}> <View style={[a.border_b, t.atoms.border_contrast_medium]}>
<View style={[a.my_sm, a.px_md, {height: 40}]}> <View style={[a.my_sm, a.px_md, {height: 40}]}>
<SearchInput <SearchInput
@@ -73,9 +69,7 @@ export function StepProfiles({
data={query ? results : topFollowers} data={query ? results : topFollowers}
renderItem={renderItem} renderItem={renderItem}
keyExtractor={keyExtractor} keyExtractor={keyExtractor}
renderScrollComponent={props => ( renderScrollComponent={props => <KeyboardAwareScrollView {...props} />}
<KeyboardAwareScrollView {...props} />
)}
keyboardShouldPersistTaps="handled" keyboardShouldPersistTaps="handled"
containWeb={true} containWeb={true}
sideBorders={false} sideBorders={false}
@@ -97,15 +91,12 @@ export function StepProfiles({
a.mt_lg, a.mt_lg,
a.leading_snug, a.leading_snug,
]}> ]}>
<Trans> <Trans>Nobody was found. Try searching for someone else.</Trans>
Nobody was found. Try searching for someone else.
</Trans>
</Text> </Text>
)} )}
</View> </View>
} }
/> />
</ScreenTransition> </ScreenTransition>
</BackGestureDetector>
) )
} }