Skip to content

Commit 1229a9a

Browse files
ian-wdiBotPeaches
authored andcommitted
feat: move example camera plugin as a dev dependency
1 parent 697524c commit 1229a9a

File tree

10 files changed

+59
-35
lines changed

10 files changed

+59
-35
lines changed

example/android/app/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ android {
159159
}
160160
}
161161
}
162+
163+
missingDimensionStrategy 'react-native-camera', 'general'
162164
}
163165

164166
if (isNewArchitectureEnabled()) {
@@ -277,6 +279,9 @@ dependencies {
277279
} else {
278280
implementation jscFlavor
279281
}
282+
283+
implementation project(':@react-native-sketch-canvas')
284+
implementation project(':react-native-camera')
280285
}
281286

282287
if (isNewArchitectureEnabled()) {

example/android/app/src/main/java/com/example/MainApplication.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import com.example.newarchitecture.MainApplicationReactNativeHost;
1313
import java.lang.reflect.InvocationTargetException;
1414
import java.util.List;
15+
import com.terrylinla.rnsketchcanvas.SketchCanvasPackage;
16+
import org.reactnative.camera.RNCameraPackage;
1517

1618
public class MainApplication extends Application implements ReactApplication {
1719

@@ -28,6 +30,8 @@ protected List<ReactPackage> getPackages() {
2830
List<ReactPackage> packages = new PackageList(this).getPackages();
2931
// Packages that cannot be autolinked yet can be added manually here, for example:
3032
// packages.add(new MyReactNativePackage());
33+
packages.add(new SketchCanvasPackage());
34+
packages.add(new RNCameraPackage());
3135
return packages;
3236
}
3337

example/android/settings.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@ if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true")
99
include(":ReactAndroid:hermes-engine")
1010
project(":ReactAndroid:hermes-engine").projectDir = file('../node_modules/react-native/ReactAndroid/hermes-engine')
1111
}
12+
13+
include ':@react-native-sketch-canvas'
14+
project(':@react-native-sketch-canvas').projectDir = new File(rootProject.projectDir, '../../android')
15+
16+
include ':react-native-camera'
17+
project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../../node_modules/react-native-camera/android')

example/ios/Podfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ target 'example' do
2626
:app_path => "#{Pod::Config.instance.installation_root}/.."
2727
)
2828

29+
pod 'react-native-camera', :path => '../../node_modules/react-native-camera'
30+
pod 'RNSketchCanvas', :path => '../..'
31+
2932
target 'exampleTests' do
3033
inherit! :complete
3134
# Pods for testing

example/ios/Podfile.lock

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ PODS:
376376
- React-jsi (= 0.70.4)
377377
- React-logger (= 0.70.4)
378378
- React-perflogger (= 0.70.4)
379+
- RNSketchCanvas (1.0.0):
380+
- React
379381
- SocketRocket (0.6.0)
380382
- Yoga (1.14.0)
381383
- YogaKit (1.18.1):
@@ -428,7 +430,7 @@ DEPENDENCIES:
428430
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
429431
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
430432
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
431-
- react-native-camera (from `../node_modules/react-native-camera`)
433+
- react-native-camera (from `../../node_modules/react-native-camera`)
432434
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
433435
- React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
434436
- React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`)
@@ -441,6 +443,7 @@ DEPENDENCIES:
441443
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
442444
- React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`)
443445
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
446+
- RNSketchCanvas (from `../..`)
444447
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
445448

446449
SPEC REPOS:
@@ -505,7 +508,7 @@ EXTERNAL SOURCES:
505508
React-logger:
506509
:path: "../node_modules/react-native/ReactCommon/logger"
507510
react-native-camera:
508-
:path: "../node_modules/react-native-camera"
511+
:path: "../../node_modules/react-native-camera"
509512
React-perflogger:
510513
:path: "../node_modules/react-native/ReactCommon/reactperflogger"
511514
React-RCTActionSheet:
@@ -530,6 +533,8 @@ EXTERNAL SOURCES:
530533
:path: "../node_modules/react-native/ReactCommon/runtimeexecutor"
531534
ReactCommon:
532535
:path: "../node_modules/react-native/ReactCommon"
536+
RNSketchCanvas:
537+
:path: "../.."
533538
Yoga:
534539
:path: "../node_modules/react-native/ReactCommon/yoga"
535540

