Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

turbo-ios: remove UIRefreshControl layout constraints #192

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 correctly 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` native land.
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
Loading