Add graph button to start plan - 1.164 🚀

This commit is contained in:
Brandon Presley 2023-10-24 16:23:07 +13:00
parent ab107793e4
commit 805f982ccf
7 changed files with 23 additions and 11 deletions

View File

@ -66,7 +66,7 @@ export default function GraphsList() {
key={item.name}
title={item.name}
description={`${item.reps} x ${item.weight}${item.unit || "kg"}`}
onPress={() => navigation.navigate("ViewGraph", { best: item })}
onPress={() => navigation.navigate("ViewGraph", { name: item.name })}
left={() =>
(settings?.images && item.image && (
<Image

View File

@ -1,13 +1,12 @@
import { createStackNavigator } from "@react-navigation/stack";
import GraphsList from "./GraphsList";
import GymSet from "./gym-set";
import ViewGraph from "./ViewGraph";
const Stack = createStackNavigator<GraphsPageParams>();
export type GraphsPageParams = {
GraphsList: {};
ViewGraph: {
best: GymSet;
name: string;
};
};

View File

@ -10,7 +10,7 @@ import { FlatList, NativeModules, TextInput, View } from "react-native";
import { Button, IconButton, ProgressBar } from "react-native-paper";
import AppInput from "./AppInput";
import { getBestSet } from "./best.service";
import { MARGIN, PADDING } from "./constants";
import { PADDING } from "./constants";
import CountMany from "./count-many";
import { AppDataSource } from "./data-source";
import { getNow, setRepo, settingsRepo } from "./db";

View File

@ -6,6 +6,7 @@ import { Like } from "typeorm";
import CountMany from "./count-many";
import { getNow, setRepo } from "./db";
import { emitter } from "./emitter";
import { GraphsPageParams } from "./GraphsPage";
import { GYM_SET_DELETED } from "./gym-set";
import { HomePageParams } from "./home-page-params";
import { PlanPageParams } from "./plan-page-params";
@ -25,6 +26,8 @@ export default function StartPlanItem(props: Props) {
const { navigate } = useNavigation<NavigationProp<PlanPageParams>>();
const { navigate: navigateHome } =
useNavigation<NavigationProp<HomePageParams>>();
const { navigate: navigateGraph } =
useNavigation<NavigationProp<GraphsPageParams>>();
const undo = useCallback(async () => {
const now = await getNow();
@ -73,6 +76,11 @@ export default function StartPlanItem(props: Props) {
navigateHome("Sets", { search: item.name });
}, [item.name, navigateHome]);
const graph = useCallback(() => {
setShowMenu(false);
navigateGraph("ViewGraph", { name: item.name });
}, [item.name, navigateGraph]);
const left = useCallback(
() => (
<View style={{ alignItems: "center", justifyContent: "center" }}>
@ -101,12 +109,17 @@ export default function StartPlanItem(props: Props) {
onDismiss={() => setShowMenu(false)}
>
<Menu.Item leadingIcon="eye-outline" onPress={view} title="View" />
<Menu.Item
leadingIcon="chart-bell-curve-cumulative"
onPress={graph}
title="Graph"
/>
<Menu.Item leadingIcon="pencil" onPress={edit} title="Edit" />
<Menu.Item leadingIcon="undo" onPress={undo} title="Undo" />
</Menu>
</View>
),
[anchor, showMenu, edit, undo, view]
[anchor, showMenu, edit, undo, view, graph]
);
return (

View File

@ -34,7 +34,7 @@ export default function ViewGraph() {
.createQueryBuilder()
.select("STRFTIME('%Y-%m-%d', created)", "created")
.addSelect("unit")
.where("name = :name", { name: params.best.name })
.where("name = :name", { name: params.name })
.andWhere("NOT hidden")
.andWhere("DATE(created) >= DATE('now', 'weekday 0', :difference)", {
difference,
@ -67,7 +67,7 @@ export default function ViewGraph() {
setWeights(newWeights);
});
}
}, [params.best.name, metric, period]);
}, [params.name, metric, period]);
const charts = useMemo(() => {
if (
@ -108,7 +108,7 @@ export default function ViewGraph() {
return (
<>
<StackHeader title={params.best.name}>
<StackHeader title={params.name}>
<IconButton
onPress={() =>
captureScreen().then(async (uri) => {

View File

@ -85,8 +85,8 @@ android {
applicationId "com.massive"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 36189
versionName "1.163"
versionCode 36190
versionName "1.164"
}
signingConfigs {
release {

View File

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