3
0

index.js 2.4 KB

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