From a82e6b9d8d389024e1ffb8668bf14796189c4dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sammy=20Guti=C3=A9rrez?= Date: Tue, 23 Jul 2024 14:41:31 -0500 Subject: [PATCH 1/6] Add flag to disable `EpoxySwiftUIHostingController` keyboard avoidance --- CHANGELOG.md | 1 + .../EpoxySwiftUIHostingController.swift | 52 ++++++++++++++++++- .../SwiftUI/EpoxySwiftUIHostingView.swift | 3 +- 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4915a528..dca721f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Made new layout-based SwiftUI cell rendering option the default. - Fixed interaction of SwiftUI bars on visionOS - Added flag for forcing layout on a hosted SwiftUI view after layout margins change +- Updated `EpoxySwiftUIHostingController` with a flag to disable its keyboard avoidance behavior ## [0.10.0](https://github.com/airbnb/epoxy-ios/compare/0.9.0...0.10.0) - 2023-06-29 diff --git a/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingController.swift b/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingController.swift index 3203775a..b6d87b0b 100644 --- a/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingController.swift +++ b/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingController.swift @@ -19,7 +19,7 @@ open class EpoxySwiftUIHostingController: UIHostingController: UIHostingController: UIHostingController Void = { _, _ in } + let implementation = imp_implementationWithBlock(keyboardWillShowOverride) + let typeEncoding = method_getTypeEncoding(method) + class_addMethod(viewSubclass, selector, implementation, typeEncoding) + + objc_registerClassPair(viewSubclass) + object_setClass(view, viewSubclass) + } } #endif diff --git a/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift b/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift index 63efb847..363c22e1 100644 --- a/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift +++ b/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift @@ -67,7 +67,8 @@ public final class EpoxySwiftUIHostingView: UIView, EpoxyableVie epoxyContent = EpoxyHostingContent(rootView: style.initialContent.rootView) viewController = EpoxySwiftUIHostingController( rootView: .init(content: epoxyContent, environment: epoxyEnvironment), - ignoreSafeArea: true) + ignoreSafeArea: true, + ignoreKeyboardAvoidance: true) dataID = style.initialContent.dataID ?? DefaultDataID.noneProvided as AnyHashable forceLayoutOnLayoutMarginsChange = style.forceLayoutOnLayoutMarginsChange From 489dbabe45b82921097087161f2c1a70d726859d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sammy=20Guti=C3=A9rrez?= Date: Tue, 23 Jul 2024 15:26:27 -0500 Subject: [PATCH 2/6] Update Xcode CI versions --- .github/workflows/main.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eb9c5d1a..b401c466 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,8 +12,8 @@ jobs: strategy: matrix: xcode: - - '13.2.1' # Swift 5.5 (lowest) - - '14.0.1' # Swift 5.7 (highest) + - '14.1' # Swift 5.7 (lowest) + - '15.2' # Swift 5.9.2 (highest) steps: - uses: actions/checkout@v2 - uses: ./.github/actions/setup @@ -27,7 +27,7 @@ jobs: strategy: matrix: xcode: - - '14.0.1' # Swift 5.7 (highest) + - '15.2' # Swift 5.9.2 (highest) steps: - uses: actions/checkout@v2 - uses: ./.github/actions/setup @@ -41,8 +41,8 @@ jobs: strategy: matrix: xcode: - - '13.2.1' # Swift 5.5 (lowest) - - '14.0.1' # Swift 5.7 (highest) + - '14.1' # Swift 5.7 (lowest) + - '15.2' # Swift 5.9.2 (highest) steps: - uses: actions/checkout@v2 - uses: ./.github/actions/setup @@ -56,8 +56,8 @@ jobs: strategy: matrix: xcode: - - '13.2.1' # Swift 5.5 (lowest) - - '14.0.1' # Swift 5.7 (highest) + - '14.1' # Swift 5.7 (lowest) + - '15.2' # Swift 5.9.2 (highest) steps: - uses: actions/checkout@v2 - uses: ./.github/actions/setup From ad592971aba2ffe747b2545ad9ee5ad27b3a5616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sammy=20Guti=C3=A9rrez?= Date: Tue, 23 Jul 2024 16:17:06 -0500 Subject: [PATCH 3/6] Update Xcode CI versions again --- .github/workflows/main.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b401c466..fef520eb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,8 +12,8 @@ jobs: strategy: matrix: xcode: - - '14.1' # Swift 5.7 (lowest) - - '15.2' # Swift 5.9.2 (highest) + - '14.3.1' # Swift 5.8 (lowest) + - '15.4' # Swift 5.10 (highest) steps: - uses: actions/checkout@v2 - uses: ./.github/actions/setup @@ -27,7 +27,7 @@ jobs: strategy: matrix: xcode: - - '15.2' # Swift 5.9.2 (highest) + - '15.4' # Swift 5.10 (highest) steps: - uses: actions/checkout@v2 - uses: ./.github/actions/setup @@ -41,8 +41,8 @@ jobs: strategy: matrix: xcode: - - '14.1' # Swift 5.7 (lowest) - - '15.2' # Swift 5.9.2 (highest) + - '14.3.1' # Swift 5.8 (lowest) + - '15.4' # Swift 5.10 (highest) steps: - uses: actions/checkout@v2 - uses: ./.github/actions/setup @@ -56,8 +56,8 @@ jobs: strategy: matrix: xcode: - - '14.1' # Swift 5.7 (lowest) - - '15.2' # Swift 5.9.2 (highest) + - '14.3.1' # Swift 5.8 (lowest) + - '15.4' # Swift 5.10 (highest) steps: - uses: actions/checkout@v2 - uses: ./.github/actions/setup From ea7fc9ae9e8eb17841a70072c683d24e8e044a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sammy=20Guti=C3=A9rrez?= Date: Tue, 23 Jul 2024 16:18:51 -0500 Subject: [PATCH 4/6] Use `ignores` instead of `ignore` --- .../EpoxyCore/SwiftUI/EpoxySwiftUIHostingController.swift | 6 +++--- Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingController.swift b/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingController.swift index b6d87b0b..6a26138c 100644 --- a/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingController.swift +++ b/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingController.swift @@ -19,7 +19,7 @@ open class EpoxySwiftUIHostingController: UIHostingController: UIHostingController: UIView, EpoxyableVie epoxyContent = EpoxyHostingContent(rootView: style.initialContent.rootView) viewController = EpoxySwiftUIHostingController( rootView: .init(content: epoxyContent, environment: epoxyEnvironment), - ignoreSafeArea: true, - ignoreKeyboardAvoidance: true) + ignoresSafeArea: true, + ignoresKeyboardAvoidance: true) dataID = style.initialContent.dataID ?? DefaultDataID.noneProvided as AnyHashable forceLayoutOnLayoutMarginsChange = style.forceLayoutOnLayoutMarginsChange From 7a7b1d844f6252e9f8806ed0929b1739c31939e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sammy=20Guti=C3=A9rrez?= Date: Tue, 23 Jul 2024 17:52:51 -0500 Subject: [PATCH 5/6] Update CI simulator version --- Rakefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index c0631351..e7abcc56 100644 --- a/Rakefile +++ b/Rakefile @@ -13,7 +13,7 @@ namespace :build do desc 'Builds the EpoxyExample app' task :example do - xcodebuild 'build -scheme EpoxyExample -destination "platform=iOS Simulator,name=iPhone 12"' + xcodebuild 'build -scheme EpoxyExample -destination "platform=iOS Simulator,name=iPhone 14"' end end @@ -23,12 +23,12 @@ namespace :test do desc 'Runs unit tests' task :unit do - xcodebuild 'test -scheme EpoxyTests -destination "platform=iOS Simulator,name=iPhone 12"' + xcodebuild 'test -scheme EpoxyTests -destination "platform=iOS Simulator,name=iPhone 14"' end desc 'Runs performance tests' task :performance do - xcodebuild 'test -scheme PerformanceTests -destination "platform=iOS Simulator,name=iPhone 12"' + xcodebuild 'test -scheme PerformanceTests -destination "platform=iOS Simulator,name=iPhone 14"' end end From fb3e17e8e8d12a317c52d01933a3a0ee4792f4d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sammy=20Guti=C3=A9rrez?= Date: Tue, 23 Jul 2024 17:52:56 -0500 Subject: [PATCH 6/6] Run swiftformat --- Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingController.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingController.swift b/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingController.swift index 6a26138c..fa690b31 100644 --- a/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingController.swift +++ b/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingController.swift @@ -46,6 +46,8 @@ open class EpoxySwiftUIHostingController: UIHostingController