Last active
December 12, 2019 06:01
-
-
Save wachunei/79a576f9a80f135274c396d8d98e2f51 to your computer and use it in GitHub Desktop.
Revisions
-
wachunei revised this gist
Feb 14, 2018 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -109,7 +109,6 @@ const styles = { backgroundColor: 'transparent', justifyContent: 'center', alignItems: 'center', }, logo: { width: 62, -
wachunei revised this gist
Feb 14, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,7 @@ class AnimatedGate extends Component { toValue: 100, duration, easing: Easing.bezier(0.42, 0, 0.42, 1), }).start(); } render() { -
wachunei revised this gist
Feb 13, 2018 . No changes.There are no files selected for viewing
-
wachunei revised this gist
Feb 13, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,3 +2,4 @@ Demo is included in [this tweet](https://twitter.com/wachunei/status/963536535479115778)  -
wachunei renamed this gist
Feb 13, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
wachunei created this gist
Feb 13, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,120 @@ import React, { Component } from 'react'; import { Animated, Easing, StatusBar, MaskedViewIOS, View } from 'react-native'; class AnimatedGate extends Component { constructor(props) { super(props); this.beginAnimation = this.beginAnimation.bind(this); this.state = { animation: new Animated.Value(0), }; } componentDidMount() { StatusBar.setHidden(true); } componentWillReceiveProps(nextProps) { if (!this.props.bootstraped && nextProps.bootstraped) { setTimeout(() => this.beginAnimation(), 1000); } } beginAnimation() { const duration = 1300; setTimeout(() => StatusBar.setHidden(false, 'fade'), 0.6 * duration); Animated.timing(this.state.animation, { toValue: 100, duration, easing: Easing.bezier(0.42, 0, 0.42, 1), }).start(() => this.setState({ displayed: false })); } render() { const { animation } = this.state; const opacity = animation.interpolate({ inputRange: [0, 30, 70], outputRange: [0, 0, 1], extrapolate: 'clamp', }); const MainApp = ( <View style={styles.mainContainer}> <Animated.View style={{ flex: 1, opacity, transform: [ { scale: animation.interpolate({ inputRange: [0, 50, 100], outputRange: [1.05, 1.05, 1], }), }, ], }} > {this.props.children} </Animated.View> </View> ); const MaskElement = ( <View style={styles.maskElementContainer}> <Animated.Image source={require('./twitter_logo.png')} style={[ styles.logo, { transform: [ { scale: animation.interpolate({ inputRange: [0, 30, 100], outputRange: [1, 0.8, 40], extrapolate: 'clamp', }), }, ], }, ]} /> </View> ); return ( <View style={styles.gateContainer}> <MaskedViewIOS style={styles.maskedView} maskElement={MaskElement}> {MainApp} </MaskedViewIOS> </View> ); } } const styles = { gateContainer: { flex: 1, backgroundColor: 'rgb(29, 161, 242)', }, mainContainer: { flex: 1, backgroundColor: 'white', }, maskedView: { flex: 1, }, maskElementContainer: { flex: 1, backgroundColor: 'transparent', justifyContent: 'center', alignItems: 'center', backgroundColor: 'transparent', }, logo: { width: 62, height: 62, }, }; export default AnimatedGate; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ # App is a regular redux app, but PersistGate # takes a function as a child component. # (see https://github.com/rt2zz/redux-persist/pull/718) import React, { Component } from 'react'; import { Provider } from 'react-redux'; import { PersistGate } from 'redux-persist/src/integration/react'; import Main from './Main'; import AnimatedGate from './AnimatedGate'; import configureStore from './configureStore'; const { store, persistor } = configureStore(); export default class App extends Component { render() { return ( <Provider store={store}> <PersistGate persistor={persistor}> {bootstraped => ( <AnimatedGate bootstraped={bootstraped}> <Main /> </AnimatedGate> )} </PersistGate> </Provider> ); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ # Demo Demo is included in [this tweet](https://twitter.com/wachunei/status/963536535479115778) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ # Twitter UI mockup (is an image) import React from 'react'; import { View, Image, StatusBar } from 'react-native'; const Main = () => ( <View style={styles.container}> <StatusBar barStyle="light-content" /> <Image source={require('./twitterimage.jpeg')} style={styles.image} resizeMode="contain" /> </View> ); const styles = { container: { flex: 1, justifyContent: 'center', alignItems: 'center', }, image: { flex: 1, }, }; export default Main;