FAQPage.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. import {StyleSheet, Text, View, ScrollView} from 'react-native';
  2. import React from 'react';
  3. import NewscoutTitleHeader from '../components/organisms/Headers/NewscoutTitleHeader';
  4. import {List, ToggleButton} from 'react-native-paper';
  5. import colors from '../theme/colors';
  6. import fonts from '../theme/fonts';
  7. const FAQPage = props => {
  8. const {navigation} = props;
  9. const faqCategories = [
  10. 'General',
  11. 'Login',
  12. 'Account',
  13. 'Viability',
  14. 'Bruh1',
  15. 'bruh2',
  16. 'bruh3',
  17. ];
  18. const [categoryValue, setCategoryValue] = React.useState(faqCategories[0]);
  19. // const [questions, setQuestions] = React.useState(
  20. // faqCategories.reduce((result, key) => ({...result, [key]: [{}]})),
  21. // );
  22. const questions = [
  23. {
  24. id: 0,
  25. title: 'What is Newscout?',
  26. answer:
  27. 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nis',
  28. },
  29. {
  30. id: 1,
  31. title: 'How to use Newscout?',
  32. answer:
  33. 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nis',
  34. },
  35. {
  36. id: 2,
  37. title: 'Can I create my own news?',
  38. answer:
  39. 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nis',
  40. },
  41. {
  42. id: 3,
  43. title: 'How can I upload images?',
  44. answer:
  45. 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nis',
  46. },
  47. {
  48. id: 4,
  49. title: 'Is Newscout free to use?',
  50. answer:
  51. 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nis',
  52. },
  53. ];
  54. const [expandedId, setExpandedId] = React.useState('');
  55. const handleAccordionPress = accordionId => {
  56. setExpandedId(accordionId === expandedId ? '' : accordionId);
  57. };
  58. return (
  59. <View style={styles.faqContainer}>
  60. <ScrollView showsVerticalScrollIndicator={false}>
  61. <NewscoutTitleHeader
  62. title={'FAQ'}
  63. backButtonShown
  64. onBackClick={() => navigation.goBack()}
  65. />
  66. <View style={styles.pillContainer}>
  67. <ScrollView horizontal showsHorizontalScrollIndicator={false}>
  68. <ToggleButton.Group
  69. onValueChange={value => {
  70. setCategoryValue(value);
  71. }}>
  72. {faqCategories.map(category => (
  73. <ToggleButton
  74. key={category}
  75. icon={() => (
  76. <Text
  77. style={[
  78. category === categoryValue
  79. ? styles.selectedPillText
  80. : styles.pillText,
  81. ]}>
  82. {category}
  83. </Text>
  84. )}
  85. style={[
  86. category === categoryValue
  87. ? styles.selectedContainer
  88. : styles.container,
  89. {marginHorizontal: fonts.getSize(4)},
  90. ]}
  91. value={category}
  92. />
  93. ))}
  94. </ToggleButton.Group>
  95. </ScrollView>
  96. </View>
  97. <List.Section style={{paddingHorizontal: 16, gap: 16}}>
  98. <List.AccordionGroup
  99. expandedId={expandedId}
  100. onAccordionPress={handleAccordionPress}>
  101. {questions.map(item => (
  102. <List.Accordion
  103. title={item.title}
  104. key={item.id}
  105. id={item.id.toString()}
  106. style={
  107. [expandedId === item.id.toString()
  108. ? styles.selectedAccordionContainer
  109. : styles.accordionContainer,
  110. // styles.baseAccordionContainer
  111. ]
  112. }
  113. titleStyle={styles.accordionTitle}>
  114. <View
  115. style={[
  116. {
  117. borderColor: colors.primaryColor,
  118. borderBottomWidth: 2,
  119. borderLeftWidth: 2,
  120. borderRightWidth: 2,
  121. borderBottomLeftRadius: 16,
  122. borderBottomRightRadius: 16,
  123. paddingHorizontal: 16,
  124. paddingBottom: 8,
  125. backgroundColor: colors.white,
  126. },
  127. ]}>
  128. <Text style={styles.accordionDescription}>
  129. {item.answer}
  130. </Text>
  131. </View>
  132. </List.Accordion>
  133. ))}
  134. </List.AccordionGroup>
  135. </List.Section>
  136. </ScrollView>
  137. </View>
  138. );
  139. };
  140. export default FAQPage;
  141. const styles = StyleSheet.create({
  142. selectedAccordionContainer: {
  143. borderTopWidth: 2,
  144. borderRightWidth: 2,
  145. borderLeftWidth: 2,
  146. borderTopLeftRadius: 16,
  147. borderTopRightRadius: 16,
  148. borderColor: colors.primaryColor,
  149. paddingVertical: 4,
  150. height:'auto',
  151. backgroundColor: colors.white
  152. },
  153. accordionContainer: {
  154. borderWidth: 2,
  155. borderColor: colors.grayShade_400,
  156. borderRadius: 16,
  157. height: 'auto',
  158. paddingVertical: 16,
  159. backgroundColor: colors.white
  160. },
  161. accordionTitle: {
  162. fontFamily: fonts.type.semibold,
  163. color: colors.black,
  164. },
  165. accordionDescription: {
  166. fontFamily: fonts.type.medium,
  167. color: colors.grayShade_200
  168. },
  169. selectedPillText: {
  170. fontFamily: fonts.type.semibold,
  171. fontSize: fonts.getSize(12),
  172. color: colors.white,
  173. },
  174. pillText: {
  175. fontFamily: fonts.type.semibold,
  176. fontSize: fonts.getSize(12),
  177. color: colors.quaternaryColor,
  178. },
  179. categoriesPillContainer: {
  180. paddingBottom: fonts.getSize(8),
  181. flexDirection: 'row',
  182. alignItems: 'space-between',
  183. paddingHorizontal: fonts.getSize(16),
  184. },
  185. container: {
  186. borderRadius: fonts.getSize(18),
  187. paddingVertical: fonts.getSize(8),
  188. paddingHorizontal: fonts.getSize(16),
  189. backgroundColor: colors.white,
  190. width: 'auto',
  191. },
  192. selectedContainer: {
  193. paddingVertical: fonts.getSize(8),
  194. paddingHorizontal: fonts.getSize(16),
  195. backgroundColor: colors.topVariantColor,
  196. borderRadius: fonts.getSize(18),
  197. width: 'auto',
  198. },
  199. pillContainer: {
  200. paddingVertical: 16,
  201. paddingLeft: 16,
  202. },
  203. faqContainer:{
  204. backgroundColor: colors.white
  205. }
  206. });