|
| 1 | +import React from 'react'; |
| 2 | +import { StyleProp, StyleSheet, Text, View, ViewStyle } from 'react-native'; |
| 3 | + |
| 4 | +import { LocalMessage } from 'stream-chat'; |
| 5 | + |
| 6 | +import { useTheme } from '../../../contexts/themeContext/ThemeContext'; |
| 7 | + |
| 8 | +export type MessageBlockedProps = { |
| 9 | + /** Current [message object](https://getstream.io/chat/docs/#message_format) */ |
| 10 | + message: LocalMessage; |
| 11 | + /** |
| 12 | + * Additional styles for the system message container. |
| 13 | + */ |
| 14 | + style?: StyleProp<ViewStyle>; |
| 15 | +}; |
| 16 | + |
| 17 | +/** |
| 18 | + * A component to display blocked message. e.g, when a message is blocked by moderation policies. |
| 19 | + */ |
| 20 | +export const MessageBlocked = (props: MessageBlockedProps) => { |
| 21 | + const { message, style } = props; |
| 22 | + |
| 23 | + const { |
| 24 | + theme: { |
| 25 | + colors: { grey, grey_whisper }, |
| 26 | + messageSimple: { |
| 27 | + messageBlocked: { container, line, text, textContainer }, |
| 28 | + }, |
| 29 | + }, |
| 30 | + } = useTheme(); |
| 31 | + |
| 32 | + return ( |
| 33 | + <View style={[styles.container, style, container]} testID='message-system'> |
| 34 | + <View style={[styles.line, { backgroundColor: grey_whisper }, line]} /> |
| 35 | + <View style={[styles.textContainer, textContainer]}> |
| 36 | + <Text style={[styles.text, { color: grey }, text]}> |
| 37 | + {message.text?.toUpperCase() || ''} |
| 38 | + </Text> |
| 39 | + </View> |
| 40 | + <View style={[styles.line, { backgroundColor: grey_whisper }, line]} /> |
| 41 | + </View> |
| 42 | + ); |
| 43 | +}; |
| 44 | + |
| 45 | +MessageBlocked.displayName = 'MessageBlocked{messageList{messageBlocked}}'; |
| 46 | + |
| 47 | +const styles = StyleSheet.create({ |
| 48 | + container: { |
| 49 | + alignItems: 'center', |
| 50 | + flexDirection: 'row', |
| 51 | + justifyContent: 'center', |
| 52 | + marginBottom: 10, |
| 53 | + }, |
| 54 | + line: { |
| 55 | + flex: 1, |
| 56 | + height: 0.5, |
| 57 | + }, |
| 58 | + text: { |
| 59 | + fontSize: 10, |
| 60 | + fontWeight: 'bold', |
| 61 | + textAlign: 'center', |
| 62 | + }, |
| 63 | + textContainer: { |
| 64 | + flex: 3, |
| 65 | + marginTop: 10, |
| 66 | + }, |
| 67 | +}); |
0 commit comments