Skip to content

Commit

Permalink
refactor: upgrade to Expo SDK 52 (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
byCedric authored Nov 13, 2024
1 parent 9d65cac commit 2ea98af
Show file tree
Hide file tree
Showing 29 changed files with 367 additions and 132 deletions.
3 changes: 1 addition & 2 deletions apps/example/.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
EXPO_USE_FAST_RESOLVER=true
EXPO_USE_METRO_WORKSPACE_ROOT=true
EXPO_UNSTABLE_ATLAS=true
EXPO_USE_FAST_RESOLVER=true
38 changes: 35 additions & 3 deletions apps/example/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files

# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb
# The following patterns were generated by expo-cli
# dependencies
node_modules/

# Expo
.expo/
dist/
web-build/
expo-env.d.ts
# @end expo-cli

# Native
*.orig.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision

# Metro
.metro-health-check*

# debug
npm-debug.*
yarn-debug.*
yarn-error.*

# macOS
.DS_Store
*.pem

# local env files
.env*.local

# typescript
*.tsbuildinfo

app-example
14 changes: 12 additions & 2 deletions apps/example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ This is an [Expo](https://expo.dev) project created with [`create-expo-app`](htt
1. Install dependencies

```bash
bun install
npm install
```

2. Start the app

```bash
bun expo start
npx expo start
```

In the output, you'll find options to open the app in a
Expand All @@ -25,6 +25,16 @@ In the output, you'll find options to open the app in a

You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction).

## Get a fresh project

When you're ready, run:

```bash
npm run reset-project
```

This command will move the starter code to the **app-example** directory and create a blank **app** directory where you can start developing.

## Learn more

To learn more about developing your project with Expo, look at the following resources:
Expand Down
17 changes: 11 additions & 6 deletions apps/example/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
"icon": "./assets/images/icon.png",
"scheme": "myapp",
"userInterfaceStyle": "automatic",
"splash": {
"image": "./assets/images/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"newArchEnabled": true,
"ios": {
"supportsTablet": true
},
Expand All @@ -27,7 +23,16 @@
"favicon": "./assets/images/favicon.png"
},
"plugins": [
"expo-router"
"expo-router",
[
"expo-splash-screen",
{
"image": "./assets/images/splash-icon.png",
"imageWidth": 200,
"resizeMode": "contain",
"backgroundColor": "#ffffff"
}
]
],
"experiments": {
"typedRoutes": true
Expand Down
22 changes: 15 additions & 7 deletions apps/example/app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Tabs } from 'expo-router';
import React from 'react';
import { Platform } from 'react-native';

import { TabBarIcon } from '@/components/navigation/TabBarIcon';
import { HapticTab } from '@/components/HapticTab';
import { IconSymbol } from '@/components/ui/IconSymbol';
import TabBarBackground from '@/components/ui/TabBarBackground';
import { Colors } from '@/constants/Colors';
import { useColorScheme } from '@/hooks/useColorScheme';

Expand All @@ -13,23 +16,28 @@ export default function TabLayout() {
screenOptions={{
tabBarActiveTintColor: Colors[colorScheme ?? 'light'].tint,
headerShown: false,
tabBarButton: HapticTab,
tabBarBackground: TabBarBackground,
tabBarStyle: Platform.select({
ios: {
// Use a transparent background on iOS to show the blur effect
position: 'absolute',
},
default: {},
}),
}}>
<Tabs.Screen
name="index"
options={{
title: 'Home',
tabBarIcon: ({ color, focused }) => (
<TabBarIcon name={focused ? 'home' : 'home-outline'} color={color} />
),
tabBarIcon: ({ color }) => <IconSymbol size={28} name="house.fill" color={color} />,
}}
/>
<Tabs.Screen
name="explore"
options={{
title: 'Explore',
tabBarIcon: ({ color, focused }) => (
<TabBarIcon name={focused ? 'code-slash' : 'code-slash-outline'} color={color} />
),
tabBarIcon: ({ color }) => <IconSymbol size={28} name="paperplane.fill" color={color} />,
}}
/>
</Tabs>
Expand Down
15 changes: 11 additions & 4 deletions apps/example/app/(tabs)/explore.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import Ionicons from '@expo/vector-icons/Ionicons';
import { StyleSheet, Image, Platform } from 'react-native';

import { Collapsible } from '@/components/Collapsible';
import { ExternalLink } from '@/components/ExternalLink';
import ParallaxScrollView from '@/components/ParallaxScrollView';
import { ThemedText } from '@/components/ThemedText';
import { ThemedView } from '@/components/ThemedView';
import { IconSymbol } from '@/components/ui/IconSymbol';

export default function TabTwoScreen() {
return (
<ParallaxScrollView
headerBackgroundColor={{ light: '#D0D0D0', dark: '#353636' }}
headerImage={<Ionicons size={310} name="code-slash" style={styles.headerImage} />}>
headerImage={
<IconSymbol
size={310}
color="#808080"
name="chevron.left.forwardslash.chevron.right"
style={styles.headerImage}
/>
}>
<ThemedView style={styles.titleContainer}>
<ThemedText type="title">Explore</ThemedText>
</ThemedView>
Expand Down Expand Up @@ -72,8 +79,8 @@ export default function TabTwoScreen() {
<ThemedText>
This template includes an example of an animated component. The{' '}
<ThemedText type="defaultSemiBold">components/HelloWave.tsx</ThemedText> component uses
the powerful <ThemedText type="defaultSemiBold">react-native-reanimated</ThemedText> library
to create a waving hand animation.
the powerful <ThemedText type="defaultSemiBold">react-native-reanimated</ThemedText>{' '}
library to create a waving hand animation.
</ThemedText>
{Platform.select({
ios: (
Expand Down
6 changes: 5 additions & 1 deletion apps/example/app/(tabs)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ export default function HomeScreen() {
Edit <ThemedText type="defaultSemiBold">app/(tabs)/index.tsx</ThemedText> to see changes.
Press{' '}
<ThemedText type="defaultSemiBold">
{Platform.select({ ios: 'cmd + d', android: 'cmd + m' })}
{Platform.select({
ios: 'cmd + d',
android: 'cmd + m',
web: 'F12'
})}
</ThemedText>{' '}
to open developer tools.
</ThemedText>
Expand Down
39 changes: 0 additions & 39 deletions apps/example/app/+html.tsx

This file was deleted.

2 changes: 2 additions & 0 deletions apps/example/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native
import { useFonts } from 'expo-font';
import { Stack } from 'expo-router';
import * as SplashScreen from 'expo-splash-screen';
import { StatusBar } from 'expo-status-bar';
import { useEffect } from 'react';
import 'react-native-reanimated';

Expand Down Expand Up @@ -32,6 +33,7 @@ export default function RootLayout() {
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
<Stack.Screen name="+not-found" />
</Stack>
<StatusBar style="auto" />
</ThemeProvider>
);
}
Binary file added apps/example/assets/images/splash-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed apps/example/assets/images/splash.png
Binary file not shown.
6 changes: 0 additions & 6 deletions apps/example/babel.config.js

This file was deleted.

9 changes: 6 additions & 3 deletions apps/example/components/Collapsible.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Ionicons from '@expo/vector-icons/Ionicons';
import { PropsWithChildren, useState } from 'react';
import { StyleSheet, TouchableOpacity, useColorScheme } from 'react-native';

import { ThemedText } from '@/components/ThemedText';
import { ThemedView } from '@/components/ThemedView';
import { IconSymbol } from '@/components/ui/IconSymbol';
import { Colors } from '@/constants/Colors';

export function Collapsible({ children, title }: PropsWithChildren & { title: string }) {
Expand All @@ -16,11 +16,14 @@ export function Collapsible({ children, title }: PropsWithChildren & { title: st
style={styles.heading}
onPress={() => setIsOpen((value) => !value)}
activeOpacity={0.8}>
<Ionicons
name={isOpen ? 'chevron-down' : 'chevron-forward-outline'}
<IconSymbol
name="chevron.right"
size={18}
weight="medium"
color={theme === 'light' ? Colors.light.icon : Colors.dark.icon}
style={{ transform: [{ rotate: isOpen ? '90deg' : '0deg' }] }}
/>

<ThemedText type="defaultSemiBold">{title}</ThemedText>
</TouchableOpacity>
{isOpen && <ThemedView style={styles.content}>{children}</ThemedView>}
Expand Down
18 changes: 18 additions & 0 deletions apps/example/components/HapticTab.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { BottomTabBarButtonProps } from '@react-navigation/bottom-tabs';
import { PlatformPressable } from '@react-navigation/elements';
import * as Haptics from 'expo-haptics';

export function HapticTab(props: BottomTabBarButtonProps) {
return (
<PlatformPressable
{...props}
onPressIn={(ev) => {
if (process.env.EXPO_OS === 'ios') {
// Add a soft haptic feedback when pressing down on the tabs.
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
}
props.onPressIn?.(ev);
}}
/>
);
}
11 changes: 8 additions & 3 deletions apps/example/components/ParallaxScrollView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Animated, {
} from 'react-native-reanimated';

import { ThemedView } from '@/components/ThemedView';
import { useBottomTabOverflow } from '@/components/ui/TabBarBackground';

const HEADER_HEIGHT = 250;

Expand All @@ -24,7 +25,7 @@ export default function ParallaxScrollView({
const colorScheme = useColorScheme() ?? 'light';
const scrollRef = useAnimatedRef<Animated.ScrollView>();
const scrollOffset = useScrollViewOffset(scrollRef);

const bottom = useBottomTabOverflow();
const headerAnimatedStyle = useAnimatedStyle(() => {
return {
transform: [
Expand All @@ -44,7 +45,11 @@ export default function ParallaxScrollView({

return (
<ThemedView style={styles.container}>
<Animated.ScrollView ref={scrollRef} scrollEventThrottle={16}>
<Animated.ScrollView
ref={scrollRef}
scrollEventThrottle={16}
scrollIndicatorInsets={{ bottom }}
contentContainerStyle={{ paddingBottom: bottom }}>
<Animated.View
style={[
styles.header,
Expand All @@ -64,7 +69,7 @@ const styles = StyleSheet.create({
flex: 1,
},
header: {
height: 250,
height: HEADER_HEIGHT,
overflow: 'hidden',
},
content: {
Expand Down
9 changes: 0 additions & 9 deletions apps/example/components/navigation/TabBarIcon.tsx

This file was deleted.

Loading

0 comments on commit 2ea98af

Please sign in to comment.