Alignment.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import React, { useState } from 'react';
  2. import {View , Text, TextInput, Button,StyleSheet} from 'react-native';
  3. import { Icon } from 'react-native-elements'
  4. export default class Alignment extends React.Component {
  5. constructor(props) {
  6. super(props);
  7. }
  8. getStyle(i) {
  9. switch(i) {
  10. case 0:
  11. return {
  12. alignItems: 'flex-start'
  13. }
  14. case 1:
  15. return {
  16. alignItems: 'center'
  17. }
  18. case 2:
  19. return {
  20. alignItems: 'flex-end'
  21. }
  22. case 3:
  23. return {
  24. alignItems: 'stretch'
  25. }
  26. }
  27. }
  28. set(i) {
  29. let style = this.getStyle(i);
  30. this.props.onSelect && this.props.onSelect(style);
  31. }
  32. render() {
  33. let iconStyle = styles.iconStyle;
  34. return (
  35. <View style={styles.container}>
  36. <Icon name="format-align-left" iconStyle={iconStyle} onClick={() => this.set(0)}/>
  37. <Icon name="format-align-center" iconStyle={iconStyle} onClick={() => this.set(1)}/>
  38. <Icon name="format-align-right" iconStyle={iconStyle} onClick={() => this.set(2)}/>
  39. <Icon name="format-align-justify" iconStyle={iconStyle} onClick={() => this.set(3)}/>
  40. </View>
  41. );
  42. }
  43. }
  44. const styles = StyleSheet.create({
  45. container:{
  46. padding:15,
  47. flexDirection: 'row',
  48. justifyContent: 'space-around',
  49. borderBottomColor: '#B4B4B4',
  50. borderBottomWidth: 1
  51. },
  52. defaultInput: {
  53. marginTop:6,
  54. borderWidth:1,
  55. width:200
  56. },
  57. title: {
  58. },
  59. iconStyle: {
  60. fontSize: 18,
  61. opacity: 0.6,
  62. cursor: 'pointer'
  63. }
  64. })