diff --git a/packages/turbo/README.md b/packages/turbo/README.md index 7c66817..cba5f6a 100644 --- a/packages/turbo/README.md +++ b/packages/turbo/README.md @@ -97,9 +97,9 @@ The amount by which the web view content is inset from the edges of the scroll v Note: available only on iOS. -### `refreshControlTopAnchor` +### `refreshControlTopAnchorConstant` -This property enables setting custom `topAnchor` for the native refresh control. If the value is set, the refresh control will be anchored to the top of the web view with the specified offset. By default, this value is set to the safe area top anchor. +This property enables setting custom `topAnchor` constant for the native refresh control. If the value is set, the `refreshControlTopAnchorConstant` value will be added to the safe area top anchor. Note: available only on iOS. diff --git a/packages/turbo/ios/RNVisitableView.swift b/packages/turbo/ios/RNVisitableView.swift index 6b49e48..5889655 100644 --- a/packages/turbo/ios/RNVisitableView.swift +++ b/packages/turbo/ios/RNVisitableView.swift @@ -25,9 +25,9 @@ class RNVisitableView: UIView, RNSessionSubscriber { controller!.visitableView.allowsPullToRefresh = pullToRefreshEnabled } } - @objc var refreshControlTopAnchor: NSNumber = 0 { + @objc var refreshControlTopAnchorConstant: NSNumber = 0 { didSet { - controller!.visitableView.refreshControlTopAnchor = refreshControlTopAnchor as! CGFloat + controller!.visitableView.refreshControlTopAnchorConstant = refreshControlTopAnchorConstant as! CGFloat } } @objc var scrollEnabled: Bool = true { diff --git a/packages/turbo/ios/RNVisitableViewManager.m b/packages/turbo/ios/RNVisitableViewManager.m index 52fd3ef..915fb6a 100644 --- a/packages/turbo/ios/RNVisitableViewManager.m +++ b/packages/turbo/ios/RNVisitableViewManager.m @@ -19,7 +19,7 @@ @interface RCT_EXTERN_MODULE(RNVisitableViewManager, NSObject) RCT_EXPORT_VIEW_PROPERTY(pullToRefreshEnabled, BOOL) RCT_EXPORT_VIEW_PROPERTY(scrollEnabled, BOOL) RCT_EXPORT_VIEW_PROPERTY(contentInset, NSDictionary) - RCT_EXPORT_VIEW_PROPERTY(refreshControlTopAnchor, NSNumber) + RCT_EXPORT_VIEW_PROPERTY(refreshControlTopAnchorConstant, NSNumber) RCT_EXPORT_VIEW_PROPERTY(webViewDebuggingEnabled, BOOL) RCT_EXPORT_VIEW_PROPERTY(onVisitProposal, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(onOpenExternalUrl, RCTDirectEventBlock) diff --git a/packages/turbo/patches/turbo-ios.patch b/packages/turbo/patches/turbo-ios.patch index fb03a09..e0b3fab 100644 --- a/packages/turbo/patches/turbo-ios.patch +++ b/packages/turbo/patches/turbo-ios.patch @@ -6,7 +6,7 @@ index 12452b5..c008c6f 100644 open var webView: WKWebView? private weak var visitable: Visitable? -+ public var refreshControlTopAnchor: CGFloat = 0 ++ public var refreshControlTopAnchorConstant: CGFloat = 0 + open func activateWebView(_ webView: WKWebView, forVisitable visitable: Visitable) { self.webView = webView @@ -16,7 +16,7 @@ index 12452b5..c008c6f 100644 NSLayoutConstraint.activate([ refreshControl.centerXAnchor.constraint(equalTo: centerXAnchor), - refreshControl.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor), -+ refreshControl.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor, constant: refreshControlTopAnchor), ++ refreshControl.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor, constant: refreshControlTopAnchorConstant), refreshControl.heightAnchor.constraint(equalToConstant: refreshControlHeight) ]) #endif diff --git a/packages/turbo/src/RNVisitableView.ts b/packages/turbo/src/RNVisitableView.ts index 450ee42..5eb5e98 100644 --- a/packages/turbo/src/RNVisitableView.ts +++ b/packages/turbo/src/RNVisitableView.ts @@ -32,7 +32,7 @@ export interface RNVisitableViewProps { scrollEnabled: boolean; contentInset: ContentInsetObject; progressViewOffset?: ProgressViewOffsetObject; - refreshControlTopAnchor: number; + refreshControlTopAnchorConstant: number; webViewDebuggingEnabled: boolean; onLoad?: (e: NativeSyntheticEvent) => void; onMessage?: (e: NativeSyntheticEvent) => void; diff --git a/packages/turbo/src/VisitableView.tsx b/packages/turbo/src/VisitableView.tsx index c16bb38..ba2dbc2 100644 --- a/packages/turbo/src/VisitableView.tsx +++ b/packages/turbo/src/VisitableView.tsx @@ -54,7 +54,7 @@ export interface Props { scrollEnabled?: boolean; contentInset?: ContentInsetObject; progressViewOffset?: ProgressViewOffsetObject; - refreshControlTopAnchor?: number; + refreshControlTopAnchorConstant?: number; webViewDebuggingEnabled?: boolean; renderLoading?: RenderLoading; renderError?: RenderError; @@ -88,7 +88,7 @@ const VisitableView = React.forwardRef>( scrollEnabled = true, contentInset = { top: 0, left: 0, right: 0, bottom: 0 }, progressViewOffset, - refreshControlTopAnchor = 0, + refreshControlTopAnchorConstant = 0, webViewDebuggingEnabled = false, renderLoading, renderError, @@ -229,7 +229,7 @@ const VisitableView = React.forwardRef>( scrollEnabled={scrollEnabled} contentInset={contentInset} progressViewOffset={progressViewOffset} - refreshControlTopAnchor={refreshControlTopAnchor} + refreshControlTopAnchorConstant={refreshControlTopAnchorConstant} webViewDebuggingEnabled={webViewDebuggingEnabled} onError={onErrorCombinedHandlers} onVisitProposal={handleVisitProposal}