diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 3d4fd12b..a521ebdf 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -92,15 +92,6 @@ body: Providing as much information as possible greatly helps us with reproducting the issues. - - type: dropdown - id: architecture - attributes: - label: Architecture - description: What React Native architecture your application is running on? - options: - - Paper (Old Architecture) - - Fabric (New Architecture) - - type: dropdown id: build-type attributes: diff --git a/.github/scripts/build-android.cmd b/.github/scripts/build-android.cmd index 14603ad9..e3d84f44 100644 --- a/.github/scripts/build-android.cmd +++ b/.github/scripts/build-android.cmd @@ -6,4 +6,4 @@ subst W: "%GITHUB_WORKSPACE%\example" || exit /b 1 robocopy W:\node_modules\react-native-test-app W:\r /MIR /NFL /NDL /NJH /NJS /NP if %ERRORLEVEL% GEQ 8 exit /b %ERRORLEVEL% cd /D W:\android || exit /b 1 -call gradlew.bat assembleDebug -PnewArchEnabled=%1 +call gradlew.bat assembleDebug diff --git a/.github/scripts/build-android.sh b/.github/scripts/build-android.sh index c353f610..1a262285 100755 --- a/.github/scripts/build-android.sh +++ b/.github/scripts/build-android.sh @@ -1,12 +1,10 @@ #!/usr/bin/env bash set -euo pipefail -new_arch="${1:-false}" - if [[ "${RUNNER_OS:-}" == "Windows" ]]; then script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - cmd //c "$(cygpath -w "$script_dir/build-android.cmd")" "$new_arch" + cmd //c "$(cygpath -w "$script_dir/build-android.cmd")" else cd example/android - ./gradlew assembleDebug -PnewArchEnabled="${new_arch}" + ./gradlew assembleDebug fi diff --git a/.github/workflows/android-release.yml b/.github/workflows/android-release.yml index 0a9a7b66..9704347a 100644 --- a/.github/workflows/android-release.yml +++ b/.github/workflows/android-release.yml @@ -35,7 +35,7 @@ jobs: working-directory: example - name: Build Android example app - run: ./gradlew assembleRelease -PnewArchEnabled=true + run: ./gradlew assembleRelease working-directory: example/android - name: Upload APK to Release diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 0fbfc149..79d36e39 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -44,6 +44,12 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] + react-native: [0.87.0] + react: [19.2.8] + include: + - os: ubuntu-latest + react-native: 0.82.0 + react: 19.1.1 defaults: run: shell: bash @@ -66,11 +72,19 @@ jobs: path: | node_modules */*/node_modules - key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + key: ${{ runner.os }}-rn-${{ matrix.react-native }}-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies run: yarn install --frozen-lockfile - - name: Install example app dependencies - run: yarn install --frozen-lockfile + - name: Install React Native ${{ matrix.react-native }} example dependencies + run: yarn add --exact "react@${{ matrix.react }}" "react-native@${{ matrix.react-native }}" working-directory: example + - name: Use RN 0.82-compatible Gradle + if: matrix.react-native == '0.82.0' + run: sed -i 's/gradle-9.4.1-bin.zip/gradle-9.0.0-bin.zip/' example/android/gradle/wrapper/gradle-wrapper.properties - name: Build Android example app - run: ./.github/scripts/build-android.sh true + if: matrix.react-native != '0.82.0' + run: ./.github/scripts/build-android.sh + - name: Compile library against the RN floor + if: matrix.react-native == '0.82.0' + run: ./gradlew :react-native-safe-area-context:compileDebugKotlin + working-directory: example/android diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 985b1514..d9a3f163 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -63,8 +63,11 @@ jobs: - name: Install example app dependencies run: yarn install --frozen-lockfile working-directory: example + - name: Validate podspec + run: bundle exec pod lib lint ../react-native-safe-area-context.podspec --quick --allow-warnings --no-ansi + working-directory: example - name: Install pods - run: RCT_NEW_ARCH_ENABLED=1 npx pod-install + run: npx pod-install working-directory: example/ios - name: Build ios example app run: xcodebuild -scheme ReactTestApp -workspace RNSACExample.xcworkspace ONLY_ACTIVE_ARCH=NO -sdk iphonesimulator -configuration Debug diff --git a/Package.swift b/Package.swift index 5ed439fa..cb1692a7 100644 --- a/Package.swift +++ b/Package.swift @@ -25,7 +25,6 @@ let package = Package( .product(name: "ReactAppHeaders", package: "React-GeneratedCode"), ], path: ".", - exclude: ["ios/RNSafeAreaContext.xcodeproj"], sources: ["ios", "common/cpp"], publicHeadersPath: "ios", cSettings: [ diff --git a/android/build.gradle b/android/build.gradle index f7007a61..cec35792 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -23,15 +23,8 @@ def getExtOrDefault(name, defaultValue) { return rootProject.ext.has(name) ? rootProject.ext.get(name) : defaultValue } -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" -} - apply plugin: 'com.android.library' +apply plugin: 'com.facebook.react' def shouldEnableAgpFallback() { @@ -50,17 +43,10 @@ if (shouldEnableAgpFallback()) { apply plugin: 'kotlin-android' } -if (isNewArchitectureEnabled()) { - apply plugin: "com.facebook.react" -} - android { def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION if (agpVersion.tokenize('.')[0].toInteger() >= 7) { namespace "com.th3rdwave.safeareacontext" - buildFeatures { - buildConfig true - } } compileSdkVersion getExtOrDefault('compileSdkVersion', 31) @@ -79,8 +65,6 @@ android { targetSdkVersion getExtOrDefault('targetSdkVersion', 28) versionCode 1 versionName "1.0" - buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() - ndk { abiFilters (*reactNativeArchitectures()) } @@ -97,15 +81,6 @@ android { // are only allowed to specify exclude patterns) exclude "**/libreact_render*.so" } - sourceSets.main { - if (isNewArchitectureEnabled()) { - java.directories.add("${project.buildDir}/generated/source/codegen/java") // contains only java files - kotlin.directories.add("src/fabric/java") // contains only kotlin files - } else { - java.directories.add("src/paper/java") // contains both java and kotlin files - kotlin.directories.add("src/paper/java") - } - } } def reactNativeArchitectures() { diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index f5da5984..f4b498e9 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,5 +1,3 @@ - + diff --git a/android/src/fabric/java/com/th3rdwave/safeareacontext/InsetsChangeEvent.kt b/android/src/main/java/com/th3rdwave/safeareacontext/InsetsChangeEvent.kt similarity index 100% rename from android/src/fabric/java/com/th3rdwave/safeareacontext/InsetsChangeEvent.kt rename to android/src/main/java/com/th3rdwave/safeareacontext/InsetsChangeEvent.kt diff --git a/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaContextPackage.kt b/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaContextPackage.kt index 29c46222..07f37fca 100644 --- a/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaContextPackage.kt +++ b/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaContextPackage.kt @@ -8,8 +8,6 @@ import com.facebook.react.module.model.ReactModuleInfo import com.facebook.react.module.model.ReactModuleInfoProvider import com.facebook.react.uimanager.ViewManager -// Fool autolinking for older versions that do not support BaseReactPackage. -// public class SafeAreaContextPackage implements ReactPackage { class SafeAreaContextPackage : BaseReactPackage() { override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? { return when (name) { @@ -30,7 +28,7 @@ class SafeAreaContextPackage : BaseReactPackage() { true, reactModule.needsEagerInit, reactModule.isCxxModule, - BuildConfig.IS_NEW_ARCHITECTURE_ENABLED, + true, ) } return ReactModuleInfoProvider { reactModuleInfoMap } diff --git a/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaProviderManager.kt b/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaProviderManager.kt index d440bc46..b92aaed2 100644 --- a/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaProviderManager.kt +++ b/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaProviderManager.kt @@ -5,6 +5,7 @@ import com.facebook.react.module.annotations.ReactModule import com.facebook.react.uimanager.ThemedReactContext import com.facebook.react.uimanager.UIManagerHelper import com.facebook.react.uimanager.ViewGroupManager +import com.facebook.react.uimanager.common.UIManagerType import com.facebook.react.viewmanagers.RNCSafeAreaProviderManagerDelegate import com.facebook.react.viewmanagers.RNCSafeAreaProviderManagerInterface @@ -43,7 +44,7 @@ private fun handleOnInsetsChange( ) { val reactContext = view.context as ReactContext val reactTag = view.id - UIManagerHelper.getEventDispatcherForReactTag(reactContext, reactTag) + UIManagerHelper.getEventDispatcher(reactContext, UIManagerType.FABRIC) ?.dispatchEvent( InsetsChangeEvent( getSurfaceId(reactContext), diff --git a/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaView.kt b/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaView.kt index e5c56eb9..e7d64f0b 100644 --- a/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaView.kt +++ b/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaView.kt @@ -9,14 +9,11 @@ import android.view.ViewTreeObserver import android.view.WindowInsets import com.facebook.react.bridge.Arguments import com.facebook.react.uimanager.StateWrapper -import com.facebook.react.uimanager.UIManagerModule import com.facebook.react.views.view.ReactViewGroup class SafeAreaView(context: Context?) : ReactViewGroup(context), ViewTreeObserver.OnPreDrawListener { - private var mMode = SafeAreaViewMode.PADDING private var mInsets: EdgeInsets? = null - private var mEdges: SafeAreaViewEdges? = null private var mCornerAdaptation = CornerAdaptation.NONE private var mLastSafeAreaInsets: EdgeInsets? = null private var mLastProviderFrame: Rect? = null @@ -36,40 +33,15 @@ class SafeAreaView(context: Context?) : private fun updateInsets() { val insets = mInsets if (insets != null) { - val edges = - mEdges - ?: SafeAreaViewEdges( - SafeAreaViewEdgeModes.ADDITIVE, - SafeAreaViewEdgeModes.ADDITIVE, - SafeAreaViewEdgeModes.ADDITIVE, - SafeAreaViewEdgeModes.ADDITIVE, - ) val stateWrapper = getStateWrapper() if (stateWrapper != null) { val map = Arguments.createMap() map.putMap("insets", edgeInsetsToJsMap(insets)) stateWrapper.updateState(map) - } else { - val localData = SafeAreaViewLocalData(insets = insets, mode = mMode, edges = edges) - val reactContext = getReactContext(this) - val uiManager = reactContext.getNativeModule(UIManagerModule::class.java) - if (uiManager != null) { - uiManager.setViewLocalData(id, localData) - } } } } - fun setMode(mode: SafeAreaViewMode) { - mMode = mode - updateInsets() - } - - fun setEdges(edges: SafeAreaViewEdges) { - mEdges = edges - updateInsets() - } - fun setCornerAdaptation(cornerAdaptation: CornerAdaptation) { mCornerAdaptation = cornerAdaptation mLastSafeAreaInsets = null diff --git a/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewEdges.kt b/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewEdges.kt deleted file mode 100644 index f6a35536..00000000 --- a/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewEdges.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.th3rdwave.safeareacontext - -enum class SafeAreaViewEdgeModes { - OFF, - ADDITIVE, - MAXIMUM, -} - -data class SafeAreaViewEdges( - val top: SafeAreaViewEdgeModes, - val right: SafeAreaViewEdgeModes, - val bottom: SafeAreaViewEdgeModes, - val left: SafeAreaViewEdgeModes, -) - -class Safe diff --git a/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewLocalData.kt b/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewLocalData.kt deleted file mode 100644 index 93d543e8..00000000 --- a/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewLocalData.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.th3rdwave.safeareacontext - -data class SafeAreaViewLocalData( - val insets: EdgeInsets, - val mode: SafeAreaViewMode, - val edges: SafeAreaViewEdges, -) diff --git a/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewManager.kt b/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewManager.kt index 05f62877..2515f512 100644 --- a/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewManager.kt +++ b/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewManager.kt @@ -15,44 +15,10 @@ class SafeAreaViewManager : ReactViewManager() { override fun createViewInstance(context: ThemedReactContext) = SafeAreaView(context) - override fun createShadowNodeInstance() = SafeAreaViewShadowNode() + // These props are applied by RNCSafeAreaViewShadowNode in C++. + @ReactProp(name = "mode") fun setMode(view: SafeAreaView, mode: String?) = Unit - override fun getShadowNodeClass() = SafeAreaViewShadowNode::class.java - - @ReactProp(name = "mode") - fun setMode(view: SafeAreaView, mode: String?) { - when (mode) { - "padding" -> { - view.setMode(SafeAreaViewMode.PADDING) - } - "margin" -> { - view.setMode(SafeAreaViewMode.MARGIN) - } - } - } - - @ReactProp(name = "edges") - fun setEdges(view: SafeAreaView, propList: ReadableMap?) { - if (propList != null) { - view.setEdges( - SafeAreaViewEdges( - top = - propList.getString("top")?.let { SafeAreaViewEdgeModes.valueOf(it.uppercase()) } - ?: SafeAreaViewEdgeModes.OFF, - right = - propList.getString("right")?.let { SafeAreaViewEdgeModes.valueOf(it.uppercase()) } - ?: SafeAreaViewEdgeModes.OFF, - bottom = - propList.getString("bottom")?.let { - SafeAreaViewEdgeModes.valueOf(it.uppercase()) - } ?: SafeAreaViewEdgeModes.OFF, - left = - propList.getString("left")?.let { SafeAreaViewEdgeModes.valueOf(it.uppercase()) } - ?: SafeAreaViewEdgeModes.OFF, - ) - ) - } - } + @ReactProp(name = "edges") fun setEdges(view: SafeAreaView, edges: ReadableMap?) = Unit @ReactProp(name = "cornerAdaptation") fun setCornerAdaptation(view: SafeAreaView, cornerAdaptation: String?) { diff --git a/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewMode.kt b/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewMode.kt deleted file mode 100644 index 06fcc983..00000000 --- a/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewMode.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.th3rdwave.safeareacontext - -enum class SafeAreaViewMode { - PADDING, - MARGIN, -} diff --git a/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewShadowNode.kt b/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewShadowNode.kt deleted file mode 100644 index 7f1d5ea9..00000000 --- a/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewShadowNode.kt +++ /dev/null @@ -1,174 +0,0 @@ -package com.th3rdwave.safeareacontext - -import com.facebook.react.bridge.Dynamic -import com.facebook.react.bridge.ReadableType -import com.facebook.react.uimanager.* -import com.facebook.react.uimanager.annotations.ReactPropGroup -import kotlin.math.max - -class SafeAreaViewShadowNode : LayoutShadowNode() { - private var mLocalData: SafeAreaViewLocalData? = null - private val mPaddings: FloatArray = FloatArray(ViewProps.PADDING_MARGIN_SPACING_TYPES.size) - private val mMargins: FloatArray = FloatArray(ViewProps.PADDING_MARGIN_SPACING_TYPES.size) - private var mNeedsUpdate = false - - init { - for (i in ViewProps.PADDING_MARGIN_SPACING_TYPES.indices) { - mPaddings[i] = Float.NaN - mMargins[i] = Float.NaN - } - } - - private fun updateInsets() { - val localData = mLocalData ?: return - var top = 0f - var right = 0f - var bottom = 0f - var left = 0f - val meta = if (localData.mode == SafeAreaViewMode.PADDING) mPaddings else mMargins - val allEdges = meta[Spacing.ALL] - if (!java.lang.Float.isNaN(allEdges)) { - top = allEdges - right = allEdges - bottom = allEdges - left = allEdges - } - val verticalEdges = meta[Spacing.VERTICAL] - if (!java.lang.Float.isNaN(verticalEdges)) { - top = verticalEdges - bottom = verticalEdges - } - val horizontalEdges = meta[Spacing.HORIZONTAL] - if (!java.lang.Float.isNaN(horizontalEdges)) { - right = horizontalEdges - left = horizontalEdges - } - val topEdge = meta[Spacing.TOP] - if (!java.lang.Float.isNaN(topEdge)) { - top = topEdge - } - val rightEdge = meta[Spacing.RIGHT] - if (!java.lang.Float.isNaN(rightEdge)) { - right = rightEdge - } - val bottomEdge = meta[Spacing.BOTTOM] - if (!java.lang.Float.isNaN(bottomEdge)) { - bottom = bottomEdge - } - val leftEdge = meta[Spacing.LEFT] - if (!java.lang.Float.isNaN(leftEdge)) { - left = leftEdge - } - top = PixelUtil.toPixelFromDIP(top) - right = PixelUtil.toPixelFromDIP(right) - bottom = PixelUtil.toPixelFromDIP(bottom) - left = PixelUtil.toPixelFromDIP(left) - val edges = localData.edges - val insets = localData.insets - if (localData.mode == SafeAreaViewMode.PADDING) { - super.setPadding(Spacing.TOP, getEdgeValue(edges.top, insets.top, top)) - super.setPadding(Spacing.RIGHT, getEdgeValue(edges.right, insets.right, right)) - super.setPadding(Spacing.BOTTOM, getEdgeValue(edges.bottom, insets.bottom, bottom)) - super.setPadding(Spacing.LEFT, getEdgeValue(edges.left, insets.left, left)) - } else { - super.setMargin(Spacing.TOP, getEdgeValue(edges.top, insets.top, top)) - super.setMargin(Spacing.RIGHT, getEdgeValue(edges.right, insets.right, right)) - super.setMargin(Spacing.BOTTOM, getEdgeValue(edges.bottom, insets.bottom, bottom)) - super.setMargin(Spacing.LEFT, getEdgeValue(edges.left, insets.left, left)) - } - } - - private fun getEdgeValue( - edgeMode: SafeAreaViewEdgeModes, - insetValue: Float, - edgeValue: Float, - ): Float { - if (edgeMode == SafeAreaViewEdgeModes.OFF) { - return edgeValue - } else if (edgeMode == SafeAreaViewEdgeModes.MAXIMUM) { - return max(insetValue, edgeValue) - } else { - return insetValue + edgeValue - } - } - - private fun resetInsets(mode: SafeAreaViewMode) { - if (mode == SafeAreaViewMode.PADDING) { - super.setPadding(Spacing.TOP, mPaddings[Spacing.TOP]) - super.setPadding(Spacing.RIGHT, mPaddings[Spacing.RIGHT]) - super.setPadding(Spacing.BOTTOM, mPaddings[Spacing.BOTTOM]) - super.setPadding(Spacing.LEFT, mPaddings[Spacing.LEFT]) - } else { - super.setMargin(Spacing.TOP, mMargins[Spacing.TOP]) - super.setMargin(Spacing.RIGHT, mMargins[Spacing.RIGHT]) - super.setMargin(Spacing.BOTTOM, mMargins[Spacing.BOTTOM]) - super.setMargin(Spacing.LEFT, mMargins[Spacing.LEFT]) - } - markUpdated() - } - - override fun onBeforeLayout(nativeViewHierarchyOptimizer: NativeViewHierarchyOptimizer) { - if (mNeedsUpdate) { - mNeedsUpdate = false - updateInsets() - } - } - - override fun setLocalData(data: Any) { - if (data !is SafeAreaViewLocalData) { - return - } - val localData = mLocalData - if (localData != null && localData.mode != data.mode) { - resetInsets(localData.mode) - } - mLocalData = data - mNeedsUpdate = false - updateInsets() - } - - // Names needs to reflect exact order in LayoutShadowNode.java - @ReactPropGroup( - names = - [ - ViewProps.PADDING, - ViewProps.PADDING_VERTICAL, - ViewProps.PADDING_HORIZONTAL, - ViewProps.PADDING_START, - ViewProps.PADDING_END, - ViewProps.PADDING_TOP, - ViewProps.PADDING_BOTTOM, - ViewProps.PADDING_LEFT, - ViewProps.PADDING_RIGHT, - ] - ) - override fun setPaddings(index: Int, padding: Dynamic) { - val spacingType = ViewProps.PADDING_MARGIN_SPACING_TYPES[index] - mPaddings[spacingType] = - if (padding.type == ReadableType.Number) padding.asDouble().toFloat() else Float.NaN - super.setPaddings(index, padding) - mNeedsUpdate = true - } - - @ReactPropGroup( - names = - [ - ViewProps.MARGIN, - ViewProps.MARGIN_VERTICAL, - ViewProps.MARGIN_HORIZONTAL, - ViewProps.MARGIN_START, - ViewProps.MARGIN_END, - ViewProps.MARGIN_TOP, - ViewProps.MARGIN_BOTTOM, - ViewProps.MARGIN_LEFT, - ViewProps.MARGIN_RIGHT, - ] - ) - override fun setMargins(index: Int, margin: Dynamic) { - val spacingType = ViewProps.PADDING_MARGIN_SPACING_TYPES[index] - mMargins[spacingType] = - if (margin.type == ReadableType.Number) margin.asDouble().toFloat() else Float.NaN - super.setMargins(index, margin) - mNeedsUpdate = true - } -} diff --git a/android/src/fabric/java/com/th3rdwave/safeareacontext/UIManagerHelperCompat.kt b/android/src/main/java/com/th3rdwave/safeareacontext/UIManagerHelperCompat.kt similarity index 100% rename from android/src/fabric/java/com/th3rdwave/safeareacontext/UIManagerHelperCompat.kt rename to android/src/main/java/com/th3rdwave/safeareacontext/UIManagerHelperCompat.kt diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaProviderManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaProviderManagerDelegate.java deleted file mode 100644 index f007c96d..00000000 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaProviderManagerDelegate.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * This code was generated by - * [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). - * - *

