Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Don't Merge Until Build] Update - Commented fill all shots button #335

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const themeColors = {
highlight: "#fff",
};

const TESTING = true;
const TESTING = false;

const prettyTitle = {
target: "Target",
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ Needs a MacOS for building the project in XCode.
- Runs Prettier + ESLint, but only reports formatting / linting issues and does not edit any files yet
- Run via GitHub Actions in `.github/workflows/main.yml`, so that each PR gets its formatting / linting automatically checked before merge

### Testing Mode

- To enable testing mode, set `TESTING` to `TRUE` located in `Constants.js`

### App Compilation Troubleshooting

- Hot Reload is enabled by default whenever you edit a page on the app, and you can also manually trigger a reload by entering `r` into command line
Expand Down
86 changes: 44 additions & 42 deletions app/segments/drill/[id]/submission/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { Appbar, Button, Divider, Text } from "react-native-paper";
import { SafeAreaView } from "react-native-safe-area-context";
import { once } from "underscore";
import { themeColors } from "~/Constants";
import { TESTING, themeColors } from "~/Constants";
import {
getErrorString,
lookUpBaselineStrokesGained,
Expand Down Expand Up @@ -850,7 +850,7 @@
}
};

const handleSubmit = useCallback(

Check warning on line 853 in app/segments/drill/[id]/submission/input.js

View workflow job for this annotation

GitHub Actions / prettier-check

React Hook useCallback received a function whose dependencies are unknown. Pass an inline function instead
once(async () => {
setSubmitLoading(true);
const outputData = createOutputData(
Expand Down Expand Up @@ -1026,47 +1026,49 @@
</KeyboardAvoiderScrollView>
{/* Navigation */}
<View style={styles.navigationContainer}>
<Text
onPress={() => {
const newInputValues = Array.from(
{ length: attemptShots.length },
() => ({}),
);
for (let i = 0; i < attemptShots.length; i++) {
drillInfo.inputs.forEach((item) => {
switch (item.id) {
case "carry":
newInputValues[i][item.id] = Math.floor(
Math.random() *
attemptShots[displayedShot].items["target"] +
attemptShots[displayedShot].items["target"] / 2,
).toString();
break;
case "sideLanding":
newInputValues[i][item.id] = Math.floor(
Math.random() * 21 - 10,
).toString();
break;
case "strokes":
newInputValues[i][item.id] = Math.floor(
Math.random() * 2 + 1,
).toString();
break;
case "distance":
newInputValues[i][item.id] = Math.floor(
Math.random() * 35 + 5,
).toString();
break;
}
});
}
setInputValues(newInputValues);
setDisplayedShot(attemptShots.length - 1);
setCurrentShot(attemptShots.length - 1);
}}
>
Fill in all inputs
</Text>
{TESTING && (
<Text
onPress={() => {
const newInputValues = Array.from(
{ length: attemptShots.length },
() => ({}),
);
for (let i = 0; i < attemptShots.length; i++) {
drillInfo.inputs.forEach((item) => {
switch (item.id) {
case "carry":
newInputValues[i][item.id] = Math.floor(
Math.random() *
attemptShots[displayedShot].items["target"] +
attemptShots[displayedShot].items["target"] / 2,
).toString();
break;
case "sideLanding":
newInputValues[i][item.id] = Math.floor(
Math.random() * 21 - 10,
).toString();
break;
case "strokes":
newInputValues[i][item.id] = Math.floor(
Math.random() * 2 + 1,
).toString();
break;
case "distance":
newInputValues[i][item.id] = Math.floor(
Math.random() * 35 + 5,
).toString();
break;
}
});
}
setInputValues(newInputValues);
setDisplayedShot(attemptShots.length - 1);
setCurrentShot(attemptShots.length - 1);
}}
>
Fill in all inputs
</Text>
)}
{buttonDisplayHandler()}

{drillInfo.reps > 1 && (
Expand Down
Loading