index.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. order,
  18. alignSelf,
  19. flexGrow,
  20. flexShrink,
  21. flexBasis,
  22. width,
  23. height,
  24. paddingTop,
  25. paddingBottom,
  26. marginLeft,
  27. marginRight,
  28. overflow,
  29. CoreSystem,
  30. stretchContainer,
  31. content,
  32. ...restProps
  33. } = this.props;
  34. if(!width) width = undefined;
  35. if(!height) height = undefined;
  36. let styl = [styles.base];
  37. if (CoreSystem && CoreSystem._devMode && selected) styl.push(styles.selected);
  38. if (stretchContainer) styl.push(styles.stretchToContent);
  39. return (
  40. // self container
  41. <View {...restProps} style={[styl, {
  42. alignSelf,
  43. flexGrow,
  44. flexShrink,
  45. flexBasis,
  46. width,
  47. height,
  48. paddingTop,
  49. paddingBottom,
  50. marginLeft,
  51. marginRight,
  52. overflow
  53. }]}>
  54. {content}
  55. <View WRAPPER={true} style={ //children Container
  56. [
  57. (!!content || stretchContainer) ? styles.stretchToContent : {},
  58. {
  59. justifyContent,
  60. alignItems,
  61. alignContent,
  62. flexDirection,
  63. flexWrap
  64. }
  65. ]}>
  66. {children}
  67. </View>
  68. </View>
  69. );
  70. }
  71. }
  72. const styles = StyleSheet.create({
  73. base: {
  74. minHeight: 10,
  75. // borderColor: 'blue',
  76. // borderWidth: 1
  77. },
  78. stretchToContent: {
  79. position: 'absolute',
  80. top: 0,
  81. left: 0,
  82. bottom: 0,
  83. right: 0,
  84. // borderColor: 'red',
  85. // borderWidth: 1
  86. },
  87. contentWrapper: {
  88. },
  89. selected: {
  90. borderWidth: 1,
  91. borderColor: '#f28d8d',
  92. shadowColor: "rgba(250,10,0,0.81)",
  93. shadowOffset: {
  94. width: 0,
  95. height: 4,
  96. },
  97. shadowOpacity: 0.30,
  98. shadowRadius: 4.65,
  99. elevation: 8
  100. // border: '1px solid green'
  101. }
  102. });
  103. BaseHolder.Inputs = {
  104. width: new Types.Integer(),
  105. height: new Types.Integer(),
  106. paddingTop: new Types.Integer(),
  107. paddingBottom: new Types.Integer(),
  108. marginLeft: new Types.Integer().default(0),
  109. marginRight: new Types.Integer().default(0),
  110. stretchContainer: new Types.Bool().default(false),
  111. overflow: new Types.Text().default('visible'),
  112. justifyContent: new Types.Text().default("flex-start"),
  113. alignItems: new Types.Text(),
  114. alignContent: new Types.Text(),
  115. flexDirection: new Types.Text(),
  116. flexWrap: new Types.Text(),
  117. alignSelf: new Types.Text(),
  118. flexGrow: new Types.Real(),
  119. flexShrink: new Types.Real(),
  120. flexBasis: new Types.Real()
  121. }