Guest User

Untitled

a guest
Dec 15th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. import React, {Component} from 'react';
  2. import {StyleSheet} from 'react-native';
  3. import FlipCard from 'react-native-flip-card';
  4.  
  5. import {
  6. View,
  7. Button,
  8. Colors,
  9. Text
  10. } from 'react-native-ui-lib';
  11.  
  12. class FlipCoin extends Component {
  13. state = {
  14. flip: false,
  15. pending: false
  16. };
  17.  
  18. startClock() {
  19. this.setState({pending: true});
  20. setTimeout(() => {
  21. this.setState({pending: false});
  22. this.setState({flip: true});
  23. }, 1000);
  24. }
  25.  
  26. render() {
  27. return (
  28. <View flex center bg-dark80>
  29. <View height={100} width={100}>
  30. <FlipCard
  31. flipHorizontal
  32. flipVertical={false}
  33. style={{borderWidth: 0}}
  34. clickable={false}
  35. flip={this.state.flip}
  36. >
  37. {/* Face Side */}
  38. <View style={styles.coinFace} center bg-red40>
  39. <Text white>The Face</Text>
  40. </View>
  41. {/* Back Side */}
  42. <View style={styles.coinFace} center bg-blue40>
  43. <Text white>The Back</Text>
  44. </View>
  45. </FlipCard>
  46. </View>
  47.  
  48. <View marginT-20>
  49. {!this.state.pending &&
  50. !this.state.flip && <Button label="Start Clock" link dark10 onPress={() => this.startClock()}/>}
  51. {this.state.pending && <Text text70>Wait for it...</Text>}
  52. {!this.state.pending && this.state.flip && <Text text70>Welcome!</Text>}
  53. </View>
  54. </View>
  55. );
  56. }
  57. }
  58.  
  59. const styles = StyleSheet.create({
  60. coinFace: {
  61. width: 100,
  62. height: 100,
  63. borderRadius: 50,
  64. },
  65. });
Add Comment
Please, Sign In to add comment