App.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. import React from 'react';
  2. import { StyleSheet, Text, TextInput, View , button } from 'react-native';
  3. import GUI from './Systems/Gui';
  4. import Mouse from './Systems/mouse';
  5. import './App.css';
  6. // let m1 = new Mouse();
  7. // m1.on('LeftDown', () => console.log("M1")).listen();
  8. // let m2 = new Mouse();
  9. // m2.on('LeftDown', () => console.log("M2")).listen();
  10. export default class App extends React.Component {
  11. constructor(props){
  12. super(props)
  13. // this.playgroundRef = React.createRef();
  14. // this.toolboxRef = React.createRef();
  15. this.GUI = null;
  16. this.state = {
  17. zoom:1,
  18. scrollPos:0
  19. }
  20. this.GUI = new GUI();
  21. this.GUI.onUpdate( () => this.forceUpdate())
  22. }
  23. componentDidMount() {
  24. this.GUI.onMount();
  25. }
  26. addScrollEvent(){
  27. /* window.addEventListener('wheel', (e) =>{
  28. if(e.deltaY < 0){
  29. this.zoom(0.2);
  30. }
  31. else if(e.deltaY > 0){
  32. this.zoom(-0.2);
  33. }
  34. });*/
  35. }
  36. zoom(delta){
  37. let z = this.state.zoom;
  38. z = z + delta;
  39. this.setState({zoom:z});
  40. }
  41. dragPage(e){
  42. //!!!!!Import document.getElementById isnt working on react native
  43. //' let playground = document.getElementById("phone");
  44. /*playground.addEventListener("mousedown",() => {
  45. console.log("mouse down")
  46. playground.onmousemove = function(e){
  47. console.log("moving now while down")
  48. }
  49. })*/
  50. }
  51. render(){
  52. let customStyle = {
  53. zoom: this.state.zoom
  54. };
  55. return (
  56. <div className="main" id="some">
  57. <div className="mainbar">
  58. {this.GUI.renderMainBar()}
  59. </div>
  60. <div style={{position: 'relative'}}>
  61. <div className="horizontal_bars">
  62. <div ref={this.toolboxRef} className="toolbox">
  63. <div className="tool_icon_bar">{this.GUI.renderToolBox()}</div>
  64. <div className="moduleBar">{this.GUI.renderModuleBar()}</div>
  65. </div>
  66. <div className="wrapper">
  67. <div className="pageNav">
  68. { this.GUI.renderPageBar()}
  69. </div>
  70. <div className="wrapperPhone">
  71. <div style={{flex:1}}>
  72. {/*This is a comment*/}
  73. <div onClick={(e) => this.dragPage(e)} className="playground" style={{zoom:this.state.zoom}}>
  74. <div className="phone">
  75. {this.GUI.mobileRender()}
  76. </div>
  77. </div>
  78. </div>
  79. <div className="sidebar">
  80. {this.GUI.renderSideBar()}
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. );
  88. }
  89. }
  90. /*
  91. const styles = StyleSheet.create({
  92. container: {
  93. flex: 1,
  94. backgroundColor: '#fff',
  95. alignItems: 'center',
  96. justifyContent: 'space-between',
  97. flexDirection: 'row'
  98. },
  99. toolbarView: {
  100. justifyContent: 'space-around',
  101. alignItems: 'center',
  102. width: 64,
  103. borderWidth: 1,
  104. borderColor: 'red',
  105. padding: 16
  106. },
  107. mainView: {
  108. backgroundColor: '#065b69',
  109. alignSelf:'stretch',
  110. flex: 1,
  111. justifyContent: 'center',
  112. alignItems: 'center'
  113. },
  114. mobileView: {
  115. backgroundColor: 'white',
  116. borderWidth: 4,
  117. borderColor: 'orange',
  118. // iphone X
  119. width:1125/3,
  120. height: 2436/3
  121. },
  122. });*/