Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@
"backgroundColor": "#fcfdf6",
"primaryColor": "#046F03",
"plugins": [
"expo-router",
[
"expo-router",
{
"headers": {
"Cross-Origin-Embedder-Policy": "credentialless",
"Cross-Origin-Opener-Policy": "same-origin"
}
}
],
[
"expo-dev-client",
{
Expand Down
14 changes: 13 additions & 1 deletion app/app/(tabs)/(session)/session/post-workout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ import FullHeightScrollView from '@/components/layout/full-height-scroll-view';
import FloatingBottomContainer from '@/components/presentation/foundation/floating-bottom-container';
import { SessionComparisonTable } from '@/components/presentation/workout/session-comparison-table';
import { spacing } from '@/hooks/useAppTheme';
import { useAppSelectorWithArg } from '@/store';
import { useAppSelector, useAppSelectorWithArg } from '@/store';
import {
finishCurrentWorkout,
selectCurrentSession,
} from '@/store/current-session';
import { selectPreferredWeightUnit } from '@/store/settings';
import {
selectPreviousComparableSession,
selectSessions,
selectSession,
} from '@/store/stored-sessions';
import { getSessionPersonalBestEntries } from '@/utils/personal-bests';
import { useTranslate } from '@tolgee/react';
import { Stack, useLocalSearchParams, useRouter } from 'expo-router';
import { useEffect } from 'react';
Expand All @@ -36,6 +39,8 @@ export default function PostWorkoutPage() {
const openedAfterFinishingWorkout = source === 'finished';
const showFinishButton = openedAfterFinishingWorkout;
const showBackButton = !openedAfterFinishingWorkout;
const sessions = useAppSelector(selectSessions);
const preferredUnit = useAppSelector(selectPreferredWeightUnit);
const previousComparableSession = useAppSelectorWithArg(
selectPreviousComparableSession,
session,
Expand All @@ -54,6 +59,12 @@ export default function PostWorkoutPage() {
return null;
}

const personalBestEntries = getSessionPersonalBestEntries(
sessions,
session,
preferredUnit,
);

const floatingBottomContainer = showFinishButton ? (
<FloatingBottomContainer
fab={
Expand Down Expand Up @@ -86,6 +97,7 @@ export default function PostWorkoutPage() {
<View style={{ marginVertical: spacing[4] }}>
<SessionComparisonTable
mode="full"
personalBestEntries={personalBestEntries}
previousSession={previousComparableSession}
session={session}
/>
Expand Down
19 changes: 5 additions & 14 deletions app/app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ export default function Layout() {
/>

<Tabs.Screen
name="stats"
name="progress"
options={{
tabBarLabel: t('stats.stats.title'),
tabBarButtonTestID: 'nav__stats',
tabBarLabel: t('progress.title'),
tabBarButtonTestID: 'nav__progress',
tabBarIcon: ({ color, size, focused }) => {
return (
<Icon
Expand All @@ -63,17 +63,8 @@ export default function Layout() {
},
}}
/>

<Tabs.Screen
name="history"
options={{
tabBarLabel: t('generic.history.title'),
tabBarButtonTestID: 'nav__history',
tabBarIcon: ({ color, size }) => {
return <Icon source={'history'} size={size} color={color} />;
},
}}
/>
<Tabs.Screen name="stats" options={{ href: null }} />
<Tabs.Screen name="history" options={{ href: null }} />

<Tabs.Screen
name="settings"
Expand Down
6 changes: 5 additions & 1 deletion app/app/(tabs)/feed/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
useScroll,
useScrollHeaderColor,
} from '@/hooks/useScrollListener';
import { spacing } from '@/hooks/useAppTheme';
import { useAppSelector } from '@/store';
import { selectFollowRequestCount } from '@/store/feed';
import { useTranslate } from '@tolgee/react';
Expand Down Expand Up @@ -38,7 +39,10 @@ export default function FeedIndexPage() {
<Stack.Screen options={{ title: t('feed.feed.title') }} />
<TabsProvider onChangeIndex={setActiveTabIndex}>
<Tabs
tabHeaderStyle={{ backgroundColor: headerColor }}
tabHeaderStyle={{
backgroundColor: headerColor,
marginBottom: spacing[1],
}}
style={{ backgroundColor: 'transparent' }}
>
<TabScreen label={t('feed.feed.title')}>
Expand Down
82 changes: 2 additions & 80 deletions app/app/(tabs)/history/edit.tsx
Original file line number Diff line number Diff line change
@@ -1,83 +1,5 @@
import SessionComponent from '@/components/smart/session-component';
import SessionMoreMenuComponent from '@/components/smart/session-more-menu-component';
import { spacing } from '@/hooks/useAppTheme';
import { useAppSelector, RootState } from '@/store';
import {
finishCurrentWorkout,
setActiveSessionDate,
} from '@/store/current-session';
import { LocalDate } from '@js-joda/core';
import { useRouter, Stack } from 'expo-router';
import { useEffect } from 'react';
import { View } from 'react-native';
import { DatePickerInput } from 'react-native-paper-dates';
import { useDispatch } from 'react-redux';
import { HistoryEditContent } from '@/components/presentation/data/history-edit-content';

export default function HistoryEditPage() {
const dispatch = useDispatch();
const session = useAppSelector(
(state: RootState) => state.currentSession.historySession,
);
const { dismissTo } = useRouter();

const save = () => {
dispatch(finishCurrentWorkout('historySession'));
};
useEffect(() => {
if (!session) {
dismissTo('/history');
}
}, [session, dismissTo]);
const showBodyweight = useAppSelector((x) => x.settings.showBodyweight);
const jsDate =
session &&
new Date(
session.date.year(),
session.date.month().ordinal(),
session.date.dayOfMonth(),
);

return (
<>
<Stack.Screen
options={{
title: session?.blueprint.name ?? 'Workout',
headerRight: () => (
<SessionMoreMenuComponent target="historySession" />
),
}}
/>
<View
style={{
paddingHorizontal: spacing.pageHorizontalMargin,
flexDirection: 'row',
}}
>
<DatePickerInput
testID="session-date-input"
locale="default"
inputMode="start"
onChange={(e) => {
if (e)
dispatch(
setActiveSessionDate({
target: 'historySession',
payload: LocalDate.of(
e.getFullYear(),
e.getMonth() + 1,
e.getDate(),
),
}),
);
}}
value={jsDate}
/>
</View>
<SessionComponent
target="historySession"
showBodyweight={showBodyweight}
saveAndClose={save}
/>
</>
);
return <HistoryEditContent emptyRoute="/history" />;
}
Loading