Skip to content

Commit

Permalink
feat: rename property
Browse files Browse the repository at this point in the history
  • Loading branch information
pklatka committed Apr 30, 2024
1 parent 9481b1f commit a394039
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions packages/turbo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions packages/turbo/ios/RNVisitableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/turbo/ios/RNVisitableViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions packages/turbo/patches/turbo-ios.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion packages/turbo/src/RNVisitableView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface RNVisitableViewProps {
scrollEnabled: boolean;
contentInset: ContentInsetObject;
progressViewOffset?: ProgressViewOffsetObject;
refreshControlTopAnchor: number;
refreshControlTopAnchorConstant: number;
webViewDebuggingEnabled: boolean;
onLoad?: (e: NativeSyntheticEvent<LoadEvent>) => void;
onMessage?: (e: NativeSyntheticEvent<MessageEvent>) => void;
Expand Down
6 changes: 3 additions & 3 deletions packages/turbo/src/VisitableView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export interface Props {
scrollEnabled?: boolean;
contentInset?: ContentInsetObject;
progressViewOffset?: ProgressViewOffsetObject;
refreshControlTopAnchor?: number;
refreshControlTopAnchorConstant?: number;
webViewDebuggingEnabled?: boolean;
renderLoading?: RenderLoading;
renderError?: RenderError;
Expand Down Expand Up @@ -88,7 +88,7 @@ const VisitableView = React.forwardRef<RefObject, React.PropsWithRef<Props>>(
scrollEnabled = true,
contentInset = { top: 0, left: 0, right: 0, bottom: 0 },
progressViewOffset,
refreshControlTopAnchor = 0,
refreshControlTopAnchorConstant = 0,
webViewDebuggingEnabled = false,
renderLoading,
renderError,
Expand Down Expand Up @@ -229,7 +229,7 @@ const VisitableView = React.forwardRef<RefObject, React.PropsWithRef<Props>>(
scrollEnabled={scrollEnabled}
contentInset={contentInset}
progressViewOffset={progressViewOffset}
refreshControlTopAnchor={refreshControlTopAnchor}
refreshControlTopAnchorConstant={refreshControlTopAnchorConstant}
webViewDebuggingEnabled={webViewDebuggingEnabled}
onError={onErrorCombinedHandlers}
onVisitProposal={handleVisitProposal}
Expand Down

0 comments on commit a394039

Please sign in to comment.