bump iced v0.7

should_exit method is replaced for the
iced:🪟:close() command at the main.rs
level. iced_native::Event message handling
is not anymore required in the sub states of
the iced application.
This commit is contained in:
edouard 2023-01-16 18:51:53 +01:00
parent f3b9a26b95
commit b8f1704f38
11 changed files with 64 additions and 116 deletions

42
gui/Cargo.lock generated
View File

@ -1329,9 +1329,9 @@ dependencies = [
[[package]]
name = "iced"
version = "0.6.0"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47627e5bb0bcc0522aca5e11cf8187e34f072ab6da4e7c2fd3f23ed508697e9f"
checksum = "df71e87f8211b57a439d0764131d2c421a9195036dd4b6608033b05f2f16c196"
dependencies = [
"iced_core",
"iced_futures",
@ -1346,13 +1346,13 @@ dependencies = [
[[package]]
name = "iced_core"
version = "0.6.2"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "232c723eecb8aef2fd69f7c618c17306ff10bdede19e44d6d9dc77f372966e80"
checksum = "6ade666613eb8b621971a59cfae9e11ec051f32afc5ed4d8e8915d5abfaf2cee"
dependencies = [
"bitflags",
"instant",
"palette",
"wasm-timer",
]
[[package]]
@ -1370,9 +1370,9 @@ dependencies = [
[[package]]
name = "iced_glow"
version = "0.5.1"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ef5090a796940dcc454f9b37f98aea9619f8e8537bb2d057d7f7dedd92d3a69"
checksum = "95755f62fec2ec2c8f8bc2c0be5072b1d0dfed8db250686059ddcce5da530acf"
dependencies = [
"bytemuck",
"euclid",
@ -1386,9 +1386,9 @@ dependencies = [
[[package]]
name = "iced_glutin"
version = "0.5.0"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39801c9d3d1ed97dc6f40e2936b5e6b8cbf749db1fbc32b55a63f9ead038e120"
checksum = "ccd8dd58586541b300b280b6fe8605add7a90283dfb8e622adc96cc545f5fa61"
dependencies = [
"glutin",
"iced_graphics",
@ -1399,9 +1399,9 @@ dependencies = [
[[package]]
name = "iced_graphics"
version = "0.5.0"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef7125f24a46fc5aa4c3c4d900c6edee79cbbe1b7ef4747bd923fd1469190bc"
checksum = "54177b85fdae36a8a1a4f052a5c65c5006565dc27f1feead13eeeed10fd0975a"
dependencies = [
"bitflags",
"bytemuck",
@ -1420,9 +1420,9 @@ dependencies = [
[[package]]
name = "iced_lazy"
version = "0.3.0"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca5123ef2db0af871a34bc63dee221987560709052e5cf1ff96b72e361d1ce0f"
checksum = "79aeddab3c88af853769fc025e4f4cf76fa5980e31572791d14858575da4a675"
dependencies = [
"iced_native",
"ouroboros",
@ -1430,9 +1430,9 @@ dependencies = [
[[package]]
name = "iced_native"
version = "0.7.0"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5748f6d4fa3a8e31ba642cf2e159100f68c2fbc3b2973db8d8035526164d6685"
checksum = "79d57c8e8672e90c55d4f9f55511b03e5a74af9d296be9693e9c07cd9eed4563"
dependencies = [
"iced_core",
"iced_futures",
@ -1444,9 +1444,9 @@ dependencies = [
[[package]]
name = "iced_style"
version = "0.5.1"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2ffb763e34a898a1f597640718cf9308efa057a054282b7bfa627a574554f5b"
checksum = "b992f5e1828c61af3661fc0e7bf141ef5284007a41fa6667c5e79d047a03daf4"
dependencies = [
"iced_core",
"once_cell",
@ -1455,9 +1455,9 @@ dependencies = [
[[package]]
name = "iced_wgpu"
version = "0.7.0"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb12ce0339a85a62fdb1ea3ce5b4fda1b5b2ab447b39c3982c30f697cc9d6c16"
checksum = "c4bb296363d1b18d4f57e1c69bb19591405e61d47764e43078bba31c6689fca5"
dependencies = [
"bitflags",
"bytemuck",
@ -1476,9 +1476,9 @@ dependencies = [
[[package]]
name = "iced_winit"
version = "0.6.0"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "595311dc80f3b0e6ac83573b2bb0efeb3be3693c205a3a8195f7709199f7e276"
checksum = "d528f882781c5594cb3d2416fe18787b4364e0cdd39f03d077ccc0becac1f9bd"
dependencies = [
"iced_futures",
"iced_graphics",

View File

@ -19,9 +19,9 @@ liana = { git = "https://github.com/revault/liana", branch = "master", default-f
backtrace = "0.3"
base64 = "0.13"
iced = { version = "0.6", default-features= false, features = ["tokio", "glow", "svg", "qr_code"] }
iced_native = "0.7"
iced_lazy = { version = "0.3"}
iced = { version = "0.7", default-features= false, features = ["tokio", "glow", "svg", "qr_code"] }
iced_native = "0.8"
iced_lazy = { version = "0.4"}
tokio = {version = "1.21.0", features = ["signal"]}
serde = { version = "1.0", features = ["derive"] }

View File

@ -15,7 +15,6 @@ use crate::{
#[derive(Debug)]
pub enum Message {
Tick,
Event(iced_native::Event),
View(view::Message),
LoadDaemonConfig(Box<DaemonConfig>),
DaemonConfigLoaded(Result<(), Error>),

View File

@ -13,7 +13,6 @@ use std::sync::Arc;
use std::time::Duration;
use iced::{clipboard, time, Command, Element, Subscription};
use iced_native::{window, Event};
pub use liana::config::Config as DaemonConfig;
@ -28,7 +27,6 @@ use crate::{
};
pub struct App {
should_exit: bool,
state: Box<dyn State>,
cache: Cache,
config: Config,
@ -45,7 +43,6 @@ impl App {
let cmd = state.load(daemon.clone());
(
Self {
should_exit: false,
state,
cache,
config,
@ -92,16 +89,11 @@ impl App {
pub fn subscription(&self) -> Subscription<Message> {
Subscription::batch(vec![
iced_native::subscription::events().map(Message::Event),
time::every(Duration::from_secs(5)).map(|_| Message::Tick),
self.state.subscription(),
])
}
pub fn should_exit(&self) -> bool {
self.should_exit
}
pub fn stop(&mut self) {
log::info!("Close requested");
if !self.daemon.is_external() {
@ -109,10 +101,7 @@ impl App {
if let Some(d) = Arc::get_mut(&mut self.daemon) {
d.stop().expect("Daemon is internal");
log::info!("Internal daemon stopped");
self.should_exit = true;
}
} else {
self.should_exit = true;
}
}
@ -150,10 +139,6 @@ impl App {
}
Message::View(view::Message::Menu(menu)) => self.load_state(&menu),
Message::View(view::Message::Clipboard(text)) => clipboard::write(text),
Message::Event(Event::Window(window::Event::CloseRequested)) => {
self.stop();
Command::none()
}
_ => self.state.update(self.daemon.clone(), &self.cache, message),
}
}

View File

@ -9,7 +9,6 @@ pub enum Message {
CreateWallet,
ImportWallet,
BackupDone(bool),
Event(iced_native::Event),
Exit(PathBuf),
Clibpboard(String),
Next,

View File

@ -5,7 +5,6 @@ mod step;
mod view;
use iced::{clipboard, Command, Element, Subscription};
use iced_native::{window, Event};
use liana::miniscript::bitcoin;
use std::convert::TryInto;
@ -23,7 +22,6 @@ use step::{
};
pub struct Installer {
should_exit: bool,
current: usize,
steps: Vec<Box<dyn Step>>,
@ -44,7 +42,6 @@ impl Installer {
) -> (Installer, Command<Message>) {
(
Installer {
should_exit: false,
current: 0,
steps: vec![Welcome::default().into()],
context: Context::new(network, destination_path),
@ -54,16 +51,10 @@ impl Installer {
}
pub fn subscription(&self) -> Subscription<Message> {
iced_native::subscription::events().map(Message::Event)
Subscription::none()
}
pub fn should_exit(&self) -> bool {
self.should_exit
}
pub fn stop(&mut self) {
self.should_exit = true;
}
pub fn stop(&mut self) {}
fn next(&mut self) -> Command<Message> {
let current_step = self
@ -144,10 +135,6 @@ impl Installer {
.update(Message::Installed(Err(e)));
Command::none()
}
Message::Event(Event::Window(window::Event::CloseRequested)) => {
self.stop();
Command::none()
}
_ => self
.steps
.get_mut(self.current)

View File

@ -433,8 +433,8 @@ pub fn backup_descriptor<'a>(
.max_width(1000),
))
.push(Checkbox::new(
done,
"I have backed up my descriptor",
done,
Message::BackupDone,
))
.push(if done {

View File

@ -13,7 +13,6 @@ use crate::ui::{
};
pub struct Launcher {
should_exit: bool,
choices: Vec<Network>,
pub datadir_path: PathBuf,
}
@ -34,20 +33,13 @@ impl Launcher {
Self {
datadir_path,
choices,
should_exit: false,
}
}
pub fn stop(&mut self) {
self.should_exit = true;
}
pub fn should_exit(&self) -> bool {
self.should_exit
}
pub fn stop(&mut self) {}
pub fn subscription(&self) -> Subscription<Message> {
iced_native::subscription::events().map(Message::Event)
Subscription::none()
}
pub fn view(&self) -> Element<Message> {
@ -115,7 +107,6 @@ impl Launcher {
#[derive(Debug, Clone)]
pub enum Message {
Event(iced_native::Event),
Install,
Run(Network),
}

View File

@ -8,7 +8,6 @@ use iced::{
Element,
};
use iced::{Alignment, Command, Length, Subscription};
use iced_native::{window, Event};
use log::{debug, info};
use liana::{
@ -35,7 +34,6 @@ pub struct Loader {
pub daemon_started: bool,
daemon_config: Config,
should_exit: bool,
step: Step,
}
@ -52,7 +50,6 @@ pub enum Step {
#[derive(Debug)]
pub enum Message {
View(ViewMessage),
Event(iced_native::Event),
Syncing(Result<GetInfoResult, DaemonError>),
Synced(
GetInfoResult,
@ -82,7 +79,6 @@ impl Loader {
daemon_config: daemon_config.clone(),
gui_config,
step: Step::Connecting,
should_exit: false,
daemon_started: false,
},
Command::perform(connect(path, daemon_config), Message::Loaded),
@ -181,13 +177,9 @@ impl Loader {
if let Some(d) = Arc::get_mut(daemon) {
d.stop().expect("Daemon is internal");
log::info!("Internal daemon stopped");
self.should_exit = true;
} else {
}
} else {
self.should_exit = true;
}
} else {
self.should_exit = true;
}
}
@ -209,20 +201,12 @@ impl Loader {
self.daemon_started = false;
Command::none()
}
Message::Event(Event::Window(window::Event::CloseRequested)) => {
self.stop();
Command::none()
}
_ => Command::none(),
}
}
pub fn subscription(&self) -> Subscription<Message> {
iced_native::subscription::events().map(Message::Event)
}
pub fn should_exit(&self) -> bool {
self.should_exit
Subscription::none()
}
pub fn view(&self) -> Element<Message> {

View File

@ -84,6 +84,7 @@ pub enum Message {
Install(Box<installer::Message>),
Load(Box<loader::Message>),
Run(Box<app::Message>),
Event(iced_native::Event),
}
async fn ctrl_c() -> Result<(), ()> {
@ -149,14 +150,20 @@ impl Application for GUI {
fn update(&mut self, message: Self::Message) -> Command<Self::Message> {
match (&mut self.state, message) {
(_, Message::CtrlC) => {
(_, Message::CtrlC)
| (
_,
Message::Event(iced_native::Event::Window(
iced_native::window::Event::CloseRequested,
)),
) => {
match &mut self.state {
State::Loader(s) => s.stop(),
State::Launcher(s) => s.stop(),
State::Installer(s) => s.stop(),
State::App(s) => s.stop(),
}
Command::none()
};
iced::window::close()
}
(State::Launcher(l), Message::Launch(msg)) => match *msg {
launcher::Message::Install => {
@ -165,12 +172,6 @@ impl Application for GUI {
self.state = State::Installer(Box::new(install));
command.map(|msg| Message::Install(Box::new(msg)))
}
launcher::Message::Event(iced_native::Event::Window(
iced_native::window::Event::CloseRequested,
)) => {
l.stop();
Command::none()
}
launcher::Message::Run(network) => {
let mut path = l.datadir_path.clone();
path.push(network.to_string());
@ -183,7 +184,6 @@ impl Application for GUI {
self.state = State::Loader(Box::new(loader));
command.map(|msg| Message::Load(Box::new(msg)))
}
_ => Command::none(),
},
(State::Installer(i), Message::Install(msg)) => {
if let installer::Message::Exit(path) = *msg {
@ -226,22 +226,16 @@ impl Application for GUI {
}
}
fn should_exit(&self) -> bool {
match &self.state {
State::Launcher(v) => v.should_exit(),
State::Installer(v) => v.should_exit(),
State::Loader(v) => v.should_exit(),
State::App(v) => v.should_exit(),
}
}
fn subscription(&self) -> Subscription<Self::Message> {
match &self.state {
State::Installer(v) => v.subscription().map(|msg| Message::Install(Box::new(msg))),
State::Loader(v) => v.subscription().map(|msg| Message::Load(Box::new(msg))),
State::App(v) => v.subscription().map(|msg| Message::Run(Box::new(msg))),
State::Launcher(v) => v.subscription().map(|msg| Message::Launch(Box::new(msg))),
}
Subscription::batch(vec![
match &self.state {
State::Installer(v) => v.subscription().map(|msg| Message::Install(Box::new(msg))),
State::Loader(v) => v.subscription().map(|msg| Message::Load(Box::new(msg))),
State::App(v) => v.subscription().map(|msg| Message::Run(Box::new(msg))),
State::Launcher(v) => v.subscription().map(|msg| Message::Launch(Box::new(msg))),
},
iced_native::subscription::events().map(Self::Message::Event),
])
}
fn view(&self) -> Element<Self::Message> {

View File

@ -138,11 +138,12 @@ where
&self,
state: &mut Tree,
layout: Layout<'_>,
renderer: &Renderer,
operation: &mut dyn widget::Operation<Message>,
) {
self.base
.as_widget()
.operate(&mut state.children[0], layout, operation);
.operate(&mut state.children[0], layout, renderer, operation);
}
}
@ -236,10 +237,18 @@ where
);
}
fn operate(&mut self, layout: Layout<'_>, operation: &mut dyn widget::Operation<Message>) {
self.content
.as_widget()
.operate(self.tree, layout.children().next().unwrap(), operation);
fn operate(
&mut self,
layout: Layout<'_>,
renderer: &Renderer,
operation: &mut dyn widget::Operation<Message>,
) {
self.content.as_widget().operate(
self.tree,
layout.children().next().unwrap(),
renderer,
operation,
);
}
fn mouse_interaction(