-
-
Notifications
You must be signed in to change notification settings - Fork 982
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description * 54710a6 - Added `sourceSets` to the package due to changes in ViewManager function signatures, which are no longer nullable * a20adca - Updated to reflect changes in facebook/react-native#47551, `findHostInstance_DEPRECATED` is now a property of the `default` object instead of being a named export. Modified implementation reads from default and fall back to named export as needed * ac7e786 - Similar change to the software-mansion/react-native-svg#2572 that uses new API to create an association map between JS components and their native implementations, avoiding `codegen` crawling through the entire filesystem for `.mm` files. ## Test plan App with React Native 0.77 (like #3277) should compile and work as expected.
- Loading branch information
Showing
5 changed files
with
107 additions
and
2 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
85 changes: 85 additions & 0 deletions
85
android/package77/src/main/java/com/swmansion/gesturehandler/RNGestureHandlerPackage.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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package com.swmansion.gesturehandler | ||
|
||
import com.facebook.react.BaseReactPackage | ||
import com.facebook.react.ViewManagerOnDemandReactPackage | ||
import com.facebook.react.bridge.ModuleSpec | ||
import com.facebook.react.bridge.NativeModule | ||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.module.annotations.ReactModule | ||
import com.facebook.react.module.annotations.ReactModuleList | ||
import com.facebook.react.module.model.ReactModuleInfo | ||
import com.facebook.react.module.model.ReactModuleInfoProvider | ||
import com.facebook.react.uimanager.ViewManager | ||
import com.swmansion.gesturehandler.react.RNGestureHandlerButtonViewManager | ||
import com.swmansion.gesturehandler.react.RNGestureHandlerModule | ||
import com.swmansion.gesturehandler.react.RNGestureHandlerRootViewManager | ||
|
||
@ReactModuleList( | ||
nativeModules = [ | ||
RNGestureHandlerModule::class | ||
] | ||
) | ||
class RNGestureHandlerPackage : BaseReactPackage(), ViewManagerOnDemandReactPackage { | ||
private val viewManagers: Map<String, ModuleSpec> by lazy { | ||
mapOf( | ||
RNGestureHandlerRootViewManager.REACT_CLASS to ModuleSpec.viewManagerSpec { | ||
RNGestureHandlerRootViewManager() | ||
}, | ||
RNGestureHandlerButtonViewManager.REACT_CLASS to ModuleSpec.viewManagerSpec { | ||
RNGestureHandlerButtonViewManager() | ||
} | ||
) | ||
} | ||
|
||
override fun createViewManagers(reactContext: ReactApplicationContext) = | ||
listOf<ViewManager<*, *>>( | ||
RNGestureHandlerRootViewManager(), | ||
RNGestureHandlerButtonViewManager() | ||
) | ||
|
||
override fun getViewManagerNames(reactContext: ReactApplicationContext) = | ||
viewManagers.keys.toList() | ||
|
||
override fun getViewManagers(reactContext: ReactApplicationContext): MutableList<ModuleSpec> = | ||
viewManagers.values.toMutableList() | ||
|
||
override fun createViewManager( | ||
reactContext: ReactApplicationContext, | ||
viewManagerName: String | ||
) = viewManagers[viewManagerName]?.provider?.get() as? ViewManager<*, *> | ||
|
||
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? { | ||
return if (name == RNGestureHandlerModule.NAME) { | ||
RNGestureHandlerModule(reactContext) | ||
} else { | ||
null | ||
} | ||
} | ||
|
||
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider { | ||
try { | ||
val reactModuleInfoProviderClass = | ||
Class.forName("com.swmansion.gesturehandler.RNGestureHandlerPackage$\$ReactModuleInfoProvider") | ||
return reactModuleInfoProviderClass.getDeclaredConstructor().newInstance() as ReactModuleInfoProvider | ||
} catch (e: ClassNotFoundException) { | ||
return ReactModuleInfoProvider { | ||
val reactModule: ReactModule = RNGestureHandlerModule::class.java.getAnnotation(ReactModule::class.java)!! | ||
|
||
mutableMapOf( | ||
RNGestureHandlerModule.NAME to ReactModuleInfo( | ||
reactModule.name, | ||
RNGestureHandlerModule::class.java.name, | ||
reactModule.canOverrideExistingModule, | ||
reactModule.needsEagerInit, | ||
reactModule.isCxxModule, | ||
true | ||
) | ||
) | ||
} | ||
} catch (e: InstantiationException) { | ||
throw RuntimeException("No ReactModuleInfoProvider for RNGestureHandlerPackage$\$ReactModuleInfoProvider", e) | ||
} catch (e: IllegalAccessException) { | ||
throw RuntimeException("No ReactModuleInfoProvider for RNGestureHandlerPackage$\$ReactModuleInfoProvider", e) | ||
} | ||
} | ||
} |
File renamed without changes.
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 |
---|---|---|
|
@@ -144,6 +144,11 @@ | |
"jsSrcsDir": "./src/specs", | ||
"android": { | ||
"javaPackageName": "com.swmansion.gesturehandler" | ||
}, | ||
"ios": { | ||
"componentProvider": { | ||
"RNGestureHandlerButton": "RNGestureHandlerButtonComponentView" | ||
} | ||
} | ||
}, | ||
"packageManager": "[email protected]" | ||
|
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