Optimize native tag input
This commit is contained in:
@@ -23,6 +23,16 @@ import {
|
|||||||
import {Loader} from '#/components/Loader'
|
import {Loader} from '#/components/Loader'
|
||||||
import {isInvalidHandle} from '#/lib/strings/handles'
|
import {isInvalidHandle} from '#/lib/strings/handles'
|
||||||
|
|
||||||
|
type TagMenuProps = {
|
||||||
|
control: Dialog.DialogOuterProps['control']
|
||||||
|
/**
|
||||||
|
* This should be the sanitized tag value from the facet itself, not the
|
||||||
|
* "display" value with a leading `#`.
|
||||||
|
*/
|
||||||
|
tag: string
|
||||||
|
authorHandle?: string
|
||||||
|
}
|
||||||
|
|
||||||
export function useTagMenuControl() {
|
export function useTagMenuControl() {
|
||||||
return Dialog.useDialogControl()
|
return Dialog.useDialogControl()
|
||||||
}
|
}
|
||||||
@@ -32,15 +42,20 @@ export function TagMenu({
|
|||||||
control,
|
control,
|
||||||
tag,
|
tag,
|
||||||
authorHandle,
|
authorHandle,
|
||||||
}: React.PropsWithChildren<{
|
}: React.PropsWithChildren<TagMenuProps>) {
|
||||||
control: Dialog.DialogOuterProps['control']
|
return (
|
||||||
/**
|
<>
|
||||||
* This should be the sanitized tag value from the facet itself, not the
|
{children}
|
||||||
* "display" value with a leading `#`.
|
|
||||||
*/
|
<Dialog.Outer control={control}>
|
||||||
tag: string
|
<Dialog.Handle />
|
||||||
authorHandle?: string
|
<TagMenuInner control={control} tag={tag} authorHandle={authorHandle} />
|
||||||
}>) {
|
</Dialog.Outer>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function TagMenuInner({control, tag, authorHandle}: TagMenuProps) {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const navigation = useNavigation<NavigationProp>()
|
const navigation = useNavigation<NavigationProp>()
|
||||||
@@ -69,12 +84,6 @@ export function TagMenu({
|
|||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
|
||||||
{children}
|
|
||||||
|
|
||||||
<Dialog.Outer control={control}>
|
|
||||||
<Dialog.Handle />
|
|
||||||
|
|
||||||
<Dialog.Inner label={_(msg`Tag menu: ${displayTag}`)}>
|
<Dialog.Inner label={_(msg`Tag menu: ${displayTag}`)}>
|
||||||
{isPreferencesLoading ? (
|
{isPreferencesLoading ? (
|
||||||
<View style={[a.w_full, a.align_center]}>
|
<View style={[a.w_full, a.align_center]}>
|
||||||
@@ -170,10 +179,7 @@ export function TagMenu({
|
|||||||
a.px_lg,
|
a.px_lg,
|
||||||
a.py_md,
|
a.py_md,
|
||||||
]}>
|
]}>
|
||||||
<Person
|
<Person size="lg" style={[t.atoms.text_contrast_medium]} />
|
||||||
size="lg"
|
|
||||||
style={[t.atoms.text_contrast_medium]}
|
|
||||||
/>
|
|
||||||
<Text
|
<Text
|
||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
ellipsizeMode="middle"
|
ellipsizeMode="middle"
|
||||||
@@ -186,8 +192,7 @@ export function TagMenu({
|
|||||||
]}>
|
]}>
|
||||||
<Trans>
|
<Trans>
|
||||||
See{' '}
|
See{' '}
|
||||||
<Text
|
<Text style={[a.text_md, a.font_bold, t.atoms.text]}>
|
||||||
style={[a.text_md, a.font_bold, t.atoms.text]}>
|
|
||||||
{displayTag}
|
{displayTag}
|
||||||
</Text>{' '}
|
</Text>{' '}
|
||||||
posts by this user
|
posts by this user
|
||||||
@@ -232,10 +237,7 @@ export function TagMenu({
|
|||||||
a.px_lg,
|
a.px_lg,
|
||||||
a.py_md,
|
a.py_md,
|
||||||
]}>
|
]}>
|
||||||
<Mute
|
<Mute size="lg" style={[t.atoms.text_contrast_medium]} />
|
||||||
size="lg"
|
|
||||||
style={[t.atoms.text_contrast_medium]}
|
|
||||||
/>
|
|
||||||
<Text
|
<Text
|
||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
ellipsizeMode="middle"
|
ellipsizeMode="middle"
|
||||||
@@ -269,7 +271,5 @@ export function TagMenu({
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Dialog.Inner>
|
</Dialog.Inner>
|
||||||
</Dialog.Outer>
|
|
||||||
</>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user