Onboarding recommended follows (#1457)
* upgrade api package * add RecommendedFollows as a step in onboarding * add list of recommended follows from suggested actor model * remove dead code * hoist suggestedActors into onboarding model * add comments * load more suggested follows on follow * styling changes * add animation * tweak animations * adjust styling slightly * adjust styles on mobile * styling improvements for web * fix text alignment in RecommendedFollows * dedupe inserted suggestions * fix animation duration * Minor spacing tweak --------- Co-authored-by: Paul Frazee <pfrazee@gmail.com> and Eric Bailey <git@esb.lol>
This commit is contained in:
parent
da8499c881
commit
859588c3f6
11 changed files with 450 additions and 20 deletions
|
@ -7,6 +7,8 @@ import {
|
|||
Pressable,
|
||||
ViewStyle,
|
||||
PressableStateCallbackType,
|
||||
ActivityIndicator,
|
||||
View,
|
||||
} from 'react-native'
|
||||
import {Text} from '../text/Text'
|
||||
import {useTheme} from 'lib/ThemeContext'
|
||||
|
@ -48,17 +50,19 @@ export function Button({
|
|||
accessibilityHint,
|
||||
accessibilityLabelledBy,
|
||||
onAccessibilityEscape,
|
||||
withLoading = false,
|
||||
}: React.PropsWithChildren<{
|
||||
type?: ButtonType
|
||||
label?: string
|
||||
style?: StyleProp<ViewStyle>
|
||||
labelStyle?: StyleProp<TextStyle>
|
||||
onPress?: () => void
|
||||
onPress?: () => void | Promise<void>
|
||||
testID?: string
|
||||
accessibilityLabel?: string
|
||||
accessibilityHint?: string
|
||||
accessibilityLabelledBy?: string
|
||||
onAccessibilityEscape?: () => void
|
||||
withLoading?: boolean
|
||||
}>) {
|
||||
const theme = useTheme()
|
||||
const typeOuterStyle = choose<ViewStyle, Record<ButtonType, ViewStyle>>(
|
||||
|
@ -138,13 +142,16 @@ export function Button({
|
|||
},
|
||||
)
|
||||
|
||||
const [isLoading, setIsLoading] = React.useState(false)
|
||||
const onPressWrapped = React.useCallback(
|
||||
(event: Event) => {
|
||||
async (event: Event) => {
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
onPress?.()
|
||||
withLoading && setIsLoading(true)
|
||||
await onPress?.()
|
||||
withLoading && setIsLoading(false)
|
||||
},
|
||||
[onPress],
|
||||
[onPress, withLoading],
|
||||
)
|
||||
|
||||
const getStyle = React.useCallback(
|
||||
|
@ -160,23 +167,35 @@ export function Button({
|
|||
[typeOuterStyle, style],
|
||||
)
|
||||
|
||||
const renderChildern = React.useCallback(() => {
|
||||
if (!label) {
|
||||
return children
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles.labelContainer}>
|
||||
{label && withLoading && isLoading ? (
|
||||
<ActivityIndicator size={12} color={typeLabelStyle.color} />
|
||||
) : null}
|
||||
<Text type="button" style={[typeLabelStyle, labelStyle]}>
|
||||
{label}
|
||||
</Text>
|
||||
</View>
|
||||
)
|
||||
}, [children, label, withLoading, isLoading, typeLabelStyle, labelStyle])
|
||||
|
||||
return (
|
||||
<Pressable
|
||||
style={getStyle}
|
||||
onPress={onPressWrapped}
|
||||
disabled={isLoading}
|
||||
testID={testID}
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={accessibilityLabel}
|
||||
accessibilityHint={accessibilityHint}
|
||||
accessibilityLabelledBy={accessibilityLabelledBy}
|
||||
onAccessibilityEscape={onAccessibilityEscape}>
|
||||
{label ? (
|
||||
<Text type="button" style={[typeLabelStyle, labelStyle]}>
|
||||
{label}
|
||||
</Text>
|
||||
) : (
|
||||
children
|
||||
)}
|
||||
{renderChildern}
|
||||
</Pressable>
|
||||
)
|
||||
}
|
||||
|
@ -187,4 +206,8 @@ const styles = StyleSheet.create({
|
|||
paddingVertical: 8,
|
||||
borderRadius: 24,
|
||||
},
|
||||
labelContainer: {
|
||||
flexDirection: 'row',
|
||||
gap: 8,
|
||||
},
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue