react-native-navigation的迁移库

RoundedButton.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. const React = require('react');
  2. const { Component } = require('react');
  3. const {
  4. StyleSheet,
  5. View,
  6. TouchableOpacity,
  7. Text,
  8. Alert,
  9. } = require('react-native');
  10. const Colors = require('../commons/Colors');
  11. const { Navigation } = require('react-native-navigation');
  12. class RoundedButton extends Component {
  13. constructor(props) {
  14. super(props);
  15. this.subscription = Navigation.events().bindComponent(this);
  16. this.state = {};
  17. }
  18. render() {
  19. return (
  20. <View style={styles.container}>
  21. <View style={styles.button}>
  22. <TouchableOpacity onPress={() => Alert.alert(this.props.title, 'Thanks for that :)')}>
  23. <Text style={styles.text}>{this.props.title}</Text>
  24. </TouchableOpacity>
  25. </View>
  26. </View>
  27. );
  28. }
  29. }
  30. module.exports = RoundedButton;
  31. const styles = StyleSheet.create({
  32. container: {
  33. flex: 1,
  34. backgroundColor: 'transparent',
  35. flexDirection: 'column',
  36. justifyContent: 'center',
  37. alignItems: 'center'
  38. },
  39. button: {
  40. width: 40,
  41. height: 40,
  42. borderRadius: 20,
  43. backgroundColor: Colors.primary,
  44. justifyContent: 'center',
  45. },
  46. text: {
  47. color: 'white',
  48. alignSelf: 'center'
  49. }
  50. });