Advertisement
vandasche

Untitled

Dec 10th, 2020
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1. import React, { useEffect, useState } from "react";
  2. import {
  3. StyleSheet,
  4. StatusBar,
  5. SafeAreaView,
  6. ScrollView,
  7. View,
  8. Platform,
  9. Dimensions,
  10. } from "react-native";
  11. import { connect, useSelector, useDispatch } from "react-redux";
  12. import { Actions } from "react-native-router-flux";
  13. import { ModalBox, Button } from "../common";
  14. import { TeaserCard } from "../cards";
  15. import { getTalent, getNewestTalent, resetGetTalentByTag } from "../Actions";
  16. import { LinearGradient } from "expo-linear-gradient";
  17. import * as actUser from "../Actions";
  18.  
  19. console.disableYellowBox = true;
  20.  
  21. const { height } = Dimensions.get("window");
  22. const styles = StyleSheet.create({
  23. containerStyle: { flex: 1, backgroundColor: "#000", position: "relative" },
  24. wrapperStyle: {
  25. position: "absolute",
  26. top: 0,
  27. left: 0,
  28. width: "100%",
  29. ...Platform.select({
  30. ios: { height: height, paddingTop: 140 },
  31. android: { height: "100%", paddingTop: 120 },
  32. }),
  33. },
  34. scrollerWrapper: {
  35. flexDirection: "row",
  36. justifyContent: "space-around",
  37. flexWrap: "wrap",
  38. padding: 10,
  39. },
  40. btnContainer: { width: "100%", padding: 10, alignSelf: "flex-end" },
  41. btnStyle: {
  42. justifyContent: "center",
  43. alignSelf: "center",
  44. borderRadius: 30,
  45. height: 40,
  46. marginHorizontal: 10,
  47. backgroundColor: "#00D3FD",
  48. width: "100%",
  49. ...Platform.select({
  50. android: { paddingBottom: 2 },
  51. }),
  52. },
  53. btnTextStyle: {
  54. fontFamily: "Montserrat-Bold",
  55. fontSize: 15,
  56. textAlign: "center",
  57. color: "#FFF",
  58. },
  59. });
  60.  
  61. const Home = (props) => {
  62. const fetchPage = 1;
  63. const fetchTotal = 8;
  64. const fetchTotalNewest = 4;
  65.  
  66. const [profile, setProfile] = useState(false);
  67. const [newestTalent, setNewestTalent] = useState("");
  68. const [modalMessage, setModalMessage] = useState("");
  69. const [showModal, setShowModal] = useState(false);
  70.  
  71. //redux state
  72. // const listTalent = useSelector((state) => state.talent_list);
  73. console.log(props, "props");
  74. //redux action
  75.  
  76. useEffect(() => {
  77. if (!props.talent_list) {
  78. props.dispatch(actUser.getTalent({ page: fetchPage, total: fetchTotal }));
  79. }
  80. }, []);
  81.  
  82. // const fetchData = async () => {
  83. // const payload = {
  84. // page: fetchPage,
  85. // total: fetchTotal,
  86. // };
  87. // getTalent(payload);
  88. // };
  89.  
  90. const toggleModal = () => {
  91. setShowModal(!showModal);
  92. };
  93.  
  94. // const featured =
  95. // listTalent && listTalent.length > 2 ? listTalent.slice(0, 2) : listTalent;
  96. // console.log(listTalent, "listTalent");
  97. return (
  98. <SafeAreaView style={styles.containerStyle}>
  99. <StatusBar
  100. backgroundColor="#000"
  101. barStyle="light-content"
  102. translucent={false}
  103. hidden={false}
  104. />
  105. <View style={[styles.wrapperStyle, { paddingBottom: profile ? 55 : 0 }]}>
  106. <ScrollView contentContainerStyle={styles.scrollerWrapper}>
  107. <TeaserCard
  108. title="Featured"
  109. onPress={() => Actions.Featured()}
  110. user={profile}
  111. // listData={talent_list}
  112. />
  113.  
  114. {!profile ? (
  115. <View style={styles.btnContainer}>
  116. <LinearGradient
  117. colors={["#1B99B3", "#622dff"]}
  118. style={styles.btnStyle}
  119. >
  120. <Button
  121. // containerStyle={styles.btnStyle}
  122. textStyle={styles.btnTextStyle}
  123. onPress={() => Actions.Login()}
  124. title={`SIGN IN`}
  125. />
  126. </LinearGradient>
  127. </View>
  128. ) : null}
  129.  
  130. <TeaserCard title="Newest" user={profile} listData={newestTalent} />
  131. </ScrollView>
  132. </View>
  133. <ModalBox
  134. infoText={modalMessage}
  135. closeModal={toggleModal}
  136. show={showModal}
  137. />
  138. </SafeAreaView>
  139. );
  140. };
  141. const mapDispatchToProps = (dispatch) => ({});
  142. const mapStateToProps = (state) => {
  143. return {
  144. talent_list: state.talent_list,
  145. };
  146. };
  147.  
  148. export default connect(mapStateToProps, mapDispatchToProps)(Home);
  149.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement