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} key={item.name}
title={item.name} title={item.name}
description={`${item.reps} x ${item.weight}${item.unit || "kg"}`} description={`${item.reps} x ${item.weight}${item.unit || "kg"}`}
onPress={() => navigation.navigate("ViewGraph", { best: item })} onPress={() => navigation.navigate("ViewGraph", { name: item.name })}
left={() => left={() =>
(settings?.images && item.image && ( (settings?.images && item.image && (
<Image <Image

View File

@ -1,13 +1,12 @@
import { createStackNavigator } from "@react-navigation/stack"; import { createStackNavigator } from "@react-navigation/stack";
import GraphsList from "./GraphsList"; import GraphsList from "./GraphsList";
import GymSet from "./gym-set";
import ViewGraph from "./ViewGraph"; import ViewGraph from "./ViewGraph";
const Stack = createStackNavigator<GraphsPageParams>(); const Stack = createStackNavigator<GraphsPageParams>();
export type GraphsPageParams = { export type GraphsPageParams = {
GraphsList: {}; GraphsList: {};
ViewGraph: { 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 { Button, IconButton, ProgressBar } from "react-native-paper";
import AppInput from "./AppInput"; import AppInput from "./AppInput";
import { getBestSet } from "./best.service"; import { getBestSet } from "./best.service";
import { MARGIN, PADDING } from "./constants"; import { PADDING } from "./constants";
import CountMany from "./count-many"; import CountMany from "./count-many";
import { AppDataSource } from "./data-source"; import { AppDataSource } from "./data-source";
import { getNow, setRepo, settingsRepo } from "./db"; import { getNow, setRepo, settingsRepo } from "./db";

View File

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

View File

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

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 36189 versionCode 36190
versionName "1.163" versionName "1.164"
} }
signingConfigs { signingConfigs {
release { release {

View File

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