Do not edit this file as changes may cause incorrect behavior and will be lost once the code - * is regenerated. - * - * @generated by codegen project: GeneratePropsJavaDelegate.js - */ -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.uimanager.BaseViewManager; -import com.facebook.react.uimanager.BaseViewManagerDelegate; -import com.facebook.react.uimanager.LayoutShadowNode; - -public class RNCSafeAreaProviderManagerDelegate< - T extends View, - U extends - BaseViewManager & RNCSafeAreaProviderManagerInterface> - extends BaseViewManagerDelegate { - public RNCSafeAreaProviderManagerDelegate(U viewManager) { - super(viewManager); - } - - @Override - public void setProperty(T view, String propName, @Nullable Object value) { - super.setProperty(view, propName, value); - } -} diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaProviderManagerInterface.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaProviderManagerInterface.java deleted file mode 100644 index 466e74c0..00000000 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaProviderManagerInterface.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * This code was generated by - * [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). - * - *

Do not edit this file as changes may cause incorrect behavior and will be lost once the code - * is regenerated. - * - * @generated by codegen project: GeneratePropsJavaInterface.js - */ -package com.facebook.react.viewmanagers; - -import android.view.View; - -public interface RNCSafeAreaProviderManagerInterface { - // No props -} diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaViewManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaViewManagerDelegate.java deleted file mode 100644 index 4324b401..00000000 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaViewManagerDelegate.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * This code was generated by - * [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). - * - *

Do not edit this file as changes may cause incorrect behavior and will be lost once the code - * is regenerated. - * - * @generated by codegen project: GeneratePropsJavaDelegate.js - */ -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ReadableMap; -import com.facebook.react.uimanager.BaseViewManager; -import com.facebook.react.uimanager.BaseViewManagerDelegate; -import com.facebook.react.uimanager.LayoutShadowNode; - -public class RNCSafeAreaViewManagerDelegate< - T extends View, - U extends - BaseViewManager & RNCSafeAreaViewManagerInterface> - extends BaseViewManagerDelegate { - public RNCSafeAreaViewManagerDelegate(U viewManager) { - super(viewManager); - } - - @Override - public void setProperty(T view, String propName, @Nullable Object value) { - switch (propName) { - case "mode": - mViewManager.setMode(view, (String) value); - break; - case "edges": - mViewManager.setEdges(view, (ReadableMap) value); - break; - case "cornerAdaptation": - mViewManager.setCornerAdaptation(view, (String) value); - break; - default: - super.setProperty(view, propName, value); - } - } -} diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaViewManagerInterface.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaViewManagerInterface.java deleted file mode 100644 index 89c1698e..00000000 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaViewManagerInterface.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This code was generated by - * [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). - * - *

Do not edit this file as changes may cause incorrect behavior and will be lost once the code - * is regenerated. - * - * @generated by codegen project: GeneratePropsJavaInterface.js - */ -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ReadableMap; - -public interface RNCSafeAreaViewManagerInterface { - void setMode(T view, @Nullable String value); - - void setEdges(T view, @Nullable ReadableMap value); - - void setCornerAdaptation(T view, @Nullable String value); -} diff --git a/android/src/paper/java/com/th3rdwave/safeareacontext/InsetsChangeEvent.kt b/android/src/paper/java/com/th3rdwave/safeareacontext/InsetsChangeEvent.kt deleted file mode 100644 index 72dbd0dc..00000000 --- a/android/src/paper/java/com/th3rdwave/safeareacontext/InsetsChangeEvent.kt +++ /dev/null @@ -1,36 +0,0 @@ -@file:Suppress("DEPRECATION") - -package com.th3rdwave.safeareacontext - -import com.facebook.react.bridge.Arguments -import com.facebook.react.uimanager.events.Event -import com.facebook.react.uimanager.events.RCTEventEmitter - -internal class InsetsChangeEvent( - @Suppress("UNUSED_PARAMETER") surfaceId: Int, - viewTag: Int, - private val mInsets: EdgeInsets, - private val mVerticalCornerAdaptedInsets: EdgeInsets, - private val mHorizontalCornerAdaptedInsets: EdgeInsets, - private val mFrame: Rect, - // New ctor is only available in RN 0.65. -) : Event(viewTag) { - override fun getEventName() = EVENT_NAME - - // TODO: Migrate to getEventData when dropping support for RN 0.64. - override fun dispatch(rctEventEmitter: RCTEventEmitter) { - val event = Arguments.createMap() - event.putMap("insets", edgeInsetsToJsMap(mInsets)) - event.putMap("verticalCornerAdaptedInsets", edgeInsetsToJsMap(mVerticalCornerAdaptedInsets)) - event.putMap( - "horizontalCornerAdaptedInsets", - edgeInsetsToJsMap(mHorizontalCornerAdaptedInsets), - ) - event.putMap("frame", rectToJsMap(mFrame)) - rctEventEmitter.receiveEvent(viewTag, eventName, event) - } - - companion object { - const val EVENT_NAME = "topInsetsChange" - } -} diff --git a/android/src/paper/java/com/th3rdwave/safeareacontext/NativeSafeAreaContextSpec.java b/android/src/paper/java/com/th3rdwave/safeareacontext/NativeSafeAreaContextSpec.java deleted file mode 100644 index eef88b79..00000000 --- a/android/src/paper/java/com/th3rdwave/safeareacontext/NativeSafeAreaContextSpec.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * This code was generated by - * [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). - * - *

Do not edit this file as changes may cause incorrect behavior and will be lost once the code - * is regenerated. - * - * @generated by codegen project: GenerateModuleJavaSpec.js - * @nolint - */ -package com.th3rdwave.safeareacontext; - -import com.facebook.proguard.annotations.DoNotStrip; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.bridge.ReactContextBaseJavaModule; -import com.facebook.react.bridge.ReactModuleWithSpec; -import com.facebook.react.common.build.ReactBuildConfig; -import com.facebook.react.turbomodule.core.interfaces.TurboModule; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import javax.annotation.Nullable; - -public abstract class NativeSafeAreaContextSpec extends ReactContextBaseJavaModule - implements ReactModuleWithSpec, TurboModule { - public NativeSafeAreaContextSpec(ReactApplicationContext reactContext) { - super(reactContext); - } - - protected abstract Map getTypedExportedConstants(); - - @Override - @DoNotStrip - public final @Nullable Map getConstants() { - Map constants = getTypedExportedConstants(); - if (ReactBuildConfig.DEBUG || ReactBuildConfig.IS_INTERNAL_BUILD) { - Set obligatoryFlowConstants = new HashSet<>(); - Set optionalFlowConstants = new HashSet<>(Arrays.asList("initialWindowMetrics")); - Set undeclaredConstants = new HashSet<>(constants.keySet()); - undeclaredConstants.removeAll(obligatoryFlowConstants); - undeclaredConstants.removeAll(optionalFlowConstants); - if (!undeclaredConstants.isEmpty()) { - throw new IllegalStateException( - String.format("Native Module Flow doesn't declare constants: %s", undeclaredConstants)); - } - undeclaredConstants = obligatoryFlowConstants; - undeclaredConstants.removeAll(constants.keySet()); - if (!undeclaredConstants.isEmpty()) { - throw new IllegalStateException( - String.format("Native Module doesn't fill in constants: %s", undeclaredConstants)); - } - } - return constants; - } -} diff --git a/android/src/paper/java/com/th3rdwave/safeareacontext/UIManagerHelperCompat.kt b/android/src/paper/java/com/th3rdwave/safeareacontext/UIManagerHelperCompat.kt deleted file mode 100644 index 0b4c61af..00000000 --- a/android/src/paper/java/com/th3rdwave/safeareacontext/UIManagerHelperCompat.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.th3rdwave.safeareacontext - -import android.content.Context -import android.content.ContextWrapper -import android.view.View -import com.facebook.react.bridge.ReactContext - -/** UIManagerHelper.getReactContext only exists in RN 0.63+ so vendor it here for a while. */ -fun getReactContext(view: View): ReactContext { - var context = view.context - if (context !is ReactContext && context is ContextWrapper) { - context = context.baseContext - } - return context as ReactContext -} - -/** UIManagerHelper.getSurfaceId only exists in RN 0.65+, surface id is only needed for new arch. */ -fun getSurfaceId(@Suppress("UNUSED_PARAMETER") context: Context): Int { - return -1 -} diff --git a/docs/docs/getting-started.mdx b/docs/docs/getting-started.mdx index a23d6c94..c0883f40 100644 --- a/docs/docs/getting-started.mdx +++ b/docs/docs/getting-started.mdx @@ -26,12 +26,13 @@ import TabItem from '@theme/TabItem'; | react-native-safe-area-context version | react-native version | | -------------------------------------- | -------------------- | +| 6.x | >= 0.82 | | 5.x | >= 0.75 | | 4.x | 0.64 - 0.74 | ## New architecture support -This library currently has experimental support for the new react-native architecture. Note that there will be breaking changes and only the latest version of react-native will be supported. +Version 6.x supports only React Native's New Architecture and requires React Native 0.82 or newer. ## Contributing diff --git a/example/android/gradle.properties b/example/android/gradle.properties index 699e2af9..0c451317 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -34,8 +34,6 @@ android.jetifier.ignorelist=hermes-android,react-android # ./gradlew -PreactNativeArchitectures=x86_64 reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 -# React Native 0.82 and newer always use the New Architecture. -newArchEnabled=true bridgelessEnabled=true # Uncomment the line below to build React Native from source. @@ -47,6 +45,9 @@ bridgelessEnabled=true # Version of Kotlin to build against. #KOTLIN_VERSION=1.8.22 +# Keep AsyncStorage's KSP plugin aligned with its Kotlin 2.2.10 compiler. +AsyncStorage_kspVersion=2.2.10-2.0.2 + # Opt out of built-in kotlin and new DSL behavior that ships with AGP 9. # Starting from AGP 10.x these opt outs will be removed. android.builtInKotlin=false diff --git a/example/ios/Podfile b/example/ios/Podfile index 522b63d8..dfb5efe8 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -7,9 +7,7 @@ require "#{ws_dir}/node_modules/react-native-test-app/test_app.rb" workspace 'RNSACExample.xcworkspace' options = { -# RCT_NEW_ARCH_ENABLED env variable (used in CI) takes precedence over the following :bridgeless_enabled => true, - :fabric_enabled => true, :hermes_enabled => true, } diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 11ddad33..37403ac5 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -2128,7 +2128,7 @@ SPEC CHECKSUMS: React-Mapbuffer: acf4ac61f163f15ced7dfad7308957816b2d7abd React-microtasksnativemodule: 512d9f7c6b66574d90832a6b10b6102d4a8fdf30 React-mutationobservernativemodule: 2c5abeb9a4ae316ba6d9420ef8d9baa81faa9d56 - react-native-safe-area-context: 3a6b38edff2a811fc1e27f5ff81249b24ea7e607 + react-native-safe-area-context: 582cd62c1264dccf5fd9fab929d18bfed0391f5c React-NativeModulesApple: 22b2f3e1538ceb1aab1ab182ccb0666ea2ec36ad React-networking: b58b3098d4a626f88bbaeaf6bf5e67b18ff39089 React-oscompat: 72573ceb65b6c6c6bc34e51e0df8f44c91081a6d @@ -2173,6 +2173,6 @@ SPEC CHECKSUMS: SocketRocket: 37aec555668fb852ec12e3c0de59a86ca58f0871 Yoga: d1c536142c5ff8ec8cd856ab2a7c227a1d875c8e -PODFILE CHECKSUM: 0fafacc6692f2be08ea55bd74268ec824584f1f4 +PODFILE CHECKSUM: 4d200fd0e37fc90adb24e6cdb2de8c092043aeb6 COCOAPODS: 1.16.2 diff --git a/ios/RNCOnInsetsChangeEvent.h b/ios/RNCOnInsetsChangeEvent.h deleted file mode 100644 index dc3c750b..00000000 --- a/ios/RNCOnInsetsChangeEvent.h +++ /dev/null @@ -1,14 +0,0 @@ -#import -#import - -@interface RNCOnInsetsChangeEvent : NSObject - -- (instancetype)initWithEventName:(NSString *)eventName - reactTag:(NSNumber *)reactTag - insets:(UIEdgeInsets)insets - verticalCornerAdaptedInsets:(UIEdgeInsets)verticalCornerAdaptedInsets - horizontalCornerAdaptedInsets:(UIEdgeInsets)horizontalCornerAdaptedInsets - frame:(CGRect)frame - coalescingKey:(uint16_t)coalescingKey NS_DESIGNATED_INITIALIZER; - -@end diff --git a/ios/RNCOnInsetsChangeEvent.m b/ios/RNCOnInsetsChangeEvent.m deleted file mode 100644 index 7d155c14..00000000 --- a/ios/RNCOnInsetsChangeEvent.m +++ /dev/null @@ -1,97 +0,0 @@ -#import "RNCOnInsetsChangeEvent.h" -#import - -@implementation RNCOnInsetsChangeEvent { - UIEdgeInsets _insets; - UIEdgeInsets _verticalCornerAdaptedInsets; - UIEdgeInsets _horizontalCornerAdaptedInsets; - CGRect _frame; - uint16_t _coalescingKey; -} - -@synthesize eventName = _eventName; -@synthesize viewTag = _viewTag; - -- (instancetype)initWithEventName:(NSString *)eventName - reactTag:(NSNumber *)reactTag - insets:(UIEdgeInsets)insets - verticalCornerAdaptedInsets:(UIEdgeInsets)verticalCornerAdaptedInsets - horizontalCornerAdaptedInsets:(UIEdgeInsets)horizontalCornerAdaptedInsets - frame:(CGRect)frame - coalescingKey:(uint16_t)coalescingKey -{ - RCTAssertParam(reactTag); - - if ((self = [super init])) { - _eventName = [eventName copy]; - _viewTag = reactTag; - _frame = frame; - _insets = insets; - _verticalCornerAdaptedInsets = verticalCornerAdaptedInsets; - _horizontalCornerAdaptedInsets = horizontalCornerAdaptedInsets; - _coalescingKey = coalescingKey; - } - - return self; -} - -RCT_NOT_IMPLEMENTED(-(instancetype)init) - -- (uint16_t)coalescingKey -{ - return _coalescingKey; -} - -- (NSDictionary *)body -{ - NSDictionary *body = @{ - @"insets" : @{ - @"top" : @(_insets.top), - @"right" : @(_insets.right), - @"bottom" : @(_insets.bottom), - @"left" : @(_insets.left), - }, - @"verticalCornerAdaptedInsets" : @{ - @"top" : @(_verticalCornerAdaptedInsets.top), - @"right" : @(_verticalCornerAdaptedInsets.right), - @"bottom" : @(_verticalCornerAdaptedInsets.bottom), - @"left" : @(_verticalCornerAdaptedInsets.left), - }, - @"horizontalCornerAdaptedInsets" : @{ - @"top" : @(_horizontalCornerAdaptedInsets.top), - @"right" : @(_horizontalCornerAdaptedInsets.right), - @"bottom" : @(_horizontalCornerAdaptedInsets.bottom), - @"left" : @(_horizontalCornerAdaptedInsets.left), - }, - @"frame" : @{ - @"x" : @(_frame.origin.x), - @"y" : @(_frame.origin.y), - @"width" : @(_frame.size.width), - @"height" : @(_frame.size.height), - }, - }; - - return body; -} - -- (BOOL)canCoalesce -{ - return YES; -} - -- (RNCOnInsetsChangeEvent *)coalesceWithEvent:(RNCOnInsetsChangeEvent *)newEvent -{ - return newEvent; -} - -+ (NSString *)moduleDotMethod -{ - return @"RCTEventEmitter.receiveEvent"; -} - -- (NSArray *)arguments -{ - return @[ self.viewTag, RCTNormalizeInputEventName(self.eventName), [self body] ]; -} - -@end diff --git a/ios/RNCSafeAreaContext.mm b/ios/RNCSafeAreaContext.mm index 7ac43abd..5cb484bb 100644 --- a/ios/RNCSafeAreaContext.mm +++ b/ios/RNCSafeAreaContext.mm @@ -6,17 +6,13 @@ #elif TARGET_OS_OSX #import #endif -#ifdef RCT_NEW_ARCH_ENABLED #import -#endif #import "RNCSafeAreaUtils.h" -#ifdef RCT_NEW_ARCH_ENABLED using namespace facebook::react; @interface RNCSafeAreaContext () @end -#endif @implementation RNCSafeAreaContext @@ -92,13 +88,9 @@ - (NSDictionary *)getConstants return constants; } -#ifdef RCT_NEW_ARCH_ENABLED - - (std::shared_ptr)getTurboModule:(const ObjCTurboModule::InitParams &)params { return std::make_shared(params); } -#endif - @end diff --git a/ios/RNCSafeAreaProvider.h b/ios/RNCSafeAreaProvider.h deleted file mode 100644 index 5f05c593..00000000 --- a/ios/RNCSafeAreaProvider.h +++ /dev/null @@ -1,23 +0,0 @@ -#if TARGET_OS_IPHONE -#import -#elif TARGET_OS_OSX -#import -#endif - -#import -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface RNCSafeAreaProvider : RCTView - -- (instancetype)initWithEventDispatcher:(id)eventDispatcher NS_DESIGNATED_INITIALIZER; - -// NOTE: currently these event props are only declared so we can export the -// event names to JS - we don't call the blocks directly because events -// need to be coalesced before sending, for performance reasons. -@property (nonatomic, copy) RCTBubblingEventBlock onInsetsChange; - -@end - -NS_ASSUME_NONNULL_END diff --git a/ios/RNCSafeAreaProvider.m b/ios/RNCSafeAreaProvider.m deleted file mode 100644 index 7977aa12..00000000 --- a/ios/RNCSafeAreaProvider.m +++ /dev/null @@ -1,150 +0,0 @@ -#import "RNCSafeAreaProvider.h" - -#import -#import -#import -#import -#import "RNCOnInsetsChangeEvent.h" -#import "RNCSafeAreaUtils.h" - -@interface RNCSafeAreaProvider () - -@end - -@implementation RNCSafeAreaProvider { - id _eventDispatcher; - UIEdgeInsets _currentSafeAreaInsets; - UIEdgeInsets _currentVerticalCornerAdaptedInsets; - UIEdgeInsets _currentHorizontalCornerAdaptedInsets; -#if TARGET_OS_IPHONE - RNCSafeAreaCornerInputs _cornerInputs; - UIEdgeInsets _measuredVerticalCornerAdaptedInsets; - UIEdgeInsets _measuredHorizontalCornerAdaptedInsets; -#endif - CGRect _currentFrame; - BOOL _initialInsetsSent; -} - -- (instancetype)initWithEventDispatcher:(id)eventDispatcher -{ - RCTAssertParam(eventDispatcher); - - if ((self = [super initWithFrame:CGRectZero])) { - _eventDispatcher = eventDispatcher; - -#if !TARGET_OS_TV && !TARGET_OS_OSX - [NSNotificationCenter.defaultCenter addObserver:self - selector:@selector(invalidateSafeAreaInsets) - name:UIKeyboardDidShowNotification - object:nil]; - [NSNotificationCenter.defaultCenter addObserver:self - selector:@selector(invalidateSafeAreaInsets) - name:UIKeyboardDidHideNotification - object:nil]; - [NSNotificationCenter.defaultCenter addObserver:self - selector:@selector(invalidateSafeAreaInsets) - name:UIKeyboardDidChangeFrameNotification - object:nil]; - [NSNotificationCenter.defaultCenter addObserver:self - selector:@selector(invalidateSafeAreaInsets) - name:UIWindowDidBecomeVisibleNotification - object:nil]; -#endif - } - return self; -} - -- (void)safeAreaInsetsDidChange -{ - [self invalidateSafeAreaInsetsMeasuringCorners:YES]; -} - -- (void)invalidateSafeAreaInsets -{ - [self invalidateSafeAreaInsetsMeasuringCorners:NO]; -} - -- (void)invalidateSafeAreaInsetsMeasuringCorners:(BOOL)measureCorners -{ - // This gets called before the view size is set by react-native so - // make sure to wait so we don't set wrong insets to JS. - if (CGSizeEqualToSize(self.frame.size, CGSizeZero)) { - return; - } - -#if TARGET_OS_IPHONE - UIEdgeInsets safeAreaInsets = self.safeAreaInsets; - RNCSafeAreaCornerInputs cornerInputs = RNCSafeAreaCornerInputsMake(self, safeAreaInsets); - if (measureCorners || !RNCSafeAreaCornerInputsEqual(cornerInputs, _cornerInputs)) { - _cornerInputs = cornerInputs; - _measuredVerticalCornerAdaptedInsets = - RNCSafeAreaInsetsWithCornerAdaptation(self, RNCSafeAreaCornerAdaptationVertical); - _measuredHorizontalCornerAdaptedInsets = - RNCSafeAreaInsetsWithCornerAdaptation(self, RNCSafeAreaCornerAdaptationHorizontal); - } - UIEdgeInsets verticalCornerAdaptedInsets = _measuredVerticalCornerAdaptedInsets; - UIEdgeInsets horizontalCornerAdaptedInsets = _measuredHorizontalCornerAdaptedInsets; -#elif TARGET_OS_OSX - NSEdgeInsets safeAreaInsets; - if (@available(macOS 11.0, *)) { - safeAreaInsets = self.safeAreaInsets; - } else { - safeAreaInsets = NSEdgeInsetsZero; - } - NSEdgeInsets verticalCornerAdaptedInsets = safeAreaInsets; - NSEdgeInsets horizontalCornerAdaptedInsets = safeAreaInsets; -#endif - - CGRect frame = [self convertRect:self.bounds toView:RNCParentViewController(self).view]; - - if (_initialInsetsSent && -#if TARGET_OS_IPHONE - UIEdgeInsetsEqualToEdgeInsetsWithThreshold(safeAreaInsets, _currentSafeAreaInsets, 1.0 / RCTScreenScale()) && - UIEdgeInsetsEqualToEdgeInsetsWithThreshold( - verticalCornerAdaptedInsets, _currentVerticalCornerAdaptedInsets, 1.0 / RCTScreenScale()) && - UIEdgeInsetsEqualToEdgeInsetsWithThreshold( - horizontalCornerAdaptedInsets, _currentHorizontalCornerAdaptedInsets, 1.0 / RCTScreenScale()) && -#elif TARGET_OS_OSX - NSEdgeInsetsEqualToEdgeInsetsWithThreshold(safeAreaInsets, _currentSafeAreaInsets, 1.0 / RCTScreenScale()) && -#endif - CGRectEqualToRect(frame, _currentFrame)) { - return; - } - _initialInsetsSent = YES; - _currentSafeAreaInsets = safeAreaInsets; - _currentVerticalCornerAdaptedInsets = verticalCornerAdaptedInsets; - _currentHorizontalCornerAdaptedInsets = horizontalCornerAdaptedInsets; - _currentFrame = frame; - - [NSNotificationCenter.defaultCenter postNotificationName:RNCSafeAreaDidChange object:self userInfo:nil]; - - RNCOnInsetsChangeEvent *onInsetsChangeEvent = - [[RNCOnInsetsChangeEvent alloc] initWithEventName:@"onInsetsChange" - reactTag:self.reactTag - insets:safeAreaInsets - verticalCornerAdaptedInsets:verticalCornerAdaptedInsets - horizontalCornerAdaptedInsets:horizontalCornerAdaptedInsets - frame:frame - coalescingKey:0]; - - [_eventDispatcher sendEvent:onInsetsChangeEvent]; -} - -- (void)layoutSubviews -{ - [super layoutSubviews]; - - // UIKit can update corner-adapted insets in a layout pass before anything they depend on changes, e.g. while - // the iPhone Duo switches displays, so layout passes always measure them again. - [self invalidateSafeAreaInsetsMeasuringCorners:YES]; -} - -RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame) -RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder) - -- (void)dealloc -{ - [_eventDispatcher.bridge.uiManager.observerCoordinator removeObserver:self]; -} - -@end diff --git a/ios/RNCSafeAreaProviderManager.h b/ios/RNCSafeAreaProviderManager.h deleted file mode 100644 index d83c3275..00000000 --- a/ios/RNCSafeAreaProviderManager.h +++ /dev/null @@ -1,9 +0,0 @@ -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface RNCSafeAreaProviderManager : RCTViewManager - -@end - -NS_ASSUME_NONNULL_END diff --git a/ios/RNCSafeAreaProviderManager.m b/ios/RNCSafeAreaProviderManager.m deleted file mode 100644 index eeeb1b8a..00000000 --- a/ios/RNCSafeAreaProviderManager.m +++ /dev/null @@ -1,20 +0,0 @@ -#import "RNCSafeAreaProviderManager.h" - -#import "RNCSafeAreaProvider.h" - -@implementation RNCSafeAreaProviderManager - -RCT_EXPORT_MODULE(RNCSafeAreaProvider) - -RCT_EXPORT_VIEW_PROPERTY(onInsetsChange, RCTDirectEventBlock) - -#if TARGET_OS_IPHONE -- (UIView *)view -#elif TARGET_OS_OSX -- (NSView *)view -#endif -{ - return [[RNCSafeAreaProvider alloc] initWithEventDispatcher:self.bridge.eventDispatcher]; -} - -@end diff --git a/ios/RNCSafeAreaShadowView.h b/ios/RNCSafeAreaShadowView.h deleted file mode 100644 index a3474cda..00000000 --- a/ios/RNCSafeAreaShadowView.h +++ /dev/null @@ -1,9 +0,0 @@ -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface RNCSafeAreaShadowView : RCTShadowView - -@end - -NS_ASSUME_NONNULL_END diff --git a/ios/RNCSafeAreaShadowView.m b/ios/RNCSafeAreaShadowView.m deleted file mode 100644 index 25c326b7..00000000 --- a/ios/RNCSafeAreaShadowView.m +++ /dev/null @@ -1,194 +0,0 @@ -#import "RNCSafeAreaShadowView.h" - -#import -#include - -#import "RNCSafeAreaViewEdgeMode.h" -#import "RNCSafeAreaViewEdges.h" -#import "RNCSafeAreaViewLocalData.h" -#import "RNCSafeAreaViewMode.h" - -// From RCTShadowView.m -typedef NS_ENUM(unsigned int, meta_prop_t) { - META_PROP_LEFT, - META_PROP_TOP, - META_PROP_RIGHT, - META_PROP_BOTTOM, - META_PROP_HORIZONTAL, - META_PROP_VERTICAL, - META_PROP_ALL, - META_PROP_COUNT, -}; - -@implementation RNCSafeAreaShadowView { - RNCSafeAreaViewLocalData *_localData; - bool _needsUpdate; - YGValue _paddingMetaProps[META_PROP_COUNT]; - YGValue _marginMetaProps[META_PROP_COUNT]; -} - -- (instancetype)init -{ - self = [super init]; - if (self) { - _needsUpdate = false; - for (unsigned int ii = 0; ii < META_PROP_COUNT; ii++) { - _paddingMetaProps[ii] = YGValueUndefined; - _marginMetaProps[ii] = YGValueUndefined; - } - } - return self; -} - -- (void)extractEdges:(YGValue[])_metaProps - top:(CGFloat *)top - right:(CGFloat *)right - bottom:(CGFloat *)bottom - left:(CGFloat *)left -{ - if (_metaProps[META_PROP_ALL].unit == YGUnitPoint) { - *top = _metaProps[META_PROP_ALL].value; - *right = _metaProps[META_PROP_ALL].value; - *bottom = _metaProps[META_PROP_ALL].value; - *left = _metaProps[META_PROP_ALL].value; - } - - if (_metaProps[META_PROP_HORIZONTAL].unit == YGUnitPoint) { - *right = _metaProps[META_PROP_HORIZONTAL].value; - *left = _metaProps[META_PROP_HORIZONTAL].value; - } - - if (_metaProps[META_PROP_VERTICAL].unit == YGUnitPoint) { - *top = _metaProps[META_PROP_VERTICAL].value; - *bottom = _metaProps[META_PROP_VERTICAL].value; - } - - if (_metaProps[META_PROP_TOP].unit == YGUnitPoint) { - *top = _metaProps[META_PROP_TOP].value; - } - - if (_metaProps[META_PROP_RIGHT].unit == YGUnitPoint) { - *right = _metaProps[META_PROP_RIGHT].value; - } - - if (_metaProps[META_PROP_BOTTOM].unit == YGUnitPoint) { - *bottom = _metaProps[META_PROP_BOTTOM].value; - } - - if (_metaProps[META_PROP_LEFT].unit == YGUnitPoint) { - *left = _metaProps[META_PROP_LEFT].value; - } -} - -- (void)resetInsetsForMode:(RNCSafeAreaViewMode)mode -{ - if (mode == RNCSafeAreaViewModePadding) { - super.paddingTop = _paddingMetaProps[META_PROP_TOP]; - super.paddingRight = _paddingMetaProps[META_PROP_RIGHT]; - super.paddingBottom = _paddingMetaProps[META_PROP_BOTTOM]; - super.paddingLeft = _paddingMetaProps[META_PROP_LEFT]; - } else if (mode == RNCSafeAreaViewModeMargin) { - super.marginTop = _marginMetaProps[META_PROP_TOP]; - super.marginRight = _marginMetaProps[META_PROP_RIGHT]; - super.marginBottom = _marginMetaProps[META_PROP_BOTTOM]; - super.marginLeft = _marginMetaProps[META_PROP_LEFT]; - } -} - -- (void)updateInsets -{ - if (_localData == nil) { - return; - } - - UIEdgeInsets insets = _localData.insets; - RNCSafeAreaViewMode mode = _localData.mode; - RNCSafeAreaViewEdges edges = _localData.edges; - - CGFloat top = 0; - CGFloat right = 0; - CGFloat bottom = 0; - CGFloat left = 0; - - if (mode == RNCSafeAreaViewModePadding) { - [self extractEdges:_paddingMetaProps top:&top right:&right bottom:&bottom left:&left]; - super.paddingTop = (YGValue){[self getEdgeValue:edges.top insetValue:insets.top edgeValue:top], YGUnitPoint}; - super.paddingRight = - (YGValue){[self getEdgeValue:edges.right insetValue:insets.right edgeValue:right], YGUnitPoint}; - super.paddingBottom = - (YGValue){[self getEdgeValue:edges.bottom insetValue:insets.bottom edgeValue:bottom], YGUnitPoint}; - super.paddingLeft = (YGValue){[self getEdgeValue:edges.left insetValue:insets.left edgeValue:left], YGUnitPoint}; - } else if (mode == RNCSafeAreaViewModeMargin) { - [self extractEdges:_marginMetaProps top:&top right:&right bottom:&bottom left:&left]; - super.marginTop = (YGValue){[self getEdgeValue:edges.top insetValue:insets.top edgeValue:top], YGUnitPoint}; - super.marginRight = (YGValue){[self getEdgeValue:edges.right insetValue:insets.right edgeValue:right], YGUnitPoint}; - super.marginBottom = - (YGValue){[self getEdgeValue:edges.bottom insetValue:insets.bottom edgeValue:bottom], YGUnitPoint}; - super.marginLeft = (YGValue){[self getEdgeValue:edges.left insetValue:insets.left edgeValue:left], YGUnitPoint}; - } -} - -- (CGFloat)getEdgeValue:(RNCSafeAreaViewEdgeMode)edgeMode insetValue:(CGFloat)insetValue edgeValue:(CGFloat)edgeValue -{ - if (edgeMode == RNCSafeAreaViewEdgeModeOff) { - return edgeValue; - } else if (edgeMode == RNCSafeAreaViewEdgeModeMaximum) { - return MAX(insetValue, edgeValue); - } else { - return insetValue + edgeValue; - } -} - -- (void)didSetProps:(NSArray *)changedProps -{ - if (_needsUpdate) { - _needsUpdate = false; - [self updateInsets]; - } - [super didSetProps:changedProps]; -} - -- (void)setLocalData:(RNCSafeAreaViewLocalData *)localData -{ - RCTAssert( - [localData isKindOfClass:[RNCSafeAreaViewLocalData class]], - @"Local data object for `RCTRNCSafeAreaShadowView` must be `RCTRNCSafeAreaViewLocalData` instance."); - - if (_localData != nil && _localData.mode != localData.mode) { - [self resetInsetsForMode:_localData.mode]; - } - - _localData = localData; - _needsUpdate = false; - [self updateInsets]; - - if (_localData.mode == RNCSafeAreaViewModePadding) { - [super didSetProps:@[ @"paddingTop", @"paddingRight", @"paddingBottom", @"paddingLeft" ]]; - } else { - [super didSetProps:@[ @"marginTop", @"marginRight", @"marginBottom", @"marginLeft" ]]; - } -} - -#define SHADOW_VIEW_MARGIN_PADDING_PROP(edge, metaProp) \ - -(void)setPadding##edge : (YGValue)value \ - { \ - [super setPadding##edge:value]; \ - _needsUpdate = true; \ - _paddingMetaProps[META_PROP_##metaProp] = value; \ - } \ - -(void)setMargin##edge : (YGValue)value \ - { \ - [super setMargin##edge:value]; \ - _needsUpdate = true; \ - _marginMetaProps[META_PROP_##metaProp] = value; \ - } - -SHADOW_VIEW_MARGIN_PADDING_PROP(, ALL); -SHADOW_VIEW_MARGIN_PADDING_PROP(Vertical, VERTICAL); -SHADOW_VIEW_MARGIN_PADDING_PROP(Horizontal, HORIZONTAL); -SHADOW_VIEW_MARGIN_PADDING_PROP(Top, TOP); -SHADOW_VIEW_MARGIN_PADDING_PROP(Right, RIGHT); -SHADOW_VIEW_MARGIN_PADDING_PROP(Bottom, BOTTOM); -SHADOW_VIEW_MARGIN_PADDING_PROP(Left, LEFT); - -@end diff --git a/ios/RNCSafeAreaUtils.h b/ios/RNCSafeAreaUtils.h index 68502f1d..cf44fa10 100644 --- a/ios/RNCSafeAreaUtils.h +++ b/ios/RNCSafeAreaUtils.h @@ -1,5 +1,5 @@ #import -#import +#import #if TARGET_OS_IPHONE #import #elif TARGET_OS_OSX diff --git a/ios/RNCSafeAreaUtils.m b/ios/RNCSafeAreaUtils.m index 0bd982fc..d004f020 100644 --- a/ios/RNCSafeAreaUtils.m +++ b/ios/RNCSafeAreaUtils.m @@ -1,7 +1,5 @@ #import "RNCSafeAreaUtils.h" -#import - NSString *const RNCSafeAreaDidChange = @"RNCSafeAreaDidChange"; #if TARGET_OS_IPHONE diff --git a/ios/RNCSafeAreaView.h b/ios/RNCSafeAreaView.h deleted file mode 100644 index f4e80e31..00000000 --- a/ios/RNCSafeAreaView.h +++ /dev/null @@ -1,27 +0,0 @@ -#import -#import -#if TARGET_OS_IPHONE -#import -#elif TARGET_OS_OSX -#import -#endif - -#import "RNCSafeAreaCornerAdaptation.h" -#import "RNCSafeAreaViewEdges.h" -#import "RNCSafeAreaViewMode.h" - -NS_ASSUME_NONNULL_BEGIN - -@class RNCSafeAreaView; - -@interface RNCSafeAreaView : RCTView - -- (instancetype)initWithBridge:(RCTBridge *)bridge; - -@property (nonatomic, assign) RNCSafeAreaViewMode mode; -@property (nonatomic, assign) RNCSafeAreaViewEdges edges; -@property (nonatomic, assign) RNCSafeAreaCornerAdaptation cornerAdaptation; - -@end - -NS_ASSUME_NONNULL_END diff --git a/ios/RNCSafeAreaView.m b/ios/RNCSafeAreaView.m deleted file mode 100644 index 5b494da3..00000000 --- a/ios/RNCSafeAreaView.m +++ /dev/null @@ -1,175 +0,0 @@ -#import "RNCSafeAreaView.h" - -#import -#import - -#import "RNCSafeAreaProvider.h" -#import "RNCSafeAreaUtils.h" -#import "RNCSafeAreaViewEdges.h" -#import "RNCSafeAreaViewLocalData.h" -#import "RNCSafeAreaViewMode.h" - -@implementation RNCSafeAreaView { - __weak RCTBridge *_bridge; -#if TARGET_OS_IPHONE - UIEdgeInsets _currentSafeAreaInsets; -#elif TARGET_OS_OSX - NSEdgeInsets _currentSafeAreaInsets; -#endif - RNCSafeAreaViewMode _mode; - RNCSafeAreaViewEdges _edges; - RNCSafeAreaCornerAdaptation _cornerAdaptation; - __weak RNCSafeAreaProvider *_Nullable _providerView; -} - -- (instancetype)initWithBridge:(RCTBridge *)bridge -{ - if (self = [super initWithFrame:CGRectZero]) { - _bridge = bridge; - // Defaults - _mode = RNCSafeAreaViewModePadding; - _edges = RNCSafeAreaViewEdgesMake( - RNCSafeAreaViewEdgeModeOff, RNCSafeAreaViewEdgeModeOff, RNCSafeAreaViewEdgeModeOff, RNCSafeAreaViewEdgeModeOff); - } - - return self; -} - -RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)decoder) -RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame) - -- (NSString *)description -{ - NSString *superDescription = [super description]; - - // Cutting the last `>` character. - if (superDescription.length > 0 && [superDescription characterAtIndex:superDescription.length - 1] == '>') { - superDescription = [superDescription substringToIndex:superDescription.length - 1]; - } - -#if TARGET_OS_IPHONE - NSString *providerViewSafeAreaInsetsString = NSStringFromUIEdgeInsets(_providerView.safeAreaInsets); - NSString *currentSafeAreaInsetsString = NSStringFromUIEdgeInsets(_currentSafeAreaInsets); -#elif TARGET_OS_OSX - NSString *providerViewSafeAreaInsetsString; - NSString *currentSafeAreaInsetsString; - if (@available(macOS 11.0, *)) { - providerViewSafeAreaInsetsString = [NSString stringWithFormat:@"{%f,%f,%f,%f}", - _providerView.safeAreaInsets.top, - _providerView.safeAreaInsets.left, - _providerView.safeAreaInsets.bottom, - _providerView.safeAreaInsets.right]; - currentSafeAreaInsetsString = [NSString stringWithFormat:@"{%f,%f,%f,%f}", - _currentSafeAreaInsets.top, - _currentSafeAreaInsets.left, - _currentSafeAreaInsets.bottom, - _currentSafeAreaInsets.right]; - } else { - providerViewSafeAreaInsetsString = @"{0.0,0.0,0.0,0.0}"; - currentSafeAreaInsetsString = @"{0.0,0.0,0.0,0.0}"; - } -#endif - - return [NSString stringWithFormat:@"%@; RNCSafeAreaInsets = %@; appliedRNCSafeAreaInsets = %@>", - superDescription, - providerViewSafeAreaInsetsString, - currentSafeAreaInsetsString]; -} - -- (void)didMoveToWindow -{ -#if TARGET_OS_IPHONE - UIView *previousProviderView = _providerView; -#elif TARGET_OS_OSX - NSView *previousProviderView = _providerView; -#endif - _providerView = [self findNearestProvider]; - - [self invalidateSafeAreaInsets]; - - if (previousProviderView != _providerView) { - if (previousProviderView != nil) { - [NSNotificationCenter.defaultCenter removeObserver:self name:RNCSafeAreaDidChange object:previousProviderView]; - } - - if (_providerView != nil) { - [NSNotificationCenter.defaultCenter addObserver:self - selector:@selector(safeAreaProviderInsetsDidChange:) - name:RNCSafeAreaDidChange - object:_providerView]; - } - } -} - -- (void)safeAreaProviderInsetsDidChange:(NSNotification *)notification -{ - [self invalidateSafeAreaInsets]; -} - -- (void)invalidateSafeAreaInsets -{ - if (_providerView == nil) { - return; - } -#if TARGET_OS_IPHONE - UIEdgeInsets safeAreaInsets = RNCSafeAreaInsetsWithCornerAdaptation(_providerView, _cornerAdaptation); - if (UIEdgeInsetsEqualToEdgeInsetsWithThreshold(safeAreaInsets, _currentSafeAreaInsets, 1.0 / RCTScreenScale())) { - return; - } -#elif TARGET_OS_OSX - NSEdgeInsets safeAreaInsets = _providerView.safeAreaInsets; - if (NSEdgeInsetsEqualToEdgeInsetsWithThreshold(safeAreaInsets, _currentSafeAreaInsets, 1.0 / RCTScreenScale())) { - return; - } -#endif - - _currentSafeAreaInsets = safeAreaInsets; - [self updateLocalData]; -} - -- (nullable RNCSafeAreaProvider *)findNearestProvider -{ -#if TARGET_OS_IPHONE - UIView *current = self.reactSuperview; -#elif TARGET_OS_OSX - NSView *current = self.reactSuperview; -#endif - while (current != nil) { - if ([current isKindOfClass:RNCSafeAreaProvider.class]) { - return (RNCSafeAreaProvider *)current; - } - current = current.reactSuperview; - } - return nil; -} - -- (void)updateLocalData -{ - if (_providerView == nil) { - return; - } - RNCSafeAreaViewLocalData *localData = [[RNCSafeAreaViewLocalData alloc] initWithInsets:_currentSafeAreaInsets - mode:_mode - edges:_edges]; - [_bridge.uiManager setLocalData:localData forView:self]; -} - -- (void)setMode:(RNCSafeAreaViewMode)mode -{ - _mode = mode; - [self updateLocalData]; -} - -- (void)setEdges:(RNCSafeAreaViewEdges)edges -{ - _edges = edges; - [self updateLocalData]; -} - -- (void)setCornerAdaptation:(RNCSafeAreaCornerAdaptation)cornerAdaptation -{ - _cornerAdaptation = cornerAdaptation; - [self invalidateSafeAreaInsets]; -} - -@end diff --git a/ios/RNCSafeAreaViewEdgeMode.h b/ios/RNCSafeAreaViewEdgeMode.h deleted file mode 100644 index 406c719e..00000000 --- a/ios/RNCSafeAreaViewEdgeMode.h +++ /dev/null @@ -1,12 +0,0 @@ -#import -#import - -typedef NS_ENUM(NSInteger, RNCSafeAreaViewEdgeMode) { - RNCSafeAreaViewEdgeModeOff, - RNCSafeAreaViewEdgeModeAdditive, - RNCSafeAreaViewEdgeModeMaximum -}; - -@interface RCTConvert (RNCSafeAreaViewEdgeMode) -+ (RNCSafeAreaViewEdgeMode)RNCSafeAreaViewEdgeMode:(nullable id)json; -@end diff --git a/ios/RNCSafeAreaViewEdgeMode.m b/ios/RNCSafeAreaViewEdgeMode.m deleted file mode 100644 index a53056eb..00000000 --- a/ios/RNCSafeAreaViewEdgeMode.m +++ /dev/null @@ -1,16 +0,0 @@ -#import "RNCSafeAreaViewEdgeMode.h" -#import - -@implementation RCTConvert (RNCSafeAreaViewEdgeMode) - -RCT_ENUM_CONVERTER( - RNCSafeAreaViewEdgeMode, - (@{ - @"off" : @(RNCSafeAreaViewEdgeModeOff), - @"additive" : @(RNCSafeAreaViewEdgeModeAdditive), - @"maximum" : @(RNCSafeAreaViewEdgeModeMaximum), - }), - RNCSafeAreaViewEdgeModeOff, - integerValue); - -@end diff --git a/ios/RNCSafeAreaViewEdges.h b/ios/RNCSafeAreaViewEdges.h deleted file mode 100644 index a2e15039..00000000 --- a/ios/RNCSafeAreaViewEdges.h +++ /dev/null @@ -1,15 +0,0 @@ -#import -#import "RNCSafeAreaViewEdgeMode.h" - -typedef struct RNCSafeAreaViewEdges { - RNCSafeAreaViewEdgeMode top; - RNCSafeAreaViewEdgeMode right; - RNCSafeAreaViewEdgeMode bottom; - RNCSafeAreaViewEdgeMode left; -} RNCSafeAreaViewEdges; - -RNCSafeAreaViewEdges RNCSafeAreaViewEdgesMake( - RNCSafeAreaViewEdgeMode top, - RNCSafeAreaViewEdgeMode right, - RNCSafeAreaViewEdgeMode bottom, - RNCSafeAreaViewEdgeMode left); diff --git a/ios/RNCSafeAreaViewEdges.m b/ios/RNCSafeAreaViewEdges.m deleted file mode 100644 index aadb8259..00000000 --- a/ios/RNCSafeAreaViewEdges.m +++ /dev/null @@ -1,36 +0,0 @@ -#import "RNCSafeAreaViewEdges.h" -#import -#import "RNCSafeAreaViewEdgeMode.h" - -RNCSafeAreaViewEdges RNCSafeAreaViewEdgesMake( - RNCSafeAreaViewEdgeMode top, - RNCSafeAreaViewEdgeMode right, - RNCSafeAreaViewEdgeMode bottom, - RNCSafeAreaViewEdgeMode left) -{ - RNCSafeAreaViewEdges edges; - edges.top = top; - edges.left = left; - edges.bottom = bottom; - edges.right = right; - return edges; -} - -RNCSafeAreaViewEdges RNCSafeAreaViewEdgesMakeString(NSString *top, NSString *right, NSString *bottom, NSString *left) -{ - RNCSafeAreaViewEdges edges; - edges.top = [RCTConvert RNCSafeAreaViewEdgeMode:top]; - edges.right = [RCTConvert RNCSafeAreaViewEdgeMode:right]; - edges.bottom = [RCTConvert RNCSafeAreaViewEdgeMode:bottom]; - edges.left = [RCTConvert RNCSafeAreaViewEdgeMode:left]; - return edges; -} - -@implementation RCTConvert (RNCSafeAreaViewEdges) - -RCT_CUSTOM_CONVERTER( - RNCSafeAreaViewEdges, - RNCSafeAreaViewEdges, - RNCSafeAreaViewEdgesMakeString(json[@"top"], json[@"right"], json[@"bottom"], json[@"left"])) - -@end diff --git a/ios/RNCSafeAreaViewLocalData.h b/ios/RNCSafeAreaViewLocalData.h deleted file mode 100644 index 1c579a23..00000000 --- a/ios/RNCSafeAreaViewLocalData.h +++ /dev/null @@ -1,29 +0,0 @@ -#if TARGET_OS_IPHONE -#import -#elif TARGET_OS_OSX -#import -#endif - -#import "RNCSafeAreaViewEdges.h" -#import "RNCSafeAreaViewMode.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface RNCSafeAreaViewLocalData : NSObject - -#if TARGET_OS_IPHONE -- (instancetype)initWithInsets:(UIEdgeInsets)insets mode:(RNCSafeAreaViewMode)mode edges:(RNCSafeAreaViewEdges)edges; - -@property (atomic, readonly) UIEdgeInsets insets; -#elif TARGET_OS_OSX -- (instancetype)initWithInsets:(NSEdgeInsets)insets mode:(RNCSafeAreaViewMode)mode edges:(RNCSafeAreaViewEdges)edges; - -@property (atomic, readonly) NSEdgeInsets insets; -#endif - -@property (atomic, readonly) RNCSafeAreaViewMode mode; -@property (atomic, readonly) RNCSafeAreaViewEdges edges; - -@end - -NS_ASSUME_NONNULL_END diff --git a/ios/RNCSafeAreaViewLocalData.m b/ios/RNCSafeAreaViewLocalData.m deleted file mode 100644 index b656f5a0..00000000 --- a/ios/RNCSafeAreaViewLocalData.m +++ /dev/null @@ -1,20 +0,0 @@ -#import "RNCSafeAreaViewLocalData.h" - -@implementation RNCSafeAreaViewLocalData - -#if TARGET_OS_IPHONE -- (instancetype)initWithInsets:(UIEdgeInsets)insets mode:(RNCSafeAreaViewMode)mode edges:(RNCSafeAreaViewEdges)edges -#elif TARGET_OS_OSX -- (instancetype)initWithInsets:(NSEdgeInsets)insets mode:(RNCSafeAreaViewMode)mode edges:(RNCSafeAreaViewEdges)edges -#endif -{ - if (self = [super init]) { - _insets = insets; - _mode = mode; - _edges = edges; - } - - return self; -} - -@end diff --git a/ios/RNCSafeAreaViewManager.h b/ios/RNCSafeAreaViewManager.h deleted file mode 100644 index cf92d53f..00000000 --- a/ios/RNCSafeAreaViewManager.h +++ /dev/null @@ -1,9 +0,0 @@ -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface RNCSafeAreaViewManager : RCTViewManager - -@end - -NS_ASSUME_NONNULL_END diff --git a/ios/RNCSafeAreaViewManager.m b/ios/RNCSafeAreaViewManager.m deleted file mode 100644 index da26a690..00000000 --- a/ios/RNCSafeAreaViewManager.m +++ /dev/null @@ -1,31 +0,0 @@ -#import "RNCSafeAreaViewManager.h" - -#import "RNCSafeAreaCornerAdaptation.h" -#import "RNCSafeAreaShadowView.h" -#import "RNCSafeAreaView.h" -#import "RNCSafeAreaViewEdges.h" -#import "RNCSafeAreaViewMode.h" - -@implementation RNCSafeAreaViewManager - -RCT_EXPORT_MODULE(RNCSafeAreaView) - -#if TARGET_OS_IPHONE -- (UIView *)view -#elif TARGET_OS_OSX -- (NSView *)view -#endif -{ - return [[RNCSafeAreaView alloc] initWithBridge:self.bridge]; -} - -- (RNCSafeAreaShadowView *)shadowView -{ - return [RNCSafeAreaShadowView new]; -} - -RCT_EXPORT_VIEW_PROPERTY(mode, RNCSafeAreaViewMode) -RCT_EXPORT_VIEW_PROPERTY(edges, RNCSafeAreaViewEdges) -RCT_EXPORT_VIEW_PROPERTY(cornerAdaptation, RNCSafeAreaCornerAdaptation) - -@end diff --git a/ios/RNCSafeAreaViewMode.h b/ios/RNCSafeAreaViewMode.h deleted file mode 100644 index a43f382e..00000000 --- a/ios/RNCSafeAreaViewMode.h +++ /dev/null @@ -1,7 +0,0 @@ -#import - -typedef NS_ENUM(NSInteger, RNCSafeAreaViewMode) { - RNCSafeAreaViewModePadding, - RNCSafeAreaViewModeMargin, - RNCSafeAreaViewModeBorder, -}; diff --git a/ios/RNCSafeAreaViewMode.m b/ios/RNCSafeAreaViewMode.m deleted file mode 100644 index b50718e7..00000000 --- a/ios/RNCSafeAreaViewMode.m +++ /dev/null @@ -1,15 +0,0 @@ -#import "RNCSafeAreaViewMode.h" -#import - -@implementation RCTConvert (RNCSafeAreaView) - -RCT_MULTI_ENUM_CONVERTER( - RNCSafeAreaViewMode, - (@{ - @"padding" : @(RNCSafeAreaViewModePadding), - @"margin" : @(RNCSafeAreaViewModeMargin), - }), - RNCSafeAreaViewModePadding, - integerValue); - -@end diff --git a/ios/RNSafeAreaContext.xcodeproj/project.pbxproj b/ios/RNSafeAreaContext.xcodeproj/project.pbxproj deleted file mode 100644 index e002de5b..00000000 --- a/ios/RNSafeAreaContext.xcodeproj/project.pbxproj +++ /dev/null @@ -1,358 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 0C7844E127C02CEE001807FB /* RNCSafeAreaViewLocalData.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C7844D227C02CEE001807FB /* RNCSafeAreaViewLocalData.m */; }; - 0C7844E227C02CEE001807FB /* RNCSafeAreaViewMode.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C7844D327C02CEE001807FB /* RNCSafeAreaViewMode.m */; }; - 0C7844E327C02CEE001807FB /* RNCSafeAreaShadowView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C7844D527C02CEE001807FB /* RNCSafeAreaShadowView.m */; }; - 0C7844E427C02CEE001807FB /* RNCSafeAreaProviderManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C7844D627C02CEE001807FB /* RNCSafeAreaProviderManager.m */; }; - 0C7844E527C02CEE001807FB /* RNCSafeAreaViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C7844D927C02CEE001807FB /* RNCSafeAreaViewManager.m */; }; - 0C7844E627C02CEE001807FB /* RNCSafeAreaViewEdges.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C7844DE27C02CEE001807FB /* RNCSafeAreaViewEdges.m */; }; - 0C7844E727C02CEE001807FB /* RNCSafeAreaUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C7844DF27C02CEE001807FB /* RNCSafeAreaUtils.m */; }; - 0C7844E827C02CEE001807FB /* RNCSafeAreaView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C7844E027C02CEE001807FB /* RNCSafeAreaView.m */; }; - 0C7844EF27C02D03001807FB /* RNCSafeAreaContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0C7844EA27C02D03001807FB /* RNCSafeAreaContext.mm */; }; - 0C7844F027C02D03001807FB /* RNCSafeAreaProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C7844ED27C02D03001807FB /* RNCSafeAreaProvider.m */; }; - AA53A9EE2A321C01009AB3B2 /* RNCSafeAreaViewEdgeModes.m in Sources */ = {isa = PBXBuildFile; fileRef = AA53A9ED2A321C01009AB3B2 /* RNCSafeAreaViewEdgeModes.m */; }; - C923EDBC220C2C1A00D3100F /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C923EDBB220C2C1A00D3100F /* SystemConfiguration.framework */; }; - D697AA982D6F1D0A009C6433 /* RNCChangeEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = D697AA972D6F1D08009C6433 /* RNCChangeEvent.m */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 58B511D91A9E6C8500147676 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 0C7844D227C02CEE001807FB /* RNCSafeAreaViewLocalData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNCSafeAreaViewLocalData.m; sourceTree = ""; }; - 0C7844D327C02CEE001807FB /* RNCSafeAreaViewMode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNCSafeAreaViewMode.m; sourceTree = ""; }; - 0C7844D427C02CEE001807FB /* RNCSafeAreaViewLocalData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCSafeAreaViewLocalData.h; sourceTree = ""; }; - 0C7844D527C02CEE001807FB /* RNCSafeAreaShadowView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNCSafeAreaShadowView.m; sourceTree = ""; }; - 0C7844D627C02CEE001807FB /* RNCSafeAreaProviderManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNCSafeAreaProviderManager.m; sourceTree = ""; }; - 0C7844D727C02CEE001807FB /* RNCSafeAreaShadowView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCSafeAreaShadowView.h; sourceTree = ""; }; - 0C7844D827C02CEE001807FB /* RNCSafeAreaView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCSafeAreaView.h; sourceTree = ""; }; - 0C7844D927C02CEE001807FB /* RNCSafeAreaViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNCSafeAreaViewManager.m; sourceTree = ""; }; - 0C7844DA27C02CEE001807FB /* RNCSafeAreaViewEdges.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCSafeAreaViewEdges.h; sourceTree = ""; }; - 0C7844DB27C02CEE001807FB /* RNCSafeAreaUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCSafeAreaUtils.h; sourceTree = ""; }; - 0C7844DC27C02CEE001807FB /* RNCSafeAreaViewMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCSafeAreaViewMode.h; sourceTree = ""; }; - 0C7844DD27C02CEE001807FB /* RNCSafeAreaViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCSafeAreaViewManager.h; sourceTree = ""; }; - 0C7844DE27C02CEE001807FB /* RNCSafeAreaViewEdges.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNCSafeAreaViewEdges.m; sourceTree = ""; }; - 0C7844DF27C02CEE001807FB /* RNCSafeAreaUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNCSafeAreaUtils.m; sourceTree = ""; }; - 0C7844E027C02CEE001807FB /* RNCSafeAreaView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNCSafeAreaView.m; sourceTree = ""; }; - 0C7844E927C02D03001807FB /* RNCSafeAreaContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCSafeAreaContext.h; sourceTree = ""; }; - 0C7844EA27C02D03001807FB /* RNCSafeAreaContext.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RNCSafeAreaContext.mm; sourceTree = ""; }; - 0C7844EB27C02D03001807FB /* RNCSafeAreaProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCSafeAreaProvider.h; sourceTree = ""; }; - 0C7844EC27C02D03001807FB /* RNCSafeAreaProviderManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCSafeAreaProviderManager.h; sourceTree = ""; }; - 0C7844ED27C02D03001807FB /* RNCSafeAreaProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNCSafeAreaProvider.m; sourceTree = ""; }; - 0C7844EE27C02D03001807FB /* Fabric */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Fabric; sourceTree = ""; }; - 134814201AA4EA6300B7C361 /* libRNCSafeAreaContext.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNCSafeAreaContext.a; sourceTree = BUILT_PRODUCTS_DIR; }; - AA53A9EC2A321C01009AB3B2 /* RNCSafeAreaViewEdgeModes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNCSafeAreaViewEdgeModes.h; sourceTree = ""; }; - AA53A9ED2A321C01009AB3B2 /* RNCSafeAreaViewEdgeModes.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNCSafeAreaViewEdgeModes.m; sourceTree = ""; }; - C923EDBB220C2C1A00D3100F /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; - D697AA962D6F1CE5009C6433 /* RNCChangeEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNCChangeEvent.h; sourceTree = ""; }; - D697AA972D6F1D08009C6433 /* RNCChangeEvent.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNCChangeEvent.m; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 58B511D81A9E6C8500147676 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - C923EDBC220C2C1A00D3100F /* SystemConfiguration.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 134814211AA4EA7D00B7C361 /* Products */ = { - isa = PBXGroup; - children = ( - 134814201AA4EA6300B7C361 /* libRNCSafeAreaContext.a */, - ); - name = Products; - sourceTree = ""; - }; - 58B511D21A9E6C8500147676 = { - isa = PBXGroup; - children = ( - D697AA972D6F1D08009C6433 /* RNCChangeEvent.m */, - D697AA962D6F1CE5009C6433 /* RNCChangeEvent.h */, - AA53A9EC2A321C01009AB3B2 /* RNCSafeAreaViewEdgeModes.h */, - AA53A9ED2A321C01009AB3B2 /* RNCSafeAreaViewEdgeModes.m */, - 0C7844EE27C02D03001807FB /* Fabric */, - 0C7844E927C02D03001807FB /* RNCSafeAreaContext.h */, - 0C7844EA27C02D03001807FB /* RNCSafeAreaContext.mm */, - 0C7844EB27C02D03001807FB /* RNCSafeAreaProvider.h */, - 0C7844ED27C02D03001807FB /* RNCSafeAreaProvider.m */, - 0C7844EC27C02D03001807FB /* RNCSafeAreaProviderManager.h */, - 0C7844D627C02CEE001807FB /* RNCSafeAreaProviderManager.m */, - 0C7844D727C02CEE001807FB /* RNCSafeAreaShadowView.h */, - 0C7844D527C02CEE001807FB /* RNCSafeAreaShadowView.m */, - 0C7844DB27C02CEE001807FB /* RNCSafeAreaUtils.h */, - 0C7844DF27C02CEE001807FB /* RNCSafeAreaUtils.m */, - 0C7844D827C02CEE001807FB /* RNCSafeAreaView.h */, - 0C7844E027C02CEE001807FB /* RNCSafeAreaView.m */, - 0C7844DA27C02CEE001807FB /* RNCSafeAreaViewEdges.h */, - 0C7844DE27C02CEE001807FB /* RNCSafeAreaViewEdges.m */, - 0C7844D427C02CEE001807FB /* RNCSafeAreaViewLocalData.h */, - 0C7844D227C02CEE001807FB /* RNCSafeAreaViewLocalData.m */, - 0C7844DD27C02CEE001807FB /* RNCSafeAreaViewManager.h */, - 0C7844D927C02CEE001807FB /* RNCSafeAreaViewManager.m */, - 0C7844DC27C02CEE001807FB /* RNCSafeAreaViewMode.h */, - 0C7844D327C02CEE001807FB /* RNCSafeAreaViewMode.m */, - 134814211AA4EA7D00B7C361 /* Products */, - C923EDBA220C2C1A00D3100F /* Frameworks */, - ); - sourceTree = ""; - }; - C923EDBA220C2C1A00D3100F /* Frameworks */ = { - isa = PBXGroup; - children = ( - C923EDBB220C2C1A00D3100F /* SystemConfiguration.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 58B511DA1A9E6C8500147676 /* RNCSafeAreaContext */ = { - isa = PBXNativeTarget; - buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNCSafeAreaContext" */; - buildPhases = ( - 58B511D71A9E6C8500147676 /* Sources */, - 58B511D81A9E6C8500147676 /* Frameworks */, - 58B511D91A9E6C8500147676 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = RNCSafeAreaContext; - productName = RCTDataManager; - productReference = 134814201AA4EA6300B7C361 /* libRNCSafeAreaContext.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 58B511D31A9E6C8500147676 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 1030; - ORGANIZATIONNAME = Facebook; - TargetAttributes = { - 58B511DA1A9E6C8500147676 = { - CreatedOnToolsVersion = 6.1.1; - }; - }; - }; - buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNSafeAreaContext" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 58B511D21A9E6C8500147676; - productRefGroup = 58B511D21A9E6C8500147676; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 58B511DA1A9E6C8500147676 /* RNCSafeAreaContext */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 58B511D71A9E6C8500147676 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - AA53A9EE2A321C01009AB3B2 /* RNCSafeAreaViewEdgeModes.m in Sources */, - 0C7844E427C02CEE001807FB /* RNCSafeAreaProviderManager.m in Sources */, - 0C7844E727C02CEE001807FB /* RNCSafeAreaUtils.m in Sources */, - 0C7844E827C02CEE001807FB /* RNCSafeAreaView.m in Sources */, - 0C7844E627C02CEE001807FB /* RNCSafeAreaViewEdges.m in Sources */, - 0C7844E527C02CEE001807FB /* RNCSafeAreaViewManager.m in Sources */, - D697AA982D6F1D0A009C6433 /* RNCChangeEvent.m in Sources */, - 0C7844EF27C02D03001807FB /* RNCSafeAreaContext.mm in Sources */, - 0C7844E127C02CEE001807FB /* RNCSafeAreaViewLocalData.m in Sources */, - 0C7844E227C02CEE001807FB /* RNCSafeAreaViewMode.m in Sources */, - 0C7844F027C02D03001807FB /* RNCSafeAreaProvider.m in Sources */, - 0C7844E327C02CEE001807FB /* RNCSafeAreaShadowView.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 58B511ED1A9E6C8500147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - }; - name = Debug; - }; - 58B511EE1A9E6C8500147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = YES; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 58B511F01A9E6C8500147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../../React/**", - "$(SRCROOT)/../../react-native/React/**", - ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = RNCSafeAreaContext; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - 58B511F11A9E6C8500147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../../React/**", - "$(SRCROOT)/../../react-native/React/**", - ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = RNCSafeAreaContext; - SKIP_INSTALL = YES; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNSafeAreaContext" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B511ED1A9E6C8500147676 /* Debug */, - 58B511EE1A9E6C8500147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNCSafeAreaContext" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B511F01A9E6C8500147676 /* Debug */, - 58B511F11A9E6C8500147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 58B511D31A9E6C8500147676 /* Project object */; -} diff --git a/package.json b/package.json index d7d13d56..6b63f6c8 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ }, "peerDependencies": { "react": "*", - "react-native": "*" + "react-native": ">=0.82.0" }, "devDependencies": { "@commitlint/config-conventional": "^19.2.2", diff --git a/react-native-safe-area-context.podspec b/react-native-safe-area-context.podspec index 078def56..d0f50a0a 100644 --- a/react-native-safe-area-context.podspec +++ b/react-native-safe-area-context.podspec @@ -1,9 +1,21 @@ require 'json' -fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1' - package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) +unless defined?(install_modules_dependencies) + react_native_path = File.dirname( + Pod::Executable.execute_command( + 'node', + [ + '-p', + "require.resolve('react-native/package.json', {paths: [process.argv[1]]})", + __dir__, + ] + ).strip + ) + require File.join(react_native_path, 'scripts/react_native_pods') +end + Pod::Spec.new do |s| s.name = "react-native-safe-area-context" s.version = package['version'] @@ -18,24 +30,21 @@ Pod::Spec.new do |s| s.visionos.deployment_target = "1.0" s.source = { :git => "https://github.com/AppAndFlow/react-native-safe-area-context.git", :tag => "v#{s.version}" } - s.source_files = "ios/**/*.{h,m,mm}" - s.exclude_files = "ios/Fabric" + s.source_files = "ios/*.{h,m,mm}" s.dependency "React-Core" - if fabric_enabled - install_modules_dependencies(s) + install_modules_dependencies(s) - s.subspec "common" do |ss| - ss.source_files = "common/cpp/**/*.{cpp,h}" - ss.header_dir = "react/renderer/components/safeareacontext" - ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/common/cpp\"" } - end + s.subspec "common" do |ss| + ss.source_files = "common/cpp/**/*.{cpp,h}" + ss.header_dir = "react/renderer/components/safeareacontext" + ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/common/cpp\"" } + end - s.subspec "fabric" do |ss| - ss.dependency "react-native-safe-area-context/common" - ss.source_files = "ios/Fabric/**/*.{h,m,mm}" - ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/common/cpp\"" } - end + s.subspec "fabric" do |ss| + ss.dependency "react-native-safe-area-context/common" + ss.source_files = "ios/Fabric/**/*.{h,m,mm}" + ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/common/cpp\"" } end end diff --git a/src/__tests__/swiftpm-test.ts b/src/__tests__/swiftpm-test.ts index 7e4dbbc2..12b0dfd4 100644 --- a/src/__tests__/swiftpm-test.ts +++ b/src/__tests__/swiftpm-test.ts @@ -141,7 +141,7 @@ describe('Package.swift', () => { name: 'ReactNativeSafeAreaContext', path: '.', sources: ['ios', 'common/cpp'], - exclude: ['ios/RNSafeAreaContext.xcodeproj'], + exclude: [], publicHeadersPath: 'ios', products: [ ['ReactHeaders', 'ReactNative'], diff --git a/src/specs/NativeSafeAreaProvider.ts b/src/specs/NativeSafeAreaProvider.ts index c88d6dca..ab3b5809 100644 --- a/src/specs/NativeSafeAreaProvider.ts +++ b/src/specs/NativeSafeAreaProvider.ts @@ -1,9 +1,5 @@ -import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; -import { - type CodegenTypes, - type HostComponent, - type ViewProps, -} from 'react-native'; +import { codegenNativeComponent } from 'react-native'; +import type { CodegenTypes, HostComponent, ViewProps } from 'react-native'; export type Event = Readonly<{ insets: Readonly<{ diff --git a/src/specs/NativeSafeAreaView.ts b/src/specs/NativeSafeAreaView.ts index dfdf692c..28dbe8bd 100644 --- a/src/specs/NativeSafeAreaView.ts +++ b/src/specs/NativeSafeAreaView.ts @@ -1,9 +1,5 @@ -import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; -import { - type CodegenTypes, - type HostComponent, - type ViewProps, -} from 'react-native'; +import { codegenNativeComponent } from 'react-native'; +import type { CodegenTypes, HostComponent, ViewProps } from 'react-native'; export interface NativeProps extends ViewProps { mode?: CodegenTypes.WithDefault<'padding' | 'margin', 'padding'>;