Environment.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import React from 'react';
  2. import { Button , View, Text, StyleSheet } from 'react-native';
  3. import {Icon} from 'react-native-elements';
  4. import BaseSystem from './System';
  5. export default class Environment extends BaseSystem{
  6. constructor(CS) {
  7. super();
  8. this.CoreSystem = CS;
  9. }
  10. addRow(){
  11. let View = this.CoreSystem.getCurrentView();
  12. let container = View.getDefaultContainer();
  13. let rows = View.getRows(container);
  14. View.setRows(container,rows.length + 1)
  15. rows = View.getRows(container)
  16. View.setColumns(rows[rows.length-1],1)
  17. rows[rows.length-1].props.selected = true;
  18. this.forceUpdate();
  19. }
  20. render() {
  21. return <View style={styles.container}>
  22. <View style={[styles.row,styles.button]}>
  23. <Button
  24. color="#D2691E"
  25. onPress = {() => this.addRow()}
  26. title={
  27. <Icon name='add'
  28. color="#606060"
  29. containerStyle={{height:10}}
  30. />}
  31. />
  32. </View>
  33. <View style={styles.row}>
  34. <View style={styles.col}>
  35. <Text>Col</Text>
  36. </View>
  37. <View style={[styles.mobileView, styles.col]}>
  38. {this.CoreSystem.render()}
  39. </View>
  40. <View style={styles.col}>
  41. <Text>Col</Text>
  42. </View>
  43. </View>
  44. <View style={[styles.row,styles.button]}>
  45. <Button
  46. color="#D2691E"
  47. onPress={() => this.addRow()}
  48. title={
  49. <Icon name='add'
  50. color="#606060"
  51. containerStyle={{height:10}}
  52. />}
  53. />
  54. </View>
  55. </View>
  56. }
  57. }
  58. const styles = StyleSheet.create({
  59. container: {
  60. flex: 1,
  61. flexDirection: "column"
  62. },
  63. mobileView: {
  64. backgroundColor: 'white',
  65. borderWidth: 4,
  66. borderColor: 'orange',
  67. flex:1,
  68. alignSelf: 'stretch',
  69. // iphone X
  70. width:1125/3,
  71. height: 2436/3
  72. },
  73. row: {
  74. flexDirection: "row",
  75. borderWidth: 1
  76. },
  77. col: {
  78. flexDirection: "column",
  79. borderWidth: 1
  80. },
  81. button:{
  82. flex:1,
  83. justifyContent:'center',
  84. }
  85. });