Skip to content
This repository was archived by the owner on Jul 13, 2022. It is now read-only.

Commit 2ac592f

Browse files
committed
new example
1 parent 2382ee0 commit 2ac592f

File tree

33 files changed

+406
-501
lines changed

33 files changed

+406
-501
lines changed

CanvasExample/.flowconfig

+5-29
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55
; Ignore "BUCK" generated dirs
66
<PROJECT_ROOT>/\.buckd/
77

8-
; Ignore unexpected extra "@providesModule"
9-
.*/node_modules/.*/node_modules/fbjs/.*
10-
11-
; Ignore duplicate module providers
12-
; For RN Apps installed via npm, "Libraries" folder is inside
13-
; "node_modules/react-native" but in the source repo it is in the root
14-
node_modules/react-native/Libraries/react-native/React.js
15-
168
; Ignore polyfills
179
node_modules/react-native/Libraries/polyfills/.*
1810

@@ -21,7 +13,7 @@ node_modules/react-native/Libraries/polyfills/.*
2113
node_modules/warning/.*
2214

2315
; Flow doesn't support platforms
24-
.*/Libraries/Utilities/HMRLoadingView.js
16+
.*/Libraries/Utilities/LoadingView.js
2517

2618
[untyped]
2719
.*/node_modules/@react-native-community/cli/.*/.*
@@ -42,27 +34,11 @@ module.file_ext=.js
4234
module.file_ext=.json
4335
module.file_ext=.ios.js
4436

45-
module.system=haste
46-
module.system.haste.use_name_reducers=true
47-
# get basename
48-
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
49-
# strip .js or .js.flow suffix
50-
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
51-
# strip .ios suffix
52-
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
53-
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
54-
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
55-
module.system.haste.paths.blacklist=.*/__tests__/.*
56-
module.system.haste.paths.blacklist=.*/__mocks__/.*
57-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
58-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/RNTester/.*
59-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/IntegrationTests/.*
60-
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation.js
61-
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
62-
6337
munge_underscores=true
6438

65-
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
39+
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation'
40+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
41+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
6642

6743
suppress_type=$FlowIssue
6844
suppress_type=$FlowFixMe
@@ -96,4 +72,4 @@ untyped-import
9672
untyped-type-import
9773

9874
[version]
99-
^0.98.0
75+
^0.105.0

CanvasExample/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ DerivedData
2020
*.hmap
2121
*.ipa
2222
*.xcuserstate
23-
project.xcworkspace
2423

2524
# Android/IntelliJ
2625
#
@@ -40,6 +39,7 @@ yarn-error.log
4039
buck-out/
4140
\.buckd/
4241
*.keystore
42+
!debug.keystore
4343

4444
# fastlane
4545
#

