2017-12-02 13:19:58 +00:00
|
|
|
import React from 'react';
|
2018-09-11 16:32:52 +00:00
|
|
|
import { View, Text, StyleSheet } from 'react-native';
|
2017-12-02 13:19:58 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2018-09-11 16:32:52 +00:00
|
|
|
import FastImage from 'react-native-fast-image';
|
2017-12-02 13:19:58 +00:00
|
|
|
|
2017-12-28 17:40:10 +00:00
|
|
|
import openLink from '../../utils/openLink';
|
2018-09-11 16:32:52 +00:00
|
|
|
import Touch from '../../utils/touch';
|
2017-12-02 13:19:58 +00:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
button: {
|
2018-09-11 16:32:52 +00:00
|
|
|
marginTop: 10
|
2017-12-02 13:19:58 +00:00
|
|
|
},
|
2018-09-11 16:32:52 +00:00
|
|
|
container: {
|
|
|
|
flex: 1,
|
|
|
|
flexDirection: 'column',
|
|
|
|
borderRadius: 4,
|
|
|
|
backgroundColor: '#F3F4F5'
|
2017-12-02 13:19:58 +00:00
|
|
|
},
|
|
|
|
textContainer: {
|
|
|
|
flex: 1,
|
|
|
|
flexDirection: 'column',
|
2018-09-11 16:32:52 +00:00
|
|
|
padding: 15,
|
2017-12-02 13:19:58 +00:00
|
|
|
justifyContent: 'flex-start',
|
|
|
|
alignItems: 'flex-start'
|
|
|
|
},
|
|
|
|
title: {
|
2018-09-11 16:32:52 +00:00
|
|
|
fontWeight: '500',
|
|
|
|
color: '#1D74F5',
|
|
|
|
fontSize: 16,
|
|
|
|
marginTop: 5
|
2017-12-02 13:19:58 +00:00
|
|
|
},
|
|
|
|
description: {
|
2018-09-11 16:32:52 +00:00
|
|
|
marginTop: 5,
|
|
|
|
fontSize: 16,
|
|
|
|
color: '#0C0D0F'
|
|
|
|
},
|
|
|
|
url: {
|
|
|
|
fontSize: 15,
|
|
|
|
fontWeight: '500',
|
|
|
|
color: '#9EA2A8'
|
|
|
|
},
|
|
|
|
marginTop: {
|
|
|
|
marginTop: 4
|
|
|
|
},
|
|
|
|
image: {
|
|
|
|
width: '100%',
|
|
|
|
height: 150,
|
|
|
|
borderTopLeftRadius: 4,
|
|
|
|
borderTopRightRadius: 4
|
2017-12-02 13:19:58 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const onPress = (url) => {
|
2017-12-28 17:40:10 +00:00
|
|
|
openLink(url);
|
2017-12-02 13:19:58 +00:00
|
|
|
};
|
2018-09-11 16:32:52 +00:00
|
|
|
const Url = ({ url, index }) => {
|
2017-12-02 13:19:58 +00:00
|
|
|
if (!url) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return (
|
2018-09-11 16:32:52 +00:00
|
|
|
<Touch onPress={() => onPress(url.url)} style={[styles.button, index > 0 && styles.marginTop]}>
|
|
|
|
<View style={styles.container}>
|
|
|
|
{/* <View style={{ backgroundColor: 'red', height: 150, borderTopLeftRadius: 5, borderTopRightRadius: 5 }}>
|
|
|
|
{url.image ? <FastImage source={{ uri: url.image }} /> : null}
|
|
|
|
</View> */}
|
|
|
|
{url.image ? <FastImage source={{ uri: url.image }} style={styles.image} resizeMode={FastImage.resizeMode.cover} /> : null}
|
|
|
|
<View style={styles.textContainer}>
|
|
|
|
<Text style={styles.url} numberOfLines={1}>{url.url}</Text>
|
|
|
|
<Text style={styles.title} numberOfLines={2}>{url.title}</Text>
|
|
|
|
<Text style={styles.description} numberOfLines={2}>{url.description}</Text>
|
|
|
|
</View>
|
2017-12-02 13:19:58 +00:00
|
|
|
</View>
|
2018-09-11 16:32:52 +00:00
|
|
|
</Touch>
|
2017-12-02 13:19:58 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
Url.propTypes = {
|
2018-09-11 16:32:52 +00:00
|
|
|
url: PropTypes.object.isRequired,
|
|
|
|
index: PropTypes.number
|
2017-12-02 13:19:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Url;
|