mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at remove-hackfix 145 lines 3.9 kB view raw
1import React from 'react' 2import {View} from 'react-native' 3import {msg, Trans} from '@lingui/macro' 4import {useLingui} from '@lingui/react' 5 6import {type Avatar} from '#/screens/Onboarding/StepProfile/index' 7import { 8 type AvatarColor, 9 avatarColors, 10 emojiItems, 11 type EmojiName, 12 emojiNames, 13} from '#/screens/Onboarding/StepProfile/types' 14import {atoms as a, useTheme} from '#/alf' 15import {Button, ButtonIcon} from '#/components/Button' 16import {Text} from '#/components/Typography' 17 18const ACTIVE_BORDER_WIDTH = 3 19const ACTIVE_BORDER_STYLES = { 20 top: -ACTIVE_BORDER_WIDTH, 21 bottom: -ACTIVE_BORDER_WIDTH, 22 left: -ACTIVE_BORDER_WIDTH, 23 right: -ACTIVE_BORDER_WIDTH, 24 opacity: 0.5, 25 borderWidth: 3, 26} 27 28export function AvatarCreatorItems({ 29 type, 30 avatar, 31 setAvatar, 32}: { 33 type: 'emojis' | 'colors' 34 avatar: Avatar 35 setAvatar: React.Dispatch<React.SetStateAction<Avatar>> 36}) { 37 const {_} = useLingui() 38 const t = useTheme() 39 const isEmojis = type === 'emojis' 40 41 const onSelectEmoji = React.useCallback( 42 (emoji: EmojiName) => { 43 setAvatar(prev => ({ 44 ...prev, 45 placeholder: emojiItems[emoji], 46 })) 47 }, 48 [setAvatar], 49 ) 50 51 const onSelectColor = React.useCallback( 52 (color: AvatarColor) => { 53 setAvatar(prev => ({ 54 ...prev, 55 backgroundColor: color, 56 })) 57 }, 58 [setAvatar], 59 ) 60 61 return ( 62 <View style={[a.w_full]}> 63 <Text style={[a.pb_md, t.atoms.text_contrast_medium]}> 64 {isEmojis ? ( 65 <Trans>Select an emoji</Trans> 66 ) : ( 67 <Trans>Select a color</Trans> 68 )} 69 </Text> 70 71 <View 72 style={[ 73 a.flex_row, 74 a.align_start, 75 a.justify_start, 76 a.flex_wrap, 77 a.gap_md, 78 ]}> 79 {isEmojis 80 ? emojiNames.map(emojiName => ( 81 <Button 82 key={emojiName} 83 label={_(msg`Select the ${emojiName} emoji as your avatar`)} 84 size="small" 85 shape="round" 86 variant="solid" 87 color="secondary" 88 onPress={() => onSelectEmoji(emojiName)}> 89 <ButtonIcon icon={emojiItems[emojiName].component} /> 90 {avatar.placeholder.name === emojiName && ( 91 <View 92 style={[ 93 a.absolute, 94 a.rounded_full, 95 ACTIVE_BORDER_STYLES, 96 { 97 borderColor: avatar.backgroundColor, 98 }, 99 ]} 100 /> 101 )} 102 </Button> 103 )) 104 : avatarColors.map(color => ( 105 <Button 106 key={color} 107 label={_(msg`Choose this color as your avatar`)} 108 size="small" 109 shape="round" 110 variant="solid" 111 onPress={() => onSelectColor(color)}> 112 {ctx => ( 113 <> 114 <View 115 style={[ 116 a.absolute, 117 a.inset_0, 118 a.rounded_full, 119 { 120 opacity: ctx.hovered || ctx.pressed ? 0.8 : 1, 121 backgroundColor: color, 122 }, 123 ]} 124 /> 125 126 {avatar.backgroundColor === color && ( 127 <View 128 style={[ 129 a.absolute, 130 a.rounded_full, 131 ACTIVE_BORDER_STYLES, 132 { 133 borderColor: color, 134 }, 135 ]} 136 /> 137 )} 138 </> 139 )} 140 </Button> 141 ))} 142 </View> 143 </View> 144 ) 145}