Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ios][android] Update react-native-screens to 3.18.0 (#19383)
- Loading branch information
Showing
87 changed files
with
644 additions
and
443 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
32 changes: 0 additions & 32 deletions
32
...xpoview/src/main/java/versioned/host/exp/exponent/modules/api/screens/RNScreensPackage.kt
This file was deleted.
Oops, something went wrong.
117 changes: 117 additions & 0 deletions
117
android/vendored/unversioned/react-native-screens/android/build.gradle
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,117 @@ | ||
buildscript { | ||
ext.safeExtGet = {prop, fallback -> | ||
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback | ||
} | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
dependencies { | ||
classpath('com.android.tools.build:gradle:4.2.2') | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${safeExtGet('kotlinVersion', '1.6.21')}" | ||
classpath "com.diffplug.spotless:spotless-plugin-gradle:5.15.0" | ||
} | ||
} | ||
|
||
def isNewArchitectureEnabled() { | ||
// To opt-in for the New Architecture, you can either: | ||
// - Set `newArchEnabled` to true inside the `gradle.properties` file | ||
// - Invoke gradle with `-newArchEnabled=true` | ||
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true` | ||
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true" | ||
} | ||
|
||
// spotless is only accessible within react-native-screens repo | ||
if (project == rootProject) { | ||
apply from: 'spotless.gradle' | ||
} | ||
|
||
if (isNewArchitectureEnabled()) { | ||
apply plugin: "com.facebook.react" | ||
} | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'kotlin-android' | ||
|
||
def reactNativeArchitectures() { | ||
def value = project.getProperties().get("reactNativeArchitectures") | ||
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] | ||
} | ||
|
||
android { | ||
compileSdkVersion safeExtGet('compileSdkVersion', 28) | ||
|
||
// Used to override the NDK path/version on internal CI or by allowing | ||
// users to customize the NDK path/version from their root project (e.g. for M1 support) | ||
if (rootProject.hasProperty("ndkPath")) { | ||
ndkPath rootProject.ext.ndkPath | ||
} | ||
if (rootProject.hasProperty("ndkVersion")) { | ||
ndkVersion rootProject.ext.ndkVersion | ||
} | ||
|
||
defaultConfig { | ||
minSdkVersion safeExtGet('minSdkVersion', 21) | ||
targetSdkVersion safeExtGet('targetSdkVersion', 22) | ||
versionCode 1 | ||
versionName "1.0" | ||
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() | ||
ndk { | ||
abiFilters (*reactNativeArchitectures()) | ||
} | ||
} | ||
lintOptions { | ||
abortOnError false | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
packagingOptions { | ||
// For some reason gradle only complains about the duplicated version of libreact_render libraries | ||
// while there are more libraries copied in intermediates folder of the lib build directory, we exlude | ||
// only the ones that make the build fail (ideally we should only include librnscreens_modules but we | ||
// are only allowed to specify exlude patterns) | ||
exclude "**/libreact_render*.so" | ||
} | ||
sourceSets.main { | ||
java { | ||
if (isNewArchitectureEnabled()) { | ||
srcDirs += [ | ||
"src/fabric/java", | ||
] | ||
} else { | ||
srcDirs += [ | ||
"src/paper/java", | ||
"build/generated/source/codegen/java" | ||
] | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
repositories { | ||
maven { | ||
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm | ||
// Matches the RN Hello World template | ||
// https://github.com/facebook/react-native/blob/1e8f3b11027fe0a7514b4fc97d0798d3c64bc895/local-cli/templates/HelloWorld/android/build.gradle#L21 | ||
url "$projectDir/../node_modules/react-native/android" | ||
} | ||
mavenCentral() | ||
mavenLocal() | ||
google() | ||
} | ||
|
||
dependencies { | ||
if (isNewArchitectureEnabled()) { | ||
implementation project(":ReactAndroid") | ||
} else { | ||
implementation 'com.facebook.react:react-native:+' | ||
} | ||
implementation 'androidx.appcompat:appcompat:1.1.0' | ||
implementation 'androidx.fragment:fragment:1.2.1' | ||
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0' | ||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0' | ||
implementation 'com.google.android.material:material:1.1.0' | ||
implementation "androidx.core:core-ktx:1.5.0" | ||
} |
49 changes: 49 additions & 0 deletions
49
...-native-screens/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledViewGroup.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,49 @@ | ||
package com.swmansion.rnscreens | ||
|
||
import android.view.ViewGroup | ||
import androidx.annotation.UiThread | ||
import com.facebook.react.bridge.ReactContext | ||
import com.facebook.react.bridge.ReadableMap | ||
import com.facebook.react.bridge.WritableMap | ||
import com.facebook.react.bridge.WritableNativeMap | ||
import com.facebook.react.uimanager.FabricViewStateManager | ||
import com.facebook.react.uimanager.PixelUtil | ||
import kotlin.math.abs | ||
|
||
abstract class FabricEnabledViewGroup constructor(context: ReactContext?) : ViewGroup(context), FabricViewStateManager.HasFabricViewStateManager { | ||
private val mFabricViewStateManager: FabricViewStateManager = FabricViewStateManager() | ||
|
||
override fun getFabricViewStateManager(): FabricViewStateManager { | ||
return mFabricViewStateManager | ||
} | ||
|
||
protected fun updateScreenSizeFabric(width: Int, height: Int) { | ||
updateState(width, height) | ||
} | ||
|
||
@UiThread | ||
fun updateState(width: Int, height: Int) { | ||
val realWidth: Float = PixelUtil.toDIPFromPixel(width.toFloat()) | ||
val realHeight: Float = PixelUtil.toDIPFromPixel(height.toFloat()) | ||
|
||
// Check incoming state values. If they're already the correct value, return early to prevent | ||
// infinite UpdateState/SetState loop. | ||
val currentState: ReadableMap? = mFabricViewStateManager.getStateData() | ||
if (currentState != null) { | ||
val delta = 0.9f | ||
val stateFrameHeight: Float = if (currentState.hasKey("frameHeight")) currentState.getDouble("frameHeight").toFloat() else 0f | ||
val stateFrameWidth: Float = if (currentState.hasKey("frameWidth")) currentState.getDouble("frameWidth").toFloat() else 0f | ||
if (abs(stateFrameWidth - realWidth) < delta && | ||
abs(stateFrameHeight - realHeight) < delta | ||
) { | ||
return | ||
} | ||
} | ||
mFabricViewStateManager.setState { | ||
val map: WritableMap = WritableNativeMap() | ||
map.putDouble("frameWidth", realWidth.toDouble()) | ||
map.putDouble("frameHeight", realHeight.toDouble()) | ||
map | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
android/vendored/unversioned/react-native-screens/android/src/main/AndroidManifest.xml
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,5 @@ | ||
|
||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.swmansion.rnscreens"> | ||
|
||
</manifest> |
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
2 changes: 1 addition & 1 deletion
2
...nent/modules/api/screens/CustomToolbar.kt → .../com/swmansion/rnscreens/CustomToolbar.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
2 changes: 1 addition & 1 deletion
2
...api/screens/FragmentBackPressOverrider.kt → ...n/rnscreens/FragmentBackPressOverrider.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
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
21 changes: 21 additions & 0 deletions
21
...ed/react-native-screens/android/src/main/java/com/swmansion/rnscreens/RNScreensPackage.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,21 @@ | ||
package com.swmansion.rnscreens | ||
|
||
import com.facebook.react.ReactPackage | ||
import com.facebook.react.bridge.NativeModule | ||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.uimanager.ViewManager | ||
|
||
class RNScreensPackage : ReactPackage { | ||
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> = | ||
emptyList() | ||
|
||
override fun createViewManagers(reactContext: ReactApplicationContext) = | ||
listOf<ViewManager<*, *>>( | ||
ScreenContainerViewManager(), | ||
ScreenViewManager(), | ||
ScreenStackViewManager(), | ||
ScreenStackHeaderConfigViewManager(), | ||
ScreenStackHeaderSubviewManager(), | ||
SearchBarManager() | ||
) | ||
} |
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.