Skip to content

Commit

Permalink
feat: apply patch to turbo-ios library
Browse files Browse the repository at this point in the history
  • Loading branch information
pklatka committed Apr 22, 2024
1 parent 820ec9e commit 8ab89ef
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
13 changes: 13 additions & 0 deletions packages/turbo/patches/README.md
Original file line number Diff line number Diff line change
@@ -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.
File renamed without changes.
21 changes: 21 additions & 0 deletions packages/turbo/patches/turbo-ios.patch
Original file line number Diff line number Diff line change
@@ -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
}

2 changes: 1 addition & 1 deletion packages/turbo/scripts/build-turbo-android.sh
Original file line number Diff line number Diff line change
@@ -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.\-]+"
Expand Down
6 changes: 5 additions & 1 deletion packages/turbo/scripts/build-turbo-ios.sh
Original file line number Diff line number Diff line change
@@ -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" ]
Expand All @@ -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
Expand Down

0 comments on commit 8ab89ef

Please sign in to comment.