From 5b066bccafe5f74344fa22be8cabce9ef436dc6b Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Sun, 18 Feb 2024 01:52:21 +1300 Subject: [PATCH] =?UTF-8?q?Add=20daily=20page=20-=202.26=20=F0=9F=9A=80=20?= =?UTF-8?q?The=20daily=20page=20is=20used=20to=20flip=20through=20your=20e?= =?UTF-8?q?xercises=20by=20day.=20This=20is=20in=20contrast=20to=20the=20H?= =?UTF-8?q?istory=20page,=20which=20is=20an=20infinitely=20scrolling=20lis?= =?UTF-8?q?t=20of=20all=20sets.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #216, #207 --- AppDrawer.tsx | 8 ++- Daily.tsx | 104 +++++++++++++++++++++++++++++++++++++++ SettingsPage.tsx | 3 +- android/app/build.gradle | 4 +- drawer-params.ts | 1 + package.json | 2 +- 6 files changed, 117 insertions(+), 5 deletions(-) create mode 100644 Daily.tsx diff --git a/AppDrawer.tsx b/AppDrawer.tsx index 5c63e34..c2cc15f 100644 --- a/AppDrawer.tsx +++ b/AppDrawer.tsx @@ -9,6 +9,7 @@ import PlanList from "./PlanList"; import SetList from "./SetList"; import SettingsPage from "./SettingsPage"; import WeightList from "./WeightList"; +import Daily from "./Daily"; const Drawer = createDrawerNavigator(); @@ -42,10 +43,15 @@ export default function AppDrawer({ component={ExerciseList} options={{ drawerIcon: () => }} /> + }} + /> }} + options={{ drawerIcon: () => }} /> (); + const [day, setDay] = useState() + const [settings, setSettings] = useState(); + const navigation = useNavigation>(); + + const onFocus = async () => { + const now = await getNow(); + let created = now.split('T')[0]; + setDay(new Date(created)); + } + + useEffect(() => { + (async () => { + if (!day) return + const created = day.toISOString().split('T')[0] + const newSets = await setRepo.find({ + where: { hidden: 0 as any, created: Like(`${created}%`) }, + take: LIMIT, + skip: 0, + order: { created: "DESC" }, + }); + setSets(newSets); + console.log(`${Daily.name}.useEffect:`, { day }); + settingsRepo.findOne({ where: {} }).then(setSettings) + })() + }, [day]) + + useFocusEffect(useCallback(() => { + onFocus(); + }, [])) + + const onAdd = async () => { + const now = await getNow(); + let set: Partial = { ...sets[0] }; + if (!set) set = { ...defaultSet }; + set.created = now; + delete set.id; + navigation.navigate("EditSet", { set }); + + } + + const onRight = () => { + const newDay = new Date(day) + newDay.setDate(newDay.getDate() + 1) + setDay(newDay) + } + + const onLeft = () => { + const newDay = new Date(day) + newDay.setDate(newDay.getDate() - 1) + setDay(newDay) + } + + const onDate = () => { + DateTimePickerAndroid.open({ + value: new Date(day), + onChange: (event, date) => { + if (event.type === 'dismissed') return; + setDay(date) + }, + mode: 'date', + }) + } + + return ( + <> + + + + + + + + + + + {settings && ( + } style={{ flex: 1 }} data={sets} renderItem={({ item }) => { }} item={item} settings={settings} />} /> + )} + + + + + + + ) +} \ No newline at end of file diff --git a/SettingsPage.tsx b/SettingsPage.tsx index fe8dd57..2501508 100644 --- a/SettingsPage.tsx +++ b/SettingsPage.tsx @@ -139,7 +139,8 @@ export default function SettingsPage() { items={[ { label: "History", value: "History", icon: 'history' }, { label: "Exercises", value: "Exercises", icon: 'dumbbell' }, - { label: "Plans", value: "Plans", icon: 'calendar-outline' }, + { label: "Daily", value: "Daily", icon: 'calendar-outline' }, + { label: "Plans", value: "Plans", icon: 'checkbox-multiple-marked-outline' }, { label: "Graphs", value: "Graphs", icon: 'chart-bell-curve-cumulative' }, { label: "Timer", value: "Timer", icon: 'timer-outline' }, { label: "Weight", value: "Weight", icon: 'scale-bathroom' }, diff --git a/android/app/build.gradle b/android/app/build.gradle index 06b1a5b..c5cc359 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -87,8 +87,8 @@ android { applicationId "com.massive" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 36240 - versionName "2.25" + versionCode 36241 + versionName "2.26" } signingConfigs { release { diff --git a/drawer-params.ts b/drawer-params.ts index 390133f..2178af4 100644 --- a/drawer-params.ts +++ b/drawer-params.ts @@ -7,4 +7,5 @@ export type DrawerParams = { Weight: {}; Insights: {}; Settings: {}; + Daily: {}; }; diff --git a/package.json b/package.json index 9bdf509..65ed9eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "massive", - "version": "2.25", + "version": "2.26", "private": true, "license": "GPL-3.0-only", "scripts": {