index.js 2.6 KB

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