Last active
June 23, 2017 22:46
-
-
Save MovingGifts/9ce96c8188f7ab6ad266d74562c65f39 to your computer and use it in GitHub Desktop.
This file contains 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 characters
/* | |
* This file demonstrates a basic ReactXP app. | |
*/ | |
import RX = require('reactxp'); | |
interface MainPanelProps { | |
onPressNavigate: () => void; | |
} | |
const styles = { | |
scroll: RX.Styles.createScrollViewStyle({ | |
alignSelf: 'stretch', | |
backgroundColor: '#f5fcff' | |
}), | |
container: RX.Styles.createViewStyle({ | |
padding: 16, | |
justifyContent: 'center', | |
alignItems: 'center' | |
}), | |
helloWorld: RX.Styles.createTextStyle({ | |
fontSize: 48, | |
fontWeight: 'bold', | |
marginBottom: 28 | |
}), | |
welcome: RX.Styles.createTextStyle({ | |
fontSize: 32, | |
marginBottom: 12 | |
}), | |
instructions: RX.Styles.createTextStyle({ | |
fontSize: 16, | |
color: '#aaa', | |
marginBottom: 16 | |
}), | |
docLink: RX.Styles.createLinkStyle({ | |
fontSize: 16, | |
color: 'blue', | |
marginBottom: 16 | |
}), | |
roundButton: RX.Styles.createViewStyle({ | |
margin: 16, | |
borderRadius: 16, | |
backgroundColor: '#7d88a9' | |
}), | |
buttonText: RX.Styles.createTextStyle({ | |
fontSize: 16, | |
marginVertical: 6, | |
marginHorizontal: 12, | |
color: 'white' | |
}), | |
image: RX.Styles.createImageStyle({ | |
width: 60, | |
height: 60 | |
}) | |
}; | |
class MainPanel extends RX.Component<MainPanelProps, null> { | |
private _translationValue: RX.Animated.Value; | |
private _animatedStyle: RX.Types.AnimatedTextStyleRuleSet; | |
constructor() { | |
super(); | |
this._translationValue = new RX.Animated.Value(-100); | |
this._animatedStyle = RX.Styles.createAnimatedTextStyle({ | |
transform: [ | |
{ | |
translateY: this._translationValue | |
} | |
] | |
}); | |
} | |
componentDidMount() { | |
let animation = RX.Animated.timing(this._translationValue, { | |
toValue: 0, | |
easing: RX.Animated.Easing.OutBack(), | |
duration: 500 | |
} | |
); | |
animation.start(); | |
} | |
render() { | |
return ( | |
<RX.ScrollView style={ styles.scroll }> | |
<RX.View style={ styles.container }> | |
<RX.Animated.Text style={ [styles.helloWorld, this._animatedStyle] }> | |
Hello World | |
</RX.Animated.Text> | |
<RX.Text style={ styles.welcome }> | |
Welcome to ReactXP | |
</RX.Text> | |
<RX.Text style={ styles.instructions }> | |
Edit App.tsx to get started | |
</RX.Text> | |
<RX.Link style={ styles.docLink } url={ 'https://microsoft.github.io/reactxp/docs' }> | |
View ReactXP documentation | |
</RX.Link> | |
<RX.Text style={ styles.welcome }>Image Local</RX.Text> | |
<RX.Image source={ './images/react.png' } style={ styles.image } /> | |
<RX.Text style={ styles.welcome }>Image Remote</RX.Text> | |
<RX.Image source={ 'http://i.imgur.com/GRIZj68.png' } style={ styles.image } /> | |
<RX.Button style={ styles.roundButton } onPress={ this._onPressNavigate }> | |
<RX.Text style={ styles.buttonText }> | |
See More Examples | |
</RX.Text> | |
</RX.Button> | |
</RX.View> | |
</RX.ScrollView> | |
); | |
} | |
private _onPressNavigate = () => { | |
this.props.onPressNavigate(); | |
} | |
} | |
export = MainPanel; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment