Files
dioxus/packages/native/src/config.rs
T
Nico Burns 35e289fe28 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>
2026-01-17 00:32:45 +00:00

33 lines
840 B
Rust

use dioxus_core::LaunchConfig;
use winit::window::WindowAttributes;
/// The configuration for the desktop application.
pub struct Config {
pub(crate) window_attributes: WindowAttributes,
}
impl LaunchConfig for Config {}
impl Default for Config {
fn default() -> Self {
Self {
window_attributes: WindowAttributes::default().with_title(
dioxus_cli_config::app_title().unwrap_or_else(|| "Dioxus App".to_string()),
),
}
}
}
impl Config {
pub fn new() -> Self {
Self::default()
}
/// Set the configuration for the window.
pub fn with_window_attributes(mut self, attrs: WindowAttributes) -> Self {
// We need to do a swap because the window builder only takes itself as muy self
self.window_attributes = attrs;
self
}
}