feat: ios impl

pull/306/head
Lucas Nogueira 2 years ago
parent c7592da835
commit bf03316a04
No known key found for this signature in database
GPG Key ID: 7C32FCA95C8C95D7

@ -0,0 +1 @@
.tauri

@ -32,6 +32,24 @@ dependencies = [
"alloc-no-stdlib",
]
[[package]]
name = "android_log-sys"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85965b6739a430150bdd138e2374a98af0c3ee0d030b3bb7fc3bddff58d0102e"
[[package]]
name = "android_logger"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8619b80c242aa7bd638b5c7ddd952addeecb71f69c75e33f1d47b2804f8f883a"
dependencies = [
"android_log-sys",
"env_logger",
"log",
"once_cell",
]
[[package]]
name = "anyhow"
version = "1.0.69"
@ -42,11 +60,13 @@ checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800"
name = "app"
version = "0.0.0"
dependencies = [
"log",
"serde",
"serde_json",
"tauri",
"tauri-build",
"tauri-plugin-dialog",
"tauri-plugin-log",
]
[[package]]
@ -273,6 +293,16 @@ version = "3.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535"
[[package]]
name = "byte-unit"
version = "4.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da78b32057b8fdfc352504708feeba7216dcd65a2c9ab02978cbd288d1279b6c"
dependencies = [
"serde",
"utf8-width",
]
[[package]]
name = "bytemuck"
version = "1.13.0"
@ -733,6 +763,16 @@ dependencies = [
"syn",
]
[[package]]
name = "env_logger"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0"
dependencies = [
"log",
"regex",
]
[[package]]
name = "errno"
version = "0.3.0"
@ -769,6 +809,15 @@ dependencies = [
"instant",
]
[[package]]
name = "fern"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9f0c14694cbd524c8720dd69b0e3179344f04ebb5f90f2e4a440c6ea3b2f1ee"
dependencies = [
"log",
]
[[package]]
name = "field-offset"
version = "0.3.4"
@ -1606,6 +1655,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [
"cfg-if",
"value-bag",
]
[[package]]
@ -3136,6 +3186,23 @@ dependencies = [
"thiserror",
]
[[package]]
name = "tauri-plugin-log"
version = "0.1.0"
dependencies = [
"android_logger",
"byte-unit",
"fern",
"log",
"serde",
"serde_json",
"serde_repr",
"swift-rs",
"tauri",
"tauri-build",
"time",
]
[[package]]
name = "tauri-runtime"
version = "0.13.0-alpha.3"
@ -3516,6 +3583,12 @@ version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
[[package]]
name = "utf8-width"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5190c9442dcdaf0ddd50f37420417d219ae5261bbf5db120d0f9bab996c9cba1"
[[package]]
name = "uuid"
version = "1.3.0"
@ -3531,6 +3604,16 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]]
name = "value-bag"
version = "1.0.0-alpha.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2209b78d1249f7e6f3293657c9779fe31ced465df091bbd433a1cf88e916ec55"
dependencies = [
"ctor",
"version_check",
]
[[package]]
name = "version-compare"
version = "0.1.1"

@ -21,6 +21,8 @@ serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "2.0.0-alpha.6", features = ["api-all"] }
tauri-plugin-dialog = { path = "../../../" }
tauri-plugin-log = { path = "../../../../log" }
log = "0.4"
[features]
# DO NOT remove this

@ -6,6 +6,11 @@
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_dialog::init())
.plugin(
tauri_plugin_log::Builder::default()
.level(log::LevelFilter::Info)
.build(),
)
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

@ -24,16 +24,11 @@
svelte-hmr "^0.15.1"
vitefu "^0.2.2"
"@tauri-apps/api@^1.1.0":
"@tauri-apps/api@^1.1.0", "@tauri-apps/api@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-1.2.0.tgz#1f196b3e012971227f41b98214c846430a4eb477"
integrity sha512-lsI54KI6HGf7VImuf/T9pnoejfgkNoXveP14pVV7XarrQ46rOejIVJLFqHI9sRReJMGdh2YuCoI3cc/yCWCsrw==
"@tauri-apps/api@^2.0.0-alpha.0":
version "2.0.0-alpha.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-2.0.0-alpha.0.tgz#901abbaf3b9515ba0437716ac0383de549e4e3bc"
integrity sha512-PQdy1Ao6JwKwW2/C11nP+IqnrWHB7+UgbM71zbzA1W3+1yyd9Zg+K7rzZ7f3yhvD7kdxmXUN3KgSfGeiDFzZ2A==
"@tauri-apps/cli-darwin-arm64@2.0.0-alpha.6":
version "2.0.0-alpha.6"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-2.0.0-alpha.6.tgz#d4fd5aa715bb3df7513f321636b3bcbade81fe06"

@ -3,14 +3,36 @@ import WebKit
import Tauri
import SwiftRs
class ExamplePlugin: Plugin {
@objc public func ping(_ invoke: Invoke) throws {
let value = invoke.getString("value")
invoke.resolve(["value": value as Any])
class DialogPlugin: Plugin {
@objc public func showMessageDialog(_ invoke: Invoke) {
let manager = self.manager
let title = invoke.getString("title")
guard let message = invoke.getString("message") else {
invoke.reject("The `message` argument is required")
return
}
let okButtonLabel = invoke.getString("okButtonLabel") ?? "OK"
let cancelButtonLabel = invoke.getString("cancelButtonLabel") ?? "Cancel"
DispatchQueue.main.async { [weak self] in
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: cancelButtonLabel, style: UIAlertAction.Style.default, handler: { (_) -> Void in
invoke.resolve([
"value": false
])
}))
alert.addAction(UIAlertAction(title: okButtonLabel, style: UIAlertAction.Style.default, handler: { (_) -> Void in
invoke.resolve([
"value": true
])
}))
manager.viewController?.present(alert, animated: true, completion: nil)
}
}
}
@_cdecl("init_plugin_dialog")
func initPlugin(name: SRString, webview: WKWebView?) {
Tauri.registerPlugin(webview: webview, name: name.toString(), plugin: ExamplePlugin())
Tauri.registerPlugin(webview: webview, name: name.toString(), plugin: DialogPlugin())
}

@ -101,7 +101,7 @@ pub fn save_file<R: Runtime, F: FnOnce(Option<PathBuf>) + Send + 'static>(
f(res.unwrap_or_default())
}
#[derive(Deserialize)]
#[derive(Debug, Deserialize)]
struct ShowMessageDialogResponse {
cancelled: bool,
value: bool,

Loading…
Cancel
Save