We need a struct to implement Sandbox, and call its run method from main.
All widgets should be placed inside the view method.
use iced::{
widget::{
column, text
},
Element
};
fn main() -> iced::Result {
iced::application("My First App", MyApp::update, MyApp::view)
.run()
}
struct MyApp {
_state: String,
}
impl Default for MyApp {
fn default() -> Self {
MyApp::new()
}
}
#[derive(Debug, Clone)]
enum Message {
_Message1,
}
impl MyApp {
fn new() -> Self {
Self {
_state: String::new(),
}
}
fn update(&mut self, _message: Message) {
todo!()
}
fn view(&self) -> Element<Message> {
column!(
text("Hello World!".to_string()),
).into()
}
}➡️ Next: Explanation of Sandbox Trait
📘 Back: Table of contents
