export default function App(props) { const [isLoadingComplete, setLoadingComplete] = useState(false); if (!isLoadingComplete && !props.skipLoadingScreen) { return ( <AppLoading startAsync={loadResourcesAsync} onError={handleLoadingError} onFinish={() => handleFinishLoading(setLoadingComplete)} /> ); } else { return ( <View style={styles.container}> {Platform.OS === 'ios' && <StatusBar barStyle="default" />} <AppNavigator /> </View> ); } }
render() { const {ready} = this.state const {decks} = this.props if (ready === false) { return ( <AppLoading/> ) } return ( <View style={styles.container}> <FlatList contentContainerStyle={{width: '100%'}} data={Object.keys(decks).map(title => (decks[title]))} renderItem={(deck) => { return <DeckSummary title={deck.item.title} cards={deck.item.questions.length} onPress={() => this.onPressDeck(deck.item.title)}/> }} keyExtractor={item => item.title} /> </View> ) }
static getDerivedStateFromProps(props, state) { const soundObject = new Audio.Sound(); const didPurr = props.cuddles > state.cuddles; const didScratch = props.scratches > state.scratches; (async function (purred, scratched) { try { if (purred) { // Purr await soundObject.loadAsync(purrSound); await soundObject.playAsync(); } if (scratched) { // Scratch await soundObject.loadAsync(screamSound); await soundObject.playAsync(); } } catch (e) { // Log error } }(didPurr, didScratch)); return props; }
export function ARKit() { const nativeRef = useRef() const onCreated = ({ gl, scene, size, setDefaultCamera }) => { AR.setPlaneDetection(AR.PlaneDetectionTypes.Horizontal); gl.gammaInput = true; gl.gammaOutput = true; scene.background = new BackgroundTexture(gl); const camera = new Camera(size.width, size.height, 0.01, 1000) setDefaultCamera(camera) } const onContextCreated = async () => { const { TrackingConfiguration, TrackingConfigurations } = AR; const finalConfig = TrackingConfiguration || TrackingConfigurations; const trackingConfiguration = finalConfig.World; await AR.startAsync(findNodeHandle(nativeRef.current), trackingConfiguration); } return ( <Canvas onCreated={onCreated} onContextCreated={onContextCreated} nativeRef_EXPERIMENTAL={nativeRef} > <ambientLight intensity={0.5} /> <pointLight color="white" intensity={1} position={[10, 10, 10]} /> <Box /> </Canvas> ) }
render() { if (!this.state.isReady) { return ( <AppLoading startAsync={this.loadAssetsAsync} onFinish={() => this.setState({ isReady: true })} onError={console.warn} /> ); }else{ return ( <Provider store = { store }> <View style={{ flex: 1, marginTop: StatusBar.currentHeight }}> <AppContainer /> </View> </Provider> ); } }
const sendSMSCode = async (phone, resolve, reject, { url }) => { Platform.OS === 'ios' && WebBrowser.dismissBrowser(); const tokenEncoded = Linking.parse(url).queryParams['token']; if (tokenEncoded) { const token = decodeURIComponent(tokenEncoded); //fake firebase.auth.ApplicationVerifier const captchaVerifier = { type: 'recaptcha', verify: () => Promise.resolve(token) }; try { const confirmationResult = await firebase .auth() .signInWithPhoneNumber(phone, captchaVerifier); resolve(async smsCode => { try { await confirmationResult.confirm(smsCode); } catch (e) { console.warn(e); } }); } catch (e) { reject(e); } } }
render() { if (!this.state.isReady) { return <AppLoading />
<AppLoading startAsync={loadResourcesAsync} onError={handleLoadingError}
export default function App(props) { const [isLoadingComplete, setLoadingComplete] = useState(false); if (!isLoadingComplete && !props.skipLoadingScreen) { return ( <AppLoading startAsync={loadResourcesAsync} onError={handleLoadingError} onFinish={() => handleFinishLoading(setLoadingComplete)} /> ); } else { return ( <View style={styles.container}> {Platform.OS === 'ios' && <StatusBar barStyle="default" />} <AppNavigator /> </View> ); } }