Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix[ios]: remove virtual keyboard accessory bar (#2454)

Peter Chinmanf57fb6184a60
diff --git a/js/app/tauri/Cargo.lock b/js/app/tauri/Cargo.lock
index 945d0a8c5f..57bb3c7d20 100644
--- a/js/app/tauri/Cargo.lock
+++ b/js/app/tauri/Cargo.lock
@@ -94,6 +94,7 @@ dependencies = [
"tauri-plugin-deep-link",
"tauri-plugin-haptics",
"tauri-plugin-http",
+ "tauri-plugin-input-accessory",
"tauri-plugin-log",
"tauri-plugin-notification",
"tauri-plugin-notifications",
@@ -4617,6 +4618,14 @@ dependencies = [
"urlpattern",
]
+[[package]]
+name = "tauri-plugin-input-accessory"
+version = "0.1.0"
+dependencies = [
+ "tauri",
+ "tauri-plugin",
+]
+
[[package]]
name = "tauri-plugin-log"
version = "2.7.1"
diff --git a/js/app/tauri/Cargo.toml b/js/app/tauri/Cargo.toml
index 30bd5a6cac..1b2edae7bd 100644
--- a/js/app/tauri/Cargo.toml
+++ b/js/app/tauri/Cargo.toml
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
-members = ["src-tauri", "navigation_plugin", "logger"]
+members = ["src-tauri", "navigation_plugin", "logger", "input_accessory_plugin"]
[workspace.dependencies]
rootcause = "0.10"
diff --git a/js/app/tauri/input_accessory_plugin/.gitignore b/js/app/tauri/input_accessory_plugin/.gitignore
new file mode 100644
index 0000000000..a2ba4dd574
--- /dev/null
+++ b/js/app/tauri/input_accessory_plugin/.gitignore
@@ -0,0 +1,6 @@
+# Swift Package Manager build artifacts
+ios/.build/
+ios/Package.resolved
+
+# Tauri-generated Swift API (placed here by `cargo tauri ios build`)
+.tauri/
diff --git a/js/app/tauri/input_accessory_plugin/Cargo.toml b/js/app/tauri/input_accessory_plugin/Cargo.toml
new file mode 100644
index 0000000000..c3ec5c00e3
--- /dev/null
+++ b/js/app/tauri/input_accessory_plugin/Cargo.toml
@@ -0,0 +1,14 @@
+[package]
+name = "tauri-plugin-input-accessory"
+version = "0.1.0"
+edition = "2024"
+links = "tauri-plugin-input-accessory"
+
+[build-dependencies]
+tauri-plugin = { version = "2.4", features = ["build"] }
+
+[dependencies]
+tauri = { workspace = true }
+
+[target.'cfg(target_os = "ios")'.dependencies]
+tauri = { workspace = true, features = ["wry"] }
diff --git a/js/app/tauri/input_accessory_plugin/build.rs b/js/app/tauri/input_accessory_plugin/build.rs
new file mode 100644
index 0000000000..d72a9dc168
--- /dev/null
+++ b/js/app/tauri/input_accessory_plugin/build.rs
@@ -0,0 +1,6 @@
+fn main() {
+ tauri_plugin::Builder::new(&[])
+ .ios_path("ios")
+ .try_build()
+ .unwrap();
+}
diff --git a/js/app/tauri/input_accessory_plugin/ios/Package.swift b/js/app/tauri/input_accessory_plugin/ios/Package.swift
new file mode 100644
index 0000000000..204c3b0c29
--- /dev/null
+++ b/js/app/tauri/input_accessory_plugin/ios/Package.swift
@@ -0,0 +1,29 @@
+// swift-tools-version:5.3
+import PackageDescription
+
+let package = Package(
+ name: "tauri-plugin-input-accessory",
+ platforms: [
+ .macOS(.v10_13),
+ .iOS(.v14),
+ ],
+ products: [
+ .library(
+ name: "tauri-plugin-input-accessory",
+ type: .static,
+ targets: ["tauri-plugin-input-accessory"]
+ )
+ ],
+ dependencies: [
+ .package(name: "Tauri", path: "../.tauri/tauri-api")
+ ],
+ targets: [
+ .target(
+ name: "tauri-plugin-input-accessory",
+ dependencies: [
+ .byName(name: "Tauri")
+ ],
+ path: "Sources"
+ )
+ ]
+)
diff --git a/js/app/tauri/input_accessory_plugin/ios/Sources/InputAccessoryPlugin.swift b/js/app/tauri/input_accessory_plugin/ios/Sources/InputAccessoryPlugin.swift
new file mode 100644
index 0000000000..ef1b45e55b
--- /dev/null
+++ b/js/app/tauri/input_accessory_plugin/ios/Sources/InputAccessoryPlugin.swift
@@ -0,0 +1,66 @@
+import UIKit
+import WebKit
+import Tauri
+
+class InputAccessoryPlugin: Plugin {
+ private static var isSwizzled = false
+
+ override public func load(webview: WKWebView) {
+ webview.scrollView.keyboardDismissMode = .interactive
+
+ guard !InputAccessoryPlugin.isSwizzled else { return }
+ if disableAccessoryBar(in: webview) {
+ InputAccessoryPlugin.isSwizzled = true
+ }
+ }
+}
+
+@discardableResult
+private func disableAccessoryBar(in rootView: UIView) -> Bool {
+ var queue = rootView.subviews
+ while !queue.isEmpty {
+ let view = queue.removeFirst()
+ if NSStringFromClass(type(of: view)).hasPrefix("WKContent") {
+ if let cls = object_getClass(view) {
+ swizzleInputAccessoryView(on: cls)
+ return true
+ }
+ return false
+ }
+ queue.append(contentsOf: view.subviews)
+ }
+ return false
+}
+
+private class NoInputAccessoryView: UIView {
+ override var inputAccessoryView: UIView? { return nil }
+}
+
+private func swizzleInputAccessoryView(on cls: AnyClass) {
+ let selector = #selector(getter: UIResponder.inputAccessoryView)
+ guard let noAccessoryMethod = class_getInstanceMethod(
+ NoInputAccessoryView.self,
+ #selector(getter: NoInputAccessoryView.inputAccessoryView)
+ ) else { return }
+
+ let added = class_addMethod(
+ cls,
+ selector,
+ method_getImplementation(noAccessoryMethod),
+ method_getTypeEncoding(noAccessoryMethod)
+ )
+
+ if !added {
+ class_replaceMethod(
+ cls,
+ selector,
+ method_getImplementation(noAccessoryMethod),
+ method_getTypeEncoding(noAccessoryMethod)
+ )
+ }
+}
+
+@_cdecl("init_plugin_input_accessory")
+func initPlugin() -> Plugin {
+ return InputAccessoryPlugin()
+}
diff --git a/js/app/tauri/input_accessory_plugin/src/lib.rs b/js/app/tauri/input_accessory_plugin/src/lib.rs
new file mode 100644
index 0000000000..e7474c1ef5
--- /dev/null
+++ b/js/app/tauri/input_accessory_plugin/src/lib.rs
@@ -0,0 +1,17 @@
+use tauri::{
+ plugin::{Builder, TauriPlugin},
+ Runtime,
+};
+
+#[cfg(target_os = "ios")]
+tauri::ios_plugin_binding!(init_plugin_input_accessory);
+
+pub fn init<R: Runtime>() -> TauriPlugin<R> {
+ Builder::new("input-accessory")
+ .setup(|_app, api| {
+ #[cfg(target_os = "ios")]
+ api.register_ios_plugin(init_plugin_input_accessory)?;
+ Ok(())
+ })
+ .build()
+}
diff --git a/js/app/tauri/src-tauri/Cargo.toml b/js/app/tauri/src-tauri/Cargo.toml
index dcce617e52..f8883cf107 100644
--- a/js/app/tauri/src-tauri/Cargo.toml
+++ b/js/app/tauri/src-tauri/Cargo.toml
@@ -61,3 +61,6 @@ tauri-plugin-single-instance = { version = "2", features = ["deep-link"] }
[target.'cfg(any(target_os = "android", target_os = "ios"))'.dependencies]
tauri-plugin-haptics = "2"
tauri-plugin-auth = { git = "https://github.com/macro-inc/tauri-plugins", rev = "2b2257722f60458921eadf4a9ab4d9e1db36e34f" }
+
+[target.'cfg(target_os = "ios")'.dependencies]
+tauri-plugin-input-accessory = { path = "../input_accessory_plugin" }
diff --git a/js/app/tauri/src-tauri/src/lib.rs b/js/app/tauri/src-tauri/src/lib.rs
index ee0280197c..a6b6de3036 100644
--- a/js/app/tauri/src-tauri/src/lib.rs
+++ b/js/app/tauri/src-tauri/src/lib.rs
@@ -145,7 +145,9 @@ pub fn run() {
#[cfg(target_os = "ios")]
{
- builder = builder.plugin(tauri_plugin_haptics::init());
+ builder = builder
+ .plugin(tauri_plugin_haptics::init())
+ .plugin(tauri_plugin_input_accessory::init());
}
// register the rest of the common plugins