/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
*/
'use strict';
const React = require('react');
const ReactNative = require('react-native');
const nativeImageSource = require('nativeImageSource');
const {StyleSheet, Text, View} = ReactNative;
const RNTesterBlock = require('./RNTesterBlock');
const RNTesterPage = require('./RNTesterPage');
const Switch = require('Switch');
const ToolbarAndroid = require('ToolbarAndroid');
class ToolbarAndroidExample extends React.Component<{}, $FlowFixMeState> {
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,
});
};
}
const 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',
},
];
const styles = StyleSheet.create({
toolbar: {
backgroundColor: '#e9eaed',
height: 56,
},
switchWrapper: {
height: 56,
flexDirection: 'row',
alignItems: 'center',
},
});
exports.title = '';
exports.description = 'Examples of using the Android toolbar.';
exports.examples = [
{
title: 'Basic toolbar',
render: function(): React.Element {
return ;
},
},
];