How to make Detail Screen from flat list React Native Expo

Viewed 71

I am trying to open new screen with flat list from Notification. Output like this from Pages Notification (when click the blue, move to another pages). Here is my notification screen enter image description here

and this is my detail screen enter image description here

and this is my Notification View

 _renderItem = ({item}) => (
    <TouchableOpacity onPress={() => this.props.navigation.navigate('LogHistoryDetail', {UserEmail: this.props.navigation.state.params.UserEmail})}>
    <Text style = {styles.item}> {item.history_content}</Text>
        </TouchableOpacity>
  );

  render() {
      
    return (
      <View style={styles.container}>
      <TouchableOpacity style={styles.btn} onPress={() => this.props.navigation.navigate('HomeScreen')}>
      <Ionicons name="arrow-back-circle" size={30} color="black" />
      </TouchableOpacity>
    <Text style = {{fontSize:30, alignContent:"flex-start", color:'black'}}>Notification</Text>
  <FlatList
   data={this.state.data}
   renderItem = {this._renderItem}
   keyExtractor = { (item, index) => index.toString() }
   />
    
        </View>  
     
    );
  }
}

and this is my Detail Screen View

_renderItem = ({item}) => (
    <View style = {{backgroundColor:'#1E90FF',margin:15, justifyContent: 'center', borderTopRightRadius: 15,
        borderTopLeftRadius: 15, borderBottomEndRadius: 15, borderBottomLeftRadius: 15 }}>
    <Text style = {{fontSize:15,margin:15, justifyContent: 'center' ,color:'white'}}> ID Log:  {item.id_log}</Text>
    <Text style = {{fontSize:15,margin:15, justifyContent: 'center' ,color:'white'}}> Email:  {this.props.navigation.state.params.UserEmail}</Text>
     <Text style = {{fontSize:15,margin:15, justifyContent: 'center' ,color:'white'}}> History Title:  {item.history_title}</Text>
    </View>
  );

  render() {
      
    return (
      <View style={styles.container}>
           <TouchableOpacity style={styles.btn2} onPress={() => this.props.navigation.navigate('LogNotification')}>
      <Ionicons name="arrow-back-circle" size={30} color="black" />
      </TouchableOpacity>
        <Text style={styles.headerTxt}>History Detail</Text>
        <View style={styles.subView}>

  <FlatList
   data={this.state.data}
   renderItem = {this._renderItem}
   keyExtractor = { (item, index) => index.toString() }
   />
   
        </View>  
      </View>
    );
  }
}

It seems like i got the wrong output on Detail Screen. I want to get output like this without picture. enter image description here

Is it possible to make Detail Screen like that? Any suggestion that i need to change my View code or wrong render? Thank you

0 Answers
Related