Fix more examples to work with dioxus-native (#5179)
* Enable native for hotdog, file-explorer, and bluetooth-scanner examples Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix crash in calculator example Signed-off-by: Nico Burns <nico@nicoburns.com> * Add config macro for native * Add Config struct to dioxus-native * Re-export dioxus-native as dioxus::native * Fix calculator example to work with dioxus-native * Fix calculator_mutable example to work with dioxus-native --------- Signed-off-by: Nico Burns <nico@nicoburns.com>
This commit is contained in:
1 parent
8aefb2a1e2
commit
35e289fe28
13 files changed
+93
-18
No files matched your search
@@ -8,7 +8,12 @@ publish = false
|
||||
|
||||
[dependencies]
|
||||
tokio = { workspace = true, features = ["full"] }
|
||||
dioxus = { workspace = true, features = ["desktop"] }
|
||||
dioxus = { workspace = true }
|
||||
futures-channel = { workspace = true }
|
||||
futures = { workspace = true }
|
||||
btleplug = "0.11.8"
|
||||
|
||||
[features]
|
||||
default = ["desktop"]
|
||||
desktop = ["dioxus/desktop"]
|
||||
native = ["dioxus/native"]
|
||||
@@ -12,15 +12,24 @@ use dioxus::events::*;
|
||||
use dioxus::html::input_data::keyboard_types::Key;
|
||||
use dioxus::prelude::*;
|
||||
|
||||
const TITLE: &str = "Calculator";
|
||||
const STYLE: Asset = asset!("/examples/assets/calculator.css");
|
||||
|
||||
fn main() {
|
||||
dioxus::LaunchBuilder::desktop()
|
||||
dioxus::LaunchBuilder::new()
|
||||
.with_cfg(desktop!({
|
||||
use dioxus::desktop::{Config, LogicalSize, WindowBuilder};
|
||||
Config::new().with_window(
|
||||
WindowBuilder::default()
|
||||
.with_title("Calculator")
|
||||
.with_title(TITLE)
|
||||
.with_inner_size(LogicalSize::new(300.0, 525.0)),
|
||||
)
|
||||
}))
|
||||
.with_cfg(native!({
|
||||
use dioxus::native::{Config, LogicalSize, WindowAttributes};
|
||||
Config::new().with_window_attributes(
|
||||
WindowAttributes::default()
|
||||
.with_title(TITLE)
|
||||
.with_inner_size(LogicalSize::new(300.0, 525.0)),
|
||||
)
|
||||
}))
|
||||
@@ -146,7 +155,7 @@ fn calc_val(val: &str) -> f64 {
|
||||
let mut temp_value;
|
||||
let mut fin_index = 0;
|
||||
|
||||
if &val[0..1] == "-" {
|
||||
if val.len() > 1 && &val[0..1] == "-" {
|
||||
temp_value = String::from("-");
|
||||
fin_index = 1;
|
||||
start_index += 1;
|
||||
|
||||
@@ -6,22 +6,29 @@
|
||||
//! Generally, you'll want to split your state into several signals if you have a large application, but for small
|
||||
//! applications, or focused components, this is a great way to manage state.
|
||||
|
||||
use dioxus::desktop::tao::dpi::LogicalSize;
|
||||
use dioxus::desktop::{Config, WindowBuilder};
|
||||
use dioxus::html::MouseEvent;
|
||||
use dioxus::html::input_data::keyboard_types::Key;
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
dioxus::LaunchBuilder::desktop()
|
||||
.with_cfg(
|
||||
dioxus::LaunchBuilder::new()
|
||||
.with_cfg(desktop! {{
|
||||
use dioxus::desktop::{Config, LogicalSize, WindowBuilder};
|
||||
Config::new().with_window(
|
||||
WindowBuilder::new()
|
||||
.with_title("Calculator Demo")
|
||||
.with_resizable(false)
|
||||
.with_inner_size(LogicalSize::new(320.0, 530.0)),
|
||||
),
|
||||
)
|
||||
)
|
||||
}})
|
||||
.with_cfg(native! {{
|
||||
use dioxus::native::{Config, LogicalSize, WindowAttributes};
|
||||
Config::new().with_window_attributes(
|
||||
WindowAttributes::default()
|
||||
.with_title("Calculator Demo")
|
||||
.with_inner_size(LogicalSize::new(300.0, 525.0)),
|
||||
)
|
||||
}})
|
||||
.launch(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,5 +7,10 @@ publish = false
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
dioxus = { workspace = true, features = ["desktop"] }
|
||||
dioxus = { workspace = true }
|
||||
open = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = ["desktop"]
|
||||
desktop = ["dioxus/desktop"]
|
||||
native = ["dioxus/native"]
|
||||
@@ -17,5 +17,6 @@ anyhow = { workspace = true }
|
||||
default = ["web", "server"]
|
||||
web = ["dioxus/web"]
|
||||
desktop = ["dioxus/desktop"]
|
||||
native = ["dioxus/native"]
|
||||
mobile = ["dioxus/mobile"]
|
||||
server = ["dioxus/server", "dep:rusqlite"]
|
||||
Reference in new issue
Block a user