Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add React Native 0.66 support (#490)
* feat: Add React Native 0.66 support * Generate lockfiles * Update Podfile.lock * chore: Migrate from react-native-navigation to react-navigation (#491) * Migrate RNN -> RN * Migrate all screens * Fix get permission status * fix app name * Update AppDelegate.m * Fix Info.plist * Set `UIViewControllerBasedStatusBarAppearance` to `YES` * Only enable `audio` if user granted microphone permission * Update App.tsx * Fix RNGH for Android * Use `navigate` instead of `push` * Fix animation * Upgrade @types/react-native * "Splash" -> "PermissionsPage"
- Loading branch information
Showing
23 changed files
with
711 additions
and
596 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ project.xcworkspace | |
.gradle | ||
local.properties | ||
android.iml | ||
*.hprof | ||
|
||
# Cocoapods | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 28 additions & 2 deletions
30
example/android/app/src/main/java/com/mrousavy/camera/example/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,34 @@ | ||
package com.mrousavy.camera.example; | ||
|
||
import com.reactnativenavigation.NavigationActivity; | ||
import com.facebook.react.ReactActivity; | ||
import com.facebook.react.ReactActivityDelegate; | ||
import com.facebook.react.ReactRootView; | ||
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView; | ||
import android.os.Bundle; | ||
|
||
public class MainActivity extends NavigationActivity { | ||
public class MainActivity extends ReactActivity { | ||
|
||
/** | ||
* Returns the name of the main component registered from JavaScript. This is used to schedule | ||
* rendering of the component. | ||
*/ | ||
@Override | ||
protected String getMainComponentName() { | ||
return "VisionCameraExample"; | ||
} | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(null); | ||
} | ||
|
||
@Override | ||
protected ReactActivityDelegate createReactActivityDelegate() { | ||
return new ReactActivityDelegate(this, getMainComponentName()) { | ||
@Override | ||
protected ReactRootView createRootView() { | ||
return new RNGestureHandlerEnabledRootView(MainActivity.this); | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,5 @@ | ||
import 'react-native-gesture-handler'; | ||
import { Navigation } from 'react-native-navigation'; | ||
import { gestureHandlerRootHOC } from 'react-native-gesture-handler'; | ||
import { CameraPage } from './src/CameraPage'; | ||
import { Splash } from './src/Splash'; | ||
import { MediaPage } from './src/MediaPage'; | ||
import { Camera } from 'react-native-vision-camera'; | ||
import { AppRegistry } from 'react-native'; | ||
import { App } from './src/App'; | ||
|
||
Navigation.setDefaultOptions({ | ||
topBar: { | ||
visible: false, | ||
}, | ||
window: { | ||
backgroundColor: 'black', | ||
}, | ||
layout: { | ||
backgroundColor: 'black', | ||
componentBackgroundColor: 'black', | ||
}, | ||
statusBar: { | ||
animated: true, | ||
drawBehind: true, | ||
translucent: true, | ||
visible: true, | ||
style: 'dark', | ||
}, | ||
animations: { | ||
setRoot: { | ||
alpha: { | ||
duration: 500, | ||
from: 0, | ||
to: 1, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
Navigation.registerComponent( | ||
'Splash', | ||
() => gestureHandlerRootHOC(Splash), | ||
() => Splash, | ||
); | ||
Navigation.registerComponent( | ||
'CameraPage', | ||
() => gestureHandlerRootHOC(CameraPage), | ||
() => CameraPage, | ||
); | ||
Navigation.registerComponent( | ||
'MediaPage', | ||
() => gestureHandlerRootHOC(MediaPage), | ||
() => MediaPage, | ||
); | ||
|
||
Navigation.events().registerNavigationButtonPressedListener((event) => { | ||
if (event.buttonId === 'back') Navigation.pop(event.componentId); | ||
}); | ||
|
||
Navigation.events().registerAppLaunchedListener(async () => { | ||
const [cameraPermission, microphonePermission] = await Promise.all([ | ||
Camera.getCameraPermissionStatus(), | ||
Camera.getMicrophonePermissionStatus(), | ||
]); | ||
let rootName = 'Splash'; | ||
if (cameraPermission === 'authorized' && microphonePermission === 'authorized') rootName = 'CameraPage'; | ||
|
||
Navigation.setRoot({ | ||
root: { | ||
stack: { | ||
children: [ | ||
{ | ||
component: { | ||
name: rootName, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}); | ||
}); | ||
AppRegistry.registerComponent('VisionCameraExample', () => App); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.