From 5189711942f9fcdec4ccd2c31a97a63ffdacb76a Mon Sep 17 00:00:00 2001 From: Stuart Lynch Date: Sun, 13 Oct 2024 19:06:59 +0100 Subject: [PATCH 01/13] Use Expo example app on Expo 51 --- apps/external-display-example/.gitignore | 23 + apps/external-display-example/README.md | 50 + apps/external-display-example/app.json | 28 + apps/external-display-example/babel.config.js | 6 + apps/external-display-example/index.tsx | 9 + apps/external-display-example/package.json | 25 + .../external-display-example/src/App.tsx | 25 +- .../src/IPadMultipleScenes.tsx | 21 +- .../external-display-example/src/Modal.tsx | 10 +- .../src/ScreenSize.tsx | 18 +- .../src/ScrollView.tsx | 57 +- .../src/SimpleTextInterval.tsx | 6 +- .../external-display-example/src/Touch.tsx | 4 +- .../external-display-example/src/WebView.tsx | 0 .../src/utils/SceneManager.tsx | 7 +- .../src/utils/ScreenControl.tsx | 18 +- apps/external-display-example/tsconfig.json | 17 + package.json | 26 +- .../package.json | 2 +- packages/RNExternalDisplayExample/.gitignore | 63 - .../RNExternalDisplayExample/.watchmanconfig | 1 - .../RNExternalDisplayExample/CHANGELOG.md | 370 - packages/RNExternalDisplayExample/README.md | 22 - .../android/app/build.gradle | 170 - .../android/app/debug.keystore | Bin 2257 -> 0 bytes .../android/app/proguard-rules.pro | 10 - .../android/app/src/debug/AndroidManifest.xml | 13 - .../ReactNativeFlipper.java | 75 - .../android/app/src/main/AndroidManifest.xml | 25 - .../MainActivity.java | 35 - .../MainApplication.java | 62 - .../res/drawable/rn_edit_text_material.xml | 36 - .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 3056 -> 0 bytes .../res/mipmap-hdpi/ic_launcher_round.png | Bin 5024 -> 0 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 2096 -> 0 bytes .../res/mipmap-mdpi/ic_launcher_round.png | Bin 2858 -> 0 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 4569 -> 0 bytes .../res/mipmap-xhdpi/ic_launcher_round.png | Bin 7098 -> 0 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 6464 -> 0 bytes .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin 10676 -> 0 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 9250 -> 0 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 15523 -> 0 bytes .../app/src/main/res/values/strings.xml | 3 - .../app/src/main/res/values/styles.xml | 9 - .../ReactNativeFlipper.java | 20 - .../android/build.gradle | 21 - .../android/gradle.properties | 44 - .../android/gradle/wrapper/gradle-wrapper.jar | Bin 59821 -> 0 bytes .../gradle/wrapper/gradle-wrapper.properties | 5 - .../RNExternalDisplayExample/android/gradlew | 234 - .../android/gradlew.bat | 89 - .../android/settings.gradle | 4 - packages/RNExternalDisplayExample/app.json | 4 - .../RNExternalDisplayExample/babel.config.js | 8 - packages/RNExternalDisplayExample/index.js | 10 - .../RNExternalDisplayExample/ios/.xcode.env | 1 - packages/RNExternalDisplayExample/ios/Podfile | 63 - .../RNExternalDisplayExample/ios/Podfile.lock | 898 -- .../project.pbxproj | 704 -- .../RNExternalDisplayExample.xcscheme | 88 - .../contents.xcworkspacedata | 10 - .../xcshareddata/IDEWorkspaceChecks.plist | 8 - .../RNExternalDisplayExample/AppDelegate.h | 6 - .../RNExternalDisplayExample/AppDelegate.mm | 52 - .../AppIcon.appiconset/Contents.json | 53 - .../Images.xcassets/Contents.json | 6 - .../ios/RNExternalDisplayExample/Info.plist | 77 - .../LaunchScreen.storyboard | 47 - .../ios/RNExternalDisplayExample/main.m | 10 - .../RNExternalDisplayExampleTests/Info.plist | 24 - .../RNExternalDisplayExampleTests.m | 66 - .../RNExternalDisplayExample/ios/_xcode.env | 11 - .../RNExternalDisplayExample/metro.config.js | 40 - .../RNExternalDisplayExample/package.json | 34 - .../react-native.config.js | 3 - .../react-native-external-display/index.d.ts | 25 +- .../js/EventEmitter.js | 8 +- .../js/NativeRNExternalDisplayEvent.js | 12 +- .../js/SceneManager.d.ts | 24 +- yarn.lock | 9978 ++++++----------- 80 files changed, 3836 insertions(+), 10097 deletions(-) create mode 100644 apps/external-display-example/.gitignore create mode 100644 apps/external-display-example/README.md create mode 100644 apps/external-display-example/app.json create mode 100644 apps/external-display-example/babel.config.js create mode 100644 apps/external-display-example/index.tsx create mode 100644 apps/external-display-example/package.json rename packages/RNExternalDisplayExample/src/App.js => apps/external-display-example/src/App.tsx (64%) rename packages/RNExternalDisplayExample/src/IPadMultipleScenes.js => apps/external-display-example/src/IPadMultipleScenes.tsx (86%) rename packages/RNExternalDisplayExample/src/Modal.js => apps/external-display-example/src/Modal.tsx (90%) rename packages/RNExternalDisplayExample/src/ScreenSize.js => apps/external-display-example/src/ScreenSize.tsx (86%) rename packages/RNExternalDisplayExample/src/ScrollView.js => apps/external-display-example/src/ScrollView.tsx (57%) rename packages/RNExternalDisplayExample/src/SimpleTextInterval.js => apps/external-display-example/src/SimpleTextInterval.tsx (94%) rename packages/RNExternalDisplayExample/src/Touch.js => apps/external-display-example/src/Touch.tsx (97%) rename packages/RNExternalDisplayExample/src/WebView.js => apps/external-display-example/src/WebView.tsx (100%) rename packages/RNExternalDisplayExample/src/utils/SceneManager.js => apps/external-display-example/src/utils/SceneManager.tsx (88%) rename packages/RNExternalDisplayExample/src/utils/ScreenControl.js => apps/external-display-example/src/utils/ScreenControl.tsx (67%) create mode 100644 apps/external-display-example/tsconfig.json delete mode 100644 packages/RNExternalDisplayExample/.gitignore delete mode 100644 packages/RNExternalDisplayExample/.watchmanconfig delete mode 100644 packages/RNExternalDisplayExample/CHANGELOG.md delete mode 100644 packages/RNExternalDisplayExample/README.md delete mode 100644 packages/RNExternalDisplayExample/android/app/build.gradle delete mode 100644 packages/RNExternalDisplayExample/android/app/debug.keystore delete mode 100644 packages/RNExternalDisplayExample/android/app/proguard-rules.pro delete mode 100644 packages/RNExternalDisplayExample/android/app/src/debug/AndroidManifest.xml delete mode 100644 packages/RNExternalDisplayExample/android/app/src/debug/java/com/rnexternaldisplayexample/ReactNativeFlipper.java delete mode 100644 packages/RNExternalDisplayExample/android/app/src/main/AndroidManifest.xml delete mode 100644 packages/RNExternalDisplayExample/android/app/src/main/java/com/rnexternaldisplayexample/MainActivity.java delete mode 100644 packages/RNExternalDisplayExample/android/app/src/main/java/com/rnexternaldisplayexample/MainApplication.java delete mode 100644 packages/RNExternalDisplayExample/android/app/src/main/res/drawable/rn_edit_text_material.xml delete mode 100644 packages/RNExternalDisplayExample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png delete mode 100644 packages/RNExternalDisplayExample/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png delete mode 100644 packages/RNExternalDisplayExample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png delete mode 100644 packages/RNExternalDisplayExample/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png delete mode 100644 packages/RNExternalDisplayExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png delete mode 100644 packages/RNExternalDisplayExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png delete mode 100644 packages/RNExternalDisplayExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png delete mode 100644 packages/RNExternalDisplayExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png delete mode 100644 packages/RNExternalDisplayExample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png delete mode 100644 packages/RNExternalDisplayExample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png delete mode 100644 packages/RNExternalDisplayExample/android/app/src/main/res/values/strings.xml delete mode 100644 packages/RNExternalDisplayExample/android/app/src/main/res/values/styles.xml delete mode 100644 packages/RNExternalDisplayExample/android/app/src/release/java/com/rnexternaldisplayexample/ReactNativeFlipper.java delete mode 100644 packages/RNExternalDisplayExample/android/build.gradle delete mode 100644 packages/RNExternalDisplayExample/android/gradle.properties delete mode 100644 packages/RNExternalDisplayExample/android/gradle/wrapper/gradle-wrapper.jar delete mode 100644 packages/RNExternalDisplayExample/android/gradle/wrapper/gradle-wrapper.properties delete mode 100755 packages/RNExternalDisplayExample/android/gradlew delete mode 100644 packages/RNExternalDisplayExample/android/gradlew.bat delete mode 100644 packages/RNExternalDisplayExample/android/settings.gradle delete mode 100644 packages/RNExternalDisplayExample/app.json delete mode 100644 packages/RNExternalDisplayExample/babel.config.js delete mode 100644 packages/RNExternalDisplayExample/index.js delete mode 100644 packages/RNExternalDisplayExample/ios/.xcode.env delete mode 100644 packages/RNExternalDisplayExample/ios/Podfile delete mode 100644 packages/RNExternalDisplayExample/ios/Podfile.lock delete mode 100644 packages/RNExternalDisplayExample/ios/RNExternalDisplayExample.xcodeproj/project.pbxproj delete mode 100644 packages/RNExternalDisplayExample/ios/RNExternalDisplayExample.xcodeproj/xcshareddata/xcschemes/RNExternalDisplayExample.xcscheme delete mode 100644 packages/RNExternalDisplayExample/ios/RNExternalDisplayExample.xcworkspace/contents.xcworkspacedata delete mode 100644 packages/RNExternalDisplayExample/ios/RNExternalDisplayExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist delete mode 100644 packages/RNExternalDisplayExample/ios/RNExternalDisplayExample/AppDelegate.h delete mode 100644 packages/RNExternalDisplayExample/ios/RNExternalDisplayExample/AppDelegate.mm delete mode 100644 packages/RNExternalDisplayExample/ios/RNExternalDisplayExample/Images.xcassets/AppIcon.appiconset/Contents.json delete mode 100644 packages/RNExternalDisplayExample/ios/RNExternalDisplayExample/Images.xcassets/Contents.json delete mode 100644 packages/RNExternalDisplayExample/ios/RNExternalDisplayExample/Info.plist delete mode 100644 packages/RNExternalDisplayExample/ios/RNExternalDisplayExample/LaunchScreen.storyboard delete mode 100644 packages/RNExternalDisplayExample/ios/RNExternalDisplayExample/main.m delete mode 100644 packages/RNExternalDisplayExample/ios/RNExternalDisplayExampleTests/Info.plist delete mode 100644 packages/RNExternalDisplayExample/ios/RNExternalDisplayExampleTests/RNExternalDisplayExampleTests.m delete mode 100644 packages/RNExternalDisplayExample/ios/_xcode.env delete mode 100644 packages/RNExternalDisplayExample/metro.config.js delete mode 100644 packages/RNExternalDisplayExample/package.json delete mode 100644 packages/RNExternalDisplayExample/react-native.config.js diff --git a/apps/external-display-example/.gitignore b/apps/external-display-example/.gitignore new file mode 100644 index 00000000..3062b237 --- /dev/null +++ b/apps/external-display-example/.gitignore @@ -0,0 +1,23 @@ +node_modules/ +.expo/ +dist/ +npm-debug.* +*.jks +*.p8 +*.p12 +*.key +*.mobileprovision +*.orig.* +web-build/ + +ios/ +android/ + +# macOS +.DS_Store + +# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb +# The following patterns were generated by expo-cli + +expo-env.d.ts +# @end expo-cli \ No newline at end of file diff --git a/apps/external-display-example/README.md b/apps/external-display-example/README.md new file mode 100644 index 00000000..cd4feb8a --- /dev/null +++ b/apps/external-display-example/README.md @@ -0,0 +1,50 @@ +# Welcome to your Expo app 👋 + +This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app). + +## Get started + +1. Install dependencies + + ```bash + npm install + ``` + +2. Start the app + + ```bash + npx expo start + ``` + +In the output, you'll find options to open the app in a + +- [development build](https://docs.expo.dev/develop/development-builds/introduction/) +- [Android emulator](https://docs.expo.dev/workflow/android-studio-emulator/) +- [iOS simulator](https://docs.expo.dev/workflow/ios-simulator/) +- [Expo Go](https://expo.dev/go), a limited sandbox for trying out app development with Expo + +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: + +- [Expo documentation](https://docs.expo.dev/): Learn fundamentals, or go into advanced topics with our [guides](https://docs.expo.dev/guides). +- [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. + +## Join the community + +Join our community of developers creating universal apps. + +- [Expo on GitHub](https://github.com/expo/expo): View our open source platform and contribute. +- [Discord community](https://chat.expo.dev): Chat with Expo users and ask questions. diff --git a/apps/external-display-example/app.json b/apps/external-display-example/app.json new file mode 100644 index 00000000..2fae5b9a --- /dev/null +++ b/apps/external-display-example/app.json @@ -0,0 +1,28 @@ +{ + "expo": { + "name": "external-display-example", + "slug": "external-display-example", + "entryPoint": "./src/App.tsx", + "version": "1.0.0", + "orientation": "portrait", + "scheme": "externaldisplay", + "userInterfaceStyle": "automatic", + "splash": { + "resizeMode": "contain", + "backgroundColor": "#ffffff" + }, + "ios": { + "supportsTablet": true, + "bundleIdentifier": "com.externaldisplay" + }, + "android": { + "package": "com.externaldisplay", + "adaptiveIcon": { + "backgroundColor": "#ffffff" + } + }, + "experiments": { + "typedRoutes": true + } + } +} diff --git a/apps/external-display-example/babel.config.js b/apps/external-display-example/babel.config.js new file mode 100644 index 00000000..9d89e131 --- /dev/null +++ b/apps/external-display-example/babel.config.js @@ -0,0 +1,6 @@ +module.exports = function (api) { + api.cache(true); + return { + presets: ['babel-preset-expo'], + }; +}; diff --git a/apps/external-display-example/index.tsx b/apps/external-display-example/index.tsx new file mode 100644 index 00000000..50958193 --- /dev/null +++ b/apps/external-display-example/index.tsx @@ -0,0 +1,9 @@ +/** + * @format + */ + +import { registerRootComponent } from 'expo' + +import App from './src/App' + +export default registerRootComponent(App) diff --git a/apps/external-display-example/package.json b/apps/external-display-example/package.json new file mode 100644 index 00000000..03669452 --- /dev/null +++ b/apps/external-display-example/package.json @@ -0,0 +1,25 @@ +{ + "name": "external-display-example", + "version": "1.0.0", + "scripts": { + "start": "expo start", + "android": "expo run:android", + "ios": "expo run:ios" + }, + "main": "./index.tsx", + "dependencies": { + "expo": "~51.0.28", + "expo-system-ui": "~3.0.7", + "react": "18.2.0", + "react-native": "0.74.5", + "react-native-external-display": "0.6.6", + "react-native-gesture-handler": "^2.20.0", + "react-native-webview": "^13.12.3" + }, + "devDependencies": { + "@babel/core": "^7.20.0", + "@types/react": "~18.2.45", + "typescript": "~5.3.3" + }, + "private": true +} diff --git a/packages/RNExternalDisplayExample/src/App.js b/apps/external-display-example/src/App.tsx similarity index 64% rename from packages/RNExternalDisplayExample/src/App.js rename to apps/external-display-example/src/App.tsx index ce085a25..ee1afb2e 100644 --- a/packages/RNExternalDisplayExample/src/App.js +++ b/apps/external-display-example/src/App.tsx @@ -1,4 +1,5 @@ import React, { useState } from 'react' + import { View, Button } from 'react-native' import { SceneManager } from 'react-native-external-display' @@ -16,26 +17,32 @@ const exampleMap = { ScreenSize, ScrollView, WebView, -} -if (SceneManager.isAvailable()) { - exampleMap.IPadMultipleScenes = IPadMultipleScenes - exampleMap.Touch = Touch + ...(SceneManager.isAvailable() + ? { + IPadMultipleScenes, + Touch, + } + : {}), } function App() { - const [page, setPage] = useState(null) + const [page, setPage] = useState(null) - const Example = exampleMap[page] + if (page) { + const Component = exampleMap[page] - if (Example) { - return setPage(null)} /> + if (Component) { + return setPage(null)} /> + } } + const keys = Object.keys(exampleMap) as Array + return ( - {Object.keys(exampleMap).map((key) => ( + {keys.map((key) => (