Skip to content

Commit 2d57a02

Browse files
committed
Use Expo example app on Expo 51
1 parent 8c5d768 commit 2d57a02

File tree

81 files changed

+3837
-10099
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+3837
-10099
lines changed
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
node_modules/
2+
.expo/
3+
dist/
4+
npm-debug.*
5+
*.jks
6+
*.p8
7+
*.p12
8+
*.key
9+
*.mobileprovision
10+
*.orig.*
11+
web-build/
12+
13+
ios/
14+
android/
15+
16+
# macOS
17+
.DS_Store
18+
19+
# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb
20+
# The following patterns were generated by expo-cli
21+
22+
expo-env.d.ts
23+
# @end expo-cli
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Welcome to your Expo app 👋
2+
3+
This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app).
4+
5+
## Get started
6+
7+
1. Install dependencies
8+
9+
```bash
10+
npm install
11+
```
12+
13+
2. Start the app
14+
15+
```bash
16+
npx expo start
17+
```
18+
19+
In the output, you'll find options to open the app in a
20+
21+
- [development build](https://docs.expo.dev/develop/development-builds/introduction/)
22+
- [Android emulator](https://docs.expo.dev/workflow/android-studio-emulator/)
23+
- [iOS simulator](https://docs.expo.dev/workflow/ios-simulator/)
24+
- [Expo Go](https://expo.dev/go), a limited sandbox for trying out app development with Expo
25+
26+
You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction).
27+
28+
## Get a fresh project
29+
30+
When you're ready, run:
31+
32+
```bash
33+
npm run reset-project
34+
```
35+
36+
This command will move the starter code to the **app-example** directory and create a blank **app** directory where you can start developing.
37+
38+
## Learn more
39+
40+
To learn more about developing your project with Expo, look at the following resources:
41+
42+
- [Expo documentation](https://docs.expo.dev/): Learn fundamentals, or go into advanced topics with our [guides](https://docs.expo.dev/guides).
43+
- [Learn Expo tutorial](https://docs.expo.dev/tutorial/introduction/): Follow a step-by-step tutorial where you'll create a project that runs on Android, iOS, and the web.
44+
45+
## Join the community
46+
47+
Join our community of developers creating universal apps.
48+
49+
- [Expo on GitHub](https://github.com/expo/expo): View our open source platform and contribute.
50+
- [Discord community](https://chat.expo.dev): Chat with Expo users and ask questions.
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"expo": {
3+
"name": "external-display-example",
4+
"slug": "external-display-example",
5+
"entryPoint": "./src/App.tsx",
6+
"version": "1.0.0",
7+
"orientation": "portrait",
8+
"scheme": "externaldisplay",
9+
"userInterfaceStyle": "automatic",
10+
"splash": {
11+
"resizeMode": "contain",
12+
"backgroundColor": "#ffffff"
13+
},
14+
"ios": {
15+
"supportsTablet": true,
16+
"bundleIdentifier": "com.externaldisplay"
17+
},
18+
"android": {
19+
"package": "com.externaldisplay",
20+
"adaptiveIcon": {
21+
"backgroundColor": "#ffffff"
22+
}
23+
},
24+
"experiments": {
25+
"typedRoutes": true
26+
}
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = function (api) {
2+
api.cache(true);
3+
return {
4+
presets: ['babel-preset-expo'],
5+
};
6+
};
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import { registerRootComponent } from 'expo'
6+
7+
import App from './src/App'
8+
9+
export default registerRootComponent(App)
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "external-display-example",
3+
"version": "1.0.0",
4+
"scripts": {
5+
"start": "expo start",
6+
"android": "expo run:android",
7+
"ios": "expo run:ios"
8+
},
9+
"main": "./index.tsx",
10+
"dependencies": {
11+
"expo": "~51.0.28",
12+
"expo-system-ui": "~3.0.7",
13+
"react": "18.2.0",
14+
"react-native": "0.74.5",
15+
"react-native-external-display": "0.6.7",
16+
"react-native-gesture-handler": "^2.20.0",
17+
"react-native-webview": "^13.12.3"
18+
},
19+
"devDependencies": {
20+
"@babel/core": "^7.20.0",
21+
"@types/react": "~18.2.45",
22+
"typescript": "~5.3.3"
23+
},
24+
"private": true
25+
}

packages/RNExternalDisplayExample/src/App.js apps/external-display-example/src/App.tsx

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useState } from 'react'
2+
23
import { View, Button } from 'react-native'
34
import { SceneManager } from 'react-native-external-display'
45

@@ -16,26 +17,32 @@ const exampleMap = {
1617
ScreenSize,
1718
ScrollView,
1819
WebView,
19-
}
20-
if (SceneManager.isAvailable()) {
21-
exampleMap.IPadMultipleScenes = IPadMultipleScenes
22-
exampleMap.Touch = Touch
20+
...(SceneManager.isAvailable()
21+
? {
22+
IPadMultipleScenes,
23+
Touch,
24+
}
25+
: {}),
2326
}
2427

2528
function App() {
26-
const [page, setPage] = useState(null)
29+
const [page, setPage] = useState<keyof typeof exampleMap | null>(null)
2730

28-
const Example = exampleMap[page]
31+
if (page) {
32+
const Component = exampleMap[page]
2933

30-
if (Example) {
31-
return <Example onBack={() => setPage(null)} />
34+
if (Component) {
35+
return <Component onBack={() => setPage(null)} />
36+
}
3237
}
3338

39+
const keys = Object.keys(exampleMap) as Array<keyof typeof exampleMap>
40+
3441
return (
3542
<View
3643
style={{ flex: 1, backgroundColor: 'black', justifyContent: 'center' }}
3744
>
38-
{Object.keys(exampleMap).map((key) => (
45+
{keys.map((key) => (
3946
<Button key={key} title={key} onPress={() => setPage(key)} />
4047
))}
4148
</View>

packages/RNExternalDisplayExample/src/IPadMultipleScenes.js apps/external-display-example/src/IPadMultipleScenes.tsx

+7-14
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,20 @@ const InScreen = () => {
2020
}}
2121
>
2222
<Text style={{ color: 'red', fontSize: 28, textAlign: 'center' }}>
23-
ID:
24-
{' '}
25-
{id || '(Main)'}
23+
ID: {id || '(Main)'}
2624
</Text>
2725
<Text style={{ color: 'red', fontSize: 28, textAlign: 'center' }}>
28-
Width:
29-
{' '}
30-
{width || '(Main)'}
26+
Width: {width || '(Main)'}
3127
</Text>
3228
<Text style={{ color: 'red', fontSize: 28, textAlign: 'center' }}>
33-
Height:
34-
{' '}
35-
{height || '(Main)'}
29+
Height: {height || '(Main)'}
3630
</Text>
3731
</View>
3832
)
3933
}
4034

4135
type Props = {
42-
onBack: () => void,
36+
onBack: () => void
4337
}
4438

4539
export default function Example(props: Props) {
@@ -56,7 +50,7 @@ export default function Example(props: Props) {
5650
}}
5751
>
5852
<View style={{ flex: 1 }}>
59-
{mount && (
53+
{mount &&
6054
Object.keys(info).map((id) => (
6155
<ExternalDisplay
6256
key={id}
@@ -65,10 +59,9 @@ export default function Example(props: Props) {
6559
>
6660
<InScreen />
6761
</ExternalDisplay>
68-
))
69-
)}
62+
))}
7063
</View>
71-
<ScreenControl
64+
<ScreenControl
7265
on={on}
7366
mount={mount}
7467
onSelectScreen={() => {}}

packages/RNExternalDisplayExample/src/Modal.js apps/external-display-example/src/Modal.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import ExternalDisplay, { getScreens } from 'react-native-external-display'
66
import ScreenControl from './utils/ScreenControl'
77

88
type Props = {
9-
onBack: () => void,
9+
onBack: () => void
1010
}
1111

1212
export default function Example(props: Props) {
@@ -16,9 +16,9 @@ export default function Example(props: Props) {
1616
const [on, setOn] = useState(true)
1717
const [mount, setMount] = useState(true)
1818
const [open, setOpen] = useState(true)
19-
const [screen, setScreen] = useState(null)
19+
const [screen, setScreen] = useState<string | null>(null)
2020
useEffect(() => {
21-
const interval = setInterval(() => setT(d => d + 1), 1000)
21+
const interval = setInterval(() => setT((d) => d + 1), 1000)
2222
return () => clearInterval(interval)
2323
}, [])
2424
return (
@@ -59,10 +59,10 @@ export default function Example(props: Props) {
5959
)}
6060
</View>
6161
<Button
62-
onPress={() => setOpen(d => !d)}
62+
onPress={() => setOpen((d) => !d)}
6363
title={open ? 'Close' : 'Open'}
6464
/>
65-
<ScreenControl
65+
<ScreenControl
6666
on={on}
6767
mount={mount}
6868
onSelectScreen={setScreen}

packages/RNExternalDisplayExample/src/ScreenSize.js apps/external-display-example/src/ScreenSize.tsx

+6-12
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,28 @@ const InScreen = () => {
2020
}}
2121
>
2222
<Text style={{ color: 'red', fontSize: 28, textAlign: 'center' }}>
23-
ID:
24-
{' '}
25-
{id || '(Main)'}
23+
ID: {id || '(Main)'}
2624
</Text>
2725
<Text style={{ color: 'red', fontSize: 28, textAlign: 'center' }}>
28-
Width:
29-
{' '}
30-
{width || '(Main)'}
26+
Width: {width || '(Main)'}
3127
</Text>
3228
<Text style={{ color: 'red', fontSize: 28, textAlign: 'center' }}>
33-
Height:
34-
{' '}
35-
{height || '(Main)'}
29+
Height: {height || '(Main)'}
3630
</Text>
3731
</View>
3832
)
3933
}
4034

4135
type Props = {
42-
onBack: () => void,
36+
onBack: () => void
4337
}
4438

4539
export default function Example(props: Props) {
4640
const { onBack } = props
4741
const info = useExternalDisplay()
4842
const [on, setOn] = useState(true)
4943
const [mount, setMount] = useState(true)
50-
const [screen, setScreen] = useState(null)
44+
const [screen, setScreen] = useState<string | null>(null)
5145
return (
5246
<SafeAreaView
5347
style={{
@@ -66,7 +60,7 @@ export default function Example(props: Props) {
6660
</ExternalDisplay>
6761
)}
6862
</View>
69-
<ScreenControl
63+
<ScreenControl
7064
on={on}
7165
mount={mount}
7266
onSelectScreen={setScreen}

0 commit comments

Comments
 (0)