Skip to content

Commit

Permalink
chore: upgrade example apps to RN 0.73
Browse files Browse the repository at this point in the history
- upgrade to RN 0.73 in example apps
- upgrade other example apps dependencies
- add patches to make Swift modules working with RN 0.73
- add patch to make react-native-safe-area-context working on Fabric Android
- format android code with ktfmt
  • Loading branch information
mateusz1913 committed Dec 19, 2023
1 parent aff4bba commit 4c27518
Show file tree
Hide file tree
Showing 118 changed files with 9,695 additions and 8,676 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ jobs:
distribution: 'temurin'
java-version: '17'
- run: yarn
- name: Spotless/Ktlint
- name: Spotless/Ktfmt
run: yarn lint:android
8 changes: 4 additions & 4 deletions .github/workflows/lint-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
echo "SwiftLint is not installed. Installing"
brew install swiftlint
fi
swiftlint lint --config ./packages/mobile/ios/.swiftlint.yml --quiet
swiftlint lint --config ./packages/fabricMobile/ios/.swiftlint.yml --quiet
yarn lint:ios:swift
yarn lint:fabric:ios:swift
- name: ClangFormat
run: |
#!/bin/bash
Expand All @@ -33,5 +33,5 @@ jobs:
echo "ClangFormat is not installed. Installing"
brew install clang-format
fi
clang-format --dry-run -i ./packages/react-native-avoid-softinput/ios/*.{h,mm} ./packages/mobile/ios/AvoidSoftinputExample/*.{h,mm} -Werror
clang-format --dry-run -i ./packages/react-native-avoid-softinput/ios/*.{h,mm} ./packages/fabricMobile/ios/FabricAvoidSoftinputExample/*.{h,mm} -Werror
yarn format:ios:objc
yarn format:fabric:ios:objc
24 changes: 24 additions & 0 deletions .yarn/patches/react-native-bootsplash-npm-5.1.3-cc4ad003e2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --git a/ios/RNBootSplash.mm b/ios/RNBootSplash.mm
index ff5361cfa3c6016d59c9cfc313dee6ddd4076855..d1201cca64945eb64c2a829408cf95b91ee4a99f 100755
--- a/ios/RNBootSplash.mm
+++ b/ios/RNBootSplash.mm
@@ -3,7 +3,7 @@
#import <React/RCTUtils.h>

#if RCT_NEW_ARCH_ENABLED
-#import <React/RCTFabricSurfaceHostingProxyRootView.h>
+#import <React/RCTSurfaceHostingProxyRootView.h>
#import <React/RCTSurfaceHostingView.h>
#else
#import <React/RCTRootView.h>
@@ -90,8 +90,8 @@ + (void)initWithStoryboard:(NSString * _Nonnull)storyboardName
}];

#ifdef RCT_NEW_ARCH_ENABLED
- if (rootView != nil && [rootView isKindOfClass:[RCTFabricSurfaceHostingProxyRootView class]]) {
- RCTFabricSurfaceHostingProxyRootView *proxy = (RCTFabricSurfaceHostingProxyRootView *)rootView;
+ if (rootView != nil && [rootView isKindOfClass:[RCTSurfaceHostingProxyRootView class]]) {
+ RCTSurfaceHostingProxyRootView *proxy = (RCTSurfaceHostingProxyRootView *)rootView;
_rootView = (RCTSurfaceHostingView *)proxy.surface.view;
#else
if (rootView != nil && [rootView isKindOfClass:[RCTRootView class]]) {
13 changes: 13 additions & 0 deletions .yarn/patches/react-native-npm-0.73.1-35751404af.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb
index d29dca30081bfb9e9191121d2652d92e6ae89ee1..dcd8c88051630522fa7a6c29d8289d9bc4041ae9 100644
--- a/scripts/react_native_pods.rb
+++ b/scripts/react_native_pods.rb
@@ -153,7 +153,7 @@ def use_react_native! (
pod 'Yoga', :path => "#{prefix}/ReactCommon/yoga", :modular_headers => true

pod 'DoubleConversion', :podspec => "#{prefix}/third-party-podspecs/DoubleConversion.podspec"
- pod 'glog', :podspec => "#{prefix}/third-party-podspecs/glog.podspec"
+ pod 'glog', :podspec => "#{prefix}/third-party-podspecs/glog.podspec", :modular_headers => true
pod 'boost', :podspec => "#{prefix}/third-party-podspecs/boost.podspec"
pod 'RCT-Folly', :podspec => "#{prefix}/third-party-podspecs/RCT-Folly.podspec", :modular_headers => true

Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
diff --git a/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaView.kt b/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaView.kt
index ca5646c2ba2377dea71ce06f8dfc8b7021d85c3c..5fefd448a35aaa48c9e52e454b7ba47cb209f548 100644
--- a/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaView.kt
+++ b/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaView.kt
@@ -4,27 +4,30 @@ import android.content.Context
import android.util.Log
import android.view.View
import android.view.ViewTreeObserver
-import com.facebook.react.bridge.Arguments
-import com.facebook.react.uimanager.FabricViewStateManager
-import com.facebook.react.uimanager.FabricViewStateManager.HasFabricViewStateManager
+import com.facebook.react.bridge.WritableNativeMap
+import com.facebook.react.uimanager.StateWrapper
import com.facebook.react.uimanager.UIManagerModule
import com.facebook.react.views.view.ReactViewGroup
-import java.util.*
+import java.util.EnumSet
import java.util.concurrent.locks.ReentrantLock
import kotlin.concurrent.withLock

private const val MAX_WAIT_TIME_NANO = 500000000L // 500ms

class SafeAreaView(context: Context?) :
- ReactViewGroup(context), ViewTreeObserver.OnPreDrawListener, HasFabricViewStateManager {
+ ReactViewGroup(context), ViewTreeObserver.OnPreDrawListener {
private var mMode = SafeAreaViewMode.PADDING
private var mInsets: EdgeInsets? = null
private var mEdges: SafeAreaViewEdges? = null
private var mProviderView: View? = null
- private val mFabricViewStateManager = FabricViewStateManager()
+ private var mStateWrapper: StateWrapper? = null

- override fun getFabricViewStateManager(): FabricViewStateManager {
- return mFabricViewStateManager
+ fun getStateWrapper(): StateWrapper? {
+ return mStateWrapper
+ }
+
+ fun setStateWrapper(stateWrapper: StateWrapper?) {
+ mStateWrapper = stateWrapper
}

private fun updateInsets() {
@@ -37,12 +40,10 @@ class SafeAreaView(context: Context?) :
SafeAreaViewEdgeModes.ADDITIVE,
SafeAreaViewEdgeModes.ADDITIVE,
SafeAreaViewEdgeModes.ADDITIVE)
- if (mFabricViewStateManager.hasStateWrapper()) {
- mFabricViewStateManager.setState {
- val map = Arguments.createMap()
- map.putMap("insets", edgeInsetsToJsMap(insets))
- map
- }
+ if (mStateWrapper != null) {
+ val map = WritableNativeMap()
+ map.putMap("insets", edgeInsetsToJsMap(insets))
+ mStateWrapper?.updateState(map)
} else {
val localData = SafeAreaViewLocalData(insets = insets, mode = mMode, edges = edges)
val reactContext = getReactContext(this)
diff --git a/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewManager.kt b/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewManager.kt
index 114e89268d12678fa5c74ef24bb6bb03b934bdd6..362ea992103737a23222452426d0a74f235fc001 100644
--- a/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewManager.kt
+++ b/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewManager.kt
@@ -64,7 +64,7 @@ class SafeAreaViewManager : ReactViewManager(), RNCSafeAreaViewManagerInterface<
props: ReactStylesDiffMap?,
stateWrapper: StateWrapper?
): Any? {
- (view as SafeAreaView).fabricViewStateManager.setStateWrapper(stateWrapper)
+ (view as SafeAreaView).setStateWrapper(stateWrapper)
return null
}

9 changes: 9 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-after-install.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable */
//prettier-ignore
module.exports = {
name: "@yarnpkg/plugin-after-install",
factory: function (require) {
"use strict";var plugin=(()=>{var s=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var r=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(o,e)=>(typeof require<"u"?require:o)[e]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var I=(t,o)=>{for(var e in o)s(t,e,{get:o[e],enumerable:!0})},h=(t,o,e,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of x(o))!C.call(t,n)&&n!==e&&s(t,n,{get:()=>o[n],enumerable:!(a=g(o,n))||a.enumerable});return t};var k=t=>h(s({},"__esModule",{value:!0}),t);var P={};I(P,{default:()=>y});var d=r("@yarnpkg/core");var f=r("@yarnpkg/core"),c={afterInstall:{description:"Hook that will always run after install",type:f.SettingsType.STRING,default:""}};var p=r("clipanion"),u=r("@yarnpkg/core");var m=r("@yarnpkg/shell"),l=async(t,o)=>{let e=t.get("afterInstall"),a=!!t.projectCwd?.endsWith(`dlx-${process.pid}`);return e&&!a?(o&&console.log("Running `afterInstall` hook..."),(0,m.execute)(e,[],{cwd:t.projectCwd||void 0})):0};var i=class extends p.Command{async execute(){let o=await u.Configuration.find(this.context.cwd,this.context.plugins);return l(o,!1)}};i.paths=[["after-install"]];var w={configuration:c,commands:[i],hooks:{afterAllInstalled:async(t,o)=>{if(o?.mode===d.InstallMode.UpdateLockfile)return;if(await l(t.configuration,!0))throw new Error("The `afterInstall` hook failed, see output above.")}}},y=w;return k(P);})();
return plugin;
}
};
8 changes: 0 additions & 8 deletions .yarn/plugins/@yarnpkg/plugin-postinstall.cjs

This file was deleted.

Loading

0 comments on commit 4c27518

Please sign in to comment.