diff options
author | Minseo Lee <itoupluk427@gmail.com> | 2024-03-19 10:52:29 +0900 |
---|---|---|
committer | Minseo Lee <itoupluk427@gmail.com> | 2024-03-19 10:52:29 +0900 |
commit | ad43d594c9f63fc85e6927d23cd3f3f21406b002 (patch) | |
tree | 8a20f9f9051ff066bd54c5bc126ccc548e2cb16c /src/components/moderation/PostAlerts.tsx | |
parent | 73dae9f7b5c169aa303e9ef9487040e850998edf (diff) | |
parent | 3abf302b0b189c50acf11489bf60bdaeb187b722 (diff) | |
download | voidsky-ad43d594c9f63fc85e6927d23cd3f3f21406b002.tar.zst |
Merge remote-tracking branch 'upstream/main' into patch-3
Diffstat (limited to 'src/components/moderation/PostAlerts.tsx')
-rw-r--r-- | src/components/moderation/PostAlerts.tsx | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/components/moderation/PostAlerts.tsx b/src/components/moderation/PostAlerts.tsx new file mode 100644 index 000000000..0bfe69678 --- /dev/null +++ b/src/components/moderation/PostAlerts.tsx @@ -0,0 +1,66 @@ +import React from 'react' +import {StyleProp, View, ViewStyle} from 'react-native' +import {ModerationUI, ModerationCause} from '@atproto/api' + +import {useModerationCauseDescription} from '#/lib/moderation/useModerationCauseDescription' +import {getModerationCauseKey} from '#/lib/moderation' + +import {atoms as a} from '#/alf' +import {Button, ButtonText, ButtonIcon} from '#/components/Button' +import { + ModerationDetailsDialog, + useModerationDetailsDialogControl, +} from '#/components/moderation/ModerationDetailsDialog' + +export function PostAlerts({ + modui, + style, +}: { + modui: ModerationUI + includeMute?: boolean + style?: StyleProp<ViewStyle> +}) { + if (!modui.alert && !modui.inform) { + return null + } + + return ( + <View style={[a.flex_col, a.gap_xs, style]}> + <View style={[a.flex_row, a.flex_wrap, a.gap_xs]}> + {modui.alerts.map(cause => ( + <PostLabel key={getModerationCauseKey(cause)} cause={cause} /> + ))} + {modui.informs.map(cause => ( + <PostLabel key={getModerationCauseKey(cause)} cause={cause} /> + ))} + </View> + </View> + ) +} + +function PostLabel({cause}: {cause: ModerationCause}) { + const control = useModerationDetailsDialogControl() + const desc = useModerationCauseDescription(cause) + + return ( + <> + <Button + label={desc.name} + variant="solid" + color="secondary" + size="small" + shape="default" + onPress={() => { + control.open() + }} + style={[a.px_sm, a.py_xs, a.gap_xs]}> + <ButtonIcon icon={desc.icon} position="left" /> + <ButtonText style={[a.text_left, a.leading_snug]}> + {desc.name} + </ButtonText> + </Button> + + <ModerationDetailsDialog control={control} modcause={cause} /> + </> + ) +} |