Labels on me and dialog

This commit is contained in:
Eric Bailey
2024-03-10 18:24:09 -05:00
parent c0ed0775ed
commit 60d043ecef
2 changed files with 53 additions and 60 deletions
+1 -2
View File
@@ -49,11 +49,10 @@ export function LabelsOnMe({
size={size || 'small'} size={size || 'small'}
label={_(msg`View information about these labels`)} label={_(msg`View information about these labels`)}
onPress={() => { onPress={() => {
console.log('open')
control.open() control.open()
}}> }}>
<ButtonIcon position="left" icon={CircleInfo} /> <ButtonIcon position="left" icon={CircleInfo} />
<ButtonText> <ButtonText style={[a.leading_snug, a.italic]}>
{labels.length}{' '} {labels.length}{' '}
{labels.length === 1 ? ( {labels.length === 1 ? (
<Trans> <Trans>
+52 -58
View File
@@ -15,6 +15,7 @@ import * as Dialog from '#/components/Dialog'
import {Button, ButtonText} from '#/components/Button' import {Button, ButtonText} from '#/components/Button'
import {InlineLink} from '#/components/Link' import {InlineLink} from '#/components/Link'
import * as Toast from '#/view/com/util/Toast' import * as Toast from '#/view/com/util/Toast'
import {Divider} from '../Divider'
export {useDialogControl as useLabelsOnMeDialogControl} from '#/components/Dialog' export {useDialogControl as useLabelsOnMeDialogControl} from '#/components/Dialog'
@@ -35,7 +36,6 @@ export interface LabelsOnMeDialogProps {
export function LabelsOnMeDialogInner(props: LabelsOnMeDialogProps) { export function LabelsOnMeDialogInner(props: LabelsOnMeDialogProps) {
const {_} = useLingui() const {_} = useLingui()
const {gtMobile} = useBreakpoints()
const [appealingLabel, setAppealingLabel] = React.useState< const [appealingLabel, setAppealingLabel] = React.useState<
ComAtprotoLabelDefs.Label | undefined ComAtprotoLabelDefs.Label | undefined
>(undefined) >(undefined)
@@ -44,8 +44,11 @@ export function LabelsOnMeDialogInner(props: LabelsOnMeDialogProps) {
return ( return (
<Dialog.ScrollableInner <Dialog.ScrollableInner
accessibilityDescribedBy="dialog-description" label={
accessibilityLabelledBy="dialog-title"> isAccount
? _(msg`The following labels were applied to your account.`)
: _(msg`The following labels were applied to your content.`)
}>
{appealingLabel ? ( {appealingLabel ? (
<AppealForm <AppealForm
label={appealingLabel} label={appealingLabel}
@@ -55,18 +58,14 @@ export function LabelsOnMeDialogInner(props: LabelsOnMeDialogProps) {
/> />
) : ( ) : (
<> <>
<Text <Text style={[a.text_2xl, a.font_bold, a.pb_xs, a.leading_tight]}>
nativeID="dialog-title"
style={[a.text_2xl, a.font_bold, a.pb_md, a.leading_tight]}>
{isAccount ? ( {isAccount ? (
<Trans>Labels on your account</Trans> <Trans>Labels on your account</Trans>
) : ( ) : (
<Trans>Labels on your content</Trans> <Trans>Labels on your content</Trans>
)} )}
</Text> </Text>
<Text <Text style={[a.text_md, a.leading_snug]}>
nativeID="dialog-description"
style={[a.text_sm, a.leading_snug]}>
<Trans> <Trans>
You may appeal these labels if you feel they were placed in error. You may appeal these labels if you feel they were placed in error.
</Trans> </Trans>
@@ -82,20 +81,10 @@ export function LabelsOnMeDialogInner(props: LabelsOnMeDialogProps) {
/> />
))} ))}
</View> </View>
<View style={gtMobile && [a.flex_row, a.justify_end]}>
<Button
testID="doneBtn"
variant="outline"
color="primary"
size="small"
onPress={() => props.control.close()}
label={_(msg`Done`)}>
{_(msg`Done`)}
</Button>
</View>
</> </>
)} )}
<Dialog.Close />
</Dialog.ScrollableInner> </Dialog.ScrollableInner>
) )
} }
@@ -124,39 +113,46 @@ function Label({
const {labeler, strings} = useLabelInfo(label) const {labeler, strings} = useLabelInfo(label)
return ( return (
<View <View
key={`${label.src}-${label.val}`}
style={[ style={[
a.p_md,
a.rounded_sm,
a.border, a.border,
t.atoms.border_contrast_low, t.atoms.border_contrast_low,
a.gap_sm, a.rounded_sm,
a.flex_row, a.overflow_hidden,
]}> ]}>
<View style={[a.flex_1, a.gap_xs]}> <View style={[a.p_md, a.gap_sm, a.flex_row]}>
<Text style={[a.font_bold, a.text_md, t.atoms.text]}> <View style={[a.flex_1, a.gap_xs]}>
{strings.name} <Text style={[a.font_bold, a.text_md]}>{strings.name}</Text>
</Text> <Text style={[t.atoms.text_contrast_medium, a.leading_snug]}>
<Text style={[t.atoms.text]}>{strings.description}</Text> {strings.description}
<InlineLink </Text>
to={makeProfileLink( </View>
labeler ? labeler.creator : {did: label.src, handle: ''}, <View>
)} <Button
onPress={() => control.close()}> variant="solid"
{labeler ? sanitizeHandle(labeler.creator.handle, '@') : label.src} color="secondary"
</InlineLink> size="small"
label={_(msg`Appeal`)}
onPress={() => onPressAppeal(label)}>
<ButtonText>
<Trans>Appeal</Trans>
</ButtonText>
</Button>
</View>
</View> </View>
<View>
<Button <Divider />
variant="solid"
color="secondary" <View style={[a.px_md, a.py_sm, t.atoms.bg_contrast_25]}>
size="small" <Text style={[t.atoms.text_contrast_medium]}>
label={_(msg`Appeal`)} <Trans>Source:</Trans>{' '}
onPress={() => onPressAppeal(label)}> <InlineLink
<ButtonText> to={makeProfileLink(
<Trans>Appeal</Trans> labeler ? labeler.creator : {did: label.src, handle: ''},
</ButtonText> )}
</Button> onPress={() => control.close()}>
{labeler ? sanitizeHandle(labeler.creator.handle, '@') : label.src}
</InlineLink>
</Text>
</View> </View>
</View> </View>
) )
@@ -200,19 +196,18 @@ function AppealForm({
return ( return (
<> <>
<Text <Text style={[a.text_2xl, a.font_bold, a.pb_xs, a.leading_tight]}>
nativeID="dialog-title"
style={[a.text_2xl, a.font_bold, a.pb_md, a.leading_tight]}>
<Trans>Appeal "{strings.name}" label</Trans> <Trans>Appeal "{strings.name}" label</Trans>
</Text> </Text>
<Text nativeID="dialog-description" style={[a.text_sm, a.leading_snug]}> <Text style={[a.text_md, a.leading_snug]}>
<Trans> <Trans>
This appeal will be sent to{' '} This appeal will be sent to{' '}
<InlineLink <InlineLink
to={makeProfileLink( to={makeProfileLink(
labeler ? labeler.creator : {did: label.src, handle: ''}, labeler ? labeler.creator : {did: label.src, handle: ''},
)} )}
onPress={() => control.close()}> onPress={() => control.close()}
style={[a.text_md, a.leading_snug]}>
{labeler ? sanitizeHandle(labeler.creator.handle, '@') : label.src} {labeler ? sanitizeHandle(labeler.creator.handle, '@') : label.src}
</InlineLink> </InlineLink>
. .
@@ -230,8 +225,7 @@ function AppealForm({
onChangeText={setDetails} onChangeText={setDetails}
autoFocus={true} autoFocus={true}
numberOfLines={3} numberOfLines={3}
multiline={true} multiline
textAlignVertical="top"
maxLength={300} maxLength={300}
/> />
</View> </View>
@@ -246,7 +240,7 @@ function AppealForm({
testID="backBtn" testID="backBtn"
variant="solid" variant="solid"
color="secondary" color="secondary"
size="small" size="medium"
onPress={onPressBack} onPress={onPressBack}
label={_(msg`Back`)}> label={_(msg`Back`)}>
{_(msg`Back`)} {_(msg`Back`)}
@@ -255,7 +249,7 @@ function AppealForm({
testID="submitBtn" testID="submitBtn"
variant="solid" variant="solid"
color="primary" color="primary"
size="small" size="medium"
onPress={onSubmit} onPress={onSubmit}
label={_(msg`Submit`)}> label={_(msg`Submit`)}>
{_(msg`Submit`)} {_(msg`Submit`)}