3
0

BaseHolder.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. }
  57. ]}>
  58. {children}
  59. </View>
  60. </View>
  61. );
  62. }
  63. }
  64. const styles = StyleSheet.create({
  65. base: {
  66. minHeight: 10
  67. },
  68. stretchToContent: {
  69. position: 'absolute',
  70. top: 0,
  71. left: 0,
  72. bottom: 0,
  73. right: 0,
  74. overflow: 'hidden'
  75. },
  76. selected: {
  77. boxShadow: 'inset 0px 0px 1px 1px rgba(250,10,0,0.81)',
  78. border: '1px solid green'
  79. }
  80. });
  81. BaseHolder.Inputs = {
  82. width: new Types.Integer(),
  83. height: new Types.Integer(),
  84. overflow: new Types.Integer().default('hidden'),
  85. justifyContent: new Types.Text().default("flex-start"),
  86. alignItems: new Types.Text(),
  87. alignContent: new Types.Text(),
  88. flexDirection: new Types.Text(),
  89. flexWrap: new Types.Text(),
  90. flexFlow: new Types.Text(),
  91. order: new Types.Text(),
  92. alignSelf: new Types.Text(),
  93. flexGrow: new Types.Text(),
  94. flexShrink: new Types.Text(),
  95. flexBasis: new Types.Text()
  96. }