11import React from 'react' ;
22import {
3- Image ,
3+ ImageBackground ,
44 ImageStyle ,
55 StyleProp ,
66 StyleSheet ,
@@ -24,6 +24,7 @@ import {
2424 useMessagesContext ,
2525} from '../../contexts/messagesContext/MessagesContext' ;
2626import { useTheme } from '../../contexts/themeContext/ThemeContext' ;
27+ import { Play } from '../../icons/Play' ;
2728import type { DefaultStreamChatGenerics } from '../../types/types' ;
2829import { makeImageCompatibleUrl } from '../../utils/utils' ;
2930
@@ -41,13 +42,15 @@ const styles = StyleSheet.create({
4142 } ,
4243 authorNameMask : {
4344 bottom : 0 ,
44- left : 8 ,
45+ left : 2 ,
4546 position : 'absolute' ,
4647 } ,
4748 cardCover : {
49+ alignItems : 'center' ,
4850 borderRadius : 8 ,
4951 height : 140 ,
50- marginHorizontal : 8 ,
52+ justifyContent : 'center' ,
53+ marginHorizontal : 2 ,
5154 } ,
5255 cardFooter : {
5356 flexDirection : 'row' ,
@@ -62,6 +65,14 @@ const styles = StyleSheet.create({
6265 fontSize : 12 ,
6366 marginHorizontal : 8 ,
6467 } ,
68+ playButtonStyle : {
69+ alignItems : 'center' ,
70+ borderRadius : 50 ,
71+ elevation : 2 ,
72+ height : 36 ,
73+ justifyContent : 'center' ,
74+ width : 36 ,
75+ } ,
6576 title : {
6677 fontSize : 12 ,
6778 marginHorizontal : 8 ,
@@ -116,11 +127,12 @@ const CardWithContext = <
116127 text,
117128 thumb_url,
118129 title,
130+ type,
119131 } = props ;
120132
121133 const {
122134 theme : {
123- colors : { accent_blue, black, blue_alice, transparent } ,
135+ colors : { accent_blue, black, blue_alice, transparent, white } ,
124136 messageSimple : {
125137 card : {
126138 authorName,
@@ -132,6 +144,8 @@ const CardWithContext = <
132144 cover,
133145 footer : { description, title : titleStyle , ...footerStyle } ,
134146 noURI,
147+ playButtonStyle : { roundedView } ,
148+ playIcon : { height, width } ,
135149 } ,
136150 } ,
137151 } ,
@@ -141,6 +155,8 @@ const CardWithContext = <
141155
142156 const defaultOnPress = ( ) => openUrlSafely ( og_scrape_url || uri ) ;
143157
158+ const isVideoCard = type === 'video' && og_scrape_url ;
159+
144160 return (
145161 < TouchableOpacity
146162 disabled = { preventPress }
@@ -181,11 +197,18 @@ const CardWithContext = <
181197 { CardCover && < CardCover { ...props } /> }
182198 { uri && ! CardCover && (
183199 < View >
184- < Image
200+ < ImageBackground
201+ imageStyle = { styles . cardCover }
185202 resizeMode = 'cover'
186203 source = { { uri : makeImageCompatibleUrl ( uri ) } }
187204 style = { [ styles . cardCover , cover , stylesProp . cardCover ] }
188- />
205+ >
206+ { isVideoCard ? (
207+ < View style = { [ styles . playButtonStyle , roundedView , { backgroundColor : white } ] } >
208+ < Play height = { height } pathFill = { black } width = { width } />
209+ </ View >
210+ ) : null }
211+ </ ImageBackground >
189212 { author_name && (
190213 < View style = { [ styles . authorNameMask , authorNameMask , stylesProp . authorNameMask ] } >
191214 < View
0 commit comments