const _ = require('lodash'); const React = require('react'); const { Component } = require('react'); const { View, Text, Platform } = require('react-native'); const { Navigation } = require('react-native-navigation'); const Button = require('./Button'); const testIDs = require('../testIDs'); class PushedScreen extends Component { static get options() { return { _statusBar: { visible: false, drawBehind: true }, topBar: { testID: testIDs.TOP_BAR_ELEMENT, rightButtons: { id: 'singleBtn', text: 'single', testID: testIDs.TOP_BAR_BUTTON }, rightButtonColor: 'red', }, layout: { backgroundColor: '#f5fcff' } }; } constructor(props) { super(props); if (this.props.simulateLongRunningTask) { this.simulateLongRunningTask(); } this.onClickPush = this.onClickPush.bind(this); this.onClickPop = this.onClickPop.bind(this); this.onClickPopPrevious = this.onClickPopPrevious.bind(this); this.onClickPopToFirstPosition = this.onClickPopToFirstPosition.bind(this); this.onClickPopToRoot = this.onClickPopToRoot.bind(this); this.onClickSetStackRoot = this.onClickSetStackRoot.bind(this); this.state = { disabled: false }; } simulateLongRunningTask() { // tslint:disable-next-line for (let i = 0; i < Math.pow(2, 25); i++); } listeners = []; componentDidMount() { this.listeners.push( Navigation.events().registerComponentDidAppearListener((event) => { if (this.state.previewComponentId === event.componentId) { this.setState({ disabled: event.type === 'ComponentDidAppear' }); } }) ); if (Platform.OS === 'ios') { // this.listeners.push( // Navigation.events().registerNativeEventListener((name, params) => { // if (name === 'previewContext') { // const { previewComponentId } = params; // this.setState({ previewComponentId }); // } // }) // ); } } componentWillUnmount() { this.listeners.forEach(listener => listener.remove && listener.remove()); } render() { const stackPosition = this.getStackPosition(); return ( {`Pushed Screen`} {`Stack Position: ${stackPosition}`}