|
| 1 | +import React from 'react'; |
| 2 | +import { Pressable, StyleProp, View, ViewStyle } from 'react-native'; |
| 3 | + |
| 4 | +import Divider from '../../components/Divider'; |
| 5 | +import Text from '../../components/Text'; |
| 6 | +import createStyleSheet from '../../styles/createStyleSheet'; |
| 7 | +import useUIKitTheme from '../../theme/useUIKitTheme'; |
| 8 | +import Avatar from '../Avatar'; |
| 9 | + |
| 10 | +type Props = { |
| 11 | + uri: string; |
| 12 | + username: string; |
| 13 | + |
| 14 | + bodyLabel: string; |
| 15 | + body: string; |
| 16 | +}; |
| 17 | + |
| 18 | +// TODO: Extract as component |
| 19 | +type OutlinedButtonProps = { |
| 20 | + children: string; |
| 21 | + containerStyle?: StyleProp<ViewStyle>; |
| 22 | +}; |
| 23 | + |
| 24 | +const OutlinedButton = ({ children, containerStyle }: OutlinedButtonProps) => { |
| 25 | + return ( |
| 26 | + <Pressable style={[styles.outlinedButton, containerStyle]}> |
| 27 | + <Text button numberOfLines={1} style={styles.outlinedButtonText}> |
| 28 | + {children} |
| 29 | + </Text> |
| 30 | + </Pressable> |
| 31 | + ); |
| 32 | +}; |
| 33 | + |
| 34 | +const ProfileCard = ({ uri, username, bodyLabel, body }: Props) => { |
| 35 | + const { colors } = useUIKitTheme(); |
| 36 | + const color = colors.ui.profileCard.default.none; |
| 37 | + |
| 38 | + return ( |
| 39 | + <View style={[styles.container, { backgroundColor: color.background }]}> |
| 40 | + <View style={styles.profileContainer}> |
| 41 | + <Avatar uri={uri} size={80} containerStyle={styles.profileAvatar} /> |
| 42 | + <Text h1 color={color.textUsername}> |
| 43 | + {username} |
| 44 | + </Text> |
| 45 | + </View> |
| 46 | + <OutlinedButton containerStyle={styles.messageButton}>{'Message'}</OutlinedButton> |
| 47 | + <Divider space={16} /> |
| 48 | + <View style={styles.profileInfoContainer}> |
| 49 | + <Text body2 color={color.textBodyLabel} style={styles.profileInfoBodyLabel}> |
| 50 | + {bodyLabel} |
| 51 | + </Text> |
| 52 | + <Text body3 color={color.textBody}> |
| 53 | + {body} |
| 54 | + </Text> |
| 55 | + </View> |
| 56 | + </View> |
| 57 | + ); |
| 58 | +}; |
| 59 | + |
| 60 | +const styles = createStyleSheet({ |
| 61 | + outlinedButton: { |
| 62 | + borderRadius: 4, |
| 63 | + padding: 16, |
| 64 | + borderWidth: 1, |
| 65 | + alignItems: 'center', |
| 66 | + justifyContent: 'center', |
| 67 | + }, |
| 68 | + outlinedButtonText: { |
| 69 | + textAlign: 'center', |
| 70 | + width: '100%', |
| 71 | + }, |
| 72 | + |
| 73 | + container: { |
| 74 | + paddingTop: 32, |
| 75 | + width: '100%', |
| 76 | + }, |
| 77 | + profileContainer: { |
| 78 | + alignItems: 'center', |
| 79 | + paddingHorizontal: 16, |
| 80 | + marginBottom: 24, |
| 81 | + }, |
| 82 | + profileAvatar: { |
| 83 | + marginBottom: 8, |
| 84 | + }, |
| 85 | + profileInfoContainer: { |
| 86 | + padding: 16, |
| 87 | + }, |
| 88 | + profileInfoBodyLabel: { |
| 89 | + marginBottom: 4, |
| 90 | + }, |
| 91 | + messageButton: { |
| 92 | + marginHorizontal: 24, |
| 93 | + marginBottom: 24, |
| 94 | + }, |
| 95 | +}); |
| 96 | + |
| 97 | +export default ProfileCard; |
0 commit comments