Ensure reps are always positive - 2.15 🚀

This commit is contained in:
Brandon Presley 2024-02-09 11:39:18 +13:00
parent 1921ecb9f4
commit 9c3d6772a9
5 changed files with 19 additions and 6 deletions

View File

@ -239,9 +239,11 @@ export default function EditSet() {
value={reps} value={reps}
onChangeText={(newReps) => { onChangeText={(newReps) => {
const fixed = fixNumeric(newReps); const fixed = fixNumeric(newReps);
setReps(fixed); setReps(fixed.replace(/-/g, ''))
if (fixed.length !== newReps.length) if (fixed.length !== newReps.length)
toast("Reps must be a number"); toast("Reps must be a number");
else if (fixed.includes('-'))
toast("Reps must be a positive value")
}} }}
onSubmitEditing={() => weightRef.current?.focus()} onSubmitEditing={() => weightRef.current?.focus()}
selection={selection} selection={selection}

View File

@ -21,6 +21,8 @@ import { DrawerParams } from "./drawer-params";
import GymSet from "./gym-set"; import GymSet from "./gym-set";
import Settings from "./settings"; import Settings from "./settings";
import PrimaryButton from "./PrimaryButton"; import PrimaryButton from "./PrimaryButton";
import { fixNumeric } from "./fix-numeric";
import { toast } from "./toast";
export default function EditSets() { export default function EditSets() {
const { params } = useRoute<RouteProp<StackParams, "EditSets">>(); const { params } = useRoute<RouteProp<StackParams, "EditSets">>();
@ -98,7 +100,14 @@ export default function EditSets() {
label={`Reps: ${oldReps}`} label={`Reps: ${oldReps}`}
keyboardType="numeric" keyboardType="numeric"
value={reps} value={reps}
onChangeText={setReps} onChangeText={(newReps) => {
const fixed = fixNumeric(newReps);
setReps(fixed.replace(/-/g, ''))
if (fixed.length !== newReps.length)
toast("Reps must be a number");
else if (fixed.includes('-'))
toast("Reps must be a positive value")
}}
selection={selection} selection={selection}
onSelectionChange={(e) => setSelection(e.nativeEvent.selection)} onSelectionChange={(e) => setSelection(e.nativeEvent.selection)}
autoFocus={!!name} autoFocus={!!name}

View File

@ -150,9 +150,11 @@ export default function StartPlan() {
value={reps} value={reps}
onChangeText={(newReps) => { onChangeText={(newReps) => {
const fixed = fixNumeric(newReps); const fixed = fixNumeric(newReps);
setReps(fixed); setReps(fixed.replace(/-/g, ''))
if (fixed.length !== newReps.length) if (fixed.length !== newReps.length)
toast("Reps must be a number"); toast("Reps must be a number");
else if (fixed.includes('-'))
toast("Reps must be a positive value")
}} }}
onSubmitEditing={() => weightRef.current?.focus()} onSubmitEditing={() => weightRef.current?.focus()}
selection={selection} selection={selection}

View File

@ -85,8 +85,8 @@ android {
applicationId "com.massive" applicationId "com.massive"
minSdkVersion rootProject.ext.minSdkVersion minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 36229 versionCode 36230
versionName "2.14" versionName "2.15"
} }
signingConfigs { signingConfigs {
release { release {

View File

@ -1,6 +1,6 @@
{ {
"name": "massive", "name": "massive",
"version": "2.14", "version": "2.15",
"private": true, "private": true,
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
"scripts": { "scripts": {