BaseHolder.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. stretchContainer,
  26. content,
  27. ...restProps
  28. } = this.props;
  29. let styl = [styles.base];
  30. if (selected) styl.push(styles.selected);
  31. if (stretchContainer) styl.push(styles.stretchToContent);
  32. return (
  33. // self container
  34. <View {...restProps} style={[styl, {
  35. order,
  36. alignSelf,
  37. flexGrow,
  38. flexShrink,
  39. flexBasis,
  40. width,
  41. height
  42. }]}>
  43. {content}
  44. <View WRAPPER={true} style={ //children Container
  45. [
  46. !!content || stretchContainer ? styles.stretchToContent : {},
  47. {
  48. justifyContent,
  49. alignItems,
  50. alignContent,
  51. flexDirection,
  52. flexWrap,
  53. flexFlow
  54. }
  55. ]}>
  56. {children}
  57. </View>
  58. </View>
  59. );
  60. }
  61. }
  62. const styles = StyleSheet.create({
  63. base: {
  64. minHeight: 10
  65. },
  66. stretchToContent: {
  67. position: 'absolute',
  68. top: 0,
  69. left: 0,
  70. bottom: 0,
  71. right: 0,
  72. overflow: 'hidden'
  73. },
  74. selected: {
  75. boxShadow: 'inset 0px 0px 1px 1px rgba(250,10,0,0.81)',
  76. border: '1px solid green'
  77. }
  78. });
  79. BaseHolder.Inputs = {
  80. width: new Types.Integer(),
  81. height: new Types.Integer(),
  82. justifyContent: new Types.Text().default("flex-start"),
  83. alignItems: new Types.Text(),
  84. alignContent: new Types.Text(),
  85. flexDirection: new Types.Text(),
  86. flexWrap: new Types.Text(),
  87. flexFlow: new Types.Text(),
  88. order: new Types.Text(),
  89. alignSelf: new Types.Text(),
  90. flexGrow: new Types.Text(),
  91. flexShrink: new Types.Text(),
  92. flexBasis: new Types.Text()
  93. }