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 Aug 8, 2023
1 parent 70aed30 commit 31f31a9
Show file tree
Hide file tree
Showing 8 changed files with 761 additions and 919 deletions.
1,575 changes: 714 additions & 861 deletions gui/Cargo.lock

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ 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"] }

tokio = {version = "1.21.0", features = ["signal"]}
serde = { version = "1.0", features = ["derive"] }
Expand Down
6 changes: 4 additions & 2 deletions gui/src/app/view/psbt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ 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{
Container::new(
Expand Down Expand Up @@ -489,7 +489,9 @@ pub fn path_view<'a>(
}),
),
)
.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
4 changes: 2 additions & 2 deletions gui/src/app/view/receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ pub fn receive<'a>(
// Space between the address and the scrollbar
.push(Space::with_height(Length::Fixed(10.0))),
)
.horizontal_scroll(
.direction(scrollable::Direction::Horizontal(
scrollable::Properties::new().scroller_width(5),
),
)),
)
.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 @@ -570,9 +570,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
24 changes: 15 additions & 9 deletions gui/src/installer/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,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 @@ -343,7 +345,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 @@ -455,9 +459,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 @@ -538,9 +542,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 @@ -1169,7 +1173,9 @@ pub fn defined_descriptor_key(
.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 @@ -1717,8 +1723,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 @@ -1805,7 +1811,7 @@ mod threshsold_input {
Message: 'a,
{
fn from(numeric_input: ThresholdInput<Message>) -> Self {
iced_lazy::component(numeric_input)
component(numeric_input)
}
}
}
61 changes: 22 additions & 39 deletions gui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,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 @@ -99,16 +106,12 @@ impl Application for GUI {

fn new(config: Config) -> (GUI, Command<Self::Message>) {
let logger = Logger::setup(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,
},
Command::perform(ctrl_c(), |_| Message::CtrlC),
)
State::Launcher(Box::new(launcher))
}
Config::Install(datadir_path, network) => {
if !datadir_path.exists() {
Expand All @@ -125,16 +128,8 @@ impl Application for GUI {
}
logger.set_installer_mode(datadir_path.clone(), LevelFilter::INFO);
let (install, command) = Installer::new(datadir_path, network);
(
Self {
state: State::Installer(Box::new(install)),
logger,
},
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 @@ -143,29 +138,17 @@ impl Application for GUI {
cfg.log_level().unwrap_or(LevelFilter::INFO),
);
let (loader, command) = Loader::new(datadir_path, cfg, network);
(
Self {
state: State::Loader(Box::new(loader)),
logger,
},
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 }, 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 @@ -254,10 +237,10 @@ 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_with(|event, _status| {
iced::subscription::events_with(|event, _status| {
if matches!(
event,
iced::Event::Window(iced_native::window::Event::CloseRequested)
iced::Event::Window(iced::window::Event::CloseRequested)
) {
Some(event)
} else {
Expand Down Expand Up @@ -389,7 +372,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/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 31f31a9

Please sign in to comment.