Created
February 17, 2019 22:14
-
-
Save andriyParashchuk/6468dbde43cb2cb989b22fe93c779e2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as RX from 'reactxp' | |
interface VideoThumbnailProps { | |
video: Video, | |
onPressVideo: (video: Video) => void; | |
} | |
interface Video { | |
id: number, | |
name: string, | |
previewImage: string, | |
videoUrl: string, | |
} | |
const styles = { | |
videoPreview: RX.Styles.createViewStyle({ | |
margin: 15, | |
borderRadius: 8, | |
overflow: 'hidden', | |
width: 386, | |
}), | |
videoThumbnail: RX.Styles.createImageStyle({ | |
height: 218, | |
}), | |
videoDescription: RX.Styles.createViewStyle({ | |
backgroundColor: 'rgba(0,0,0,0.5)', | |
position: 'relative', | |
paddingHorizontal: 8, | |
paddingVertical: 12, | |
overflow: 'visible', | |
color: '#fff', | |
}), | |
videoName: RX.Styles.createTextStyle({ | |
overflow: 'hidden', | |
height: 60, | |
fontSize: 26, | |
lineHeight: 30, | |
}) | |
} | |
export class VideoThumbnail extends RX.Component<VideoThumbnailProps> { | |
render() { | |
const { video } = this.props | |
return ( | |
<RX.View key={video.id} onPress={this._onPressVideo} style={styles.videoPreview}> | |
<RX.Image source={video.previewImage} resizeMode="cover" style={styles.videoThumbnail}/> | |
<RX.View style={styles.videoDescription}> | |
<RX.Text style={styles.videoName}>{video.name}</RX.Text> | |
</RX.View> | |
</RX.View> | |
); | |
} | |
private _onPressVideo = () => { | |
const { onPressVideo, video} = this.props | |
onPressVideo(video) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment