0

I am using react native elements Header to show my drawer, I am facing two problems: 1) My drawer does not cover entire top(header area). (As can be viewed in Picture the blue color not covering whole header) 2) How to add Image instead of Icon as I dont want to use react-native-vector-icons and how to add onPress() method on that Image, basically I want to add custom drawer image which onPress openDrawer. Header color not covering whole of the header

This is my code:

import React, { Component } from 'react';
import { StyleSheet, Text, View,Image,TouchableOpacity, Alert } from 'react-native';
import Timeline from 'react-native-timeline-flatlist';
import {Header} from 'react-native-elements';
export default class HomeTimeTable extends Component {
  render() {
    //'rgb(45,156,219)'
    return (
      <View style={styles.container}>
      <Header
  placement="left"
  leftComponent={{ icon: 'menu', color: '#fff' }}
  centerComponent={{ text: 'MY TITLE', style: { color: '#fff' } }}
  rightComponent={{ icon: 'home', color: '#fff' }}
/>
        <Timeline
          ...
        />
      </View>
    );
  }
}

This is my stylesheet:

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
    backgroundColor: 'white',
  },
  list: {
    flex: 1,
    marginTop: 20,
  },
  drawer:{
      width:20,
      height:20,
      justifyContent:"flex-start",
  }
});
Talha Nadeem
  • 99
  • 1
  • 4
  • 22

1 Answers1

4

Below code should works.

import React, { Component } from 'react';
import { StyleSheet, Text, View,Image,TouchableOpacity, Alert, Image } from 'react-native';
import Timeline from 'react-native-timeline-flatlist';
import {Header} from 'react-native-elements';
export default class HomeTimeTable extends Component {

  const renderCustomIconA = () => {
    return(
      <TouchableOpacity onPress={() => {console.log('A Pressed!')}}>
        <Image
          style={{width: 50, height: 50}}
          source={{uri: 'https://reactnative.dev/img/tiny_logo.png'}}
         />
       </TouchableOpacity>
    );
  };

  const renderCustomIconB = () => {
    return(
      <TouchableOpacity onPress={() => {console.log('B Pressed!')}}>
        <Image
          style={{width: 50, height: 50}}
          source={{uri: 'https://reactnative.dev/img/tiny_logo.png'}}
         />
       </TouchableOpacity>
    );
  };

  render() {
    //'rgb(45,156,219)'
    return (
      <>
        <Header
          placement="left"
          leftComponent={() => renderCustomIconA()}
          centerComponent={{ text: 'MY TITLE', style: { color: '#fff' } }}
          rightComponent={() => renderCustomIconB()}
        />
        <View style={styles.container}>
          <Timeline
          ...
          />
        </View>
      </>

    );
  }
}
ridvanaltun
  • 2,595
  • 2
  • 15
  • 28