componentDidMount(){ SplashScreen.hide() BackAndroid.addEventListener('hardwareBackPress', function () { BackAndroid.exitApp(0) return true }) }
// this is used to scroll the view up when typing is active componentDidMount() { if (Platform.OS === 'ios') { SplashScreen.hide(); let keyboardHeight = null; let moveUpForKeyboard_onKeyboardEvent = () => {}; let keyboardDidShow = (event) => { keyboardHeight = event.endCoordinates.height; moveUpForKeyboard_onKeyboardEvent(); moveUpForKeyboard_onKeyboardEvent = () => {}; } let keyboardDidHide = (event) => { // console.log("keyboardDidHide", event) } this.focusTime = 0; let snapBack = () => { this.state.top.stopAnimation() Animated.timing(this.state.top, {toValue: 0, duration:0}).start(); }; let snapBackKeyboard = () => { this.state.top.stopAnimation() if (new Date().valueOf() - this.focusTime > 100) { Animated.timing(this.state.top, {toValue: 0, duration: 200}).start(); } }; let moveUpForKeyboard = (posY_bottomTextfield) => { this.state.top.stopAnimation() let distFromBottom = screenHeight - ((posY_bottomTextfield + 20) - this.state.top._value); // 20 is padding this.focusTime = new Date().valueOf(); Animated.timing(this.state.top, {toValue: Math.min(0,distFromBottom - keyboardHeight), duration: 200}).start() } this.unsubscribe.push(eventBus.on('focus', (posY_bottomTextfield) => { if (keyboardHeight === null) { moveUpForKeyboard_onKeyboardEvent = () => { moveUpForKeyboard(posY_bottomTextfield); }; } else { moveUpForKeyboard(posY_bottomTextfield); } })); this.unsubscribe.push(eventBus.on('hidePopup', snapBackKeyboard)); this.unsubscribe.push(eventBus.on('showPopup', snapBackKeyboard)); this.unsubscribe.push(eventBus.on('blur', snapBackKeyboard)); // catch for the simulator this.unsubscribe.push(eventBus.on('showLoading', snapBack)); this.unsubscribe.push(eventBus.on('showProgress', snapBack)); this.unsubscribe.push(eventBus.on('hideLoading', snapBack)); this.unsubscribe.push(eventBus.on('hideProgress', snapBack)); this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', keyboardDidShow); this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', keyboardDidHide); } }
InteractionManager.runAfterInteractions(() => { SplashScreen.hide(); navigator.resetTo({ component: HomePage, name: 'HomePage', params:{ theme:this.theme } }); });
componentDidMount() { // do anything while splash screen keeps, use await to wait for an async task. SplashScreen.hide(); AsyncStorageHelper.get('app.intro.done', (err, result) => { if (result !== 'true') { this.setState({ hasShowIntro: false, }); } }); }
import '../../utils/shim' import debounce from 'lodash/debounce' import React from 'react' import { Alert, AppRegistry, StyleSheet, View, } from 'react-native' import { RNCamera } from 'react-native-camera' import SplashScreen from 'react-native-splash-screen' if (SplashScreen) { SplashScreen.hide() } const prettify = obj => obj ? JSON.stringify(obj, null, 2) : '' class Scanner extends React.Component { onBarCodeRead = debounce(result => { Alert.alert('barcode read', prettify(result)) }, 500, { leading: true, trailing: false }) render = () => { return ( <View style={styles.container}> <RNCamera ref={ref => { this.camera = ref }}
componentDidMount() { SplashScreen.hide(); }