Browse Source

Make example app easier to run

Janic Duplessis 4 years ago
parent
commit
05bdb89f95
9 changed files with 7271 additions and 198 deletions
  1. 1
    2
      example/App.tsx
  2. 1
    1
      example/app.json
  3. 12
    0
      example/babel.config.js
  4. 1
    1
      example/ios/SafeAreaViewExample.xcodeproj/project.pbxproj
  5. 10
    0
      example/package.json
  6. 0
    17
      metro.config.js
  7. 5
    1
      package.json
  8. 5
    1
      tsconfig.json
  9. 7236
    175
      yarn.lock

+ 1
- 2
example/App.tsx View File

@@ -1,13 +1,12 @@
1 1
 import * as React from 'react';
2 2
 import { View, Text, StatusBar, ScrollView } from 'react-native';
3 3
 
4
-// import { SafeAreaProvider, useSafeArea } from 'react-native-safe-area-context'; in your app.
5 4
 import {
6 5
   SafeAreaProvider,
7 6
   useSafeAreaInsets,
8 7
   initialWindowMetrics,
9 8
   useSafeAreaFrame,
10
-} from '../src';
9
+} from 'react-native-safe-area-context';
11 10
 
12 11
 const DataView = ({ data }: { data: object | null | undefined }) => (
13 12
   <Text style={{ fontSize: 16, lineHeight: 24, color: '#292929' }}>

+ 1
- 1
example/app.json View File

@@ -2,7 +2,7 @@
2 2
   "name": "SafeAreaViewExample",
3 3
   "displayName": "SafeAreaViewExample",
4 4
   "expo": {
5
-    "entryPoint": "./example/index",
5
+    "entryPoint": "./example/index.expo",
6 6
     "name": "react-native-safe-area-context",
7 7
     "slug": "react-native-safe-area-context",
8 8
     "version": "0.1.0",

+ 12
- 0
example/babel.config.js View File

@@ -0,0 +1,12 @@
1
+module.exports = {
2
+  plugins: [
3
+    [
4
+      'module-resolver',
5
+      {
6
+        alias: {
7
+          'react-native-safe-area-context': './src',
8
+        },
9
+      },
10
+    ],
11
+  ],
12
+};

+ 1
- 1
example/ios/SafeAreaViewExample.xcodeproj/project.pbxproj View File

@@ -248,7 +248,7 @@
248 248
 			);
249 249
 			runOnlyForDeploymentPostprocessing = 0;
250 250
 			shellPath = /bin/sh;
251
-			shellScript = "export RCT_METRO_PORT=\"${RCT_METRO_PORT:=8081}\"\necho \"export RCT_METRO_PORT=${RCT_METRO_PORT}\" > \"${SRCROOT}/../../node_modules/react-native/scripts/.packager.env\"\nif [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n  if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then\n    if ! curl -s \"http://localhost:${RCT_METRO_PORT}/status\" | grep -q \"packager-status:running\" ; then\n      echo \"Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly\"\n      exit 2\n    fi\n  else\n    open \"$SRCROOT/../node_modules/react-native/scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n  fi\nfi\n";
251
+			shellScript = "export RCT_METRO_PORT=\"${RCT_METRO_PORT:=8081}\"\necho \"export RCT_METRO_PORT=${RCT_METRO_PORT}\" > \"${SRCROOT}/../../node_modules/react-native/scripts/.packager.env\"\nif [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n  if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then\n    if ! curl -s \"http://localhost:${RCT_METRO_PORT}/status\" | grep -q \"packager-status:running\" ; then\n      echo \"Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly\"\n      exit 2\n    fi\n  else\n    open \"$SRCROOT/../../node_modules/react-native/scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n  fi\nfi\n";
252 252
 			showEnvVarsInLog = 0;
253 253
 		};
254 254
 /* End PBXShellScriptBuildPhase section */

+ 10
- 0
example/package.json View File

@@ -0,0 +1,10 @@
1
+{
2
+  "name": "example",
3
+  "dependencies": {
4
+    "expo": "^37.0.8",
5
+    "react": "^16.13.1",
6
+    "react-dom": "^16.13.1",
7
+    "react-native": "^0.63.0-rc.0",
8
+    "react-native-web": "^0.12.2"
9
+  }
10
+}

+ 0
- 17
metro.config.js View File

@@ -1,17 +0,0 @@
1
-/**
2
- * Metro configuration for React Native
3
- * https://github.com/facebook/react-native
4
- *
5
- * @format
6
- */
7
-
8
-module.exports = {
9
-  transformer: {
10
-    getTransformOptions: async () => ({
11
-      transform: {
12
-        experimentalImportSupport: false,
13
-        inlineRequires: false,
14
-      },
15
-    }),
16
-  },
17
-};

+ 5
- 1
package.json View File

@@ -28,7 +28,9 @@
28 28
     "validate:prettier": "prettier \"src/**/*.{js,ts,tsx}\" \"example/**/*.{js,ts,tsx}\" --check",
29 29
     "validate:jest": "jest",
30 30
     "prepare": "bob build",
31
-    "example:ios": "cd example && react-native run-ios"
31
+    "example:ios": "cd ./example && react-native run-ios",
32
+    "example:android": "cd ./example && react-native run-android --no-jetifier",
33
+    "example:expo": "expo start --config example/app.json"
32 34
   },
33 35
   "keywords": [
34 36
     "react-native",
@@ -53,10 +55,12 @@
53 55
     "@types/react-test-renderer": "^16.9.2",
54 56
     "@typescript-eslint/eslint-plugin": "^2.30.0",
55 57
     "@typescript-eslint/parser": "^2.30.0",
58
+    "babel-plugin-module-resolver": "^4.0.0",
56 59
     "eslint": "6.8.0",
57 60
     "eslint-config-prettier": "^6.11.0",
58 61
     "eslint-plugin-prettier": "3.1.3",
59 62
     "expo": "^37.0.8",
63
+    "expo-cli": "^3.20.1",
60 64
     "jest": "^25.5.4",
61 65
     "metro-react-native-babel-preset": "^0.59.0",
62 66
     "prettier": "^2.0.5",

+ 5
- 1
tsconfig.json View File

@@ -12,7 +12,11 @@
12 12
     "moduleResolution": "node",
13 13
     "skipLibCheck": true,
14 14
     "lib": ["dom", "es2015", "es2016", "esnext"],
15
-    "jsx": "react-native"
15
+    "jsx": "react-native",
16
+    "baseUrl": ".",
17
+    "paths": {
18
+      "react-native-safe-area-context": ["./src"]
19
+    }
16 20
   },
17 21
   "exclude": ["node_modules"]
18 22
 }

+ 7236
- 175
yarn.lock
File diff suppressed because it is too large
View File