Environment.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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, phoneRef) {
  7. super()
  8. this.phoneRef = phoneRef;
  9. this.CoreSystem = CS;
  10. }
  11. addRow(){
  12. let View = this.CoreSystem.getCurrentView();
  13. let container = View.getDefaultContainer();
  14. let rows = View.getRows(container);
  15. View.setRows(container,rows.length + 1)
  16. rows = View.getRows(container)
  17. View.setColumns(rows[rows.length-1],1)
  18. rows[rows.length-1].props.selected = true;
  19. this.forceUpdate();
  20. }
  21. render() {
  22. let CurrentView = this.CoreSystem.getCurrentView();
  23. let defaultContainer = CurrentView.getDefaultContainer();
  24. let Rows = CurrentView.getRows(defaultContainer);
  25. return <View style={styles.container}>
  26. <View style={[styles.row,styles.button]}>
  27. <Button
  28. color="#D2691E"
  29. onPress = {() => this.addRow()}
  30. title={
  31. <Icon name='add'
  32. color="#606060"
  33. containerStyle={{height:10}}
  34. />}
  35. />
  36. </View>
  37. <View style={styles.row}>
  38. <View style={styles.col}>
  39. <Text>Colasdasdasdasdasd</Text>
  40. {Rows.map((row) => {
  41. return <Text>Row : {row.id}</Text>
  42. })}
  43. </View>
  44. <div ref={this.phoneRef}>
  45. <View style={[styles.mobileView]}>
  46. {this.CoreSystem.render()}
  47. </View>
  48. </div>
  49. <View style={styles.col}>
  50. <Text>Col</Text>
  51. </View>
  52. </View>
  53. <View style={[styles.row,styles.button]}>
  54. <Button
  55. color="#D2691E"
  56. onPress={() => this.addRow()}
  57. title={
  58. <Icon name='add'
  59. color="#606060"
  60. containerStyle={{height:10}}
  61. />}
  62. />
  63. </View>
  64. </View>
  65. }
  66. }
  67. const styles = StyleSheet.create({
  68. container: {
  69. flex: 1,
  70. flexDirection: "column"
  71. },
  72. mobileView: {
  73. backgroundColor: 'white',
  74. borderWidth: 4,
  75. borderColor: 'orange',
  76. flex:1,
  77. alignSelf: 'stretch',
  78. // iphone X
  79. width:1125/3,
  80. height: 2436/3
  81. },
  82. row: {
  83. flexDirection: "row",
  84. borderWidth: 1
  85. },
  86. col: {
  87. flexDirection: "column",
  88. borderWidth: 1
  89. },
  90. button:{
  91. flex:1,
  92. justifyContent:'center',
  93. }
  94. });