Add some logging and debug
This commit is contained in:
1 parent
ea3b199eb2
commit
10a3b228f6
3 files changed
+49
-17
No files matched your search
@@ -0,0 +1,12 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Dioxus app</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||||
|
<!-- CUSTOM HEAD -->
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="main"></div>
|
||||||
|
<!-- MODULE LOADER -->
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,15 +1,8 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use dioxus::prelude::*;
|
||||||
|
use dioxus_desktop::Config;
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
use wry::android_binding;
|
use wry::android_binding;
|
||||||
use wry::{
|
|
||||||
application::{
|
|
||||||
event::{Event, StartCause, WindowEvent},
|
|
||||||
event_loop::{ControlFlow, EventLoop, EventLoopWindowTarget},
|
|
||||||
window::WindowBuilder,
|
|
||||||
},
|
|
||||||
http::Response,
|
|
||||||
webview::{WebView, WebViewBuilder},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
fn init_logging() {
|
fn init_logging() {
|
||||||
@@ -54,13 +47,40 @@ pub extern "C" fn start_app() {
|
|||||||
pub fn main() -> Result<()> {
|
pub fn main() -> Result<()> {
|
||||||
init_logging();
|
init_logging();
|
||||||
|
|
||||||
use dioxus::prelude::*;
|
// Right now we're going through dioxus-desktop but we'd like to go through dioxus-mobile
|
||||||
|
// That will seed the index.html with some fixes that prevent the page from scrolling/zooming etc
|
||||||
dioxus_desktop::launch(|cx| {
|
dioxus_desktop::launch_cfg(
|
||||||
cx.render(rsx! {
|
app,
|
||||||
"hello world!"
|
// Note that we have to disable the viewport goofiness of the browser.
|
||||||
})
|
// Dioxus_mobile should do this for us
|
||||||
});
|
Config::default().with_custom_index(include_str!("index.html").to_string()),
|
||||||
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app(cx: Scope) -> Element {
|
||||||
|
let items = cx.use_hook(|| vec![1, 2, 3]);
|
||||||
|
|
||||||
|
log::debug!("Hello from the app");
|
||||||
|
|
||||||
|
render! {
|
||||||
|
div {
|
||||||
|
h1 { "Hello, Mobile"}
|
||||||
|
div { margin_left: "auto", margin_right: "auto", width: "200px", padding: "10px", border: "1px solid black",
|
||||||
|
button {
|
||||||
|
onclick: move|_| {
|
||||||
|
println!("Clicked!");
|
||||||
|
items.push(items.len());
|
||||||
|
cx.needs_update_any(ScopeId(0));
|
||||||
|
println!("Requested update");
|
||||||
|
},
|
||||||
|
"Add item"
|
||||||
|
}
|
||||||
|
for item in items.iter() {
|
||||||
|
div { "- {item}" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,7 +22,7 @@ pub(crate) struct ElementRef {
|
|||||||
pub template: Option<NonNull<VNode<'static>>>,
|
pub template: Option<NonNull<VNode<'static>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub enum ElementPath {
|
pub enum ElementPath {
|
||||||
Deep(&'static [u8]),
|
Deep(&'static [u8]),
|
||||||
Root(usize),
|
Root(usize),
|
||||||
|
|||||||
Reference in new issue
Block a user