App.js (1463B)
1 import React from 'react'; 2 import { AngSizeCalc } from "./highLevel/angSize"; 3 import { ConsecNumCalc } from "./highLevel/consecNum"; 4 import { ModeSelect } from "./highLevel/modeSelect"; 5 import { PolygonAngle } from "./highLevel/polygonAngle"; 6 import { SimpleCalc } from "./highLevel/simpleCalc"; 7 import { SimultaneousEquation } from "./highLevel/simultaneousEquation"; 8 9 export class App extends React.Component { 10 constructor(props) { 11 super(props); 12 this.state = { 13 mode: 'select' 14 }; 15 this.changeMode = this.changeMode.bind(this); 16 } 17 18 changeMode(object) { 19 const newMode = object.target.value; 20 this.setState({ 21 mode: newMode 22 }); 23 } 24 25 render() { 26 if (this.state.mode === 'basic') { 27 return <SimpleCalc mode={this.state.mode} onModeChange={this.changeMode}/>; 28 } else if (this.state.mode === 'angSize') { 29 return <AngSizeCalc mode={this.state.mode} onModeChange={this.changeMode}/>; 30 } else if (this.state.mode === 'consecNum') { 31 return <ConsecNumCalc mode={this.state.mode} onModeChange={this.changeMode}/>; 32 } else if (this.state.mode === 'polyAng') { 33 return <PolygonAngle mode={this.state.mode} onModeChange={this.changeMode} />; 34 } else if (this.state.mode === 'simultaneousEQ') { 35 return <SimultaneousEquation mode={this.state.mode} onModeChange={this.changeMode} />; 36 } else { 37 return <ModeSelect mode={this.state.mode} onButtonPress={this.changeMode} />; 38 } 39 } 40 }