CanvasExample/App.js

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/**
2+
* Sample React Native App
3+
* https://github.com/facebook/react-native
4+
*
5+
* @format
6+
* @flow
7+
*/
8+
9+
import React from 'react';
10+
import {
11+
SafeAreaView,
12+
StyleSheet,
13+
ScrollView,
14+
View,
15+
Text,
16+
StatusBar,
17+
} from 'react-native';
18+
19+
import {
20+
Header,
21+
LearnMoreLinks,
22+
Colors,
23+
DebugInstructions,
24+
ReloadInstructions,
25+
} from 'react-native/Libraries/NewAppScreen';
26+
27+
const App: () => React$Node = () => {
28+
return (
29+
<>
30+
<StatusBar barStyle="dark-content" />
31+
<SafeAreaView>
32+
<ScrollView
33+
contentInsetAdjustmentBehavior="automatic"
34+
style={styles.scrollView}>
35+
<Header />
36+
{global.HermesInternal == null ? null : (
37+
<View style={styles.engine}>
38+
<Text style={styles.footer}>Engine: Hermes</Text>
39+
</View>
40+
)}
41+
<View style={styles.body}>
42+
<View style={styles.sectionContainer}>
43+
<Text style={styles.sectionTitle}>Step One</Text>
44+
<Text style={styles.sectionDescription}>
45+
Edit <Text style={styles.highlight}>App.js</Text> to change this
46+
screen and then come back to see your edits.
47+
</Text>
48+
</View>
49+
<View style={styles.sectionContainer}>
50+
<Text style={styles.sectionTitle}>See Your Changes</Text>
51+
<Text style={styles.sectionDescription}>
52+
<ReloadInstructions />
53+
</Text>
54+
</View>
55+
<View style={styles.sectionContainer}>
56+
<Text style={styles.sectionTitle}>Debug</Text>
57+
<Text style={styles.sectionDescription}>
58+
<DebugInstructions />
59+
</Text>
60+
</View>
61+
<View style={styles.sectionContainer}>
62+
<Text style={styles.sectionTitle}>Learn More</Text>
63+
<Text style={styles.sectionDescription}>
64+
Read the docs to discover what to do next:
65+
</Text>
66+
</View>
67+
<LearnMoreLinks />
68+
</View>
69+
</ScrollView>
70+
</SafeAreaView>
71+
</>
72+
);
73+
};
74+
75+
const styles = StyleSheet.create({
76+
scrollView: {
77+
backgroundColor: Colors.lighter,
78+
},
79+
engine: {
80+
position: 'absolute',
81+
right: 0,
82+
},
83+
body: {
84+
backgroundColor: Colors.white,
85+
},
86+
sectionContainer: {
87+
marginTop: 32,
88+
paddingHorizontal: 24,
89+
},
90+
sectionTitle: {
91+
fontSize: 24,
92+
fontWeight: '600',
93+
color: Colors.black,
94+
},
95+
sectionDescription: {
96+
marginTop: 8,
97+
fontSize: 18,
98+
fontWeight: '400',
99+
color: Colors.dark,
100+
},
101+
highlight: {
102+
fontWeight: '700',
103+
},
104+
footer: {
105+
color: Colors.dark,
106+
fontSize: 12,
107+
fontWeight: '600',
108+
padding: 4,
109+
paddingRight: 12,
110+
textAlign: 'right',
111+
},
112+
});
113+
114+
export default App;

