SidebarPage.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import {
  2. LayoutAnimation,
  3. Platform,
  4. StyleSheet,
  5. Text,
  6. UIManager,
  7. View,
  8. } from 'react-native';
  9. import React from 'react';
  10. import NewscoutLogo from '../components/molecules/NewscoutLogo';
  11. import fonts from '../theme/fonts';
  12. import CircularPrimaryBackButton from '../components/organisms/Buttons/CircularPrimaryBackButton';
  13. import {List} from 'react-native-paper';
  14. import colors from '../theme/colors';
  15. import EntypoIcon from 'react-native-vector-icons/Entypo'
  16. const data = [
  17. {
  18. title: 'Sector Update',
  19. subTitles: ['Banking', 'Retail', 'Transport', 'Banking', 'Food & Drink'],
  20. },
  21. {
  22. title: 'Regional Update',
  23. subTitles: ['Banking', 'Retail', 'Transport', 'Banking', 'Food & Drink'],
  24. },
  25. {
  26. title: 'Finance',
  27. subTitles: ['Banking', 'Retail', 'Transport', 'Banking', 'Food & Drink'],
  28. },
  29. {
  30. title: 'Economic',
  31. subTitles: ['Banking', 'Retail', 'Transport', 'Banking', 'Food & Drink'],
  32. },
  33. {
  34. title: 'Miscellaneous',
  35. subTitles: ['Banking', 'Retail', 'Transport', 'Banking', 'Food & Drink'],
  36. },
  37. ];
  38. const SidebarPage = ({navigation}) => {
  39. if (
  40. Platform.OS === 'android' &&
  41. UIManager.setLayoutAnimationEnabledExperimental
  42. ) {
  43. UIManager.setLayoutAnimationEnabledExperimental(true);
  44. }
  45. return (
  46. <View style={styles.sideBarContainer}>
  47. <View style={styles.logoContainer}>
  48. <NewscoutLogo style={styles.logo} />
  49. </View>
  50. <View style={styles.buttonContainer}>
  51. <CircularPrimaryBackButton onPress={() => navigation.toggleDrawer()} />
  52. </View>
  53. <View style={styles.accordionContainer}>
  54. <List.AccordionGroup>
  55. {data.map(item => (
  56. <List.Accordion
  57. style={styles.accordionStyle}
  58. titleStyle={styles.accordionTextStyle}
  59. onPress={() =>
  60. LayoutAnimation.configureNext(
  61. LayoutAnimation.Presets.easeInEaseOut,
  62. )
  63. }
  64. right={() => <EntypoIcon name="chevron-down" size={12}/>}
  65. id={data.indexOf(item)}
  66. title={item.title}>
  67. {item.subTitles.map(subTitle => (
  68. <List.Item
  69. style={styles.accordionItemStyle}
  70. titleStyle={styles.accordionItemTextStyle}
  71. title={subTitle}
  72. />
  73. ))}
  74. </List.Accordion>
  75. ))}
  76. </List.AccordionGroup>
  77. </View>
  78. </View>
  79. );
  80. };
  81. export default SidebarPage;
  82. const styles = StyleSheet.create({
  83. sideBarContainer: {
  84. paddingHorizontal: fonts.getSize(24),
  85. },
  86. logo: {
  87. width: fonts.getSize(84),
  88. height: fonts.getSize(84),
  89. },
  90. logoContainer: {
  91. justifyContent: 'center',
  92. alignItems: 'center',
  93. },
  94. buttonContainer: {},
  95. accordionContainer: {
  96. paddingVertical: fonts.getSize(16),
  97. gap: fonts.getSize(8),
  98. },
  99. accordionItemStyle: {},
  100. accordionItemTextStyle: {},
  101. accordionStyle: {
  102. backgroundColor: colors.white,
  103. borderRadius: fonts.getSize(8),
  104. borderWidth: fonts.getSize(3),
  105. borderColor: colors.lightGray,
  106. maxHeight: fonts.getSize(52)
  107. },
  108. accordionTextStyle: {fontFamily: fonts.type.medium},
  109. });