diff options
author | 2024-03-16 15:53:03 +0100 | |
---|---|---|
committer | 2024-03-16 15:54:37 +0100 | |
commit | 93ae790da14544667176ecdbdd6a4eaaa98a248a (patch) | |
tree | 4af03301f9a16049d29be305c48b4054a3afee99 /examples/system_information/src/main.rs | |
parent | 5a986897d22f6d79a7a1fbaa4f3d1aaa1f9ca3bb (diff) | |
download | iced-93ae790da14544667176ecdbdd6a4eaaa98a248a.tar.gz iced-93ae790da14544667176ecdbdd6a4eaaa98a248a.tar.bz2 iced-93ae790da14544667176ecdbdd6a4eaaa98a248a.zip |
Implement `Program::load` to specify startup `Command`
Diffstat (limited to 'examples/system_information/src/main.rs')
-rw-r--r-- | examples/system_information/src/main.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/examples/system_information/src/main.rs b/examples/system_information/src/main.rs index 079c2c46..75a4d8d6 100644 --- a/examples/system_information/src/main.rs +++ b/examples/system_information/src/main.rs @@ -1,18 +1,23 @@ use iced::widget::{button, column, container, text}; use iced::{system, Command, Element, Length}; -use bytesize::ByteSize; - pub fn main() -> iced::Result { - iced::application(Example::new, Example::update, Example::view) - .title("System Information - Iced") - .run() + iced::application( + "System Information - Iced", + Example::update, + Example::view, + ) + .run() } +#[derive(Default)] #[allow(clippy::large_enum_variant)] enum Example { + #[default] Loading, - Loaded { information: system::Information }, + Loaded { + information: system::Information, + }, } #[derive(Clone, Debug)] @@ -23,13 +28,6 @@ enum Message { } impl Example { - fn new() -> (Self, Command<Message>) { - ( - Self::Loading, - system::fetch_information(Message::InformationReceived), - ) - } - fn update(&mut self, message: Message) -> Command<Message> { match message { Message::Refresh => { @@ -46,6 +44,8 @@ impl Example { } fn view(&self) -> Element<Message> { + use bytesize::ByteSize; + let content: Element<_> = match self { Example::Loading => text("Loading...").size(40).into(), Example::Loaded { information } => { |