-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix enum and boolean handling issue (#3)
- Loading branch information
Showing
8 changed files
with
58 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"HOST": "192.168.49.1", | ||
"HOST": "192.168.1.20", | ||
"PORT": 8000 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const BooleanInput = ({ value, onChange }) => ( | ||
<input type="checkbox" checked={value} onChange={evt => onChange(evt.target.checked, true)} /> | ||
const BooleanInput = ({ value, onChange, onSave }) => ( | ||
<span> | ||
<input type="checkbox" checked={value} onChange={evt => onChange({ | ||
value: evt.target.checked, | ||
valid: true | ||
})} /> | ||
<button onClick={onSave}>Save</button> | ||
</span> | ||
); | ||
|
||
BooleanInput.propTypes = { | ||
value: PropTypes.bool.isRequired, | ||
onChange: PropTypes.func.isRequired | ||
onChange: PropTypes.func.isRequired, | ||
onSave: PropTypes.func.isRequired | ||
}; | ||
|
||
export default BooleanInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const EnumInput = ({ value, values, onChange }) => ( | ||
<select | ||
className="valid" | ||
value={value} | ||
onChange={evt => onChange(evt.target.value, true)}> | ||
{ | ||
values.map(v => (<option key={v} value={v}>{v}</option>)) | ||
} | ||
</select> | ||
const EnumInput = ({ value, values, onChange, onSave }) => ( | ||
<span> | ||
<select | ||
className="valid" | ||
value={value} | ||
onChange={evt => onChange({ | ||
value: evt.target.value, | ||
valid: true | ||
})}> | ||
{ | ||
values.map(v => (<option key={v} value={v}>{v}</option>)) | ||
} | ||
</select> | ||
<button onClick={onSave}>Save</button> | ||
</span> | ||
); | ||
|
||
EnumInput.propTypes = { | ||
value: PropTypes.string.isRequired, | ||
values: PropTypes.arrayOf(PropTypes.string).isRequired, | ||
onChange: PropTypes.func.isRequired | ||
onChange: PropTypes.func.isRequired, | ||
onSave: PropTypes.func.isRequired | ||
}; | ||
|
||
export default EnumInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
TeamCode/src/main/java/org/firstinspires/ftc/teamcode/SampleConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.firstinspires.ftc.teamcode; | ||
|
||
import com.acmerobotics.dashboard.config.Config; | ||
import com.qualcomm.robotcore.hardware.DcMotorSimple; | ||
|
||
/* | ||
* Some additional constants for testing. | ||
*/ | ||
@Config | ||
public class SampleConstants { | ||
public static DcMotorSimple.Direction DIR = DcMotorSimple.Direction.FORWARD; | ||
public static boolean FF_ENABLED = false; | ||
} |