UnsignedPage.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. import { StyleSheet, Text, View, ScrollView, FlatList, TouchableWithoutFeedback } from 'react-native'
  2. import { useContext, useState } from 'react'
  3. import colors from '../../constants/colors'
  4. import { Portal, Modal, PaperProvider, IconButton } from 'react-native-paper'
  5. import fonts from '../../constants/fonts'
  6. import ThemedTextButton from '../../components/molecules/Buttons/ThemeTextButton'
  7. import RecentPostsSection from '../../components/organisms/Sections/RecentPostsSection'
  8. import TrendingSection from '../../components/organisms/Sections/TrendingSection'
  9. import CategorySection from '../../components/organisms/Sections/CategorySection'
  10. import { horizontalScale, moderateScale, verticalScale } from '../../constants/metrics'
  11. import CloseButton from '../../components/atoms/Buttons/CloseButton'
  12. import NewscoutHomeHeader from '../../components/molecules/Header/NewscoutHomeHeader'
  13. import { ThemeContext } from '../../context/theme.context'
  14. const UnsignedPage = props => {
  15. const {
  16. navigation
  17. } = props
  18. const theme = useContext(ThemeContext)
  19. const currentTheme = theme.state.theme
  20. const [visible, setVisible] = useState(false);
  21. const showModal = () => setVisible(true);
  22. const hideModal = () => setVisible(false);
  23. // For Login prompt
  24. const [isDimissed, setDismissed] = useState(false);
  25. const styles = StyleSheet.create({
  26. container: {
  27. backgroundColor: colors().dominant,
  28. // paddingBottom: verticalScale(16)
  29. },
  30. loginContainer:{
  31. backgroundColor: colors().dominant
  32. },
  33. loginText: {
  34. fontFamily: fonts.type.regular,
  35. padding: 16,
  36. color: colors().recessive
  37. },
  38. underlinePillContainer: {
  39. paddingVertical: 8,
  40. flexDirection: 'row',
  41. alignItems: 'space-between',
  42. },
  43. selectedPillText: {
  44. fontFamily: fonts.type.semibold,
  45. fontSize: moderateScale(12),
  46. color: colors().recessive,
  47. borderBottomWidth: verticalScale(4),
  48. borderBottomColor: colors().secondaryColor,
  49. borderRadius: 0
  50. },
  51. pillText: {
  52. fontFamily: fonts.type.semibold,
  53. fontSize: moderateScale(12),
  54. color: colors().gray
  55. },
  56. underlinePill: {
  57. width: 'auto',
  58. },
  59. cardContainer: {
  60. gap: moderateScale(4),
  61. paddingVertical: verticalScale(4)
  62. },
  63. modalContainerStyle: {
  64. padding: moderateScale(16),
  65. width: 'auto',
  66. marginHorizontal: horizontalScale(32),
  67. backgroundColor: colors().dominant,
  68. borderRadius: moderateScale(4)
  69. }
  70. })
  71. return (
  72. <PaperProvider>
  73. <View style={styles.container}>
  74. <Portal>
  75. <Modal visible={visible} onDismiss={hideModal} contentContainerStyle={styles.modalContainerStyle}>
  76. <IconButton
  77. icon="close"
  78. iconColor={colors().recessive}
  79. size={16}
  80. onPress={hideModal}
  81. style={{ alignSelf: 'flex-end' }}
  82. />
  83. <Text
  84. style={{
  85. fontFamily: fonts.type.regular,
  86. color: colors().recessive,
  87. fontSize: moderateScale(14),
  88. paddingTop: moderateScale(8),
  89. paddingBottom: moderateScale(16)
  90. }}
  91. >
  92. You are not logged in. Log in to bookmark news, leave comment and to explore more!
  93. </Text>
  94. <ThemedTextButton title="Login" onPress={() => navigation.navigate("SignIn")} theme={"secondary-contained"} />
  95. <View style={{ flexDirection: 'row', justifyContent: 'center', alignItems: 'center', paddingVertical: moderateScale(16) }}>
  96. <Text
  97. style={{
  98. color: colors().recessive,
  99. fontFamily: fonts.type.regular
  100. }}
  101. >Don’t have account? </Text>
  102. <TouchableWithoutFeedback onPress={() => navigation.navigate("SignUp")}>
  103. <Text
  104. style={{
  105. color: colors().secondaryColor,
  106. fontFamily: fonts.type.regular
  107. }}
  108. >
  109. Create one
  110. </Text>
  111. </TouchableWithoutFeedback>
  112. </View>
  113. </Modal>
  114. </Portal>
  115. <ScrollView showsVerticalScrollIndicator={false}>
  116. {
  117. isDimissed === false ? <View style={styles.loginContainer}>
  118. <NewscoutHomeHeader >
  119. <CloseButton onPress={() => setDismissed(!isDimissed)} />
  120. </NewscoutHomeHeader>
  121. <Text style={styles.loginText}>You are not logged in. Sign in or log in to bookmark news leave comment and a lot more!</Text>
  122. <View style={{ paddingHorizontal: 16 }}>
  123. <ThemedTextButton theme={'secondary'} title={"Login"} onPress={showModal} />
  124. </View>
  125. </View> : <NewscoutHomeHeader />
  126. }
  127. <TrendingSection navigation={navigation}/>
  128. <CategorySection navigation={navigation}/>
  129. <RecentPostsSection navigation={navigation}/>
  130. {/* <View style={styles.underlinePillContainer}>
  131. <ScrollView horizontal showsHorizontalScrollIndicator={false}>
  132. <ToggleButton.Group onValueChange={value => setCategoryValue(value)}>
  133. {
  134. categories.map((category) => {
  135. let valueId = category.toLowerCase()
  136. return <ToggleButton
  137. icon={() =>
  138. <Text style={
  139. [
  140. valueId === categoryValue ?
  141. styles.selectedPillText :
  142. styles.pillText,
  143. {
  144. paddingHorizontal: fonts.getSize(11),
  145. fontSize: fonts.getSize(16)
  146. }
  147. ]
  148. }>
  149. {category}
  150. </Text>}
  151. style={[styles.underlinePill]}
  152. value={valueId}
  153. />
  154. })
  155. }
  156. </ToggleButton.Group>
  157. </ScrollView>
  158. </View>
  159. <FlatList
  160. showsVerticalScrollIndicator={false}
  161. ItemSeparatorComponent={() => <View style={{ height: fonts.getSize(8) }}></View>}
  162. // ListFooterComponent={() => <View style={{height: fonts.getSize(16)}}></View>}
  163. ListHeaderComponent={() => <View style={{ height: fonts.getSize(16) }}></View>}
  164. data={news}
  165. renderItem={(item) => <HorizontalNewsCardVariant onPress={true} />}
  166. keyExtractor={item => news.indexOf(item)}
  167. /> */}
  168. </ScrollView>
  169. </View>
  170. </PaperProvider>
  171. )
  172. }
  173. export default UnsignedPage