From fe9089881aaa5312a33d01d34478405353d075eb Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Fri, 26 Jun 2020 12:11:19 +0200 Subject: [PATCH] Show amicale services even when not logged in --- src/screens/Services/ServicesScreen.js | 77 +++----------------------- 1 file changed, 8 insertions(+), 69 deletions(-) diff --git a/src/screens/Services/ServicesScreen.js b/src/screens/Services/ServicesScreen.js index edd5f37..cc53dbc 100644 --- a/src/screens/Services/ServicesScreen.js +++ b/src/screens/Services/ServicesScreen.js @@ -6,11 +6,9 @@ import CardList from "../../components/Lists/CardList/CardList"; import CustomTabBar from "../../components/Tabbar/CustomTabBar"; import {withCollapsible} from "../../utils/withCollapsible"; import {Collapsible} from "react-navigation-collapsible"; -import {CommonActions} from "@react-navigation/native"; import {Animated, View} from "react-native"; -import {Avatar, Button, Card, Divider, List, Title, TouchableRipple, withTheme} from "react-native-paper"; +import {Avatar, Card, Divider, List, TouchableRipple, withTheme} from "react-native-paper"; import type {CustomTheme} from "../../managers/ThemeManager"; -import ConnectionManager from "../../managers/ConnectionManager"; import i18n from 'i18n-js'; import MaterialHeaderButtons, {Item} from "../../components/Overrides/CustomHeaderButton"; @@ -45,9 +43,7 @@ export type listItem = { content: cardList, } -type State = { - isLoggedIn: boolean, -} +type State = {} class ServicesScreen extends React.Component { @@ -111,12 +107,6 @@ class ServicesScreen extends React.Component { image: TUTORINSA_IMAGE, onPress: () => nav.navigate("tutorinsa"), }, - { - title: i18n.t('screens.amicaleWebsite'), - subtitle: i18n.t('servicesScreen.descriptions.amicaleWebsite'), - image: AMICALE_IMAGE, - onPress: () => nav.navigate("amicale-website"), - }, ]; this.insaDataset = [ { @@ -173,13 +163,9 @@ class ServicesScreen extends React.Component { content: this.insaDataset }, ]; - this.state = { - isLoggedIn: ConnectionManager.getInstance().isLoggedIn() - } } componentDidMount() { - this.props.navigation.addListener('focus', this.onFocus); this.props.navigation.setOptions({ headerRight: this.getAboutButton, }); @@ -192,21 +178,6 @@ class ServicesScreen extends React.Component { onAboutPress = () => this.props.navigation.navigate('amicale-contact'); - onFocus = () => { - this.handleNavigationParams(); - this.setState({isLoggedIn: ConnectionManager.getInstance().isLoggedIn()}) - } - - handleNavigationParams() { - if (this.props.route.params != null) { - if (this.props.route.params.nextScreen != null) { - this.props.navigation.navigate(this.props.route.params.nextScreen); - // reset params to prevent infinite loop - this.props.navigation.dispatch(CommonActions.setParams({nextScreen: null})); - } - } - }; - getAvatar(props, source: string | number) { if (typeof source === "number") return { /> } - getLoginMessage() { - return ( - - - {i18n.t("servicesScreen.notLoggedIn")} - - - - ) - } - renderItem = ({item}: { item: listItem }) => { - const shouldShowLogin = !this.state.isLoggedIn && item.shouldLogin; return ( this.props.navigation.navigate("services-section", {data: item})} + onPress={() => this.props.navigation.navigate("services-section", {data: item})} > this.getAvatar(props, item.image)} - right={shouldShowLogin - ? undefined - : (props) => } + right={(props) => } + /> + - { - shouldShowLogin - ? this.getLoginMessage() - : - }