Bluesky app fork with some witchin' additions 馃挮
0
fork

Configure Feed

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

at cope-settings-sync 83 lines 2.6 kB view raw
1import {memo} from 'react' 2import {useWindowDimensions, View} from 'react-native' 3import {type $Typed, type AppBskyEmbedRecord} from '@atproto/api' 4 5import {useEnableSquareButtons} from '#/state/preferences/enable-square-buttons' 6import {atoms as a, native, useTheme, web} from '#/alf' 7import {Embed, PostEmbedViewContext} from '#/components/Post/Embed' 8import {MessageContextProvider} from './MessageContext' 9 10const CLUSTERED_MESSAGE_GAP = 2 11const SQUARED_BORDER_RADIUS = 4 12 13let MessageItemEmbed = ({ 14 embed, 15 isFromSelf, 16 squaredTopCorner, 17 squaredBottomCorner, 18}: { 19 embed: $Typed<AppBskyEmbedRecord.View> 20 isFromSelf: boolean 21 squaredTopCorner: boolean 22 squaredBottomCorner: boolean 23}): React.ReactNode => { 24 const enableSquareButtons = useEnableSquareButtons() 25 const t = useTheme() 26 const screen = useWindowDimensions() 27 const borderRadius = enableSquareButtons ? 4 : 20 28 29 return ( 30 <MessageContextProvider> 31 <View 32 style={[ 33 !isFromSelf && a.ml_sm, 34 native({ 35 flexBasis: 0, 36 width: Math.min(screen.width, 600) / 1.4, 37 }), 38 web({ 39 width: '100%', 40 minWidth: 280, 41 maxWidth: 360, 42 }), 43 { 44 marginTop: CLUSTERED_MESSAGE_GAP, 45 }, 46 ]}> 47 <View style={{marginTop: -8}}> 48 <Embed 49 embed={embed} 50 allowNestedQuotes 51 viewContext={PostEmbedViewContext.ChatMessage} 52 style={[ 53 enableSquareButtons ? a.rounded_sm : a.rounded_xl, 54 a.overflow_hidden, 55 a.border_0, 56 isFromSelf 57 ? { 58 backgroundColor: t.palette.primary_50, 59 borderBottomRightRadius: squaredBottomCorner 60 ? SQUARED_BORDER_RADIUS 61 : borderRadius, 62 borderTopRightRadius: squaredTopCorner 63 ? SQUARED_BORDER_RADIUS 64 : borderRadius, 65 } 66 : { 67 backgroundColor: t.palette.contrast_50, 68 borderBottomLeftRadius: squaredBottomCorner 69 ? SQUARED_BORDER_RADIUS 70 : borderRadius, 71 borderTopLeftRadius: squaredTopCorner 72 ? SQUARED_BORDER_RADIUS 73 : borderRadius, 74 }, 75 ]} 76 /> 77 </View> 78 </View> 79 </MessageContextProvider> 80 ) 81} 82MessageItemEmbed = memo(MessageItemEmbed) 83export {MessageItemEmbed}