Skip to content

Commit

Permalink
gui: bump iced 0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
edouardparis committed Jan 3, 2024
1 parent 1b315b5 commit 1616a9b
Show file tree
Hide file tree
Showing 11 changed files with 162 additions and 1,331 deletions.
1,358 changes: 100 additions & 1,258 deletions gui/Cargo.lock

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ backtrace = "0.3"
base64 = "0.13"
hex = "0.4.3"

iced = { version = "0.9", default-features= false, features = ["tokio", "glow", "svg", "qr_code", "image"] }
iced_native = "0.10"
iced_lazy = { version = "0.6"}
iced = { version = "0.10", default-features = false, features = ["tokio", "svg", "qr_code", "image", "lazy"] }
iced_runtime = "0.1.1"

tokio = {version = "1.21.0", features = ["signal"]}
serde = { version = "1.0", features = ["derive"] }
Expand All @@ -47,9 +46,6 @@ bitcoin_hashes = "0.12"
reqwest = { version = "0.11", default-features=false, features = ["rustls-tls"] }
rust-ini = "0.19.0"

[patch.crates-io]
iced_futures = { git = "https://github.com/edouardparis/iced", branch = "fix-futures-recipe"}

[target.'cfg(windows)'.dependencies]
zip = { version = "0.6", default-features=false, features = ["bzip2", "deflate"] }

Expand Down
8 changes: 6 additions & 2 deletions gui/src/app/view/psbt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,9 @@ pub fn signatures<'a>(
},
)),
)
.horizontal_scroll(scrollable::Properties::new().width(2).scroller_width(2)),
.direction(scrollable::Direction::Horizontal(
scrollable::Properties::new().width(2).scroller_width(2),
)),
)
.padding(15)
} else {
Expand Down Expand Up @@ -530,7 +532,9 @@ pub fn path_view<'a>(
)
.push(row_signed),
)
.horizontal_scroll(scrollable::Properties::new().width(2).scroller_width(2))
.direction(scrollable::Direction::Horizontal(
scrollable::Properties::new().width(2).scroller_width(2),
))
.into()
}

Expand Down
7 changes: 4 additions & 3 deletions gui/src/app/view/receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ pub fn receive<'a>(
Length::Fixed(10.0),
)),
)
.horizontal_scroll(
.direction(scrollable::Direction::Horizontal(
scrollable::Properties::new()
.scroller_width(5),
),
.width(2)
.scroller_width(2),
)),
)
.width(Length::Fill),
)
Expand Down
4 changes: 2 additions & 2 deletions gui/src/app/view/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,9 @@ pub fn wallet_settings<'a>(
.push(text(descriptor.to_owned()).small())
.push(Space::with_height(Length::Fixed(5.0))),
)
.horizontal_scroll(
.direction(scrollable::Direction::Horizontal(
scrollable::Properties::new().width(5).scroller_width(5),
),
)),
)
.push(
Row::new()
Expand Down
2 changes: 1 addition & 1 deletion gui/src/installer/step/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,7 @@ impl From<BackupDescriptor> for Box<dyn Step> {
#[cfg(test)]
mod tests {
use super::*;
use iced_native::command::Action;
use iced_runtime::command::Action;
use std::sync::{Arc, Mutex};

pub struct Sandbox<S: Step> {
Expand Down
24 changes: 15 additions & 9 deletions gui/src/installer/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ pub fn define_descriptor<'a>(
)
.padding(5),
)
.horizontal_scroll(Properties::new().width(3).scroller_width(3)),
.direction(scrollable::Direction::Horizontal(
Properties::new().width(3).scroller_width(3),
)),
),
))
.spacing(10);
Expand Down Expand Up @@ -349,7 +351,9 @@ pub fn recovery_path_view(
)
.padding(5),
)
.horizontal_scroll(Properties::new().width(3).scroller_width(3)),
.direction(scrollable::Direction::Horizontal(
Properties::new().width(3).scroller_width(3),
)),
),
),
)
Expand Down Expand Up @@ -464,9 +468,9 @@ pub fn signer_xpubs(xpubs: &Vec<String>) -> Element<Message> {
.push(
Container::new(
scrollable(Container::new(text(xpub).small()).padding(10))
.horizontal_scroll(
.direction(scrollable::Direction::Horizontal(
Properties::new().width(5).scroller_width(5),
),
)),
)
.width(Length::Fill),
)
Expand Down Expand Up @@ -537,9 +541,9 @@ pub fn hardware_wallet_xpubs<'a>(
.push(
Container::new(
scrollable(Container::new(text(xpub).small()).padding(10))
.horizontal_scroll(
.direction(scrollable::Direction::Horizontal(
Properties::new().width(5).scroller_width(5),
),
)),
)
.width(Length::Fill),
)
Expand Down Expand Up @@ -1292,7 +1296,9 @@ pub fn defined_descriptor_key<'a>(
.push(text(name).bold())
.push(Space::with_height(Length::Fixed(5.0))),
)
.horizontal_scroll(Properties::new().width(5).scroller_width(5)),
.direction(scrollable::Direction::Horizontal(
Properties::new().width(5).scroller_width(5),
)),
)
.push(image::success_mark_icon().width(Length::Fixed(50.0)))
.push(Space::with_width(Length::Fixed(1.0))),
Expand Down Expand Up @@ -1850,8 +1856,8 @@ fn layout<'a>(

