diff --git a/CHANGELOG.md b/CHANGELOG.md index dce828b..91a3e8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## Unreleased + +### Features + +* Added support for back and forward swipe navigation gestures in `WKWebView` via the `allowsBackForwardNavigationGestures` option. (for openInWebView option only) ([35ab447](https://github.com/ionic-team/capacitor-os-inappbrowser/commit/35ab44790eb98b2d0d748c130642b321e9dc1156)) + # [2.1.0](https://github.com/ionic-team/capacitor-os-inappbrowser/compare/v2.0.1...v2.1.0) (2025-04-15) ### Features diff --git a/CapacitorInappbrowser.podspec b/CapacitorInappbrowser.podspec index 9fbd379..313598b 100644 --- a/CapacitorInappbrowser.podspec +++ b/CapacitorInappbrowser.podspec @@ -12,7 +12,7 @@ Pod::Spec.new do |s| s.source = { :git => package['repository']['url'], :tag => s.version.to_s } s.source_files = 'ios/Sources/InAppBrowserPlugin/*.{swift,h,m,c,cc,mm,cpp}' s.ios.deployment_target = '14.0' - s.dependency 'OSInAppBrowserLib', spec='~> 2.0' + s.dependency 'OSInAppBrowserLib', spec='~> 2.0.1' s.dependency 'Capacitor' s.swift_version = '5.1' end diff --git a/README.md b/README.md index a626bf9..e289b23 100644 --- a/README.md +++ b/README.md @@ -242,14 +242,15 @@ Defines the options for opening a URL in the web view. #### iOSWebViewOptions -| Prop | Type | Description | -| ---------------------------------- | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **`allowOverScroll`** | boolean | Turns on the Web View bounce property. | -| **`enableViewportScale`** | boolean | Prevents viewport scaling through a meta tag. | -| **`allowInLineMediaPlayback`** | boolean | Allows in-line HTML5 media playback, displaying within the browser window rather than a device-specific playback interface. Note: The HTML's video element must also include the webkit-playsinline attribute. | -| **`surpressIncrementalRendering`** | boolean | Waits until all new view content is received before being rendered. | -| **`viewStyle`** | iOSViewStyle | Sets the presentation style of the Web View. | -| **`animationEffect`** | iOSAnimation | Sets the transition style of the Web View. | +| Prop | Type | Description | +| ----------------------------------------- | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **`allowOverScroll`** | boolean | Turns on the Web View bounce property. | +| **`enableViewportScale`** | boolean | Prevents viewport scaling through a meta tag. | +| **`allowInLineMediaPlayback`** | boolean | Allows in-line HTML5 media playback, displaying within the browser window rather than a device-specific playback interface. Note: The HTML's video element must also include the webkit-playsinline attribute. | +| **`surpressIncrementalRendering`** | boolean | Waits until all new view content is received before being rendered. | +| **`viewStyle`** | iOSViewStyle | Sets the presentation style of the Web View. | +| **`animationEffect`** | iOSAnimation | Sets the transition style of the Web View. | +| **`allowsBackForwardNavigationGestures`** | boolean | Enables back and forward swipe gestures in the Web View. | #### OpenInSystemBrowserParameterModel diff --git a/example-app/package-lock.json b/example-app/package-lock.json index ef754e7..becbbf9 100644 --- a/example-app/package-lock.json +++ b/example-app/package-lock.json @@ -9,13 +9,13 @@ "version": "0.0.1", "dependencies": { "@capacitor/android": "next", - "@capacitor/app": "6.0.0", + "@capacitor/app": "next", "@capacitor/core": "next", - "@capacitor/haptics": "6.0.0", + "@capacitor/haptics": "next", "@capacitor/inappbrowser": "file:../", "@capacitor/ios": "next", - "@capacitor/keyboard": "6.0.0", - "@capacitor/status-bar": "6.0.0", + "@capacitor/keyboard": "next", + "@capacitor/status-bar": "next", "@ionic/react": "^8.0.0", "@ionic/react-router": "^8.0.0", "@types/react-router": "^5.1.20", @@ -32,6 +32,7 @@ "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^14.0.0", "@testing-library/user-event": "^14.4.3", + "@types/jest": "^29.5.14", "@types/react": "^18.0.27", "@types/react-dom": "^18.0.10", "@vitejs/plugin-legacy": "^5.0.0", @@ -48,7 +49,7 @@ }, "..": { "name": "@capacitor/inappbrowser", - "version": "1.0.2", + "version": "2.1.0", "license": "MIT", "devDependencies": { "@capacitor/android": "next", @@ -73,10 +74,10 @@ "swiftlint": "^1.0.2", "typescript": "~5.4.5", "vite": "^5.2.11", - "vite-plugin-dts": "^3.9.1" + "vite-plugin-dts": "^4.4.0" }, "peerDependencies": { - "@capacitor/core": "next" + "@capacitor/core": ">=7.0.0" } }, "node_modules/@adobe/css-tools": { @@ -3586,11 +3587,10 @@ } }, "node_modules/@types/jest": { - "version": "29.5.12", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.12.tgz", - "integrity": "sha512-eDC8bTvT/QhYdxJAulQikueigY5AsdBRH2yDKW3yveW7svY3+DzN84/2NUgkw10RTiJbWqZrTtoGVdYlvFJdLw==", + "version": "29.5.14", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.14.tgz", + "integrity": "sha512-ZN+4sdnLUbo8EVvVc2ao0GFW6oVrQRPn4K2lglySj7APvSrgzxHiNNK99us4WDMi57xxA2yggblIAMNhXOotLQ==", "dev": true, - "license": "MIT", "dependencies": { "expect": "^29.0.0", "pretty-format": "^29.0.0" diff --git a/example-app/src/pages/Home.tsx b/example-app/src/pages/Home.tsx index f2bfbb5..9bfff64 100644 --- a/example-app/src/pages/Home.tsx +++ b/example-app/src/pages/Home.tsx @@ -86,7 +86,8 @@ const Home: React.FC = () => { allowInLineMediaPlayback: true, surpressIncrementalRendering: true, viewStyle: iOSViewStyle.PAGE_SHEET, - animationEffect: iOSAnimation.CROSS_DISSOLVE + animationEffect: iOSAnimation.CROSS_DISSOLVE, + allowsBackForwardNavigationGestures: true } } }); @@ -116,7 +117,8 @@ const Home: React.FC = () => { allowInLineMediaPlayback: true, surpressIncrementalRendering: true, viewStyle: iOSViewStyle.PAGE_SHEET, - animationEffect: iOSAnimation.CROSS_DISSOLVE + animationEffect: iOSAnimation.CROSS_DISSOLVE, + allowsBackForwardNavigationGestures: true } } }); diff --git a/ios/Sources/InAppBrowserPlugin/OSInAppBrowserWebViewModel.swift b/ios/Sources/InAppBrowserPlugin/OSInAppBrowserWebViewModel.swift index 318cc13..8d131ae 100644 --- a/ios/Sources/InAppBrowserPlugin/OSInAppBrowserWebViewModel.swift +++ b/ios/Sources/InAppBrowserPlugin/OSInAppBrowserWebViewModel.swift @@ -9,6 +9,7 @@ struct OSInAppBrowserWebViewModel: Decodable { let surpressIncrementalRendering: Bool let viewStyle: OSIABViewStyle let animationEffect: OSIABAnimationEffect + let allowsBackForwardNavigationGestures: Bool enum CodingKeys: CodingKey { case allowOverScroll @@ -17,6 +18,7 @@ struct OSInAppBrowserWebViewModel: Decodable { case surpressIncrementalRendering case viewStyle case animationEffect + case allowsBackForwardNavigationGestures } init(from decoder: Decoder) throws { @@ -31,6 +33,7 @@ struct OSInAppBrowserWebViewModel: Decodable { self.surpressIncrementalRendering = try container.decode(Bool.self, forKey: .surpressIncrementalRendering) self.viewStyle = .init(viewStyleValue) self.animationEffect = .init(animationValue) + self.allowsBackForwardNavigationGestures = try container.decode(Bool.self, forKey: .allowsBackForwardNavigationGestures) } } @@ -98,7 +101,8 @@ extension OSInAppBrowserWebViewModel { surpressIncrementalRendering: self.iOS.surpressIncrementalRendering, viewStyle: self.iOS.viewStyle, animationEffect: self.iOS.animationEffect, - customUserAgent: self.customWebViewUserAgent + customUserAgent: self.customWebViewUserAgent, + allowsBackForwardNavigationGestures: self.iOS.allowsBackForwardNavigationGestures ) } } diff --git a/src/defaults.ts b/src/defaults.ts index 569da53..a6952fb 100644 --- a/src/defaults.ts +++ b/src/defaults.ts @@ -28,6 +28,7 @@ export const DefaultiOSWebViewOptions: iOSWebViewOptions = { viewStyle: iOSViewStyle.FULL_SCREEN, animationEffect: iOSAnimation.COVER_VERTICAL, + allowsBackForwardNavigationGestures: true, }; export const DefaultWebViewOptions: WebViewOptions = { diff --git a/src/definitions.ts b/src/definitions.ts index de9f172..39828cd 100644 --- a/src/definitions.ts +++ b/src/definitions.ts @@ -76,6 +76,9 @@ export interface iOSWebViewOptions { viewStyle: iOSViewStyle; /** Sets the transition style of the Web View. */ animationEffect: iOSAnimation; + + /** Enables back and forward swipe gestures in the Web View. */ + allowsBackForwardNavigationGestures: boolean; } export interface AndroidWebViewOptions {