Simplify the QueryInformation Action
This commit is contained in:
parent
6e167675d6
commit
5eefa5d4ea
7 changed files with 15 additions and 35 deletions
|
|
@ -6,5 +6,5 @@ edition = "2021"
|
|||
publish = false
|
||||
|
||||
[dependencies]
|
||||
iced = { path = "../..", features = ["sysinfo"] }
|
||||
iced = { path = "../.." }
|
||||
bytesize = { version = "1.1.0" }
|
||||
|
|
@ -15,12 +15,11 @@ enum Example {
|
|||
information: system::Information,
|
||||
refresh_button: button::State,
|
||||
},
|
||||
Unsupported,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
enum Message {
|
||||
InformationReceived(Option<system::Information>),
|
||||
InformationReceived(system::Information),
|
||||
Refresh,
|
||||
}
|
||||
|
||||
|
|
@ -46,15 +45,11 @@ impl Application for Example {
|
|||
return system::fetch_information(Message::InformationReceived);
|
||||
}
|
||||
Message::InformationReceived(information) => {
|
||||
if let Some(information) = information {
|
||||
let refresh_button = button::State::new();
|
||||
*self = Self::Loaded {
|
||||
information,
|
||||
refresh_button,
|
||||
};
|
||||
} else {
|
||||
*self = Self::Unsupported;
|
||||
}
|
||||
let refresh_button = button::State::new();
|
||||
*self = Self::Loaded {
|
||||
information,
|
||||
refresh_button,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -156,7 +151,6 @@ impl Application for Example {
|
|||
.spacing(10)
|
||||
.into()
|
||||
}
|
||||
Example::Unsupported => Text::new("Unsupported!").size(20).into(),
|
||||
};
|
||||
|
||||
Container::new(content)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue