Handle fresh user experience better for Plans - 2.9 🚀

1. Add a button to insert some Exercises if none exist
2. Show a toast for the first plan, explaining you should
  tap it to begin the plan.
This commit is contained in:
Brandon Presley 2023-11-29 09:38:56 +13:00
parent 81421e5be7
commit 5a3b926dcf
3 changed files with 25 additions and 5 deletions

View File

@ -12,7 +12,12 @@ import {
StyleSheet,
View,
} from "react-native";
import { IconButton, Switch as PaperSwitch, Text } from "react-native-paper";
import {
Button,
IconButton,
Switch as PaperSwitch,
Text,
} from "react-native-paper";
import AppInput from "./AppInput";
import { StackParams } from "./AppStack";
import PrimaryButton from "./PrimaryButton";
@ -23,6 +28,7 @@ import { DAYS } from "./days";
import { planRepo, setRepo } from "./db";
import { DrawerParams } from "./drawer-params";
import GymSet, { defaultSet } from "./gym-set";
import { toast } from "./toast";
export default function EditPlan() {
const { params } = useRoute<RouteProp<StackParams, "EditPlan">>();
@ -62,12 +68,13 @@ export default function EditPlan() {
if (!days || !exercises) return;
const newExercises = exercises.filter((exercise) => exercise).join(",");
const newDays = days.filter((day) => day).join(",");
await planRepo.save({
const saved = await planRepo.save({
title: title,
days: newDays,
exercises: newExercises,
id: plan.id,
});
if (saved.id === 1) toast("Tap your plan again to begin using it");
}, [title, days, exercises, plan]);
const toggleExercise = useCallback(
@ -185,6 +192,19 @@ export default function EditPlan() {
{exercises.map((exercise, index) =>
renderExercise(exercise, index, true)
)}
{names?.length === 0 && (
<>
<Text>No exercises yet.</Text>
<Button
onPress={() =>
stackNavigate("EditExercise", { gymSet: defaultSet })
}
style={{ alignSelf: "flex-start" }}
>
Add some?
</Button>
</>
)}
{names !== undefined &&
names
.filter((name) => !exercises.includes(name))

View File

@ -85,8 +85,8 @@ android {
applicationId "com.massive"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 36223
versionName "2.8"
versionCode 36224
versionName "2.9"
}
signingConfigs {
release {

View File

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