-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update android to use as native fabric component
- Loading branch information
Showing
6 changed files
with
96 additions
and
39 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
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
42 changes: 40 additions & 2 deletions
42
package/android/src/main/java/com/mrousavy/camera/react/CameraPackage.kt
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,16 +1,54 @@ | ||
package com.mrousavy.camera.react | ||
|
||
import com.facebook.react.ReactPackage | ||
import com.facebook.react.TurboReactPackage | ||
import com.facebook.react.bridge.NativeModule | ||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.module.model.ReactModuleInfo | ||
import com.facebook.react.module.model.ReactModuleInfoProvider | ||
import com.facebook.react.uimanager.ViewManager | ||
|
||
class CameraPackage : ReactPackage { | ||
class CameraPackage : TurboReactPackage() { | ||
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> = | ||
listOf( | ||
CameraViewModule(reactContext), | ||
CameraDevicesManager(reactContext) | ||
) | ||
|
||
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> = listOf(CameraViewManager()) | ||
|
||
override fun getModule(name: String, context: ReactApplicationContext): NativeModule? { | ||
return when (name) { | ||
CameraViewModule.TAG -> CameraViewModule(context) | ||
CameraDevicesManager.TAG -> CameraDevicesManager(context) | ||
else -> null | ||
} | ||
} | ||
|
||
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider { | ||
return ReactModuleInfoProvider { | ||
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap() | ||
|
||
moduleInfos[CameraViewModule.TAG] = ReactModuleInfo( | ||
CameraViewModule.TAG, | ||
CameraViewModule.TAG, | ||
canOverrideExistingModule = false, | ||
needsEagerInit = true, | ||
hasConstants = true, | ||
isCxxModule = false, | ||
isTurboModule = false | ||
) | ||
|
||
moduleInfos[CameraDevicesManager.TAG] = ReactModuleInfo( | ||
CameraDevicesManager.TAG, | ||
CameraDevicesManager.TAG, | ||
canOverrideExistingModule = false, | ||
needsEagerInit = true, | ||
hasConstants = true, | ||
isCxxModule = false, | ||
isTurboModule = false | ||
) | ||
|
||
moduleInfos | ||
} | ||
} | ||
} |
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