react-native-navigation的迁移库

RoundedButton.js 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. padding: 4
  39. },
  40. button: {
  41. width: 40,
  42. height: 40,
  43. borderRadius: 20,
  44. backgroundColor: Colors.primary,
  45. justifyContent: 'center',
  46. },
  47. text: {
  48. color: 'white',
  49. alignSelf: 'center'
  50. }
  51. });