Skip to content
Open
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
53 changes: 46 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"buffer": "^6.0.3",
"expo": "^47.0.0",
"expo-constants": "~14.0.2",
"expo-dev-client": "~2.0.1",
"expo-file-system": "~15.1.1",
"expo-image-picker": "~14.0.2",
"expo-keep-awake": "~11.0.1",
Expand All @@ -50,9 +51,11 @@
"react-icons": "^4.3.1",
"react-native": "0.70.5",
"react-native-cache": "^2.0.2",
"react-native-drax": "^0.10.3",
"react-native-gesture-handler": "~2.8.0",
"react-native-pager-view": "5.4.15",
"react-native-paper": "^4.11.1",
"react-native-reanimated": "^2.13.0",
"react-native-safe-area-context": "4.4.1",
"react-native-screens": "~3.18.0",
"react-native-vector-icons": "^9.1.0",
Expand All @@ -62,8 +65,7 @@
"react-spacer": "^1.3.0",
"recyclerlistview": "^4.2.0",
"swiper": "^8.0.7",
"xdate": "^0.8.2",
"expo-dev-client": "~2.0.1"
"xdate": "^0.8.2"
},
"devDependencies": {
"@babel/core": "^7.19.3",
Expand Down
5 changes: 3 additions & 2 deletions src/screens/weeklyrecipelist/WeeklyRecipeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ export const WeeklyRecipeCard = (props: Props) => {
<View style={styles.borderCard}>
<Pressable
style={styles.card}
onLongPress={() => setEditMode(!editMode)}
onPress={props.onPress}>
// onLongPress={() => setEditMode(!editMode)}
// onPress={props.on Press}
>
{props.imageUuid && <View style={{height: 80, borderRadius: 16, overflow: 'hidden'}}>
<RecipeImageComponent
useThumbnail={true}
Expand Down
122 changes: 75 additions & 47 deletions src/screens/weeklyrecipelist/WeeklyRecipeListScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {StackScreenProps} from '@react-navigation/stack';
import React, {useEffect, useState} from 'react';
import {useTranslation} from 'react-i18next';
import {StyleSheet, View} from 'react-native';
import {ScrollView} from 'react-native-gesture-handler';
import {GestureHandlerRootView, LongPressGestureHandler, ScrollView} from 'react-native-gesture-handler';
import {Divider, IconButton, Subheading, Surface, Text} from 'react-native-paper';
import {useDispatch} from 'react-redux';
import XDate from 'xdate';
Expand All @@ -18,7 +18,8 @@ import {useAppSelector} from '../../redux/hooks';
import CentralStyles from '../../styles/CentralStyles';
import {RecipeSelectionPopup} from './RecipeSelectionPopup';
import {WeeklyRecipeCard} from './WeeklyRecipeCard';

import {DraxProvider, DraxScrollView, DraxView} from 'react-native-drax';
import {Platform} from 'react-native';

type Props =
CompositeScreenProps<
Expand Down Expand Up @@ -94,60 +95,87 @@ export const WeeklyRecipeListScreen = (props: Props) => {
weekdayDate.setDate(weekdayDate.getDate() + weekdayIndex);
const existingWeekplanDay = weekplanDays.filter((weekplanDay) => weekplanDay.day === weekdayDate.toString(dateFormat))[0];
return (
<CustomCard key={weekdayIndex} style={{marginVertical: 5}}>
<View style={{flexDirection: 'row', justifyContent: 'space-between'}}>
<Text style={styles.weekTitle}>{weekday} {weekdayDate.toLocaleDateString()}</Text>
<IconButton
icon="plus-circle-outline"
onPress={() => {
setRecipeSelectionVisible(true);
setSelectedWeekplanDay(existingWeekplanDay ? existingWeekplanDay : {day: weekdayDate.toString(dateFormat), recipes: []});
}
} />
</View>
<SideScroller>
{weekplanDays.filter((weekplanDay) => weekplanDay.day === weekdayDate.toString(dateFormat)).map((weekplanDay) => (
weekplanDay.recipes.map((recipe, index) => {
if (recipe.type === 'NORMAL_RECIPE') {
return <WeeklyRecipeCard
key={weekplanDay.day + index}
// @ts-ignore
onPress={() => openRecipe(recipe.id)}
onRemovePress={() => removeRecipeFromWeekplanDay(index, weekplanDay)}
title={recipe.title}
imageUuid={recipe.titleImageUuid} />;
} else if (recipe.type === 'SIMPLE_RECIPE') {
return <WeeklyRecipeCard
key={weekplanDay.day + index}
// @ts-ignore
onRemovePress={() => removeRecipeFromWeekplanDay(recipe.id, weekplanDay)}
title={recipe.title} />;
<DraxView
key={weekdayIndex}
draggable={false}
onReceiveDragDrop={({dragged: {payload}}) => {
console.log(`received ${payload}`);
}}>
<CustomCard style={{marginVertical: 5}}>
<View style={{flexDirection: 'row', justifyContent: 'space-between'}}>
<Text style={styles.weekTitle}>{weekday} {weekdayDate.toLocaleDateString()}</Text>
<IconButton
icon="plus-circle-outline"
onPress={() => {
setRecipeSelectionVisible(true);
setSelectedWeekplanDay(existingWeekplanDay ? existingWeekplanDay : {day: weekdayDate.toString(dateFormat), recipes: []});
}
})
))}
</SideScroller>
</CustomCard>
} />
</View>
<SideScroller>
{weekplanDays.filter((weekplanDay) => weekplanDay.day === weekdayDate.toString(dateFormat)).map((weekplanDay) => (
weekplanDay.recipes.map((recipe, index) => {
if (recipe.type === 'NORMAL_RECIPE') {
return (
<DraxView key={weekplanDay.day + index}
onDragStart={() => {
console.log('start drag');
}}
draggable={true}
dragPayload="world">
<WeeklyRecipeCard
// @ts-ignore
onPress={() => openRecipe(recipe.id)}
onRemovePress={() => removeRecipeFromWeekplanDay(index, weekplanDay)}
title={recipe.title}
imageUuid={recipe.titleImageUuid} />
</DraxView>
);
} else if (recipe.type === 'SIMPLE_RECIPE') {
return <WeeklyRecipeCard
key={weekplanDay.day + index}
// @ts-ignore
onRemovePress={() => removeRecipeFromWeekplanDay(recipe.id, weekplanDay)}
title={recipe.title} />;
}
})
))}
</SideScroller>
</CustomCard>
</DraxView>
);
});
};

const wrapGuestureHandlerIfNeeded = (children: React.Element) => {
/* Needed to make drax work on android */
if (Platform.OS === 'web') {
return <ScrollView
contentContainerStyle={CentralStyles.contentContainer}>{children}</ScrollView>;
} else {
return <GestureHandlerRootView><DraxScrollView
contentContainerStyle={CentralStyles.contentContainer}>{children}</DraxScrollView></GestureHandlerRootView>;
}
};

return (
<>
<ChunkView>
<Surface style={CentralStyles.fullscreen}>
<ScrollView contentContainerStyle={CentralStyles.contentContainer}>
<Subheading>{t('screens.weekplan.currentWeek')}</Subheading>
{renderWeek(getCurrentWeekNumber(now), now.getFullYear())}
<Divider style={{marginVertical: 25}}/>
<Subheading>{t('screens.weekplan.nextWeek')}</Subheading>
{renderWeek(getCurrentWeekNumber(now) + 1, now.getFullYear())}
<Divider style={{marginVertical: 25}}/>
<Subheading>{t('screens.weekplan.week')} {getCurrentWeekNumber(now) + 2}</Subheading>
{renderWeek(getCurrentWeekNumber(now) + 2, now.getFullYear())}
<Divider style={{marginVertical: 25}}/>
<Subheading>{t('screens.weekplan.week')} {getCurrentWeekNumber(now) + 3}</Subheading>
{renderWeek(getCurrentWeekNumber(now) + 3, now.getFullYear())}
</ScrollView>
<DraxProvider>
{wrapGuestureHandlerIfNeeded(<>
<Subheading>{t('screens.weekplan.currentWeek')}</Subheading>
{renderWeek(getCurrentWeekNumber(now), now.getFullYear())}
<Divider style={{marginVertical: 25}}/>
<Subheading>{t('screens.weekplan.nextWeek')}</Subheading>
{renderWeek(getCurrentWeekNumber(now) + 1, now.getFullYear())}
<Divider style={{marginVertical: 25}}/>
<Subheading>{t('screens.weekplan.week')} {getCurrentWeekNumber(now) + 2}</Subheading>
{renderWeek(getCurrentWeekNumber(now) + 2, now.getFullYear())}
<Divider style={{marginVertical: 25}}/>
<Subheading>{t('screens.weekplan.week')} {getCurrentWeekNumber(now) + 3}</Subheading>
{renderWeek(getCurrentWeekNumber(now) + 3, now.getFullYear())}</>)}
</DraxProvider>
</Surface>
</ChunkView>

Expand Down