Skip to content

Commit

Permalink
fix(ios): allow enabling gesture navigation via config (ionic-team#3808)
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Mazein <[email protected]>
  • Loading branch information
MegaMaddin committed Aug 2, 2024
1 parent ceee68a commit 1cb9471
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 0 deletions.
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

0 comments on commit 1cb9471

Please sign in to comment.