From 8ab89ef21185880abe3c2f1dc2d50fed2886faa3 Mon Sep 17 00:00:00 2001 From: Patryk Klatka Date: Mon, 22 Apr 2024 22:07:19 +0200 Subject: [PATCH] feat: apply patch to turbo-ios library --- packages/turbo/patches/README.md | 13 ++++++++++++ ...tive-support.patch => turbo-android.patch} | 0 packages/turbo/patches/turbo-ios.patch | 21 +++++++++++++++++++ packages/turbo/scripts/build-turbo-android.sh | 2 +- packages/turbo/scripts/build-turbo-ios.sh | 6 +++++- 5 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 packages/turbo/patches/README.md rename packages/turbo/patches/{turbo-android-react-native-support.patch => turbo-android.patch} (100%) create mode 100644 packages/turbo/patches/turbo-ios.patch diff --git a/packages/turbo/patches/README.md b/packages/turbo/patches/README.md new file mode 100644 index 00000000..11a09a2e --- /dev/null +++ b/packages/turbo/patches/README.md @@ -0,0 +1,13 @@ +# Patches for `turbo-ios` and `turbo-android` libraries + +This directory contains patches for the turbo-ios and turbo-android libraries. The patches are applied during the build process. Unfortunately, this process is necessary to make the libraries work with `react-native-turbo`. + +## Changes + +### `turbo-ios` + +The patch removes the `NSLayoutConstraint` set in `VisitableView.installRefreshControl` method. This is necessary to make `contentInset` work properly with `UIRefreshControl`. + +### `turbo-android` + +The patch makes the necessary interfaces, classes and methods public so that they can be accessed from the `react-native-turbo` library. diff --git a/packages/turbo/patches/turbo-android-react-native-support.patch b/packages/turbo/patches/turbo-android.patch similarity index 100% rename from packages/turbo/patches/turbo-android-react-native-support.patch rename to packages/turbo/patches/turbo-android.patch diff --git a/packages/turbo/patches/turbo-ios.patch b/packages/turbo/patches/turbo-ios.patch new file mode 100644 index 00000000..06fb01fa --- /dev/null +++ b/packages/turbo/patches/turbo-ios.patch @@ -0,0 +1,21 @@ +diff --git a/Source/Visitable/VisitableView.swift b/Source/Visitable/VisitableView.swift +index 12452b5..e9c37b8 100644 +--- a/Source/Visitable/VisitableView.swift ++++ b/Source/Visitable/VisitableView.swift +@@ -69,16 +69,6 @@ open class VisitableView: UIView { + + #if !targetEnvironment(macCatalyst) + scrollView.addSubview(refreshControl) +- +- /// Infer refresh control's default height from its frame, if given. +- /// Otherwise fallback to 60 (the default height). +- let refreshControlHeight = refreshControl.frame.height > 0 ? refreshControl.frame.height : 60 +- +- NSLayoutConstraint.activate([ +- refreshControl.centerXAnchor.constraint(equalTo: centerXAnchor), +- refreshControl.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor), +- refreshControl.heightAnchor.constraint(equalToConstant: refreshControlHeight) +- ]) + #endif + } + diff --git a/packages/turbo/scripts/build-turbo-android.sh b/packages/turbo/scripts/build-turbo-android.sh index c1282fff..3c004289 100755 --- a/packages/turbo/scripts/build-turbo-android.sh +++ b/packages/turbo/scripts/build-turbo-android.sh @@ -1,7 +1,7 @@ TURBO_ANDROID_REPO_PATH="https://github.com/hotwired/turbo-android.git" TURBO_ANDROID_MAIN_SOURCE_DIR="./turbo/src/main/*" TURBO_ANDROID_VERSION=$1 -PATCH_FILE=$(realpath ./patches/turbo-android-react-native-support.patch) +PATCH_FILE=$(realpath ./patches/turbo-android.patch) TURBO_ANDROID_DIR=$(realpath ./android) DEPENDENCIES_GRADLE_FILE="turbo-android-dependencies.gradle" DEPENDENCY_REGEX="[a-zA-Z0-9.\-]+:[a-zA-Z0-9.\-]+:[0-9a-zA-Z.\-]+" diff --git a/packages/turbo/scripts/build-turbo-ios.sh b/packages/turbo/scripts/build-turbo-ios.sh index 6bb5f867..03cedd80 100644 --- a/packages/turbo/scripts/build-turbo-ios.sh +++ b/packages/turbo/scripts/build-turbo-ios.sh @@ -1,5 +1,6 @@ TURBO_IOS_REPO_PATH="https://github.com/hotwired/turbo-ios.git" TURBO_IOS_VERSION=$1 +PATCH_FILE=$(realpath ./patches/turbo-ios.patch) # First argument is the version tag if [ -z "$TURBO_IOS_VERSION" ] @@ -17,8 +18,11 @@ mkdir vendor cd vendor git clone --branch $TURBO_IOS_VERSION --depth 1 $TURBO_IOS_REPO_PATH -# Keep the Source folder and remove the rest +# Apply patch cd turbo-ios +git apply $PATCH_FILE + +# Keep the Source folder and remove the rest for file in *; do if [ "$file" != "Source" ]; then rm -rf $file