mod threshsold_input {
use iced::alignment::{self, Alignment};
use iced::widget::{component, Component};
use iced::Length;
use iced_lazy::{self, Component};
use liana_ui::{component::text::*, icon, theme, widget::*};

pub struct ThresholdInput<Message> {
Expand Down Expand Up @@ -1938,7 +1944,7 @@ mod threshsold_input {
Message: 'a,
{
fn from(numeric_input: ThresholdInput<Message>) -> Self {
iced_lazy::component(numeric_input)
component(numeric_input)
}
}
}
3 changes: 2 additions & 1 deletion gui/src/launcher.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::path::PathBuf;

use iced::{
alignment::Horizontal,
widget::{tooltip, Space},
Alignment, Command, Length, Subscription,
};
Expand Down Expand Up @@ -330,7 +331,7 @@ impl DeleteWalletModal {
.push(icon::circle_check_icon().style(color::GREEN))
.push(text("Wallet successfully deleted").style(color::GREEN))
})
.align_x(iced_native::alignment::Horizontal::Center)
.align_x(Horizontal::Center)
.width(Length::Fill),
),
)
Expand Down
75 changes: 28 additions & 47 deletions gui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,18 @@ enum State {
#[derive(Debug)]
pub enum Message {
CtrlC,
FontLoaded(Result<(), iced::font::Error>),
Launch(Box<launcher::Message>),
Install(Box<installer::Message>),
Load(Box<loader::Message>),
Run(Box<app::Message>),
Event(iced_native::Event),
Event(iced::Event),
}

impl From<Result<(), iced::font::Error>> for Message {
fn from(value: Result<(), iced::font::Error>) -> Self {
Self::FontLoaded(value)
}
}

async fn ctrl_c() -> Result<(), ()> {
Expand All @@ -101,17 +108,12 @@ impl Application for GUI {

fn new((config, log_level): (Config, Option<LevelFilter>)) -> (GUI, Command<Self::Message>) {
let logger = Logger::setup(log_level.unwrap_or(LevelFilter::INFO));
match config {
let mut cmds = font::loads();
cmds.push(Command::perform(ctrl_c(), |_| Message::CtrlC));
let state = match config {
Config::Launcher(datadir_path) => {
let launcher = Launcher::new(datadir_path);
(
Self {
state: State::Launcher(Box::new(launcher)),
logger,
log_level,
},
Command::perform(ctrl_c(), |_| Message::CtrlC),
)
State::Launcher(Box::new(launcher))
}
Config::Install(datadir_path, network) => {
if !datadir_path.exists() {
Expand All @@ -131,17 +133,8 @@ impl Application for GUI {
log_level.unwrap_or(LevelFilter::INFO),
);
let (install, command) = Installer::new(datadir_path, network);
(
Self {
state: State::Installer(Box::new(install)),
logger,
log_level,
},
Command::batch(vec![
command.map(|msg| Message::Install(Box::new(msg))),
Command::perform(ctrl_c(), |_| Message::CtrlC),
]),
)
cmds.push(command.map(|msg| Message::Install(Box::new(msg))));
State::Installer(Box::new(install))
}
Config::Run(datadir_path, cfg, network) => {
logger.set_running_mode(
Expand All @@ -150,30 +143,24 @@ impl Application for GUI {
log_level.unwrap_or_else(|| cfg.log_level().unwrap_or(LevelFilter::INFO)),
);
let (loader, command) = Loader::new(datadir_path, cfg, network, None);
(
Self {
state: State::Loader(Box::new(loader)),
logger,
log_level,
},
Command::batch(vec![
command.map(|msg| Message::Load(Box::new(msg))),
Command::perform(ctrl_c(), |_| Message::CtrlC),
]),
)
cmds.push(command.map(|msg| Message::Load(Box::new(msg))));
State::Loader(Box::new(loader))
}
}
};
(
Self {
state,
logger,
log_level,
},
Command::batch(cmds),
)
}

fn update(&mut self, message: Self::Message) -> Command<Self::Message> {
match (&mut self.state, message) {
(_, Message::CtrlC)
| (
_,
Message::Event(iced_native::Event::Window(
iced_native::window::Event::CloseRequested,
)),
) => {
| (_, Message::Event(iced::Event::Window(iced::window::Event::CloseRequested))) => {
match &mut self.state {
State::Loader(s) => s.stop(),
State::Launcher(s) => s.stop(),
Expand Down Expand Up @@ -271,14 +258,8 @@ impl Application for GUI {
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),
iced::subscription::events().map(Self::Message::Event),
])
.with_filter(|(event, _status)| {
matches!(
event,
iced::Event::Window(iced_native::window::Event::CloseRequested)
)
})
}

fn view(&self) -> Element<Self::Message> {
Expand Down Expand Up @@ -408,7 +389,7 @@ fn main() -> Result<(), Box<dyn Error>> {
settings.id = Some("liana-gui".to_string());
settings.window.icon = Some(image::liana_app_icon());
settings.default_text_size = text::P1_SIZE.into();
settings.default_font = Some(font::REGULAR_BYTES);
settings.default_font = liana_ui::font::REGULAR;
settings.exit_on_close_request = false;

if let Err(e) = GUI::run(settings) {
Expand Down
2 changes: 1 addition & 1 deletion gui/src/utils/sandbox.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::Arc;

use iced_native::command::Action;
use iced_runtime::command::Action;

use crate::{
app::{cache::Cache, message::Message, state::State},
Expand Down
2 changes: 1 addition & 1 deletion gui/ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
iced = { version = "0.10", default_features = false, features = ["svg", "image", "lazy", "advanced"] }
iced = { version = "0.10", default-features = false, features = ["svg", "image", "lazy", "advanced"] }
bitcoin = "0.30"
chrono = "0.4"

0 comments on commit 1616a9b

Please sign in to comment.