App.js 2.9 KB

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