Где здесь проблема? - PullRequest
       1

Где здесь проблема?

0 голосов
/ 19 сентября 2019

У меня проблема с основным экраном моего мобильного приложения.Я строю это с реагировать на родной и Firebase.На главном экране у меня есть условное отображение: если пользователь вошел в систему, я хочу показать простой текст (пока), но если нет, я хочу показать ссылку на экране входа в систему.

Вот код:

import React from'react'
import { View, Text, TouchableOpacity, StyleSheet, Image, ImageBackground } from 'react-native'
import Firebase from '../Components/Firebase'

class Home extends React.Component {

  renderButton(){
    Firebase.auth().onAuthStateChanged( (user) => {
      if (user) {
        return (
            <TouchableOpacity>
              <Text style={{ color: '#FFF', fontSize: 20 }}>Taratata</Text>
            </TouchableOpacity>
          )
      } else {
        return (
          <TouchableOpacity onPress={ () => this.props.navigation.navigate('Login') }>
            <Text style={{ color: '#FFF', fontSize: 20 }}>Se connecter</Text>
          </TouchableOpacity>
        )
      }
    })
  }



render(){
    return(
      <View style={ styles.main_container }>
        <ImageBackground source={ require('../assets/bg.jpeg')} style={{ width: '100%', height: '100%' }}>
          <View style={ styles.header }>
            <View style={ styles.title }>
              <Text style={ styles.title_text_regular }>Au-delà, ensemble</Text>
            </View>
          </View>
          <View style={ styles.body }>
            <TouchableOpacity style={ styles.find_button_container }>
              <Text style={ styles.find_button_text }>Trouver un trajet </Text>
              <Image source={ require('../assets/passenger-icon.png') }/>
            </TouchableOpacity>
            <TouchableOpacity style={ styles.propose_button_container }>
              <Image source={ require('../assets/driver-icon.png') }/>
              <Text style={ styles.propose_button_text }>Proposer un trajet</Text>
            </TouchableOpacity>
          </View>
          <View style={ styles.footer }>
          {
            this.renderButton()
          }
          </View>
        </ImageBackground>
      </View>
    )
  }
}

Это работает, когда я не вошел в систему и появляется ссылка на страницу входа в систему.Но это ничего не показывает, когда я на связи.У вас есть идея?

Вот экран, когда я вошел в систему. Текст должен появиться в нижней части экрана: enter image description here

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...