CanvasExample/android/app/BUCK renamed to CanvasExample/android/app/_BUCK

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ android_library(
3535

3636
android_build_config(
3737
name = "build_config",
38-
package = "com.sketchexample",
38+
package = "com.canvasexample",
3939
)
4040

4141
android_resource(
4242
name = "res",
43-
package = "com.sketchexample",
43+
package = "com.canvasexample",
4444
res = "src/main/res",
4545
)
4646

CanvasExample/android/app/build.gradle

+5-15
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,11 @@ android {
128128
}
129129

130130
defaultConfig {
131-
applicationId "com.sketchexample"
131+
applicationId "com.canvasexample"
132132
minSdkVersion rootProject.ext.minSdkVersion
133133
targetSdkVersion rootProject.ext.targetSdkVersion
134134
versionCode 1
135135
versionName "1.0"
136-
missingDimensionStrategy 'react-native-camera', 'general'
137136
}
138137
splits {
139138
abi {
@@ -177,27 +176,18 @@ android {
177176

178177
}
179178
}
180-
181-
packagingOptions {
182-
pickFirst '**/armeabi-v7a/libc++_shared.so'
183-
pickFirst '**/x86/libc++_shared.so'
184-
pickFirst '**/arm64-v8a/libc++_shared.so'
185-
pickFirst '**/x86_64/libc++_shared.so'
186-
pickFirst '**/x86/libjsc.so'
187-
pickFirst '**/armeabi-v7a/libjsc.so'
188-
}
189179
}
190180

191181
dependencies {
192182
implementation fileTree(dir: "libs", include: ["*.jar"])
193183
implementation "com.facebook.react:react-native:+" // From node_modules
194184

195185
if (enableHermes) {
196-
def hermesPath = "../../node_modules/hermesvm/android/";
197-
debugImplementation files(hermesPath + "hermes-debug.aar")
198-
releaseImplementation files(hermesPath + "hermes-release.aar")
186+
def hermesPath = "../../node_modules/hermes-engine/android/";
187+
debugImplementation files(hermesPath + "hermes-debug.aar")
188+
releaseImplementation files(hermesPath + "hermes-release.aar")
199189
} else {
200-
implementation jscFlavor
190+
implementation jscFlavor
201191
}
202192
}
203193

2.2 KB
Binary file not shown.

CanvasExample/android/app/src/main/AndroidManifest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.sketchexample">
2+
package="com.canvasexample">
33

44
<uses-permission android:name="android.permission.INTERNET" />
55

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.sketchexample;
2+
3+
import com.facebook.react.ReactActivity;
4+
import com.facebook.react.ReactActivityDelegate;
5+
import com.facebook.react.ReactRootView;
6+
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
7+
8+
public class MainActivity extends ReactActivity {
9+
10+
/**
11+
* Returns the name of the main component registered from JavaScript.
12+
* This is used to schedule rendering of the component.
13+
*/
14+
@Override
15+
protected String getMainComponentName() {
16+
return "CanvasExample";
17+
}
18+
19+
@Override
20+
protected ReactActivityDelegate createReactActivityDelegate() {
21+
return new ReactActivityDelegate(this, getMainComponentName()) {
22+
@Override
23+
protected ReactRootView createRootView() {
24+
return new RNGestureHandlerEnabledRootView(MainActivity.this);
25+
}
26+
};
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package com.canvasexample;
2+
3+
import android.app.Application;
4+
import android.content.Context;
5+
import com.facebook.react.PackageList;
6+
import com.facebook.react.ReactApplication;
7+
import com.facebook.react.ReactNativeHost;
8+
import com.facebook.react.ReactPackage;
9+
import com.facebook.soloader.SoLoader;
10+
import java.lang.reflect.InvocationTargetException;
11+
import java.util.List;
12+
13+
public class MainApplication extends Application implements ReactApplication {
14+
15+
private final ReactNativeHost mReactNativeHost =
16+
new ReactNativeHost(this) {
17+
@Override
18+
public boolean getUseDeveloperSupport() {
19+
return BuildConfig.DEBUG;
20+
}
21+
22+
@Override
23+
protected List<ReactPackage> getPackages() {
24+
@SuppressWarnings("UnnecessaryLocalVariable")
25+
List<ReactPackage> packages = new PackageList(this).getPackages();
26+
// Packages that cannot be autolinked yet can be added manually here, for example:
27+
// packages.add(new MyReactNativePackage());
28+
return packages;
29+
}
30+
31+
@Override
32+
protected String getJSMainModuleName() {
33+
return "index";
34+
}
35+
};
36+
37+
@Override
38+
public ReactNativeHost getReactNativeHost() {
39+
return mReactNativeHost;
40+
}
41+
42+
@Override
43+
public void onCreate() {
44+
super.onCreate();
45+
SoLoader.init(this, /* native exopackage */ false);
46+
initializeFlipper(this); // Remove this line if you don't want Flipper enabled
47+
}
48+
49+
/**
50+
* Loads Flipper in React Native templates.
51+
*
52+
* @param context
53+
*/
54+
private static void initializeFlipper(Context context) {
55+
if (BuildConfig.DEBUG) {
56+
try {
57+
/*
58+
We use reflection here to pick up the class that initializes Flipper,
59+
since Flipper library is not available in release mode
60+
*/
61+
Class<?> aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper");
62+
aClass.getMethod("initializeFlipper", Context.class).invoke(null, context);
63+
} catch (ClassNotFoundException e) {
64+
e.printStackTrace();
65+
} catch (NoSuchMethodException e) {
66+
e.printStackTrace();
67+
} catch (IllegalAccessException e) {
68+
e.printStackTrace();
69+
} catch (InvocationTargetException e) {
70+
e.printStackTrace();
71+
}
72+
}
73+
}
74+
}

CanvasExample/android/app/src/main/java/com/sketchexample/MainActivity.java

-28
This file was deleted.

0 commit comments

Comments
 (0)