CategorySection.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { StyleSheet, Text, View, ScrollView } from 'react-native'
  2. import React from 'react'
  3. import fonts from '../../../theme/fonts'
  4. import colors from '../../../theme/colors'
  5. import { ToggleButton } from 'react-native-paper'
  6. import HorizontalNewsCard from '../Cards/HorizontalNewsCard'
  7. import SectionHeader from '../Headers/SectionHeader'
  8. const CategorySection = () => {
  9. const categories = [ "Sector Update","Finance", "Sports", "Regional Update", "Entertainment"]
  10. const news = [{},{},{},{},{}]
  11. const [categoryValue, setCategoryValue] = React.useState(categories[0].toLowerCase());
  12. return (
  13. <View style={styles.categoriesContainer}>
  14. <SectionHeader label={"Categories"}/>
  15. <View style={styles.categoriesPillContainer}>
  16. <ScrollView horizontal showsHorizontalScrollIndicator={false}>
  17. <ToggleButton.Group onValueChange={value => {setCategoryValue(value) }}>
  18. {
  19. categories.map((category) =>
  20. <ToggleButton
  21. icon={() => <Text style={[category.toLowerCase() === categoryValue ? styles.selectedPillText: styles.pillText]}>{category}</Text>}
  22. style={[category.toLowerCase() === categoryValue ? styles.selectedContainer : styles.container, {marginHorizontal: fonts.getSize(4)}]}
  23. value={category.toLowerCase()}
  24. />)
  25. }
  26. </ToggleButton.Group>
  27. </ScrollView>
  28. </View>
  29. <View style={styles.categoriesNewsContainer}>
  30. <ScrollView showsVerticalScrollIndicator={false}>
  31. {news.map((item) => <HorizontalNewsCard key={news.indexOf(item)} style={{marginBottom: fonts.getSize(20)}} onPress={true}/>)}
  32. </ScrollView>
  33. </View>
  34. </View>
  35. )
  36. }
  37. export default CategorySection
  38. const styles = StyleSheet.create({
  39. categoriesTitle: {
  40. flexDirection: 'row',
  41. paddingTop: fonts.getSize(20),
  42. paddingHorizontal: fonts.getSize(20)
  43. },
  44. categoriesTitleText: {
  45. flex: 1,
  46. fontFamily: fonts.type.semibold,
  47. fontSize: fonts.getSize(16),
  48. color: colors.black
  49. },
  50. categoriesPillContainer: {
  51. paddingBottom: fonts.getSize(8),
  52. flexDirection: 'row',
  53. alignItems: 'space-between',
  54. paddingHorizontal: fonts.getSize(16)
  55. },
  56. container: {
  57. borderRadius: fonts.getSize(18),
  58. paddingVertical: fonts.getSize(8),
  59. paddingHorizontal: fonts.getSize(16),
  60. backgroundColor: colors.white,
  61. width: 'auto'
  62. },
  63. selectedContainer: {
  64. paddingVertical: fonts.getSize(8),
  65. paddingHorizontal: fonts.getSize(16),
  66. backgroundColor: colors.topVariantColor,
  67. borderRadius: fonts.getSize(18),
  68. width: 'auto'
  69. },
  70. selectedPillText: {
  71. fontFamily: fonts.type.semibold,
  72. fontSize: fonts.getSize(12),
  73. color: colors.white
  74. },
  75. pillText: {
  76. fontFamily: fonts.type.semibold,
  77. fontSize: fonts.getSize(12),
  78. color: colors.quaternaryColor
  79. },
  80. categoriesNewsContainer:{
  81. paddingHorizontal: fonts.getSize(16),
  82. paddingTop: fonts.getSize(10),
  83. }
  84. })