go back gesture, tweak header copy

This commit is contained in:
Hailey
2024-06-22 13:15:40 -07:00
parent 0a0c738790
commit 48ef612c4c
6 changed files with 214 additions and 143 deletions
@@ -0,0 +1,28 @@
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>
}
@@ -0,0 +1,11 @@
import React from 'react'
export function BackGestureDetector({
onBack: _onBack,
children,
}: {
onBack: () => void
children: React.ReactNode
}) {
return children
}
+69 -55
View File
@@ -2,13 +2,16 @@ 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'
@@ -16,6 +19,7 @@ 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({
@@ -24,61 +28,71 @@ export function StepDetails() {
}) })
return ( return (
<ScreenTransition direction={state.transitionDirection}> <BackGestureDetector
<View style={[a.px_xl, a.gap_xl, a.mt_4xl]}> onBack={() => {
<View style={[a.gap_md, a.align_center, a.px_md, a.mb_md]}> if (navigation.canGoBack()) {
<StarterPack width={90} gradient="sky" /> navigation.goBack()
<Text style={[a.font_bold, a.text_3xl]}> } else {
<Trans>Invites, but personal</Trans> navigation.navigate('Home')
</Text> }
<Text style={[a.text_center, a.text_md, a.px_md]}> }}>
<Trans> <ScreenTransition direction={state.transitionDirection}>
Invite your friends to follow your favorite feeds and people <View style={[a.px_xl, a.gap_xl, a.mt_4xl]}>
</Trans> <View style={[a.gap_md, a.align_center, a.px_md, a.mb_md]}>
</Text> <StarterPack width={90} gradient="sky" />
<Text style={[a.font_bold, a.text_3xl]}>
<Trans>Invites, but personal</Trans>
</Text>
<Text style={[a.text_center, a.text_md, a.px_md]}>
<Trans>
Invite your friends to follow your favorite feeds and people
</Trans>
</Text>
</View>
<View>
<TextField.LabelText>
<Trans>What do you want to call your starter pack?</Trans>
</TextField.LabelText>
<TextField.Root>
<TextField.Input
label={_(
msg`${
currentProfile?.displayName || currentProfile?.handle
}'s starter pack`,
)}
value={state.name}
onChangeText={text => dispatch({type: 'SetName', name: text})}
/>
<TextField.SuffixText
label={_(`${state.name?.length} out of 50`)}>
<Text style={[t.atoms.text_contrast_medium]}>
{state.name?.length ?? 0}/50
</Text>
</TextField.SuffixText>
</TextField.Root>
</View>
<View>
<TextField.LabelText>
<Trans>Tell us a little more</Trans>
</TextField.LabelText>
<TextField.Root>
<TextField.Input
label={_(
msg`${
currentProfile?.displayName || currentProfile?.handle
}'s favorite feeds and people - join me!`,
)}
value={state.description}
onChangeText={text =>
dispatch({type: 'SetDescription', description: text})
}
multiline
style={{minHeight: 150}}
/>
</TextField.Root>
</View>
</View> </View>
<View> </ScreenTransition>
<TextField.LabelText> </BackGestureDetector>
<Trans>What do you want to call your starter pack?</Trans>
</TextField.LabelText>
<TextField.Root>
<TextField.Input
label={_(
msg`${
currentProfile?.displayName || currentProfile?.handle
}'s starter pack`,
)}
value={state.name}
onChangeText={text => dispatch({type: 'SetName', name: text})}
/>
<TextField.SuffixText label={_(`${state.name?.length} out of 50`)}>
<Text style={[t.atoms.text_contrast_medium]}>
{state.name?.length ?? 0}/50
</Text>
</TextField.SuffixText>
</TextField.Root>
</View>
<View>
<TextField.LabelText>
<Trans>Tell us a little more</Trans>
</TextField.LabelText>
<TextField.Root>
<TextField.Input
label={_(
msg`${
currentProfile?.displayName || currentProfile?.handle
}'s favorite feeds and people - join me!`,
)}
value={state.description}
onChangeText={text =>
dispatch({type: 'SetDescription', description: text})
}
multiline
style={{minHeight: 150}}
/>
</TextField.Root>
</View>
</View>
</ScreenTransition>
) )
} }
+53 -44
View File
@@ -17,6 +17,7 @@ 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'
@@ -64,50 +65,58 @@ export function StepFeeds({moderationOpts}: {moderationOpts: ModerationOpts}) {
} }
return ( return (
<ScreenTransition style={[a.flex_1]} direction={state.transitionDirection}> <BackGestureDetector onBack={() => dispatch({type: 'Back'})}>
<View style={[a.border_b, t.atoms.border_contrast_medium]}> <ScreenTransition
<View style={[a.my_sm, a.px_md, {height: 40}]}> style={[a.flex_1]}
<SearchInput direction={state.transitionDirection}>
query={query} <View style={[a.border_b, t.atoms.border_contrast_medium]}>
onChangeQuery={t => setQuery(t)} <View style={[a.my_sm, a.px_md, {height: 40}]}>
onPressCancelSearch={() => setQuery('')} <SearchInput
onSubmitQuery={() => {}} query={query}
/> onChangeQuery={t => setQuery(t)}
</View> onPressCancelSearch={() => setQuery('')}
</View> onSubmitQuery={() => {}}
<List />
data={query ? searchedFeeds : suggestedFeeds}
renderItem={renderItem}
keyExtractor={keyExtractor}
contentContainerStyle={{paddingTop: 6}}
onEndReached={
!query && !screenReaderEnabled ? () => fetchNextPage() : undefined
}
onEndReachedThreshold={2}
renderScrollComponent={props => <KeyboardAwareScrollView {...props} />}
keyboardShouldPersistTaps="handled"
containWeb={true}
sideBorders={false}
style={{flex: 1}}
ListEmptyComponent={
<View style={[a.flex_1, a.align_center, a.mt_lg, a.px_lg]}>
{isLoadingSearch ? (
<Loader size="lg" />
) : (
<Text
style={[
a.font_bold,
a.text_lg,
a.text_center,
a.mt_lg,
a.leading_snug,
]}>
<Trans>No feeds found. Try searching for something else.</Trans>
</Text>
)}
</View> </View>
} </View>
/> <List
</ScreenTransition> data={query ? searchedFeeds : suggestedFeeds}
renderItem={renderItem}
keyExtractor={keyExtractor}
contentContainerStyle={{paddingTop: 6}}
onEndReached={
!query && !screenReaderEnabled ? () => fetchNextPage() : undefined
}
onEndReachedThreshold={2}
renderScrollComponent={props => (
<KeyboardAwareScrollView {...props} />
)}
keyboardShouldPersistTaps="handled"
containWeb={true}
sideBorders={false}
style={{flex: 1}}
ListEmptyComponent={
<View style={[a.flex_1, a.align_center, a.mt_lg, a.px_lg]}>
{isLoadingSearch ? (
<Loader size="lg" />
) : (
<Text
style={[
a.font_bold,
a.text_lg,
a.text_center,
a.mt_lg,
a.leading_snug,
]}>
<Trans>
No feeds found. Try searching for something else.
</Trans>
</Text>
)}
</View>
}
/>
</ScreenTransition>
</BackGestureDetector>
) )
} }
+51 -42
View File
@@ -13,6 +13,7 @@ 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'
@@ -53,49 +54,57 @@ export function StepProfiles({
} }
return ( return (
<ScreenTransition style={[a.flex_1]} direction={state.transitionDirection}> <BackGestureDetector onBack={() => dispatch({type: 'Back'})}>
<View style={[a.border_b, t.atoms.border_contrast_medium]}> <ScreenTransition
<View style={[a.my_sm, a.px_md, {height: 40}]}>
<SearchInput
query={query}
onChangeQuery={setQuery}
onPressCancelSearch={() => setQuery('')}
onSubmitQuery={() => {}}
/>
</View>
</View>
<List
data={query ? results : topFollowers}
renderItem={renderItem}
keyExtractor={keyExtractor}
renderScrollComponent={props => <KeyboardAwareScrollView {...props} />}
keyboardShouldPersistTaps="handled"
containWeb={true}
sideBorders={false}
style={[a.flex_1]} style={[a.flex_1]}
onEndReached={ direction={state.transitionDirection}>
!query && !screenReaderEnabled ? () => fetchNextPage() : undefined <View style={[a.border_b, t.atoms.border_contrast_medium]}>
} <View style={[a.my_sm, a.px_md, {height: 40}]}>
onEndReachedThreshold={isNative ? 2 : 0.25} <SearchInput
ListEmptyComponent={ query={query}
<View style={[a.flex_1, a.align_center, a.mt_lg, a.px_lg]}> onChangeQuery={setQuery}
{isLoadingResults ? ( onPressCancelSearch={() => setQuery('')}
<Loader size="lg" /> onSubmitQuery={() => {}}
) : ( />
<Text
style={[
a.font_bold,
a.text_lg,
a.text_center,
a.mt_lg,
a.leading_snug,
]}>
<Trans>Nobody was found. Try searching for someone else.</Trans>
</Text>
)}
</View> </View>
} </View>
/> <List
</ScreenTransition> data={query ? results : topFollowers}
renderItem={renderItem}
keyExtractor={keyExtractor}
renderScrollComponent={props => (
<KeyboardAwareScrollView {...props} />
)}
keyboardShouldPersistTaps="handled"
containWeb={true}
sideBorders={false}
style={[a.flex_1]}
onEndReached={
!query && !screenReaderEnabled ? () => fetchNextPage() : undefined
}
onEndReachedThreshold={isNative ? 2 : 0.25}
ListEmptyComponent={
<View style={[a.flex_1, a.align_center, a.mt_lg, a.px_lg]}>
{isLoadingResults ? (
<Loader size="lg" />
) : (
<Text
style={[
a.font_bold,
a.text_lg,
a.text_center,
a.mt_lg,
a.leading_snug,
]}>
<Trans>
Nobody was found. Try searching for someone else.
</Trans>
</Text>
)}
</View>
}
/>
</ScreenTransition>
</BackGestureDetector>
) )
} }
+2 -2
View File
@@ -579,9 +579,9 @@ function Footer({
function getName(item: AppBskyActorDefs.ProfileViewBasic | GeneratorView) { function getName(item: AppBskyActorDefs.ProfileViewBasic | GeneratorView) {
if (typeof item.displayName === 'string') { if (typeof item.displayName === 'string') {
return enforceLen(sanitizeDisplayName(item.displayName), 16, true) return enforceLen(sanitizeDisplayName(item.displayName), 28, true)
} else if (typeof item.handle === 'string') { } else if (typeof item.handle === 'string') {
return enforceLen(sanitizeHandle(item.handle), 16, true) return enforceLen(sanitizeHandle(item.handle), 28, true)
} }
return '' return ''
} }