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

fix(ios): allow enabling gesture navigation via config (#3808) #7599

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions ios/Capacitor/Capacitor/CAPBridgeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ extension CAPBridgeViewController {
aWebView.scrollView.bounces = false
aWebView.scrollView.contentInsetAdjustmentBehavior = configuration.contentInsetAdjustmentBehavior
aWebView.allowsLinkPreview = configuration.allowLinkPreviews
aWebView.allowsBackForwardNavigationGestures = configuration.allowsBackForwardNavigationGestures
aWebView.scrollView.isScrollEnabled = configuration.scrollingEnabled
if let overrideUserAgent = configuration.overridenUserAgentString {
aWebView.customUserAgent = overrideUserAgent
Expand Down
1 change: 1 addition & 0 deletions ios/Capacitor/Capacitor/CAPInstanceConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ NS_SWIFT_NAME(InstanceConfiguration)
@property (nonatomic, readonly) BOOL scrollingEnabled;
@property (nonatomic, readonly) BOOL zoomingEnabled;
@property (nonatomic, readonly) BOOL allowLinkPreviews;
@property (nonatomic, readonly) BOOL allowsBackForwardNavigationGestures;
@property (nonatomic, readonly) BOOL handleApplicationNotifications;
@property (nonatomic, readonly) BOOL isWebDebuggable;
@property (nonatomic, readonly) BOOL cordovaDeployDisabled;
Expand Down
2 changes: 2 additions & 0 deletions ios/Capacitor/Capacitor/CAPInstanceConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ - (instancetype)initWithDescriptor:(CAPInstanceDescriptor *)descriptor isDebug:(
_scrollingEnabled = descriptor.scrollingEnabled;
_zoomingEnabled = descriptor.zoomingEnabled;
_allowLinkPreviews = descriptor.allowLinkPreviews;
_allowsBackForwardNavigationGestures = descriptor.allowsBackForwardNavigationGestures;
_handleApplicationNotifications = descriptor.handleApplicationNotifications;
_contentInsetAdjustmentBehavior = descriptor.contentInsetAdjustmentBehavior;
_appLocation = descriptor.appLocation;
Expand Down Expand Up @@ -69,6 +70,7 @@ - (instancetype)initWithConfiguration:(CAPInstanceConfiguration*)configuration a
_scrollingEnabled = configuration.scrollingEnabled;
_zoomingEnabled = configuration.zoomingEnabled;
_allowLinkPreviews = configuration.allowLinkPreviews;
_allowsBackForwardNavigationGestures = configuration.allowsBackForwardNavigationGestures;
_handleApplicationNotifications = configuration.handleApplicationNotifications;
_isWebDebuggable = configuration.isWebDebuggable;
_cordovaDeployDisabled = configuration.cordovaDeployDisabled;
Expand Down
5 changes: 5 additions & 0 deletions ios/Capacitor/Capacitor/CAPInstanceDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ NS_SWIFT_NAME(InstanceDescriptor)
@discussion Set by @c ios.allowsLinkPreview in the configuration file. Corresponds to @c allowsLinkPreview on WKWebView.
*/
@property (nonatomic, assign) BOOL allowLinkPreviews;
/**
@brief Whether or not the web view will allow gesture navigation .
@discussion Set by @c ios.allowsBackForwardNavigationGestures in the configuration file. Corresponds to @c allowsBackForwardNavigationGestures on WKWebView.
*/
@property (nonatomic, assign) BOOL allowsBackForwardNavigationGestures;
/**
@brief Whether or not the Capacitor runtime will set itself as the @c UNUserNotificationCenter delegate.
@discussion Defaults to @c true. Required to be @c true for notification plugins to work correctly. Set to @c false if your application will handle notifications independently.
Expand Down
1 change: 1 addition & 0 deletions ios/Capacitor/Capacitor/CAPInstanceDescriptor.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ - (void)_setDefaultsWithAppLocation:(NSURL*)location {
_scrollingEnabled = YES;
_zoomingEnabled = NO;
_allowLinkPreviews = YES;
_allowsBackForwardNavigationGestures = NO;
_handleApplicationNotifications = YES;
_isWebDebuggable = NO;
_contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
Expand Down
3 changes: 3 additions & 0 deletions ios/Capacitor/Capacitor/CAPInstanceDescriptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ internal extension InstanceDescriptor {
if let allowPreviews = config[keyPath: "ios.allowsLinkPreview"] as? Bool {
allowLinkPreviews = allowPreviews
}
if let allowsNavigationGestures = config[keyPath: "ios.allowsBackForwardNavigationGestures"] as? Bool {
allowsBackForwardNavigationGestures = allowsNavigationGestures
}
if let scrollEnabled = config[keyPath: "ios.scrollEnabled"] as? Bool {
scrollingEnabled = scrollEnabled
}
Expand Down