1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
import {useMemo} from 'react'
import {View} from 'react-native'
import {type AppBskyFeedDefs, AtUri} from '@atproto/api'
import {PressableScale} from '#/lib/custom-animations/PressableScale'
import {makeCustomFeedLink} from '#/lib/routes/links'
import {logger} from '#/logger'
import {UserAvatar} from '#/view/com/util/UserAvatar'
import {
atoms as a,
native,
useGutters,
useTheme,
type ViewStyleProp,
web,
} from '#/alf'
import {Button, ButtonIcon} from '#/components/Button'
import * as FeedCard from '#/components/FeedCard'
import {sizes as iconSizes} from '#/components/icons/common'
import {MagnifyingGlass2_Stroke2_Corner0_Rounded as SearchIcon} from '#/components/icons/MagnifyingGlass2'
import {Link} from '#/components/Link'
import {Text, type TextProps} from '#/components/Typography'
export function Container({
style,
children,
headerHeight,
}: {children: React.ReactNode; headerHeight?: number} & ViewStyleProp) {
const t = useTheme()
const gutters = useGutters([0, 'base'])
return (
<View
style={[
gutters,
a.flex_row,
a.align_center,
a.pt_2xl,
a.pb_md,
a.gap_sm,
t.atoms.bg,
headerHeight && web({position: 'sticky', top: headerHeight}),
style,
]}>
{children}
</View>
)
}
export function FeedLink({
feed,
children,
}: {
feed: AppBskyFeedDefs.GeneratorView
children?: React.ReactNode
}) {
const t = useTheme()
const {host: did, rkey} = useMemo(() => new AtUri(feed.uri), [feed.uri])
return (
<Link
to={makeCustomFeedLink(did, rkey)}
label={feed.displayName}
style={[a.flex_1]}>
{({focused, hovered, pressed}) => (
<View
style={[
a.flex_1,
a.flex_row,
a.align_center,
{gap: 10},
a.rounded_md,
a.p_xs,
{marginLeft: -6},
(focused || hovered || pressed) && t.atoms.bg_contrast_25,
]}>
{children}
</View>
)}
</Link>
)
}
export function FeedAvatar({feed}: {feed: AppBskyFeedDefs.GeneratorView}) {
return <UserAvatar type="algo" size={38} avatar={feed.avatar} />
}
export function Icon({
icon: Comp,
size = 'lg',
}: Pick<React.ComponentProps<typeof ButtonIcon>, 'icon' | 'size'>) {
const iconSize = iconSizes[size]
return (
<View style={[a.z_20, {width: iconSize, height: iconSize, marginLeft: -2}]}>
<Comp width={iconSize} />
</View>
)
}
export function TitleText({style, ...props}: TextProps) {
return (
<Text style={[a.font_bold, a.flex_1, a.text_xl, style]} emoji {...props} />
)
}
export function SubtitleText({style, ...props}: TextProps) {
const t = useTheme()
return (
<Text
style={[
t.atoms.text_contrast_medium,
a.leading_tight,
a.flex_1,
a.text_sm,
style,
]}
{...props}
/>
)
}
export function SearchButton({
label,
metricsTag,
onPress,
}: {
label: string
metricsTag: 'suggestedAccounts' | 'suggestedFeeds'
onPress?: () => void
}) {
return (
<Button
label={label}
size="small"
variant="ghost"
color="secondary"
shape="round"
PressableComponent={native(PressableScale)}
onPress={() => {
logger.metric(
'explore:module:searchButtonPress',
{module: metricsTag},
{statsig: true},
)
onPress?.()
}}
style={[
{
right: -4,
},
]}>
<ButtonIcon icon={SearchIcon} size="lg" />
</Button>
)
}
export function PinButton({feed}: {feed: AppBskyFeedDefs.GeneratorView}) {
return (
<View style={[a.z_20, {marginRight: -6}]}>
<FeedCard.SaveButton
pin
view={feed}
size="large"
color="secondary"
variant="ghost"
shape="square"
text={false}
/>
</View>
)
}
|