mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 12:43:08 +00:00
FIx desktop for android
This commit is contained in:
parent
4343abf76d
commit
2ce8ded74d
6 changed files with 42 additions and 6 deletions
|
@ -38,6 +38,7 @@ log = "0.4.11"
|
||||||
im-rc = "15.1.0"
|
im-rc = "15.1.0"
|
||||||
dioxus = { path = "../../packages/dioxus" }
|
dioxus = { path = "../../packages/dioxus" }
|
||||||
dioxus-desktop = { path = "../../packages/desktop" }
|
dioxus-desktop = { path = "../../packages/desktop" }
|
||||||
|
wry = { version = "0.27.2" }
|
||||||
|
|
||||||
[target.'cfg(target_os = "android")'.dependencies]
|
[target.'cfg(target_os = "android")'.dependencies]
|
||||||
android_logger = "0.9.0"
|
android_logger = "0.9.0"
|
||||||
|
|
|
@ -33,3 +33,13 @@ From there, just click the "play" button with the right target and the app shoul
|
||||||
|
|
||||||
Note that clicking play doesn't cause a new build, so you'll need to keep rebuilding the app between changes. The tooling here is very young, so please be patient. If you want to contribute to make things easier, please do! We'll be happy to help.
|
Note that clicking play doesn't cause a new build, so you'll need to keep rebuilding the app between changes. The tooling here is very young, so please be patient. If you want to contribute to make things easier, please do! We'll be happy to help.
|
||||||
|
|
||||||
|
|
||||||
|
## Running on Android
|
||||||
|
|
||||||
|
Again, we want to make sure we have the right targets installed.
|
||||||
|
|
||||||
|
The common targets here are
|
||||||
|
- aarch64-linux-android
|
||||||
|
- armv7-linux-androideabi
|
||||||
|
- i686-linux-android
|
||||||
|
- x86_64-linux-android
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
use wry::android_binding;
|
||||||
|
|
||||||
pub fn main() -> Result<()> {
|
pub fn main() -> Result<()> {
|
||||||
init_logging();
|
init_logging();
|
||||||
|
@ -70,8 +72,6 @@ fn _start_app() {
|
||||||
}
|
}
|
||||||
|
|
||||||
use dioxus_desktop::Config;
|
use dioxus_desktop::Config;
|
||||||
#[cfg(target_os = "android")]
|
|
||||||
use wry::android_binding;
|
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
|
|
|
@ -39,7 +39,8 @@ slab = { workspace = true }
|
||||||
futures-util = { workspace = true }
|
futures-util = { workspace = true }
|
||||||
urlencoding = "2.1.2"
|
urlencoding = "2.1.2"
|
||||||
|
|
||||||
[target.'cfg(not(target_os = "ios"))'.dependencies]
|
|
||||||
|
[target.'cfg(any(target_os = "windows",target_os = "macos",target_os = "linux",target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
|
||||||
rfd = "0.11.3"
|
rfd = "0.11.3"
|
||||||
|
|
||||||
[target.'cfg(target_os = "ios")'.dependencies]
|
[target.'cfg(target_os = "ios")'.dependencies]
|
||||||
|
|
|
@ -13,12 +13,28 @@ pub(crate) struct FileDialogRequest {
|
||||||
pub bubbles: bool,
|
pub bubbles: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "ios")]
|
#[cfg(not(any(
|
||||||
|
target_os = "windows",
|
||||||
|
target_os = "macos",
|
||||||
|
target_os = "linux",
|
||||||
|
target_os = "dragonfly",
|
||||||
|
target_os = "freebsd",
|
||||||
|
target_os = "netbsd",
|
||||||
|
target_os = "openbsd"
|
||||||
|
)))]
|
||||||
pub(crate) fn get_file_event(_request: &FileDialogRequest) -> Vec<PathBuf> {
|
pub(crate) fn get_file_event(_request: &FileDialogRequest) -> Vec<PathBuf> {
|
||||||
vec![]
|
vec![]
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "ios"))]
|
#[cfg(any(
|
||||||
|
target_os = "windows",
|
||||||
|
target_os = "macos",
|
||||||
|
target_os = "linux",
|
||||||
|
target_os = "dragonfly",
|
||||||
|
target_os = "freebsd",
|
||||||
|
target_os = "netbsd",
|
||||||
|
target_os = "openbsd"
|
||||||
|
))]
|
||||||
pub(crate) fn get_file_event(request: &FileDialogRequest) -> Vec<PathBuf> {
|
pub(crate) fn get_file_event(request: &FileDialogRequest) -> Vec<PathBuf> {
|
||||||
let mut dialog = rfd::FileDialog::new();
|
let mut dialog = rfd::FileDialog::new();
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,15 @@ impl ShortcutRegistry {
|
||||||
callbacks.remove(id.number);
|
callbacks.remove(id.number);
|
||||||
if callbacks.is_empty() {
|
if callbacks.is_empty() {
|
||||||
if let Some(_shortcut) = shortcuts.remove(&id.id) {
|
if let Some(_shortcut) = shortcuts.remove(&id.id) {
|
||||||
#[cfg(not(target_os = "ios"))]
|
#[cfg(any(
|
||||||
|
target_os = "windows",
|
||||||
|
target_os = "macos",
|
||||||
|
target_os = "linux",
|
||||||
|
target_os = "dragonfly",
|
||||||
|
target_os = "freebsd",
|
||||||
|
target_os = "netbsd",
|
||||||
|
target_os = "openbsd"
|
||||||
|
))]
|
||||||
let _ = self.manager.borrow_mut().unregister(_shortcut.shortcut);
|
let _ = self.manager.borrow_mut().unregister(_shortcut.shortcut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue