pub fn application<State, Message, Theme, Renderer>(
title: impl Title<State>,
update: impl Update<State, Message>,
view: impl for<'a> View<'a, State, Message, Theme, Renderer>,
) -> Application<impl Program<State = State, Message = Message, Theme = Theme>>where
State: 'static,
Message: Send + Debug + 'static,
Theme: Default + DefaultStyle,
Renderer: Renderer,
Expand description
Creates an iced Application
given its title, update, and view logic.
ยงExample
use iced::widget::{button, column, text, Column};
pub fn main() -> iced::Result {
iced::application("A counter", update, view).run()
}
#[derive(Debug, Clone)]
enum Message {
Increment,
}
fn update(value: &mut u64, message: Message) {
match message {
Message::Increment => *value += 1,
}
}
fn view(value: &u64) -> Column<Message> {
column![
text(value),
button("+").on_press(Message::Increment),
]
}