Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 40.85 KB | None | 0 0
  1. import React, { Component } from "react";
  2. import * as Progress from "react-native-progress";
  3. import {
  4. Text,
  5. TouchableOpacity,
  6. View,
  7. ScrollView,
  8. RefreshControl
  9. } from "react-native";
  10. import Dataset from "impagination";
  11. import { Container } from "native-base";
  12. import { Icon } from "react-native-elements";
  13. import Api from "../../../Services/Api";
  14. import firebase from 'react-native-firebase';
  15. import CommonHeader from "../../../Components/CommonHeader";
  16. import DashboardCardView from "../../../Components/DashboardCardView";
  17. import SampleDashBoardCard from "../../../Components/SampleDashBoardCard";
  18. import Modal from "react-native-modalbox";
  19. // Styles
  20. import DeviceInfo from 'react-native-device-info';
  21. import styles from "./DashboardScreenStyle";
  22.  
  23. export default class DashboardScreen extends Component {
  24. static navigationOptions = {
  25. title: "Dashboard",
  26. drawerIcon: ({ tintColor }) => (
  27. <Icon
  28. name="md-home"
  29. type="ionicon"
  30. style={[styles.icon, { color: tintColor }]}
  31. />
  32. )
  33. };
  34. constructor(props) {
  35. super(props);
  36.  
  37. this.state = {
  38. dataset: null,
  39. datasetState: null,
  40. refreshing: false,
  41. viewedmeFlag: false,
  42. FavouriteFlag: false,
  43. FavouriteMeFlag: false,
  44.  
  45. // Top bar loading state
  46. progressHide: false
  47. };
  48. }
  49.  
  50.  
  51.  
  52.  
  53. _onRefresh = () => {
  54. this.setState({ refreshing: true });
  55. this.componentDidMount(this);
  56. this.setState({ refreshing: false });
  57. };
  58. componentDidMount() {
  59. this.setupFMessaging()
  60. this.testingUserMessage()
  61. this.setupImpaginationOfRecentUsers();
  62. this.setupImpaginationOfInterestFavourite();
  63. this.setupImpaginationOfInterestViewedMe();
  64. this.setupImpaginationOfInterestFavouritedMe();
  65. }
  66.  
  67.  
  68. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  69. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  70. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  71. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  72. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  73. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  74. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  75. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  76. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  77. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  78. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  79. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  80. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  81. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  82. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  83. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  84. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  85. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  86. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  87. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  88. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  89. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  90. //
  91. //
  92. //
  93. // S E T U P ------> F C M T O K E N
  94. //
  95. //
  96. //
  97. //
  98. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  99. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  100. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  101. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  102. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  103. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  104. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  105. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  106. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  107. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  108. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  109. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  110. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  111. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  112. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  113. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  114. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  115. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  116. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  117. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  118. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  119. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  120.  
  121. // complete setup firebase
  122. setupFMessaging = async () => {
  123. await this.firebaseCheckPermission().then(IsUserPer => {
  124. if(IsUserPer == true){
  125. this.firebaseGetToken().then(deviceToken => {
  126. this.getDeviceId().then(deviceId => {
  127. console.log(deviceToken)
  128. console.log(deviceId)
  129. Api.registerDeviceToken(deviceId,deviceToken).then(res => {
  130. console.log('yahoo')
  131. console.log(res)
  132.  
  133. }).catch(err => console.log(err))
  134. })
  135. })
  136. }else{
  137. this.firebaseRequestPermission().then(() => {
  138. this.firebaseGetToken().then(token => {
  139. this.getDeviceId().then(deviceId => {
  140. console.log(token)
  141. console.log(deviceId)
  142. Api.registerDeviceToken(deviceId,deviceToken).then(res => {
  143. console.log('yahoo')
  144. console.log(res)
  145.  
  146. }).catch(err => console.log(err))
  147.  
  148. })
  149. })
  150. }).catch(() => { this.setState({ errMsg : 'Your device is not supported to notifications' })
  151. this.refs.errAlert.open() })
  152. }
  153. })
  154. }
  155.  
  156.  
  157. // Get device token
  158. firebaseGetToken = async () => {
  159. return new Promise(async (resolve, reject) => {
  160. await firebase.messaging().getToken().then(fcmToken => {
  161. if (fcmToken) {
  162. resolve(fcmToken)
  163. } else {
  164. reject('Your device is not supported to notifications')
  165. }
  166. });
  167. })
  168. }
  169. // Checking user permission
  170. firebaseCheckPermission = async () => {
  171. return new Promise(async (resolve,reject) => {
  172. await firebase.messaging().hasPermission()
  173. .then(enabled => {
  174. if (enabled) {
  175. resolve(true)
  176. } else {
  177. reslove(false)
  178. }
  179. });
  180. })
  181.  
  182. }
  183. // Request firebase permission
  184. firebaseRequestPermission = async () => {
  185. return new Promise(async (resolve,reject) => {
  186. try {await firebase.messaging().requestPermission().then( resolve(true))} catch (error) { reject('Your device is not supported to notifications') }
  187. })
  188. }
  189.  
  190.  
  191.  
  192.  
  193. // get specific device unique id
  194. getDeviceId = async () => {
  195. return new Promise(async (resolve,reject) => {
  196. let deviceId= DeviceInfo.getUniqueID()
  197. resolve(deviceId)
  198. })
  199. }
  200.  
  201.  
  202. testingUserMessage = async () => {
  203. this.messageListener = firebase.messaging().onMessage((msg) => {
  204. console.log(msg)
  205. })
  206. }
  207.  
  208. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  209. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  210. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  211. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  212. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  213. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  214. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  215. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  216. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  217. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  218. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  219. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  220. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  221. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  222. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  223. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  224. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  225. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  226. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  227. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  228. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  229. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  230. //
  231. //
  232. //
  233. // S E T U P ------> F C M T O K E N
  234. //
  235. //
  236. //
  237. //
  238. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  239. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  240. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  241. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  242. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  243. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  244. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  245. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  246. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  247. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  248. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  249. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  250. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  251. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  252. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  253. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  254. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  255. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  256. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  257. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  258. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  259. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274. gotoUserProfile = user => {
  275. this.props.navigation.navigate("UserProfile", { user_name: user });
  276. };
  277. // Setup Impagination of Recent Users
  278. setupImpaginationOfRecentUsers() {
  279. let _this = this;
  280.  
  281. let dataset = new Dataset({
  282. pageSize: 6,
  283. loadHorizon: 2,
  284.  
  285. observe(datasetState) {
  286. _this.setState({ datasetState });
  287. },
  288.  
  289. // Where to fetch the data from.
  290. fetch(pageOffset, pageSize, stats) {
  291. return Api.search("", pageOffset + 1, pageSize)
  292. .then(data => data.users)
  293. .catch(error => {
  294. _this.refs.errAlert.open();
  295. _this.setState({
  296. errMsg:
  297. "Looks like you are offline now. Please connect your connection and try again"
  298. });
  299. });
  300. }
  301. });
  302. dataset.setReadOffset(0);
  303. this.setState({ dataset });
  304. }
  305. // Setup Impagination of Interest favourite Users
  306. setupImpaginationOfInterestViewedMe() {
  307. let _this = this;
  308. let dataset = new Dataset({
  309. pageSize: 15,
  310. loadHorizon: 15,
  311.  
  312. observe(datasetStateOfInterestViewedMe) {
  313. _this.setState({ datasetStateOfInterestViewedMe });
  314. },
  315.  
  316. // Where to fetch the data from.
  317. fetch(pageOffset, pageSize, stats) {
  318. return Api.interests("viewedme", pageOffset + 1, pageSize)
  319. .then(data => {
  320. if (data.users.length != 0) return data.users;
  321. else {
  322. _this.setState({ viewedmeFlag: true });
  323. return;
  324. }
  325. })
  326. .catch(error => {
  327. _this.refs.errAlert.open();
  328. _this.setState({
  329. errMsg:
  330. "Looks like you are offline now. Please connect your connection and try again"
  331. });
  332. });
  333. }
  334. });
  335. dataset.setReadOffset(0);
  336. this.setState({ dataset });
  337. }
  338.  
  339. // Setup Impagination of Interest favourite Users
  340. setupImpaginationOfInterestFavourite() {
  341. console.log("favourited");
  342.  
  343. let _this = this;
  344. let dataset = new Dataset({
  345. pageSize: 15,
  346. loadHorizon: 15,
  347. observe(datasetStateOfInterestFavourite) {
  348. _this.setState({ datasetStateOfInterestFavourite });
  349. },
  350. // Where to fetch the data from.
  351. fetch(pageOffset, pageSize, stats) {
  352. return Api.interests("favourited", pageOffset + 1, pageSize)
  353. .then(data => {
  354. if (data.users.length != 0) return data.users;
  355. else {
  356. _this.setState({ FavouriteFlag: true });
  357. return;
  358. }
  359. })
  360. .catch(error => {
  361. _this.refs.errAlert.open();
  362. _this.setState({
  363. errMsg:
  364. "Looks like you are offline now. Please connect your connection and try again"
  365. });
  366. });
  367. }
  368. });
  369. dataset.setReadOffset(0);
  370. this.setState({ dataset });
  371. }
  372. // Setup Impagination of favourited Me Users
  373. setupImpaginationOfInterestFavouritedMe() {
  374. console.log("favouritedme");
  375. let _this = this;
  376. let dataset = new Dataset({
  377. pageSize: 15,
  378. loadHorizon: 15,
  379. observe(datasetStateOfInterestFavouritedMe) {
  380. _this.setState({ datasetStateOfInterestFavouritedMe });
  381. },
  382. // Where to fetch the data from.
  383. fetch(pageOffset, pageSize, stats) {
  384. return Api.interests("favouritedme", pageOffset + 1, pageSize)
  385. .then(data => {
  386. if (data.users.length != 0) return data.users;
  387. else {
  388. _this.setState({ FavouriteMeFlag: true });
  389. return;
  390. }
  391. })
  392. .catch(error => {
  393. _this.refs.errAlert.open();
  394. _this.setState({
  395. errMsg:
  396. "Looks like you are offline now. Please connect your connection and try again"
  397. });
  398. });
  399. }
  400. });
  401. dataset.setReadOffset(0);
  402. this.setState({ dataset });
  403. }
  404.  
  405. // =================================================================================================================================
  406. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  407. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  408. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  409. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  410. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  411. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  412. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  413. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  414. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  415. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  416. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  417. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  418. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  419. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  420. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  421. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  422. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  423. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  424. // =================================================================================================================================
  425.  
  426.  
  427.  
  428. renderRecentUsers() {
  429. if (!this.state.datasetState) return null;
  430.  
  431. const that = this;
  432. return this.state.datasetState.map(function(user, index) {
  433. if (
  434. !user ||
  435. !user.content ||
  436. !user.content.meta ||
  437. (user.isPending && !user.isSettled)
  438. ) {
  439. return <SampleDashBoardCard />;
  440. }
  441. return (
  442. <DashboardCardView user={user.content} onPress={that.gotoUserProfile} />
  443. );
  444. });
  445. }
  446.  
  447. // =================================================================================================================================
  448. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  449. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  450. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  451. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  452. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  453. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  454. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  455. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  456. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  457. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  458. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  459. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  460. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  461. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  462. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  463. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  464. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  465. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  466. // =================================================================================================================================
  467.  
  468. renderFavouritesUsers() {
  469. if (!this.state.datasetStateOfInterestFavourite) return null;
  470.  
  471. const that = this;
  472. return this.state.datasetStateOfInterestFavourite.map(function(
  473. user,
  474. index
  475. ) {
  476. if (
  477. !user ||
  478. !user.content ||
  479. !user.content.meta ||
  480. (user.isPending && !user.isSettled)
  481. ) {
  482. return <SampleDashBoardCard />;
  483. }
  484. return (
  485. <DashboardCardView user={user.content} onPress={that.gotoUserProfile} />
  486. );
  487. });
  488. }
  489.  
  490. // =================================================================================================================================
  491. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  492. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  493. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  494. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  495. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  496. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  497. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  498. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  499. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  500. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  501. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  502. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  503. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  504. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  505. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  506. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  507. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  508. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  509. // =================================================================================================================================
  510. renderViewedMeUsers() {
  511. if (!this.state.datasetStateOfInterestViewedMe) return null;
  512.  
  513. const that = this;
  514. return this.state.datasetStateOfInterestViewedMe.map(function(user, index) {
  515. if (
  516. !user ||
  517. !user.content ||
  518. !user.content.meta ||
  519. (user.isPending && !user.isSettled)
  520. ) {
  521. return <SampleDashBoardCard />;
  522. }
  523. return (
  524. <DashboardCardView user={user.content} onPress={that.gotoUserProfile} />
  525. );
  526. });
  527. }
  528. // =================================================================================================================================
  529. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  530. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  531. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  532. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  533. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  534. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  535. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  536. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  537. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  538. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  539. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  540. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  541. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  542. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  543. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  544. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  545. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  546. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  547. // =================================================================================================================================
  548. renderFavouritedMe() {
  549. if (!this.state.datasetStateOfInterestFavouritedMe) return null;
  550. const that = this;
  551. return this.state.datasetStateOfInterestFavouritedMe.map(function(
  552. user,
  553. index
  554. ) {
  555. if (
  556. !user ||
  557. !user.content ||
  558. !user.content.meta ||
  559. (user.isPending && !user.isSettled)
  560. ) {
  561. return <SampleDashBoardCard />;
  562. }
  563. return (
  564. <DashboardCardView user={user.content} onPress={that.gotoUserProfile} />
  565. );
  566. });
  567. }
  568. // =================================================================================================================================
  569. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  570. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  571. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  572. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  573. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  574. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  575. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  576. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  577. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  578. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  579. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  580. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  581. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  582. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  583. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  584. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  585. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  586. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  587. // =================================================================================================================================
  588.  
  589. render() {
  590. return (
  591. <Container>
  592. <CommonHeader title={"GoMarry"} />
  593. {this.state.progressHide == false && (
  594. <Progress.Bar
  595. width={450}
  596. color={"#FC3838"}
  597. height={1.5}
  598. borderWidth={0}
  599. />
  600. )}
  601. <ScrollView
  602. style={styles.mainContainerHome}
  603. showsVerticalScrollIndicator={false}
  604. refreshControl={
  605. <RefreshControl
  606. refreshing={this.state.refreshing}
  607. onRefresh={this._onRefresh}
  608. />
  609. }
  610. >
  611. <View style={styles.row}>
  612. <Text style={styles.maintitle}>Recently</Text>
  613. <TouchableOpacity
  614. onPress={() =>
  615. // this.props.navigation.navigate("AllRecentUsersScreen")
  616. this.props.navigation.navigate("ViewAll", {
  617. title: "All Recent Me Users",
  618. filter: "recent"
  619. })
  620. }
  621. >
  622. <Text style={styles.viewall}>View all</Text>
  623. </TouchableOpacity>
  624. </View>
  625. <ScrollView showsHorizontalScrollIndicator={false} horizontal={true}>
  626. {this.renderRecentUsers()}
  627. </ScrollView>
  628. {!this.state.FavouriteFlag && (
  629. <React.Fragment>
  630. <View style={styles.row}>
  631. <Text style={styles.maintitle}>Favourite Users</Text>
  632. <TouchableOpacity
  633. onPress={() =>
  634. this.props.navigation.navigate("ViewAll", {
  635. section: "favourited",
  636. title: "All Favourite Users"
  637. })
  638. }
  639. >
  640. <Text style={styles.viewall}>View all</Text>
  641. </TouchableOpacity>
  642. </View>
  643.  
  644. <ScrollView
  645. showsHorizontalScrollIndicator={false}
  646. horizontal={true}
  647. >
  648. {this.renderFavouritesUsers()}
  649. </ScrollView>
  650. </React.Fragment>
  651. )}
  652.  
  653. {!this.state.viewedmeFlag && (
  654. <React.Fragment>
  655. <View style={styles.row}>
  656. <Text style={styles.maintitle}>Viewed me</Text>
  657. <TouchableOpacity
  658. onPress={() =>
  659. this.props.navigation.navigate("ViewAll", {
  660. section: "viewedme",
  661. title: "All Viewed Me Users"
  662. })
  663. }
  664. >
  665. <Text style={styles.viewall}>View all</Text>
  666. </TouchableOpacity>
  667. </View>
  668. <ScrollView
  669. showsHorizontalScrollIndicator={false}
  670. horizontal={true}
  671. >
  672. {this.renderViewedMeUsers()}
  673. </ScrollView>
  674. </React.Fragment>
  675. )}
  676. {!this.state.FavouriteMeFlag && (
  677. <React.Fragment>
  678. <View style={styles.row}>
  679. <Text style={styles.maintitle}>Favourited me</Text>
  680. <TouchableOpacity
  681. onPress={() =>
  682. this.props.navigation.navigate("ViewAll", {
  683. section: "favouritedme",
  684. title: "All Favourited Me Users"
  685. })
  686. }
  687. >
  688. <Text style={styles.viewall}>View all</Text>
  689. </TouchableOpacity>
  690. </View>
  691.  
  692. <ScrollView
  693. showsHorizontalScrollIndicator={false}
  694. horizontal={true}
  695. >
  696. {this.renderFavouritedMe()}
  697. </ScrollView>
  698. </React.Fragment>
  699. )}
  700.  
  701. {/* ERROR POPUP */}
  702. <Modal
  703. style={[styles.errAlert, styles.errAlert3]}
  704. position={"center"}
  705. ref={"errAlert"}
  706. backdrop={true}
  707. coverScreen={true}
  708. backdropPressToClose={false}
  709. >
  710. <View>
  711. <View
  712. style={{
  713. justifyContent: "center",
  714. alignItems: "center"
  715. }}
  716. >
  717. <Icon
  718. type="antdesign"
  719. name="closecircle"
  720. size={50}
  721. color={"#FC3838"}
  722. />
  723. </View>
  724. <View
  725. style={{ paddingLeft: 20, paddingRight: 10, paddingTop: 15 }}
  726. >
  727. <Text style={{ textAlign: "center", fontSize: 14 }}>
  728. {this.state.errMsg}
  729. </Text>
  730. </View>
  731. <View style={{ marginTop: 10 }}>
  732. <Text
  733. onPress={() => this.refs.errAlert.close()}
  734. style={{
  735. color: "#FC3838",
  736. fontWeight: "bold",
  737. textAlign: "center"
  738. }}
  739. >
  740. Review Credientials !
  741. </Text>
  742. </View>
  743. </View>
  744. </Modal>
  745. </ScrollView>
  746. </Container>
  747. );
  748. }
  749. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement