App.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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.addScrollEvent();
  21. this.GUI = new GUI();
  22. console.log("@@@@@@@@@@@@@@@@@@###########")
  23. this.GUI.onUpdate( () => this.forceUpdate())
  24. }
  25. componentDidMount() {
  26. this.GUI.onMount();
  27. }
  28. addScrollEvent(){
  29. window.addEventListener('wheel', (e) =>{
  30. if(e.deltaY < 0){
  31. this.zoom(0.2);
  32. }
  33. else if(e.deltaY > 0){
  34. this.zoom(-0.2);
  35. }
  36. });
  37. }
  38. zoom(delta){
  39. let z = this.state.zoom;
  40. z = z + delta;
  41. this.setState({zoom:z});
  42. }
  43. dragPage(e){
  44. //!!!!!Import document.getElementById isnt working on react native
  45. //' let playground = document.getElementById("phone");
  46. /*playground.addEventListener("mousedown",() => {
  47. console.log("mouse down")
  48. playground.onmousemove = function(e){
  49. console.log("moving now while down")
  50. }
  51. })*/
  52. }
  53. render(){
  54. let customStyle = {
  55. zoom: this.state.zoom
  56. };
  57. return (
  58. <div className="main" id="some">
  59. <div className="mainbar">
  60. {this.GUI.renderMainBar()}
  61. </div>
  62. <div style={{position: 'relative'}}>
  63. <div className="horizontal_bars">
  64. <div ref={this.toolboxRef} className="toolbox">
  65. <div className="tool_icon_bar">{this.GUI.renderToolBox()}</div>
  66. <div className="moduleBar">{this.GUI.renderModuleBar()}</div>
  67. </div>
  68. <div className="sidebar">
  69. {this.GUI.renderSideBar()}
  70. </div>
  71. </div>
  72. {/*This is a comment*/}
  73. <div onClick={(e) => this.dragPage(e)} className="playground" style={{zoom:this.state.zoom}}>
  74. <div className="pageNav">{ this.GUI.renderPageBar()}</div>
  75. <div className="phone">
  76. {this.GUI.mobileRender()}
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. );
  82. }
  83. }
  84. /*
  85. const styles = StyleSheet.create({
  86. container: {
  87. flex: 1,
  88. backgroundColor: '#fff',
  89. alignItems: 'center',
  90. justifyContent: 'space-between',
  91. flexDirection: 'row'
  92. },
  93. toolbarView: {
  94. justifyContent: 'space-around',
  95. alignItems: 'center',
  96. width: 64,
  97. borderWidth: 1,
  98. borderColor: 'red',
  99. padding: 16
  100. },
  101. mainView: {
  102. backgroundColor: '#065b69',
  103. alignSelf:'stretch',
  104. flex: 1,
  105. justifyContent: 'center',
  106. alignItems: 'center'
  107. },
  108. mobileView: {
  109. backgroundColor: 'white',
  110. borderWidth: 4,
  111. borderColor: 'orange',
  112. // iphone X
  113. width:1125/3,
  114. height: 2436/3
  115. },
  116. });*/