Fix android/ios desktop builds, move type from native over
This commit is contained in:
3 files changed
+31
-35
No files matched your search
@@ -18,12 +18,7 @@ pub enum UserWindowEvent {
|
|||||||
Ipc { id: WindowId, msg: IpcMessage },
|
Ipc { id: WindowId, msg: IpcMessage },
|
||||||
|
|
||||||
/// Handle a hotreload event, basically telling us to update our templates
|
/// Handle a hotreload event, basically telling us to update our templates
|
||||||
#[cfg(all(
|
#[cfg(all(feature = "devtools", debug_assertions))]
|
||||||
feature = "devtools",
|
|
||||||
debug_assertions,
|
|
||||||
not(target_os = "android"),
|
|
||||||
not(target_os = "ios")
|
|
||||||
))]
|
|
||||||
HotReloadEvent(dioxus_devtools::DevserverMsg),
|
HotReloadEvent(dioxus_devtools::DevserverMsg),
|
||||||
|
|
||||||
/// Create a new window
|
/// Create a new window
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
|
use crate::document::DesktopDocument;
|
||||||
use crate::element::DesktopElement;
|
use crate::element::DesktopElement;
|
||||||
use crate::file_upload::DesktopFileDragEvent;
|
use crate::file_upload::DesktopFileDragEvent;
|
||||||
use crate::menubar::DioxusMenu;
|
use crate::menubar::DioxusMenu;
|
||||||
use crate::{
|
use crate::{
|
||||||
app::SharedContext, assets::AssetHandlerRegistry, document::DesktopDocument, edits::WryQueue,
|
app::SharedContext, assets::AssetHandlerRegistry, edits::WryQueue,
|
||||||
file_upload::NativeFileHover, ipc::UserWindowEvent, protocol, waker::tao_waker, Config,
|
file_upload::NativeFileHover, ipc::UserWindowEvent, protocol, waker::tao_waker, Config,
|
||||||
DesktopContext, DesktopService,
|
DesktopContext, DesktopService,
|
||||||
};
|
};
|
||||||
use dioxus_core::{Runtime, ScopeId, VirtualDom};
|
use dioxus_core::{Runtime, ScopeId, VirtualDom};
|
||||||
use dioxus_hooks::to_owned;
|
use dioxus_hooks::to_owned;
|
||||||
use dioxus_html::document::Document;
|
use dioxus_html::{
|
||||||
use dioxus_html::native_bind::NativeFileEngine;
|
native_bind::NativeFileEngine, prelude::Document, HasFileData, HtmlEvent, PlatformEventData,
|
||||||
use dioxus_html::{HasFileData, HtmlEvent, PlatformEventData};
|
};
|
||||||
use dioxus_interpreter_js::SynchronousEventResponse;
|
|
||||||
use futures_util::{pin_mut, FutureExt};
|
use futures_util::{pin_mut, FutureExt};
|
||||||
use std::cell::OnceCell;
|
use std::cell::OnceCell;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -90,7 +90,7 @@ impl WebviewEdits {
|
|||||||
// check for a mounted event placeholder and replace it with a desktop specific element
|
// check for a mounted event placeholder and replace it with a desktop specific element
|
||||||
let as_any = match data {
|
let as_any = match data {
|
||||||
dioxus_html::EventData::Mounted => {
|
dioxus_html::EventData::Mounted => {
|
||||||
let element = DesktopElement::new(element, desktop_context.clone(), query);
|
let element = DesktopElement::new(element, desktop_context.clone(), query.clone());
|
||||||
Rc::new(PlatformEventData::new(Box::new(element)))
|
Rc::new(PlatformEventData::new(Box::new(element)))
|
||||||
}
|
}
|
||||||
dioxus_html::EventData::Drag(ref drag) => {
|
dioxus_html::EventData::Drag(ref drag) => {
|
||||||
@@ -147,9 +147,15 @@ impl WebviewInstance {
|
|||||||
) -> WebviewInstance {
|
) -> WebviewInstance {
|
||||||
let mut window = cfg.window.clone();
|
let mut window = cfg.window.clone();
|
||||||
|
|
||||||
// tao makes small windows for some reason, make them bigger
|
// tao makes small windows for some reason, make them bigger on desktop
|
||||||
if cfg.window.window.inner_size.is_none() {
|
//
|
||||||
window = window.with_inner_size(tao::dpi::LogicalSize::new(800.0, 600.0));
|
// on mobile, we want them to be `None` so tao makes them the size of the screen. Otherwise we
|
||||||
|
// get a window that is not the size of the screen and weird black bars.
|
||||||
|
#[cfg(not(any(target_os = "ios", target_os = "android")))]
|
||||||
|
{
|
||||||
|
if cfg.window.window.inner_size.is_none() {
|
||||||
|
window = window.with_inner_size(tao::dpi::LogicalSize::new(800.0, 600.0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We assume that if the icon is None in cfg, then the user just didnt set it
|
// We assume that if the icon is None in cfg, then the user just didnt set it
|
||||||
@@ -391,3 +397,18 @@ impl WebviewInstance {
|
|||||||
.evaluate_script("window.interpreter.kickAllStylesheetsOnPage()");
|
.evaluate_script("window.interpreter.kickAllStylesheetsOnPage()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A synchronous response to a browser event which may prevent the default browser's action
|
||||||
|
#[derive(serde::Serialize, Default)]
|
||||||
|
pub struct SynchronousEventResponse {
|
||||||
|
#[serde(rename = "preventDefault")]
|
||||||
|
prevent_default: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SynchronousEventResponse {
|
||||||
|
/// Create a new SynchronousEventResponse
|
||||||
|
#[allow(unused)]
|
||||||
|
pub fn new(prevent_default: bool) -> Self {
|
||||||
|
Self { prevent_default }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -192,23 +192,3 @@ impl WriteMutations for MutationState {
|
|||||||
self.channel.push_root(id.0 as _);
|
self.channel.push_root(id.0 as _);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A synchronous response to a browser event which may prevent the default browser's action
|
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
|
|
||||||
#[derive(Default)]
|
|
||||||
pub struct SynchronousEventResponse {
|
|
||||||
#[cfg(feature = "serialize")]
|
|
||||||
#[serde(rename = "preventDefault")]
|
|
||||||
prevent_default: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SynchronousEventResponse {
|
|
||||||
/// Create a new SynchronousEventResponse
|
|
||||||
#[allow(unused)]
|
|
||||||
pub fn new(prevent_default: bool) -> Self {
|
|
||||||
Self {
|
|
||||||
#[cfg(feature = "serialize")]
|
|
||||||
prevent_default,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user