mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 06:34:20 +00:00
Fix android/ios desktop builds, move type from native over
This commit is contained in:
parent
fd9229a768
commit
5c6b72627b
3 changed files with 31 additions and 35 deletions
|
@ -18,12 +18,7 @@ pub enum UserWindowEvent {
|
|||
Ipc { id: WindowId, msg: IpcMessage },
|
||||
|
||||
/// Handle a hotreload event, basically telling us to update our templates
|
||||
#[cfg(all(
|
||||
feature = "devtools",
|
||||
debug_assertions,
|
||||
not(target_os = "android"),
|
||||
not(target_os = "ios")
|
||||
))]
|
||||
#[cfg(all(feature = "devtools", debug_assertions))]
|
||||
HotReloadEvent(dioxus_devtools::DevserverMsg),
|
||||
|
||||
/// Create a new window
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
use crate::document::DesktopDocument;
|
||||
use crate::element::DesktopElement;
|
||||
use crate::file_upload::DesktopFileDragEvent;
|
||||
use crate::menubar::DioxusMenu;
|
||||
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,
|
||||
DesktopContext, DesktopService,
|
||||
};
|
||||
use dioxus_core::{Runtime, ScopeId, VirtualDom};
|
||||
use dioxus_hooks::to_owned;
|
||||
use dioxus_html::document::Document;
|
||||
use dioxus_html::native_bind::NativeFileEngine;
|
||||
use dioxus_html::{HasFileData, HtmlEvent, PlatformEventData};
|
||||
use dioxus_interpreter_js::SynchronousEventResponse;
|
||||
use dioxus_html::{
|
||||
native_bind::NativeFileEngine, prelude::Document, HasFileData, HtmlEvent, PlatformEventData,
|
||||
};
|
||||
use futures_util::{pin_mut, FutureExt};
|
||||
use std::cell::OnceCell;
|
||||
use std::sync::Arc;
|
||||
|
@ -90,7 +90,7 @@ impl WebviewEdits {
|
|||
// check for a mounted event placeholder and replace it with a desktop specific element
|
||||
let as_any = match data {
|
||||
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)))
|
||||
}
|
||||
dioxus_html::EventData::Drag(ref drag) => {
|
||||
|
@ -147,10 +147,16 @@ impl WebviewInstance {
|
|||
) -> WebviewInstance {
|
||||
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
|
||||
//
|
||||
// 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
|
||||
if cfg.window.window.window_icon.is_none() {
|
||||
|
@ -391,3 +397,18 @@ impl WebviewInstance {
|
|||
.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 _);
|
||||
}
|
||||
}
|
||||
|
||||
/// 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue