BaseHolder.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import React , { useState } from 'react';
  2. import { StyleSheet, Text, View, TextInput, Button } from 'react-native';
  3. import Types from '../lib/Types';
  4. export default class BaseHolder extends React.Component {
  5. constructor(props){
  6. super(props);
  7. }
  8. render() {
  9. let {
  10. children,
  11. selected,
  12. justifyContent,
  13. alignItems,
  14. alignContent,
  15. flexDirection,
  16. flexWrap,
  17. flexFlow,
  18. order,
  19. alignSelf,
  20. flexGrow,
  21. flexShrink,
  22. flexBasis,
  23. width,
  24. height,
  25. overflow,
  26. stretchContainer,
  27. content,
  28. ...restProps
  29. } = this.props;
  30. let styl = [styles.base];
  31. if (selected) styl.push(styles.selected);
  32. if (stretchContainer) styl.push(styles.stretchToContent);
  33. return (
  34. // self container
  35. <View {...restProps} style={[styl, {
  36. order,
  37. alignSelf,
  38. flexGrow,
  39. flexShrink,
  40. flexBasis,
  41. width,
  42. height,
  43. overflow
  44. }]}>
  45. {content}
  46. <View WRAPPER={true} style={ //children Container
  47. [
  48. (!!content || stretchContainer) ? styles.stretchToContent : {},
  49. {
  50. justifyContent,
  51. alignItems,
  52. alignContent,
  53. flexDirection,
  54. flexWrap,
  55. flexFlow,
  56. padding: 5
  57. }
  58. ]}>
  59. {children}
  60. </View>
  61. </View>
  62. );
  63. }
  64. }
  65. const styles = StyleSheet.create({
  66. base: {
  67. minHeight: 10
  68. },
  69. stretchToContent: {
  70. position: 'absolute',
  71. top: 0,
  72. left: 0,
  73. bottom: 0,
  74. right: 0,
  75. overflow: 'hidden'
  76. },
  77. selected: {
  78. boxShadow: 'inset 0px 0px 1px 1px #fce8e8',
  79. border: '1px solid #f28d8d'
  80. }
  81. });
  82. BaseHolder.Inputs = {
  83. width: new Types.Integer(),
  84. height: new Types.Integer(),
  85. stretchContainer: new Types.Bool().default(false),
  86. overflow: new Types.Integer().default('hidden'),
  87. justifyContent: new Types.Text().default("flex-start"),
  88. alignItems: new Types.Text(),
  89. alignContent: new Types.Text(),
  90. flexDirection: new Types.Text(),
  91. flexWrap: new Types.Text(),
  92. flexFlow: new Types.Text(),
  93. order: new Types.Text(),
  94. alignSelf: new Types.Text(),
  95. flexGrow: new Types.Text(),
  96. flexShrink: new Types.Text(),
  97. flexBasis: new Types.Text()
  98. }