Allow swipe to go back

This commit is contained in:
Philip Peterson 2026-08-25 03:00:32 -08:00
parent fe8010cb80
commit 9506629586
3 changed files with 41 additions and 0 deletions

View file

@ -2070,6 +2070,16 @@ dependencies = [
"objc2-core-foundation",
]
[[package]]
name = "objc2-javascript-core"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a1e6550c4caed348956ce3370c9ffeca70bb1dbed4fa96112e7c6170e074586"
dependencies = [
"objc2",
"objc2-core-foundation",
]
[[package]]
name = "objc2-quartz-core"
version = "0.3.2"
@ -2082,6 +2092,17 @@ dependencies = [
"objc2-foundation",
]
[[package]]
name = "objc2-security"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "709fe137109bd1e8b5a99390f77a7d8b2961dafc1a1c5db8f2e60329ad6d895a"
dependencies = [
"bitflags 2.13.1",
"objc2",
"objc2-core-foundation",
]
[[package]]
name = "objc2-ui-kit"
version = "0.3.2"
@ -2125,6 +2146,8 @@ dependencies = [
"objc2-app-kit",
"objc2-core-foundation",
"objc2-foundation",
"objc2-javascript-core",
"objc2-security",
]
[[package]]
@ -2430,6 +2453,7 @@ name = "quintodrome"
version = "0.1.0"
dependencies = [
"libc",
"objc2-web-kit",
"serde_json",
"tauri",
"tauri-build",

View file

@ -21,6 +21,9 @@ thiserror = "1"
[target.'cfg(unix)'.dependencies]
libc = "0.2"
[target.'cfg(target_os = "macos")'.dependencies]
objc2-web-kit = { version = "0.3", features = ["WKWebView"] }
[features]
# This feature is used for production builds or when `devPath` points to the
# filesystem and the built-in dev server is disabled.

View file

@ -38,6 +38,17 @@ fn navigate(app: tauri::AppHandle, url: String) {
}
}
/// Enables two-finger swipe-to-navigate (back/forward) in the content webview.
#[cfg(target_os = "macos")]
fn enable_swipe_navigation(app: &tauri::AppHandle) {
if let Some(content) = app.get_webview("content") {
let _ = content.with_webview(|webview| unsafe {
let view: &objc2_web_kit::WKWebView = &*webview.inner().cast();
view.setAllowsBackForwardNavigationGestures(true);
});
}
}
/// Positions the toolbar strip at the top and the content webview below it.
fn layout(app: &tauri::AppHandle) {
let Some(window) = app.get_window("main") else {
@ -114,6 +125,9 @@ pub fn run() {
layout(app.handle());
#[cfg(target_os = "macos")]
enable_swipe_navigation(app.handle());
if let Some(toolbar) = app.get_webview("main") {
let _ = toolbar.emit("url-changed", &navidrome_url);
}