[Sheets] [Pt. 14] Portaling behaviors for nested dialogs (#5588)
Co-authored-by: Eric Bailey <git@esb.lol> Co-authored-by: Samuel Newman <mozzius@protonmail.com>
This commit is contained in:
@@ -16,7 +16,7 @@ import {
|
|||||||
DialogOuterProps,
|
DialogOuterProps,
|
||||||
} from '#/components/Dialog/types'
|
} from '#/components/Dialog/types'
|
||||||
import {createInput} from '#/components/forms/TextField'
|
import {createInput} from '#/components/forms/TextField'
|
||||||
import {Portal} from '#/components/Portal'
|
import {Portal as DefaultPortal} from '#/components/Portal'
|
||||||
import {
|
import {
|
||||||
BottomSheetSnapPoint,
|
BottomSheetSnapPoint,
|
||||||
BottomSheetView,
|
BottomSheetView,
|
||||||
@@ -34,26 +34,7 @@ export function Outer({
|
|||||||
onClose,
|
onClose,
|
||||||
nativeOptions,
|
nativeOptions,
|
||||||
testID,
|
testID,
|
||||||
}: React.PropsWithChildren<DialogOuterProps>) {
|
Portal = DefaultPortal,
|
||||||
return (
|
|
||||||
<Portal>
|
|
||||||
<OuterWithoutPortal
|
|
||||||
control={control}
|
|
||||||
onClose={onClose}
|
|
||||||
nativeOptions={nativeOptions}
|
|
||||||
testID={testID}>
|
|
||||||
{children}
|
|
||||||
</OuterWithoutPortal>
|
|
||||||
</Portal>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function OuterWithoutPortal({
|
|
||||||
children,
|
|
||||||
control,
|
|
||||||
onClose,
|
|
||||||
nativeOptions,
|
|
||||||
testID,
|
|
||||||
}: React.PropsWithChildren<DialogOuterProps>) {
|
}: React.PropsWithChildren<DialogOuterProps>) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const ref = React.useRef<BottomSheetView>(null)
|
const ref = React.useRef<BottomSheetView>(null)
|
||||||
@@ -119,26 +100,28 @@ export function OuterWithoutPortal({
|
|||||||
const Wrapper = isIOS ? View : GestureHandlerRootView
|
const Wrapper = isIOS ? View : GestureHandlerRootView
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Context.Provider value={context}>
|
<Portal>
|
||||||
<BottomSheetView
|
<Context.Provider value={context}>
|
||||||
ref={ref}
|
<BottomSheetView
|
||||||
topInset={30}
|
ref={ref}
|
||||||
bottomInset={insets.bottom}
|
topInset={30}
|
||||||
onSnapPointChange={e => {
|
bottomInset={insets.bottom}
|
||||||
setSnapPoint(e.nativeEvent.snapPoint)
|
onSnapPointChange={e => {
|
||||||
}}
|
setSnapPoint(e.nativeEvent.snapPoint)
|
||||||
onStateChange={e => {
|
}}
|
||||||
if (e.nativeEvent.state === 'closed') {
|
onStateChange={e => {
|
||||||
onCloseAnimationComplete()
|
if (e.nativeEvent.state === 'closed') {
|
||||||
}
|
onCloseAnimationComplete()
|
||||||
}}
|
}
|
||||||
cornerRadius={20}
|
}}
|
||||||
{...nativeOptions}>
|
cornerRadius={20}
|
||||||
<Wrapper testID={testID} style={[t.atoms.bg]}>
|
{...nativeOptions}>
|
||||||
{children}
|
<Wrapper testID={testID} style={[t.atoms.bg]}>
|
||||||
</Wrapper>
|
{children}
|
||||||
</BottomSheetView>
|
</Wrapper>
|
||||||
</Context.Provider>
|
</BottomSheetView>
|
||||||
|
</Context.Provider>
|
||||||
|
</Portal>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import type {
|
|||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
|
|
||||||
import {ViewStyleProp} from '#/alf'
|
import {ViewStyleProp} from '#/alf'
|
||||||
|
import {PortalComponent} from '#/components/Portal'
|
||||||
import {BottomSheetViewProps} from '../../../modules/bottom-sheet'
|
import {BottomSheetViewProps} from '../../../modules/bottom-sheet'
|
||||||
import {BottomSheetSnapPoint} from '../../../modules/bottom-sheet/src/BottomSheet.types'
|
import {BottomSheetSnapPoint} from '../../../modules/bottom-sheet/src/BottomSheet.types'
|
||||||
|
|
||||||
@@ -58,6 +59,7 @@ export type DialogOuterProps = {
|
|||||||
nativeOptions?: Omit<BottomSheetViewProps, 'children'>
|
nativeOptions?: Omit<BottomSheetViewProps, 'children'>
|
||||||
webOptions?: {}
|
webOptions?: {}
|
||||||
testID?: string
|
testID?: string
|
||||||
|
Portal?: PortalComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
type DialogInnerPropsBase<T> = React.PropsWithChildren<ViewStyleProp> & T
|
type DialogInnerPropsBase<T> = React.PropsWithChildren<ViewStyleProp> & T
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ type ComponentMap = {
|
|||||||
[id: string]: Component
|
[id: string]: Component
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type PortalComponent = ({children}: {children?: React.ReactNode}) => null
|
||||||
|
|
||||||
export function createPortalGroup() {
|
export function createPortalGroup() {
|
||||||
const Context = React.createContext<ContextType>({
|
const Context = React.createContext<ContextType>({
|
||||||
outlet: null,
|
outlet: null,
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ import {GestureResponderEvent, View} from 'react-native'
|
|||||||
import {msg} from '@lingui/macro'
|
import {msg} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {isNative} from '#/platform/detection'
|
|
||||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||||
import {Button, ButtonColor, ButtonText} from '#/components/Button'
|
import {Button, ButtonColor, ButtonText} from '#/components/Button'
|
||||||
import * as Dialog from '#/components/Dialog'
|
import * as Dialog from '#/components/Dialog'
|
||||||
|
import {PortalComponent} from '#/components/Portal'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
|
||||||
export {
|
export {
|
||||||
@@ -26,11 +26,11 @@ export function Outer({
|
|||||||
children,
|
children,
|
||||||
control,
|
control,
|
||||||
testID,
|
testID,
|
||||||
withoutPortal,
|
Portal,
|
||||||
}: React.PropsWithChildren<{
|
}: React.PropsWithChildren<{
|
||||||
control: Dialog.DialogControlProps
|
control: Dialog.DialogControlProps
|
||||||
testID?: string
|
testID?: string
|
||||||
withoutPortal?: boolean
|
Portal?: PortalComponent
|
||||||
}>) {
|
}>) {
|
||||||
const {gtMobile} = useBreakpoints()
|
const {gtMobile} = useBreakpoints()
|
||||||
const titleId = React.useId()
|
const titleId = React.useId()
|
||||||
@@ -41,11 +41,8 @@ export function Outer({
|
|||||||
[titleId, descriptionId],
|
[titleId, descriptionId],
|
||||||
)
|
)
|
||||||
|
|
||||||
const Wrapper =
|
|
||||||
withoutPortal && isNative ? Dialog.OuterWithoutPortal : Dialog.Outer
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper control={control} testID={testID}>
|
<Dialog.Outer control={control} testID={testID} Portal={Portal}>
|
||||||
<Context.Provider value={context}>
|
<Context.Provider value={context}>
|
||||||
<Dialog.ScrollableInner
|
<Dialog.ScrollableInner
|
||||||
accessibilityLabelledBy={titleId}
|
accessibilityLabelledBy={titleId}
|
||||||
@@ -56,7 +53,7 @@ export function Outer({
|
|||||||
{children}
|
{children}
|
||||||
</Dialog.ScrollableInner>
|
</Dialog.ScrollableInner>
|
||||||
</Context.Provider>
|
</Context.Provider>
|
||||||
</Wrapper>
|
</Dialog.Outer>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +182,7 @@ export function Basic({
|
|||||||
onConfirm,
|
onConfirm,
|
||||||
confirmButtonColor,
|
confirmButtonColor,
|
||||||
showCancel = true,
|
showCancel = true,
|
||||||
withoutPortal,
|
Portal,
|
||||||
}: React.PropsWithChildren<{
|
}: React.PropsWithChildren<{
|
||||||
control: Dialog.DialogOuterProps['control']
|
control: Dialog.DialogOuterProps['control']
|
||||||
title: string
|
title: string
|
||||||
@@ -202,13 +199,10 @@ export function Basic({
|
|||||||
onConfirm: (e: GestureResponderEvent) => void
|
onConfirm: (e: GestureResponderEvent) => void
|
||||||
confirmButtonColor?: ButtonColor
|
confirmButtonColor?: ButtonColor
|
||||||
showCancel?: boolean
|
showCancel?: boolean
|
||||||
withoutPortal?: boolean
|
Portal?: PortalComponent
|
||||||
}>) {
|
}>) {
|
||||||
return (
|
return (
|
||||||
<Outer
|
<Outer control={control} testID="confirmModal" Portal={Portal}>
|
||||||
control={control}
|
|
||||||
testID="confirmModal"
|
|
||||||
withoutPortal={withoutPortal}>
|
|
||||||
<TitleText>{title}</TitleText>
|
<TitleText>{title}</TitleText>
|
||||||
<DescriptionText>{description}</DescriptionText>
|
<DescriptionText>{description}</DescriptionText>
|
||||||
<Actions>
|
<Actions>
|
||||||
|
|||||||
@@ -31,11 +31,14 @@ import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus
|
|||||||
import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times'
|
import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times'
|
||||||
import {Loader} from '#/components/Loader'
|
import {Loader} from '#/components/Loader'
|
||||||
import {NormalizedRNGHPressable} from '#/components/NormalizedRNGHPressable'
|
import {NormalizedRNGHPressable} from '#/components/NormalizedRNGHPressable'
|
||||||
|
import {createPortalGroup} from '#/components/Portal'
|
||||||
import * as Prompt from '#/components/Prompt'
|
import * as Prompt from '#/components/Prompt'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
|
||||||
const ONE_DAY = 24 * 60 * 60 * 1000
|
const ONE_DAY = 24 * 60 * 60 * 1000
|
||||||
|
|
||||||
|
const Portal = createPortalGroup()
|
||||||
|
|
||||||
export function MutedWordsDialog() {
|
export function MutedWordsDialog() {
|
||||||
const {mutedWordsDialogControl: control} = useGlobalDialogsControlContext()
|
const {mutedWordsDialogControl: control} = useGlobalDialogsControlContext()
|
||||||
return (
|
return (
|
||||||
@@ -105,314 +108,356 @@ function MutedWordsInner() {
|
|||||||
}, [_, field, targets, addMutedWord, setField, durations, excludeFollowing])
|
}, [_, field, targets, addMutedWord, setField, durations, excludeFollowing])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog.ScrollableInner label={_(msg`Manage your muted words and tags`)}>
|
<Portal.Provider>
|
||||||
<View>
|
<Dialog.ScrollableInner label={_(msg`Manage your muted words and tags`)}>
|
||||||
<Text
|
<View>
|
||||||
style={[a.text_md, a.font_bold, a.pb_sm, t.atoms.text_contrast_high]}>
|
|
||||||
<Trans>Add muted words and tags</Trans>
|
|
||||||
</Text>
|
|
||||||
<Text style={[a.pb_lg, a.leading_snug, t.atoms.text_contrast_medium]}>
|
|
||||||
<Trans>
|
|
||||||
Posts can be muted based on their text, their tags, or both. We
|
|
||||||
recommend avoiding common words that appear in many posts, since it
|
|
||||||
can result in no posts being shown.
|
|
||||||
</Trans>
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
<View style={[a.pb_sm]}>
|
|
||||||
<Dialog.Input
|
|
||||||
autoCorrect={false}
|
|
||||||
autoCapitalize="none"
|
|
||||||
autoComplete="off"
|
|
||||||
label={_(msg`Enter a word or tag`)}
|
|
||||||
placeholder={_(msg`Enter a word or tag`)}
|
|
||||||
value={field}
|
|
||||||
onChangeText={value => {
|
|
||||||
if (error) {
|
|
||||||
setError('')
|
|
||||||
}
|
|
||||||
setField(value)
|
|
||||||
}}
|
|
||||||
onSubmitEditing={submit}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<View style={[a.pb_xl, a.gap_sm]}>
|
|
||||||
<Toggle.Group
|
|
||||||
label={_(msg`Select how long to mute this word for.`)}
|
|
||||||
type="radio"
|
|
||||||
values={durations}
|
|
||||||
onChange={setDurations}>
|
|
||||||
<Text
|
|
||||||
style={[
|
|
||||||
a.pb_xs,
|
|
||||||
a.text_sm,
|
|
||||||
a.font_bold,
|
|
||||||
t.atoms.text_contrast_medium,
|
|
||||||
]}>
|
|
||||||
<Trans>Duration:</Trans>
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
<View
|
|
||||||
style={[
|
|
||||||
gtMobile && [a.flex_row, a.align_center, a.justify_start],
|
|
||||||
a.gap_sm,
|
|
||||||
]}>
|
|
||||||
<View
|
|
||||||
style={[
|
|
||||||
a.flex_1,
|
|
||||||
a.flex_row,
|
|
||||||
a.justify_start,
|
|
||||||
a.align_center,
|
|
||||||
a.gap_sm,
|
|
||||||
]}>
|
|
||||||
<Toggle.Item
|
|
||||||
label={_(msg`Mute this word until you unmute it`)}
|
|
||||||
name="forever"
|
|
||||||
style={[a.flex_1]}
|
|
||||||
PressableComponent={NormalizedRNGHPressable}>
|
|
||||||
<TargetToggle>
|
|
||||||
<View
|
|
||||||
style={[a.flex_1, a.flex_row, a.align_center, a.gap_sm]}>
|
|
||||||
<Toggle.Radio />
|
|
||||||
<Toggle.LabelText style={[a.flex_1, a.leading_tight]}>
|
|
||||||
<Trans>Forever</Trans>
|
|
||||||
</Toggle.LabelText>
|
|
||||||
</View>
|
|
||||||
</TargetToggle>
|
|
||||||
</Toggle.Item>
|
|
||||||
|
|
||||||
<Toggle.Item
|
|
||||||
label={_(msg`Mute this word for 24 hours`)}
|
|
||||||
name="24_hours"
|
|
||||||
style={[a.flex_1]}
|
|
||||||
PressableComponent={NormalizedRNGHPressable}>
|
|
||||||
<TargetToggle>
|
|
||||||
<View
|
|
||||||
style={[a.flex_1, a.flex_row, a.align_center, a.gap_sm]}>
|
|
||||||
<Toggle.Radio />
|
|
||||||
<Toggle.LabelText style={[a.flex_1, a.leading_tight]}>
|
|
||||||
<Trans>24 hours</Trans>
|
|
||||||
</Toggle.LabelText>
|
|
||||||
</View>
|
|
||||||
</TargetToggle>
|
|
||||||
</Toggle.Item>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<View
|
|
||||||
style={[
|
|
||||||
a.flex_1,
|
|
||||||
a.flex_row,
|
|
||||||
a.justify_start,
|
|
||||||
a.align_center,
|
|
||||||
a.gap_sm,
|
|
||||||
]}>
|
|
||||||
<Toggle.Item
|
|
||||||
label={_(msg`Mute this word for 7 days`)}
|
|
||||||
name="7_days"
|
|
||||||
style={[a.flex_1]}
|
|
||||||
PressableComponent={NormalizedRNGHPressable}>
|
|
||||||
<TargetToggle>
|
|
||||||
<View
|
|
||||||
style={[a.flex_1, a.flex_row, a.align_center, a.gap_sm]}>
|
|
||||||
<Toggle.Radio />
|
|
||||||
<Toggle.LabelText style={[a.flex_1, a.leading_tight]}>
|
|
||||||
<Trans>7 days</Trans>
|
|
||||||
</Toggle.LabelText>
|
|
||||||
</View>
|
|
||||||
</TargetToggle>
|
|
||||||
</Toggle.Item>
|
|
||||||
|
|
||||||
<Toggle.Item
|
|
||||||
label={_(msg`Mute this word for 30 days`)}
|
|
||||||
name="30_days"
|
|
||||||
style={[a.flex_1]}
|
|
||||||
PressableComponent={NormalizedRNGHPressable}>
|
|
||||||
<TargetToggle>
|
|
||||||
<View
|
|
||||||
style={[a.flex_1, a.flex_row, a.align_center, a.gap_sm]}>
|
|
||||||
<Toggle.Radio />
|
|
||||||
<Toggle.LabelText style={[a.flex_1, a.leading_tight]}>
|
|
||||||
<Trans>30 days</Trans>
|
|
||||||
</Toggle.LabelText>
|
|
||||||
</View>
|
|
||||||
</TargetToggle>
|
|
||||||
</Toggle.Item>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
</Toggle.Group>
|
|
||||||
|
|
||||||
<Toggle.Group
|
|
||||||
label={_(msg`Select what content this mute word should apply to.`)}
|
|
||||||
type="radio"
|
|
||||||
values={targets}
|
|
||||||
onChange={setTargets}>
|
|
||||||
<Text
|
|
||||||
style={[
|
|
||||||
a.pb_xs,
|
|
||||||
a.text_sm,
|
|
||||||
a.font_bold,
|
|
||||||
t.atoms.text_contrast_medium,
|
|
||||||
]}>
|
|
||||||
<Trans>Mute in:</Trans>
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
<View style={[a.flex_row, a.align_center, a.gap_sm, a.flex_wrap]}>
|
|
||||||
<Toggle.Item
|
|
||||||
label={_(msg`Mute this word in post text and tags`)}
|
|
||||||
name="content"
|
|
||||||
style={[a.flex_1]}
|
|
||||||
PressableComponent={NormalizedRNGHPressable}>
|
|
||||||
<TargetToggle>
|
|
||||||
<View
|
|
||||||
style={[a.flex_1, a.flex_row, a.align_center, a.gap_sm]}>
|
|
||||||
<Toggle.Radio />
|
|
||||||
<Toggle.LabelText style={[a.flex_1, a.leading_tight]}>
|
|
||||||
<Trans>Text & tags</Trans>
|
|
||||||
</Toggle.LabelText>
|
|
||||||
</View>
|
|
||||||
<PageText size="sm" />
|
|
||||||
</TargetToggle>
|
|
||||||
</Toggle.Item>
|
|
||||||
|
|
||||||
<Toggle.Item
|
|
||||||
label={_(msg`Mute this word in tags only`)}
|
|
||||||
name="tag"
|
|
||||||
style={[a.flex_1]}
|
|
||||||
PressableComponent={NormalizedRNGHPressable}>
|
|
||||||
<TargetToggle>
|
|
||||||
<View
|
|
||||||
style={[a.flex_1, a.flex_row, a.align_center, a.gap_sm]}>
|
|
||||||
<Toggle.Radio />
|
|
||||||
<Toggle.LabelText style={[a.flex_1, a.leading_tight]}>
|
|
||||||
<Trans>Tags only</Trans>
|
|
||||||
</Toggle.LabelText>
|
|
||||||
</View>
|
|
||||||
<Hashtag size="sm" />
|
|
||||||
</TargetToggle>
|
|
||||||
</Toggle.Item>
|
|
||||||
</View>
|
|
||||||
</Toggle.Group>
|
|
||||||
|
|
||||||
<View>
|
|
||||||
<Text
|
|
||||||
style={[
|
|
||||||
a.pb_xs,
|
|
||||||
a.text_sm,
|
|
||||||
a.font_bold,
|
|
||||||
t.atoms.text_contrast_medium,
|
|
||||||
]}>
|
|
||||||
<Trans>Options:</Trans>
|
|
||||||
</Text>
|
|
||||||
<Toggle.Item
|
|
||||||
label={_(msg`Do not apply this mute word to users you follow`)}
|
|
||||||
name="exclude_following"
|
|
||||||
style={[a.flex_row, a.justify_between]}
|
|
||||||
value={excludeFollowing}
|
|
||||||
onChange={setExcludeFollowing}
|
|
||||||
PressableComponent={NormalizedRNGHPressable}>
|
|
||||||
<TargetToggle>
|
|
||||||
<View style={[a.flex_1, a.flex_row, a.align_center, a.gap_sm]}>
|
|
||||||
<Toggle.Checkbox />
|
|
||||||
<Toggle.LabelText style={[a.flex_1, a.leading_tight]}>
|
|
||||||
<Trans>Exclude users you follow</Trans>
|
|
||||||
</Toggle.LabelText>
|
|
||||||
</View>
|
|
||||||
</TargetToggle>
|
|
||||||
</Toggle.Item>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<View style={[a.pt_xs]}>
|
|
||||||
<Button
|
|
||||||
disabled={isPending || !field}
|
|
||||||
label={_(msg`Add mute word for configured settings`)}
|
|
||||||
size="large"
|
|
||||||
color="primary"
|
|
||||||
variant="solid"
|
|
||||||
style={[]}
|
|
||||||
onPress={submit}>
|
|
||||||
<ButtonText>
|
|
||||||
<Trans>Add</Trans>
|
|
||||||
</ButtonText>
|
|
||||||
<ButtonIcon icon={isPending ? Loader : Plus} position="right" />
|
|
||||||
</Button>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
{error && (
|
|
||||||
<View
|
|
||||||
style={[
|
|
||||||
a.mb_lg,
|
|
||||||
a.flex_row,
|
|
||||||
a.rounded_sm,
|
|
||||||
a.p_md,
|
|
||||||
a.mb_xs,
|
|
||||||
t.atoms.bg_contrast_25,
|
|
||||||
{
|
|
||||||
backgroundColor: t.palette.negative_400,
|
|
||||||
},
|
|
||||||
]}>
|
|
||||||
<Text
|
|
||||||
style={[
|
|
||||||
a.italic,
|
|
||||||
{color: t.palette.white},
|
|
||||||
native({marginTop: 2}),
|
|
||||||
]}>
|
|
||||||
{error}
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
)}
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<Divider />
|
|
||||||
|
|
||||||
<View style={[a.pt_2xl]}>
|
|
||||||
<Text
|
<Text
|
||||||
style={[
|
style={[
|
||||||
a.text_md,
|
a.text_md,
|
||||||
a.font_bold,
|
a.font_bold,
|
||||||
a.pb_md,
|
a.pb_sm,
|
||||||
t.atoms.text_contrast_high,
|
t.atoms.text_contrast_high,
|
||||||
]}>
|
]}>
|
||||||
<Trans>Your muted words</Trans>
|
<Trans>Add muted words and tags</Trans>
|
||||||
|
</Text>
|
||||||
|
<Text style={[a.pb_lg, a.leading_snug, t.atoms.text_contrast_medium]}>
|
||||||
|
<Trans>
|
||||||
|
Posts can be muted based on their text, their tags, or both. We
|
||||||
|
recommend avoiding common words that appear in many posts, since
|
||||||
|
it can result in no posts being shown.
|
||||||
|
</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
{isPreferencesLoading ? (
|
<View style={[a.pb_sm]}>
|
||||||
<Loader />
|
<Dialog.Input
|
||||||
) : preferencesError || !preferences ? (
|
autoCorrect={false}
|
||||||
<View
|
autoCapitalize="none"
|
||||||
style={[a.py_md, a.px_lg, a.rounded_md, t.atoms.bg_contrast_25]}>
|
autoComplete="off"
|
||||||
<Text style={[a.italic, t.atoms.text_contrast_high]}>
|
label={_(msg`Enter a word or tag`)}
|
||||||
<Trans>
|
placeholder={_(msg`Enter a word or tag`)}
|
||||||
We're sorry, but we weren't able to load your muted words at
|
value={field}
|
||||||
this time. Please try again.
|
onChangeText={value => {
|
||||||
</Trans>
|
if (error) {
|
||||||
|
setError('')
|
||||||
|
}
|
||||||
|
setField(value)
|
||||||
|
}}
|
||||||
|
onSubmitEditing={submit}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View style={[a.pb_xl, a.gap_sm]}>
|
||||||
|
<Toggle.Group
|
||||||
|
label={_(msg`Select how long to mute this word for.`)}
|
||||||
|
type="radio"
|
||||||
|
values={durations}
|
||||||
|
onChange={setDurations}>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
a.pb_xs,
|
||||||
|
a.text_sm,
|
||||||
|
a.font_bold,
|
||||||
|
t.atoms.text_contrast_medium,
|
||||||
|
]}>
|
||||||
|
<Trans>Duration:</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
|
||||||
) : preferences.moderationPrefs.mutedWords.length ? (
|
<View
|
||||||
[...preferences.moderationPrefs.mutedWords]
|
style={[
|
||||||
.reverse()
|
gtMobile && [a.flex_row, a.align_center, a.justify_start],
|
||||||
.map((word, i) => (
|
a.gap_sm,
|
||||||
<MutedWordRow
|
]}>
|
||||||
key={word.value + i}
|
<View
|
||||||
word={word}
|
style={[
|
||||||
style={[i % 2 === 0 && t.atoms.bg_contrast_25]}
|
a.flex_1,
|
||||||
/>
|
a.flex_row,
|
||||||
))
|
a.justify_start,
|
||||||
) : (
|
a.align_center,
|
||||||
<View
|
a.gap_sm,
|
||||||
style={[a.py_md, a.px_lg, a.rounded_md, t.atoms.bg_contrast_25]}>
|
]}>
|
||||||
<Text style={[a.italic, t.atoms.text_contrast_high]}>
|
<Toggle.Item
|
||||||
<Trans>You haven't muted any words or tags yet</Trans>
|
label={_(msg`Mute this word until you unmute it`)}
|
||||||
|
name="forever"
|
||||||
|
style={[a.flex_1]}
|
||||||
|
PressableComponent={NormalizedRNGHPressable}>
|
||||||
|
<TargetToggle>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
a.flex_1,
|
||||||
|
a.flex_row,
|
||||||
|
a.align_center,
|
||||||
|
a.gap_sm,
|
||||||
|
]}>
|
||||||
|
<Toggle.Radio />
|
||||||
|
<Toggle.LabelText style={[a.flex_1, a.leading_tight]}>
|
||||||
|
<Trans>Forever</Trans>
|
||||||
|
</Toggle.LabelText>
|
||||||
|
</View>
|
||||||
|
</TargetToggle>
|
||||||
|
</Toggle.Item>
|
||||||
|
|
||||||
|
<Toggle.Item
|
||||||
|
label={_(msg`Mute this word for 24 hours`)}
|
||||||
|
name="24_hours"
|
||||||
|
style={[a.flex_1]}
|
||||||
|
PressableComponent={NormalizedRNGHPressable}>
|
||||||
|
<TargetToggle>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
a.flex_1,
|
||||||
|
a.flex_row,
|
||||||
|
a.align_center,
|
||||||
|
a.gap_sm,
|
||||||
|
]}>
|
||||||
|
<Toggle.Radio />
|
||||||
|
<Toggle.LabelText style={[a.flex_1, a.leading_tight]}>
|
||||||
|
<Trans>24 hours</Trans>
|
||||||
|
</Toggle.LabelText>
|
||||||
|
</View>
|
||||||
|
</TargetToggle>
|
||||||
|
</Toggle.Item>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
a.flex_1,
|
||||||
|
a.flex_row,
|
||||||
|
a.justify_start,
|
||||||
|
a.align_center,
|
||||||
|
a.gap_sm,
|
||||||
|
]}>
|
||||||
|
<Toggle.Item
|
||||||
|
label={_(msg`Mute this word for 7 days`)}
|
||||||
|
name="7_days"
|
||||||
|
style={[a.flex_1]}
|
||||||
|
PressableComponent={NormalizedRNGHPressable}>
|
||||||
|
<TargetToggle>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
a.flex_1,
|
||||||
|
a.flex_row,
|
||||||
|
a.align_center,
|
||||||
|
a.gap_sm,
|
||||||
|
]}>
|
||||||
|
<Toggle.Radio />
|
||||||
|
<Toggle.LabelText style={[a.flex_1, a.leading_tight]}>
|
||||||
|
<Trans>7 days</Trans>
|
||||||
|
</Toggle.LabelText>
|
||||||
|
</View>
|
||||||
|
</TargetToggle>
|
||||||
|
</Toggle.Item>
|
||||||
|
|
||||||
|
<Toggle.Item
|
||||||
|
label={_(msg`Mute this word for 30 days`)}
|
||||||
|
name="30_days"
|
||||||
|
style={[a.flex_1]}
|
||||||
|
PressableComponent={NormalizedRNGHPressable}>
|
||||||
|
<TargetToggle>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
a.flex_1,
|
||||||
|
a.flex_row,
|
||||||
|
a.align_center,
|
||||||
|
a.gap_sm,
|
||||||
|
]}>
|
||||||
|
<Toggle.Radio />
|
||||||
|
<Toggle.LabelText style={[a.flex_1, a.leading_tight]}>
|
||||||
|
<Trans>30 days</Trans>
|
||||||
|
</Toggle.LabelText>
|
||||||
|
</View>
|
||||||
|
</TargetToggle>
|
||||||
|
</Toggle.Item>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</Toggle.Group>
|
||||||
|
|
||||||
|
<Toggle.Group
|
||||||
|
label={_(
|
||||||
|
msg`Select what content this mute word should apply to.`,
|
||||||
|
)}
|
||||||
|
type="radio"
|
||||||
|
values={targets}
|
||||||
|
onChange={setTargets}>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
a.pb_xs,
|
||||||
|
a.text_sm,
|
||||||
|
a.font_bold,
|
||||||
|
t.atoms.text_contrast_medium,
|
||||||
|
]}>
|
||||||
|
<Trans>Mute in:</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
|
<View style={[a.flex_row, a.align_center, a.gap_sm, a.flex_wrap]}>
|
||||||
|
<Toggle.Item
|
||||||
|
label={_(msg`Mute this word in post text and tags`)}
|
||||||
|
name="content"
|
||||||
|
style={[a.flex_1]}
|
||||||
|
PressableComponent={NormalizedRNGHPressable}>
|
||||||
|
<TargetToggle>
|
||||||
|
<View
|
||||||
|
style={[a.flex_1, a.flex_row, a.align_center, a.gap_sm]}>
|
||||||
|
<Toggle.Radio />
|
||||||
|
<Toggle.LabelText style={[a.flex_1, a.leading_tight]}>
|
||||||
|
<Trans>Text & tags</Trans>
|
||||||
|
</Toggle.LabelText>
|
||||||
|
</View>
|
||||||
|
<PageText size="sm" />
|
||||||
|
</TargetToggle>
|
||||||
|
</Toggle.Item>
|
||||||
|
|
||||||
|
<Toggle.Item
|
||||||
|
label={_(msg`Mute this word in tags only`)}
|
||||||
|
name="tag"
|
||||||
|
style={[a.flex_1]}
|
||||||
|
PressableComponent={NormalizedRNGHPressable}>
|
||||||
|
<TargetToggle>
|
||||||
|
<View
|
||||||
|
style={[a.flex_1, a.flex_row, a.align_center, a.gap_sm]}>
|
||||||
|
<Toggle.Radio />
|
||||||
|
<Toggle.LabelText style={[a.flex_1, a.leading_tight]}>
|
||||||
|
<Trans>Tags only</Trans>
|
||||||
|
</Toggle.LabelText>
|
||||||
|
</View>
|
||||||
|
<Hashtag size="sm" />
|
||||||
|
</TargetToggle>
|
||||||
|
</Toggle.Item>
|
||||||
|
</View>
|
||||||
|
</Toggle.Group>
|
||||||
|
|
||||||
|
<View>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
a.pb_xs,
|
||||||
|
a.text_sm,
|
||||||
|
a.font_bold,
|
||||||
|
t.atoms.text_contrast_medium,
|
||||||
|
]}>
|
||||||
|
<Trans>Options:</Trans>
|
||||||
|
</Text>
|
||||||
|
<Toggle.Item
|
||||||
|
label={_(msg`Do not apply this mute word to users you follow`)}
|
||||||
|
name="exclude_following"
|
||||||
|
style={[a.flex_row, a.justify_between]}
|
||||||
|
value={excludeFollowing}
|
||||||
|
onChange={setExcludeFollowing}
|
||||||
|
PressableComponent={NormalizedRNGHPressable}>
|
||||||
|
<TargetToggle>
|
||||||
|
<View
|
||||||
|
style={[a.flex_1, a.flex_row, a.align_center, a.gap_sm]}>
|
||||||
|
<Toggle.Checkbox />
|
||||||
|
<Toggle.LabelText style={[a.flex_1, a.leading_tight]}>
|
||||||
|
<Trans>Exclude users you follow</Trans>
|
||||||
|
</Toggle.LabelText>
|
||||||
|
</View>
|
||||||
|
</TargetToggle>
|
||||||
|
</Toggle.Item>
|
||||||
</View>
|
</View>
|
||||||
)}
|
|
||||||
|
<View style={[a.pt_xs]}>
|
||||||
|
<Button
|
||||||
|
disabled={isPending || !field}
|
||||||
|
label={_(msg`Add mute word for configured settings`)}
|
||||||
|
size="large"
|
||||||
|
color="primary"
|
||||||
|
variant="solid"
|
||||||
|
style={[]}
|
||||||
|
onPress={submit}>
|
||||||
|
<ButtonText>
|
||||||
|
<Trans>Add</Trans>
|
||||||
|
</ButtonText>
|
||||||
|
<ButtonIcon icon={isPending ? Loader : Plus} position="right" />
|
||||||
|
</Button>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{error && (
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
a.mb_lg,
|
||||||
|
a.flex_row,
|
||||||
|
a.rounded_sm,
|
||||||
|
a.p_md,
|
||||||
|
a.mb_xs,
|
||||||
|
t.atoms.bg_contrast_25,
|
||||||
|
{
|
||||||
|
backgroundColor: t.palette.negative_400,
|
||||||
|
},
|
||||||
|
]}>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
a.italic,
|
||||||
|
{color: t.palette.white},
|
||||||
|
native({marginTop: 2}),
|
||||||
|
]}>
|
||||||
|
{error}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<Divider />
|
||||||
|
|
||||||
|
<View style={[a.pt_2xl]}>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
a.text_md,
|
||||||
|
a.font_bold,
|
||||||
|
a.pb_md,
|
||||||
|
t.atoms.text_contrast_high,
|
||||||
|
]}>
|
||||||
|
<Trans>Your muted words</Trans>
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
{isPreferencesLoading ? (
|
||||||
|
<Loader />
|
||||||
|
) : preferencesError || !preferences ? (
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
a.py_md,
|
||||||
|
a.px_lg,
|
||||||
|
a.rounded_md,
|
||||||
|
t.atoms.bg_contrast_25,
|
||||||
|
]}>
|
||||||
|
<Text style={[a.italic, t.atoms.text_contrast_high]}>
|
||||||
|
<Trans>
|
||||||
|
We're sorry, but we weren't able to load your muted words at
|
||||||
|
this time. Please try again.
|
||||||
|
</Trans>
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
) : preferences.moderationPrefs.mutedWords.length ? (
|
||||||
|
[...preferences.moderationPrefs.mutedWords]
|
||||||
|
.reverse()
|
||||||
|
.map((word, i) => (
|
||||||
|
<MutedWordRow
|
||||||
|
key={word.value + i}
|
||||||
|
word={word}
|
||||||
|
style={[i % 2 === 0 && t.atoms.bg_contrast_25]}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
a.py_md,
|
||||||
|
a.px_lg,
|
||||||
|
a.rounded_md,
|
||||||
|
t.atoms.bg_contrast_25,
|
||||||
|
]}>
|
||||||
|
<Text style={[a.italic, t.atoms.text_contrast_high]}>
|
||||||
|
<Trans>You haven't muted any words or tags yet</Trans>
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{isNative && <View style={{height: 20}} />}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{isNative && <View style={{height: 20}} />}
|
<Dialog.Close />
|
||||||
</View>
|
</Dialog.ScrollableInner>
|
||||||
|
|
||||||
<Dialog.Close />
|
<Portal.Outlet />
|
||||||
</Dialog.ScrollableInner>
|
</Portal.Provider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,6 +489,7 @@ function MutedWordRow({
|
|||||||
onConfirm={remove}
|
onConfirm={remove}
|
||||||
confirmButtonCta={_(msg`Remove`)}
|
confirmButtonCta={_(msg`Remove`)}
|
||||||
confirmButtonColor="negative"
|
confirmButtonColor="negative"
|
||||||
|
Portal={Portal.Portal}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
|||||||
Reference in New Issue
Block a user