NewsDetailPage.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. import { StyleSheet, Text, View, TouchableWithoutFeedback, ScrollView, Image } from 'react-native'
  2. import React, { useRef, useCallback, useMemo } from 'react'
  3. import Header from '../components/atoms/Header'
  4. import FeatherIcon from 'react-native-vector-icons/Feather'
  5. import MaterialIcon from 'react-native-vector-icons/MaterialIcons'
  6. import colors from '../theme/colors'
  7. import fonts from '../theme/fonts'
  8. import images from '../assets/images/images'
  9. import IonIcon from 'react-native-vector-icons/Ionicons'
  10. import BookmarkButton from '../components/organisms/Buttons/BookmarkButton'
  11. import ShareButton from '../components/organisms/Buttons/ShareButton'
  12. import {
  13. BottomSheetModal,
  14. BottomSheetModalProvider,
  15. BottomSheetView,
  16. BottomSheetScrollView
  17. } from '@gorhom/bottom-sheet';
  18. import ButtonWrapper from '../components/atoms/ButtonWrapper'
  19. import CommentCard from '../components/organisms/Cards/CommentCard'
  20. const NewsDetailPage = ({ navigation, headline, tagline, timestamp, author, newsText, image, comments }) => {
  21. const commentsData = [{},{},{},{},{}]
  22. const bottomSheetModalRef = useRef('');
  23. // Variables
  24. const snapPoints = useMemo(() => ['70%', '100%'], []);
  25. // Callbacks
  26. const handlePresentModalPress = useCallback(() => {
  27. bottomSheetModalRef.current?.present();
  28. }, []);
  29. const handleCloseModalPress = () => bottomSheetModalRef.current.close();
  30. const handleSheetChanges = useCallback((index) => {
  31. console.log('handleSheetChanges', index);
  32. }, []);
  33. return (
  34. <BottomSheetModalProvider>
  35. <ScrollView>
  36. <View style={styles.container}>
  37. <Header>
  38. <TouchableWithoutFeedback onPress={() => { navigation.goBack() }}>
  39. <FeatherIcon name={'chevron-left'} size={24} color={colors.black} />
  40. </TouchableWithoutFeedback>
  41. <TouchableWithoutFeedback onPress={() => navigation.toggleDrawer()}>
  42. <MaterialIcon name='list' color={colors.topColor} size={30} />
  43. </TouchableWithoutFeedback>
  44. </Header>
  45. <View style={styles.newsContainer}>
  46. <Text style={styles.headline}>
  47. {headline ?? "ICICI Securities sees over 49% upside potential on this chemical stock"}
  48. </Text>
  49. <Text style={styles.tagline}>
  50. {tagline ?? "The reason behind theirent is that iPhone users have been The reason behind theirent is that iPhone.."}
  51. </Text>
  52. <View style={styles.descriptors}>
  53. <Text style={styles.descriptorText}>{timestamp ?? "15 min ago"}</Text>
  54. <Text style={styles.descriptorText}>{author ?? "By Lucy Hiddleston"}</Text>
  55. </View>
  56. {/* Test Card */}
  57. <View style={styles.imagesContainer}>
  58. <Image source={image ?? images.verticalCard} style={styles.image} />
  59. </View>
  60. <View style={styles.utilButtons}>
  61. <TouchableWithoutFeedback onPress={handlePresentModalPress}>
  62. <View style={styles.commentSection}>
  63. <IonIcon name="chatbubble-outline" size={fonts.getSize(20)} color={colors.topColor} />
  64. <Text style={styles.commentText}>{comments ?? 123} COMMENTS</Text>
  65. </View>
  66. </TouchableWithoutFeedback>
  67. <View style={{ flexDirection: 'row' }}>
  68. <BookmarkButton
  69. buttonStyle={styles.buttonStyle}
  70. iconSize={20}
  71. onPress={true}
  72. />
  73. <ShareButton
  74. buttonStyle={styles.buttonStyle}
  75. iconSize={20}
  76. onPress={true}
  77. />
  78. </View>
  79. </View>
  80. <Text style={styles.newsText}>
  81. {newsText ?? "Samsung had a pretty quiet Mobile World Congress event, but it did tell us we’d learn more about its upcoming Google-approved smartwatch at its next Unpacked event. Unfortunately, the company didn’t tell us when exactly that would be, but a new report from Korean publication DigitalDaily News (via 9to5Google) claims the next Unpacked will take place on August 11, at 10 AM ET."}
  82. </Text>
  83. <TouchableWithoutFeedback onPress={true}>
  84. <Text style={styles.backToTopText}>Back to Top</Text>
  85. </TouchableWithoutFeedback>
  86. </View>
  87. <>
  88. <BottomSheetModal
  89. ref={bottomSheetModalRef}
  90. index={1}
  91. snapPoints={snapPoints}
  92. onChange={handleSheetChanges}
  93. >
  94. <BottomSheetScrollView>
  95. <BottomSheetView style={{ paddingHorizontal: fonts.getSize(24) }}>
  96. <BottomSheetView style={styles.commentInputContainer}>
  97. <Text style={{ fontFamily: fonts.type.semibold, color: colors.black, fontSize: fonts.getSize(16) }}>
  98. Comments
  99. </Text>
  100. <ButtonWrapper onPress={handleCloseModalPress}>
  101. <IonIcon name='close-sharp' size={fonts.getSize(20)} color={colors.black} />
  102. </ButtonWrapper>
  103. </BottomSheetView>
  104. <View style={styles.commentInput}>
  105. <Image source={images.imageCard} style={[styles.profileImage]} />
  106. <Text >Comment Text Input</Text>
  107. </View>
  108. <>
  109. <Text style={{fontFamily:fonts.type.medium, color: colors.black,paddingBottom: fonts.getSize(8)}}>View all Comments(04)</Text>
  110. </>
  111. <BottomSheetView style={{gap:fonts.getSize(16)}}>
  112. {commentsData.map(() => <CommentCard />)}
  113. </BottomSheetView>
  114. </BottomSheetView>
  115. </BottomSheetScrollView>
  116. </BottomSheetModal>
  117. </>
  118. </View>
  119. </ScrollView>
  120. </BottomSheetModalProvider>
  121. )
  122. }
  123. export default NewsDetailPage
  124. const styles = StyleSheet.create({
  125. newsContainer: {
  126. paddingHorizontal: fonts.getSize(24)
  127. },
  128. headline: {
  129. fontFamily: fonts.type.semibold,
  130. fontSize: fonts.getSize(18),
  131. paddingVertical: fonts.getSize(8),
  132. color: colors.black,
  133. },
  134. tagline: {
  135. fontFamily: fonts.type.regular,
  136. color: colors.gray
  137. },
  138. descriptors: {
  139. flexDirection: 'row',
  140. gap: fonts.getSize(16),
  141. },
  142. descriptorText: {
  143. fontFamily: fonts.type.semibold,
  144. fontSize: fonts.getSize(10),
  145. color: colors.black,
  146. paddingTop: fonts.getSize(8),
  147. paddingBottom: fonts.getSize(16)
  148. },
  149. newsText: {
  150. color: colors.gray,
  151. fontFamily: fonts.type.regular,
  152. lineHeight: fonts.getSize(24),
  153. paddingVertical: fonts.getSize(4)
  154. },
  155. backToTopText: {
  156. color: colors.topColor,
  157. alignSelf: 'center',
  158. justifyContent: 'center',
  159. paddingVertical: fonts.getSize(16),
  160. fontSize: fonts.getSize(16),
  161. fontFamily: fonts.type.regular,
  162. textDecorationStyle: 'solid',
  163. textDecorationLine: 'underline'
  164. },
  165. imagesContainer: {
  166. width: "auto",
  167. height: fonts.getSize(196),
  168. paddingHorizontal: 0
  169. },
  170. image: {
  171. borderRadius: fonts.getSize(4),
  172. width: '100%',
  173. height: '100%'
  174. },
  175. utilButtons: {
  176. flexDirection: 'row',
  177. justifyContent: 'space-between',
  178. paddingVertical: fonts.getSize(4)
  179. },
  180. buttonStyle: {
  181. padding: fonts.getSize(8)
  182. },
  183. commentSection: {
  184. alignItems: 'center',
  185. justifyContent: 'center',
  186. flexDirection: 'row',
  187. gap: fonts.getSize(8),
  188. paddingLeft: fonts.getSize(4)
  189. },
  190. commentText: {
  191. fontFamily: fonts.type.regular,
  192. color: colors.gray
  193. },
  194. commentInputContainer: {
  195. flexDirection: 'row',
  196. justifyContent: 'space-between',
  197. alignItems: 'center',
  198. paddingVertical: fonts.getSize(4)
  199. },
  200. profileImage: {
  201. height: 42,
  202. width: 42,
  203. borderRadius: 32,
  204. marginRight: fonts.getSize(16)
  205. },
  206. commentInput: {
  207. paddingVertical: fonts.getSize(16),
  208. alignItems: 'center',
  209. justifyContent: 'flex-start',
  210. flexDirection: 'row'
  211. },
  212. })