@@ -581,10 +586,11 @@ SPEC CHECKSUMS:
581586
React-RCTVibration: 0e247407238d3bd6b29d922d7b5de0404359431b
582587
React-runtimeexecutor: 5407e26b5aaafa9b01a08e33653255f8247e7c31
583588
ReactCommon: abf3605a56f98b91671d0d1327addc4ffb87af77
589+
RNSketchCanvas: 27cbc63da3478b6b2dc5ac4e1dbaa526b5e110d1
584590
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
585591
Yoga: 1f02ef4ce4469aefc36167138441b27d988282b1
586592
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
587593

588-
PODFILE CHECKSUM: e9774a3132cc2072013fd07ec1ade8155544b823
594+
PODFILE CHECKSUM: 8586834ad461ad53144d789d760fd51d75fc4a5e
589595

590596
COCOAPODS: 1.11.3

example/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
},
1212
"dependencies": {
1313
"react": "18.1.0",
14-
"react-native": "0.70.4",
15-
"react-native-camera": "https://github.com/sourcetoad/react-native-camera#ee265b22c7a3544a720478a6397d0e547430ff93"
14+
"react-native": "0.70.4"
1615
},
1716
"devDependencies": {
1817
"@babel/core": "^7.12.9",

example/src/App.tsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,16 @@ export default class example extends Component<any, ExampleState> {
4646

4747
takePicture = async () => {
4848
if (this.camera) {
49-
const options = {quality: 0.5, base64: true};
50-
const data = await this.camera.takePictureAsync(options);
51-
this.setState({
52-
photoPath: data.uri.replace('file://', ''),
53-
});
49+
try {
50+
const options = {quality: 0.5, base64: true};
51+
const data = await this.camera.takePictureAsync(options);
52+
53+
this.setState({
54+
photoPath: data.uri.replace('file://', ''),
55+
});
56+
} catch (err) {
57+
console.log(err);
58+
}
5459
}
5560
};
5661

@@ -513,16 +518,20 @@ export default class example extends Component<any, ExampleState> {
513518
(this.state.photoPath === null ? (
514519
<View style={styles.cameraContainer}>
515520
<RNCamera
516-
ref={ref => {
521+
cameraId="1"
522+
ref={(ref: any) => {
517523
this.camera = ref;
518524
}}
519525
style={styles.preview}
520526
type={RNCamera.Constants.Type.back}
521527
flashMode={RNCamera.Constants.FlashMode.on}
522-
permissionDialogTitle={'Permission to use camera'}
523-
permissionDialogMessage={
524-
'We need your permission to use your camera phone'
525-
}
528+
androidCameraPermissionOptions={{
529+
title: 'Permission to use camera',
530+
message: 'We need your permission to use your camera',
531+
buttonPositive: 'Ok',
532+
buttonNegative: 'Cancel',
533+
}}
534+
captureAudio={false}
526535
/>
527536
<View
528537
style={{

example/yarn.lock

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,7 @@
12671267
resolved "https://registry.yarnpkg.com/@react-native/assets/-/assets-1.0.0.tgz#c6f9bf63d274bafc8e970628de24986b30a55c8e"
12681268
integrity sha512-KrwSpS1tKI70wuKl68DwJZYEvXktDHdZMG0k2AXD/rJVSlB23/X2CB2cutVR0HwNMJIal9HOUOBB2rVfa6UGtQ==
12691269

1270-
"@react-native/normalize-color@*", "@react-native/normalize-color@2.0.0":
1270+
"@react-native/normalize-color@2.0.0":
12711271
version "2.0.0"
12721272
resolved "https://registry.yarnpkg.com/@react-native/normalize-color/-/normalize-color-2.0.0.tgz#da955909432474a9a0fe1cbffc66576a0447f567"
12731273
integrity sha512-Wip/xsc5lw8vsBlmY2MO/gFLp3MvuZ2baBZjDeTjjndMgM0h5sxz7AZR62RDPGgstp8Np7JzjvVqVT7tpFZqsw==
@@ -2437,15 +2437,6 @@ depd@2.0.0:
24372437
resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df"
24382438
integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==
24392439

2440-
deprecated-react-native-prop-types@^2.3.0:
2441-
version "2.3.0"
2442-
resolved "https://registry.yarnpkg.com/deprecated-react-native-prop-types/-/deprecated-react-native-prop-types-2.3.0.tgz#c10c6ee75ff2b6de94bb127f142b814e6e08d9ab"
2443-
integrity sha512-pWD0voFtNYxrVqvBMYf5gq3NA2GCpfodS1yNynTPc93AYA/KEMGeWDqqeUB6R2Z9ZofVhks2aeJXiuQqKNpesA==
2444-
dependencies:
2445-
"@react-native/normalize-color" "*"
2446-
invariant "*"
2447-
prop-types "*"
2448-
24492440
destroy@1.2.0:
24502441
version "1.2.0"
24512442
resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.2.0.tgz#4803735509ad8be552934c67df614f94e66fa015"
@@ -3441,7 +3432,7 @@ internal-slot@^1.0.3:
34413432
has "^1.0.3"
34423433
side-channel "^1.0.4"
34433434

3444-
invariant@*, invariant@^2.2.4:
3435+
invariant@^2.2.4:
34453436
version "2.2.4"
34463437
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6"
34473438
integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==
@@ -5422,7 +5413,7 @@ prompts@^2.0.1, prompts@^2.4.0:
54225413
kleur "^3.0.3"
54235414
sisteransi "^1.0.5"
54245415

5425-
prop-types@*, prop-types@^15.6.2, prop-types@^15.8.1:
5416+
prop-types@^15.8.1:
54265417
version "15.8.1"
54275418
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
54285419
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
@@ -5482,13 +5473,6 @@ react-is@^17.0.1:
54825473
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
54835474
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==
54845475

5485-
"react-native-camera@https://github.com/sourcetoad/react-native-camera#ee265b22c7a3544a720478a6397d0e547430ff93":
5486-
version "4.2.1"
5487-
resolved "https://github.com/sourcetoad/react-native-camera#ee265b22c7a3544a720478a6397d0e547430ff93"
5488-
dependencies:
5489-
deprecated-react-native-prop-types "^2.3.0"
5490-
prop-types "^15.6.2"
5491-
54925476
react-native-codegen@^0.70.6:
54935477
version "0.70.6"
54945478
resolved "https://registry.yarnpkg.com/react-native-codegen/-/react-native-codegen-0.70.6.tgz#2ce17d1faad02ad4562345f8ee7cbe6397eda5cb"

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"react": "18.1.0",
7575
"react-native": "0.70.4",
7676
"react-native-builder-bob": "^0.18.0",
77+
"react-native-camera": "https://github.com/sourcetoad/react-native-camera#ee265b22c7a3544a720478a6397d0e547430ff93",
7778
"react-test-renderer": "18.1.0",
7879
"typescript": "^4.1.3"
7980
},

yarn.lock

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6110,7 +6110,7 @@ prompts@^2.0.1, prompts@^2.4.0, prompts@^2.4.2:
61106110
kleur "^3.0.3"
61116111
sisteransi "^1.0.5"
61126112

6113-
prop-types@*, prop-types@^15.8.1:
6113+
prop-types@*, prop-types@^15.6.2, prop-types@^15.8.1:
61146114
version "15.8.1"
61156115
resolved "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz"
61166116
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
@@ -6202,6 +6202,13 @@ react-native-builder-bob@^0.18.0:
62026202
optionalDependencies:
62036203
jetifier "^2.0.0"
62046204

6205+
"react-native-camera@https://github.com/sourcetoad/react-native-camera#ee265b22c7a3544a720478a6397d0e547430ff93":
6206+
version "4.2.1"
6207+
resolved "https://github.com/sourcetoad/react-native-camera#ee265b22c7a3544a720478a6397d0e547430ff93"
6208+
dependencies:
6209+
deprecated-react-native-prop-types "^2.3.0"
6210+
prop-types "^15.6.2"
6211+
62056212
react-native-codegen@^0.70.6:
62066213
version "0.70.6"
62076214
resolved "https://registry.npmjs.org/react-native-codegen/-/react-native-codegen-0.70.6.tgz"

0 commit comments

Comments
 (0)