react-native : header bar(title + option button) example

Render

  render() {
      return (
        <View style={styles.container}>
          <View style={styles.header}>
            <Text style={styles.title}>
              {I18n.t('wcsqa')} // your title
            </Text>
            <TouchableOpacity onPress={() => {}}>
              <Image
                style={styles.option}
                source={require('./res/img/nav_icon.png')}
              />
            </TouchableOpacity>
          </View>
          <View style={styles.content}>
            <Text>
              {this.wcs[0].Q} // your content
            </Text>
          </View>
        </View>
      )
  }

Style

const styles = StyleSheet.create({
  container: {
    flex: 2,
  },
  header: {
    backgroundColor: '#00FF7F',
    flex: 1,
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'space-around',
  },
  title: {
    fontSize: 20,
    fontWeight: 'bold'
  },
  option: {
    width:32,
    height:32
  },
  content: {
    backgroundColor: '#F5DEB3',
    flex: 12
  }
});

No Image, No Truth

header-bar

Subscribe to Post, Code and Quiet Time.

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe