Skip to content

Commit

Permalink
structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert27 committed Jul 5, 2024
1 parent cc95f8e commit 464fef7
Show file tree
Hide file tree
Showing 9 changed files with 503 additions and 464 deletions.
218 changes: 112 additions & 106 deletions ios/NeulandNext.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions src/app/(food)/meal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ export default function FoodDetail(): JSX.Element {
title: variant.name[i18n.language as LanguageKey],
value:
(variant?.additional ? '+ ' : '') +
formatPrice(variant.prices[userKind]),
formatPrice(variant.prices[userKind ?? USER_GUEST]),
onPress: () => {
trackEvent('Share', {
type: 'mealVariant',
Expand All @@ -335,7 +335,9 @@ export default function FoodDetail(): JSX.Element {
meal: variant.name[
i18n.language as LanguageKey
],
price: formatPrice(variant.prices[userKind]),
price: formatPrice(
variant.prices[userKind ?? USER_GUEST]
),
location: restaurant,
id: variant?.id,
}),
Expand Down Expand Up @@ -398,7 +400,9 @@ export default function FoodDetail(): JSX.Element {
await Share.share({
message: t('details.share.message', {
meal: meal?.name[i18n.language as LanguageKey],
price: formatPrice(meal?.prices[userKind]),
price: formatPrice(
meal?.prices[userKind ?? USER_GUEST]
),
location: restaurant,
id: meal?.id,
}),
Expand Down
116 changes: 8 additions & 108 deletions src/app/(tabs)/(food)/food.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { MealDay } from '@/components/Elements/Food'
import { AllergensBanner } from '@/components/Elements/Food/AllergensBanner'
import { FoodHeaderRight } from '@/components/Elements/Food/HeaderRight'
import ErrorView from '@/components/Elements/Universal/ErrorView'
import PlatformIcon from '@/components/Elements/Universal/Icon'
import { type Colors } from '@/components/colors'
import { FoodFilterContext } from '@/components/contexts'
import { useRefreshByUser } from '@/hooks'
import { type Food } from '@/types/neuland-api'
import { networkError } from '@/utils/api-utils'
import { loadFoodEntries } from '@/utils/food-utils'
import { PAGE_BOTTOM_SAFE_AREA } from '@/utils/style-utils'
import { getContrastColor, showToast } from '@/utils/ui-utils'
import { showToast } from '@/utils/ui-utils'
import { useTheme } from '@react-navigation/native'
import { useQuery } from '@tanstack/react-query'
import * as Haptics from 'expo-haptics'
import { router, useNavigation } from 'expo-router'
import { useNavigation } from 'expo-router'
import Head from 'expo-router/head'
import React, {
useContext,
Expand All @@ -33,20 +33,15 @@ import {
ScrollView,
StyleSheet,
Text,
TouchableOpacity,
View,
} from 'react-native'
import PagerView from 'react-native-pager-view'

export function FoodScreen(): JSX.Element {
const colors = useTheme().colors as Colors
const [selectedDay, setSelectedDay] = useState<number>(0)
const {
selectedRestaurants,
showStatic,
allergenSelection,
initAllergenSelection,
} = useContext(FoodFilterContext)
const { selectedRestaurants, showStatic, allergenSelection } =
useContext(FoodFilterContext)
const [data, setData] = useState<Food[]>([])
const { t, i18n } = useTranslation('common')
const {
Expand Down Expand Up @@ -184,77 +179,6 @@ export function FoodScreen(): JSX.Element {
)
}

const AllergensBanner = (): JSX.Element => {
const contrastTextColor = getContrastColor(colors.primary)
return (
<Animated.View
style={{
...styles.paddingContainer,
borderBottomColor: colors.border,
borderBottomWidth: scrollY.interpolate({
inputRange: [0, 0, 0],
outputRange: [0, 0, 0.5],
extrapolate: 'clamp',
}),
}}
>
<View
style={{
backgroundColor: colors.primary,
...styles.bannerContainer,
}}
>
<TouchableOpacity
onPress={() => {
initAllergenSelection()
}}
hitSlop={6}
style={styles.dismissButton}
>
<PlatformIcon
ios={{
name: 'xmark',
size: 16,
}}
android={{
name: 'close',
size: 20,
}}
color={contrastTextColor}
/>
</TouchableOpacity>
<View>
<TouchableOpacity
onPress={() => {
router.push('(food)/allergens')
}}
>
<Text
style={{
color: contrastTextColor,
...styles.bannerTitle,
}}
>
{t('navigation.allergens', {
ns: 'navigation',
})}
</Text>

<Text
style={{
color: contrastTextColor,
...styles.bannerText,
}}
>
{t('empty.config', { ns: 'food' })}
</Text>
</TouchableOpacity>
</View>
</View>
</Animated.View>
)
}

const screenHeight = Dimensions.get('window').height
const scrollY = new Animated.Value(0)
const showAllergensBanner =
Expand Down Expand Up @@ -339,7 +263,9 @@ export function FoodScreen(): JSX.Element {
))}
</View>
</Animated.View>
{showAllergensBanner && <AllergensBanner />}
{showAllergensBanner && (
<AllergensBanner scrollY={scrollY} />
)}
<PagerView
ref={pagerViewRef}
style={{
Expand Down Expand Up @@ -467,32 +393,6 @@ const styles = StyleSheet.create({
justifyContent: 'space-evenly',
paddingVertical: 8,
},
bannerContainer: {
padding: 10,
borderRadius: 8,
marginTop: 2,
marginBottom: 10,
},
dismissButton: {
position: 'absolute',
zIndex: 1,
top: 5,
right: 5,
padding: 5,
borderRadius: 8,
},
bannerTitle: {
fontSize: 16,
fontWeight: 'bold',
},
bannerText: {
marginTop: 3,
fontSize: 14,
},
paddingContainer: {
paddingHorizontal: 12,
borderBottomWidth: 0.5,
},
innerScrollContainer: {
marginHorizontal: 12,
paddingBottom: PAGE_BOTTOM_SAFE_AREA,
Expand Down
Loading

0 comments on commit 464fef7

Please sign in to comment.