/** * Copyright (c) 2015-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @flow * @providesModule ToolbarAndroidExample */ 'use strict'; var React = require('react'); var ReactNative = require('react-native'); var nativeImageSource = require('nativeImageSource'); var { StyleSheet, Text, View, } = ReactNative; var RNTesterBlock = require('./RNTesterBlock'); var RNTesterPage = require('./RNTesterPage'); var Switch = require('Switch'); var ToolbarAndroid = require('ToolbarAndroid'); class ToolbarAndroidExample extends React.Component<{}, $FlowFixMeState> { static title = ''; static description = 'Examples of using the Android toolbar.'; state = { actionText: 'Example app with toolbar component', toolbarSwitch: false, colorProps: { titleColor: '#3b5998', subtitleColor: '#6a7180', }, }; render() { return ( this.setState({actionText: 'Icon clicked'})} style={styles.toolbar} subtitle={this.state.actionText} title="Toolbar" /> {this.state.actionText} this.setState({'toolbarSwitch': value})} /> {'\'Tis but a switch'} this.setState({colorProps: {}})} title="Wow, such toolbar" style={styles.toolbar} subtitle="Much native" {...this.state.colorProps} /> Touch the icon to reset the custom colors to the default (theme-provided) ones. ); } _onActionSelected = (position) => { this.setState({ actionText: 'Selected ' + toolbarActions[position].title, }); }; } var toolbarActions = [ {title: 'Create', icon: nativeImageSource({ android: 'ic_create_black_48dp', width: 96, height: 96 }), show: 'always'}, {title: 'Filter'}, {title: 'Settings', icon: nativeImageSource({ android: 'ic_settings_black_48dp', width: 96, height: 96 }), show: 'always'}, ]; var styles = StyleSheet.create({ toolbar: { backgroundColor: '#e9eaed', height: 56, }, }); module.exports = ToolbarAndroidExample;