const React = require('react');
const { Component } = require('react');
const { View, Text, Button } = require('react-native');
const { Navigation } = require('react-native-navigation');
const testIDs = require('../testIDs');
let globalFirstComponentID;
class TextScreen extends Component {
static get options() {
return {
bottomTabs: {
testID: testIDs.BOTTOM_TABS_ELEMENT
},
topBar: {
testID: testIDs.TOP_BAR_ELEMENT
}
};
}
constructor(props) {
super(props);
globalFirstComponentID = (props.text === 'This is tab 1') ? props.componentId : globalFirstComponentID;
this.onClickPop = this.onClickPop.bind(this);
}
render() {
return (
{this.props.text || 'Text Screen'}
{this.renderTextFromFunctionInProps()}
{`this.props.componentId = ${this.props.componentId}`}
);
}
async onClickPop() {
await Navigation.pop(this.props.componentId);
}
renderTextFromFunctionInProps() {
if (!this.props.myFunction) {
return undefined;
}
return (
{this.props.myFunction()}
);
}
onButtonPress() {
Navigation.mergeOptions(this.props.componentId, {
bottomTab: {
badge: `TeSt`
}
});
}
onClickSwitchToTab() {
Navigation.mergeOptions(this.props.componentId, {
bottomTabs: {
currentTabIndex: 1,
visible: false,
animate: true,
tabColor: 'blue',
selectedTabColor: 'red'
}
});
}
onClickSwitchToTabByComponentID() {
Navigation.mergeOptions(this.props.componentId, {
bottomTabs: {
currentTabId: globalFirstComponentID
}
});
}
hideTabBar(visible) {
Navigation.mergeOptions(this.props.componentId, {
bottomTabs: {
visible,
animate: true
}
});
}
showSideMenu(side) {
Navigation.mergeOptions(this.props.componentId, {
sideMenu: {
[side]: {
visible: true
}
}
});
}
onClickPop() {
Navigation.pop(this.props.componentId);
}
}
module.exports = TextScreen;
const styles = {
root: {
flexGrow: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f5fcff'
},
h1: {
fontSize: 24,
textAlign: 'center',
margin: 10
},
h2: {
fontSize: 12,
textAlign: 'center',
margin: 10
},
footer: {
fontSize: 10,
color: '#888',
marginTop: 10
}
};