ImageBGCard.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { Image, StyleSheet, Text, View, ImageBackground, TouchableOpacity } from 'react-native'
  2. import React from 'react'
  3. import Card from '../../atoms/Card'
  4. import fonts from '../../../theme/fonts'
  5. import metrics from '../../../theme/metrics'
  6. import images from '../../../assets/images/images'
  7. import LinearGradient from 'react-native-linear-gradient'
  8. import colors from '../../../theme/colors'
  9. const ImageBGCard = ({image, author, headline, onPress, }) => {
  10. return (
  11. <TouchableOpacity onPress={onPress}>
  12. <ImageBackground source={image}
  13. imageStyle={{ borderRadius: fonts.getSize(8), }}
  14. style={styles.cardImage}
  15. >
  16. <LinearGradient
  17. colors={['transparent', 'black']}
  18. style={styles.gradient}
  19. start={{ x: 0.5, y: 0.3 }}
  20. >
  21. <Text style={styles.authorText}>
  22. by {author}
  23. </Text>
  24. <Text style={styles.headlineText}>{headline}</Text>
  25. </LinearGradient>
  26. </ImageBackground>
  27. </TouchableOpacity>
  28. )
  29. }
  30. export default ImageBGCard
  31. const styles = StyleSheet.create({
  32. cardImage: {
  33. height: 'auto',
  34. width: 'auto',
  35. },
  36. gradient: {
  37. borderRadius: fonts.getSize(8),
  38. height: fonts.getSize(240),
  39. justifyContent: 'flex-end',
  40. paddingHorizontal: fonts.getSize(16),
  41. paddingVertical: fonts.getSize(10)
  42. },
  43. authorText: {
  44. color: colors.white,
  45. fontFamily: fonts.type.bold,
  46. fontSize: fonts.getSize(12)
  47. },
  48. headlineText: {
  49. color: colors.white,
  50. fontFamily: fonts.type.medium,
  51. fontSize: fonts.getSize(16)
  52. }
  53. })