Skip to content

Commit

Permalink
wip iced-0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
edouardparis committed Mar 29, 2024
1 parent 532a585 commit ed7eafd
Show file tree
Hide file tree
Showing 32 changed files with 1,877 additions and 1,676 deletions.
2,707 changes: 1,403 additions & 1,304 deletions gui/Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ liana_ui = { path = "ui" }
backtrace = "0.3"
hex = "0.4.3"

iced = { version = "0.10", default-features = false, features = ["tokio", "svg", "qr_code", "image", "lazy", "wgpu"] }
iced_runtime = "0.1.1"
iced = { version = "0.12.1", default-features = false, features = ["tokio", "svg", "qr_code", "image", "lazy", "webgl"] }
iced_runtime = "0.12.1"

tokio = {version = "1.21.0", features = ["signal"]}
serde = { version = "1.0", features = ["derive"] }
Expand Down
4 changes: 2 additions & 2 deletions gui/src/app/state/receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,13 @@ impl VerifyAddressModal {
}

pub struct ShowQrCodeModal {
qr_code: qr_code::State,
qr_code: qr_code::Data,
address: String,
}

impl ShowQrCodeModal {
pub fn new(address: &Address, index: ChildNumber) -> Option<Self> {
qr_code::State::new(format!("bitcoin:{}?index={}", address, index))
qr_code::Data::new(format!("bitcoin:{}?index={}", address, index))
.ok()
.map(|qr_code| Self {
qr_code,
Expand Down
1 change: 0 additions & 1 deletion gui/src/app/view/coins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use liana_ui::{
color,
component::{amount::*, badge, button, form, text::*},
icon, theme,
util::Collection,
widget::*,
};

Expand Down
1 change: 0 additions & 1 deletion gui/src/app/view/home.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use liana_ui::{
color,
component::{amount::*, button, card, event, form, text::*},
icon, theme,
util::Collection,
widget::*,
};

Expand Down
1 change: 0 additions & 1 deletion gui/src/app/view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use liana_ui::{
},
image::*,
theme,
util::Collection,
widget::*,
};

Expand Down
5 changes: 2 additions & 3 deletions gui/src/app/view/psbt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use liana_ui::{
text::{self, *},
},
icon, theme,
util::Collection,
widget::*,
};

Expand Down Expand Up @@ -426,7 +425,7 @@ pub fn signatures<'a>(
Container::new(text(alias))
.padding(10)
.style(theme::Container::Pill(theme::Pill::Simple)),
value.to_string(),
liana_ui::widget::Text::new(value.to_string()),
tooltip::Position::Bottom,
)
.style(theme::Container::Card(theme::Card::Simple)),
Expand Down Expand Up @@ -522,7 +521,7 @@ fn container_from_fg(
Container::new(text(alias))
.padding(10)
.style(theme::Container::Pill(theme::Pill::Simple)),
fg.to_string(),
liana_ui::widget::Text::new(fg.to_string()),
tooltip::Position::Bottom,
)
.style(theme::Container::Card(theme::Card::Simple)),
Expand Down
1 change: 0 additions & 1 deletion gui/src/app/view/psbts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use liana_ui::{
color,
component::{amount::*, badge, button, card, form, text::*},
icon, theme,
util::Collection,
widget::*,
};

Expand Down
5 changes: 2 additions & 3 deletions gui/src/app/view/receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use liana_ui::{
text::{self, *},
},
icon, theme,
util::Collection,
widget::*,
};

Expand Down Expand Up @@ -216,13 +215,13 @@ pub fn verify_address_modal<'a>(
.into()
}

pub fn qr_modal<'a>(qr: &'a qr_code::State, address: &'a String) -> Element<'a, Message> {
pub fn qr_modal<'a>(qr: &'a qr_code::Data, address: &'a String) -> Element<'a, Message> {
Column::new()
.push(
Row::new()
.push(Space::with_width(Length::Fill))
.push(
Container::new(QRCode::new(qr).cell_size(8))
Container::new(QRCode::<liana_ui::theme::Theme>::new(qr).cell_size(8))
.padding(10)
.style(theme::Container::QrCode),
)
Expand Down
10 changes: 5 additions & 5 deletions gui/src/app/view/recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use liana::miniscript::bitcoin::{
use liana_ui::{
component::{amount::*, button, form, text::*},
icon, theme,
util::*,
widget::*,
};

Expand Down Expand Up @@ -144,9 +143,10 @@ pub fn recovery_path_view<'a>(
selected: bool,
) -> Element<'a, Message> {
Row::new()
.push(checkbox("", selected, move |_| {
Message::CreateSpend(CreateSpendMessage::SelectPath(index))
}))
.push(
checkbox("", selected)
.on_toggle(move |_| Message::CreateSpend(CreateSpendMessage::SelectPath(index))),
)
.push(
Column::new()
.push(
Expand All @@ -170,7 +170,7 @@ pub fn recovery_path_view<'a>(
Container::new(text(alias))
.padding(5)
.style(theme::Container::Pill(theme::Pill::Simple)),
fg.to_string(),
liana_ui::widget::Text::new(fg.to_string()),
tooltip::Position::Bottom,
)
.style(theme::Container::Card(theme::Card::Simple)),
Expand Down
1 change: 0 additions & 1 deletion gui/src/app/view/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use liana_ui::{
color,
component::{badge, button, card, form, separation, text::*, tooltip::tooltip},
icon, theme,
util::Collection,
widget::*,
};

Expand Down
14 changes: 7 additions & 7 deletions gui/src/app/view/spend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use liana_ui::{
color,
component::{amount::*, badge, button, form, text::*},
icon, theme,
util::Collection,
widget::*,
};

Expand Down Expand Up @@ -403,9 +402,8 @@ pub fn recipient_view<'a>(
None
})
.push(tooltip::Tooltip::new(
checkbox("MAX", is_max_selected, move |_| {
CreateSpendMessage::SendMaxToRecipient(index)
}),
checkbox("MAX", is_max_selected)
.on_toggle(move |_| CreateSpendMessage::SendMaxToRecipient(index)),
"Total amount remaining after paying fee and any other recipients",
tooltip::Position::Left,
))
Expand All @@ -428,9 +426,11 @@ fn coin_list_view<'a>(
Row::new()
.push(
Row::new()
.push(checkbox("", selected, move |_| {
Message::CreateSpend(CreateSpendMessage::SelectCoin(i))
}))
.push(
checkbox("", selected).on_toggle(move |_| {
Message::CreateSpend(CreateSpendMessage::SelectCoin(i))
}),
)
.push(
if let Some(label) = coins_labels.get(&coin.outpoint.to_string()) {
Container::new(p1_regular(label)).width(Length::Fill)
Expand Down
1 change: 0 additions & 1 deletion gui/src/app/view/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use liana_ui::{
color,
component::{amount::*, badge, button, card, form, text::*},
icon, theme,
util::Collection,
widget::*,
};

Expand Down
31 changes: 11 additions & 20 deletions gui/src/installer/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use liana_ui::{
tooltip,
},
icon, image, theme,
util::Collection,
widget::*,
};

Expand Down Expand Up @@ -719,11 +718,10 @@ pub fn participate_xpub<'a>(
.push(signer)
.width(Length::Fill),
)
.push(checkbox(
"I have shared my extended public key",
shared,
Message::UserActionDone,
))
.push(
checkbox("I have shared my extended public key", shared)
.on_toggle(Message::UserActionDone),
)
.push(if shared {
button::primary(None, "Next")
.width(Length::Fixed(200.0))
Expand Down Expand Up @@ -806,8 +804,7 @@ pub fn register_descriptor<'a>(
.push_maybe(created_desc.then_some(checkbox(
"I have registered the descriptor on my device(s)",
done,
Message::UserActionDone,
)))
).on_toggle(Message::UserActionDone)))
.push(if !created_desc || (done && !processing) {
button::primary(None, "Next")
.on_press(Message::Next)
Expand Down Expand Up @@ -871,11 +868,9 @@ pub fn backup_descriptor<'a>(
.spacing(10)
.max_width(1000),
))
.push(checkbox(
"I have backed up my descriptor",
done,
Message::UserActionDone,
))
.push(
checkbox("I have backed up my descriptor", done).on_toggle(Message::UserActionDone),
)
.push(if done {
button::primary(None, "Next")
.on_press(Message::Next)
Expand Down Expand Up @@ -1677,7 +1672,7 @@ pub fn edit_sequence_modal<'a>(sequence: &form::Value<String>) -> Element<'a, Me
message::SequenceModal::SequenceEdited(v.to_string()),
))
})
.step(144), // 144 blocks per day
.step(144_u16), // 144 blocks per day
)
.width(Length::Fixed(500.0)),
);
Expand Down Expand Up @@ -1820,11 +1815,7 @@ pub fn backup_mnemonic<'a>(
)
}),
)
.push(checkbox(
"I have backed up my mnemonic",
done,
Message::UserActionDone,
))
.push(checkbox("I have backed up my mnemonic", done).on_toggle(Message::UserActionDone))
.push(if done {
button::primary(None, "Next")
.on_press(Message::Next)
Expand Down Expand Up @@ -2040,7 +2031,7 @@ mod threshsold_input {
}
}

impl<Message> Component<Message, iced::Renderer<theme::Theme>> for ThresholdInput<Message> {
impl<Message> Component<Message, theme::Theme> for ThresholdInput<Message> {
type State = ();
type Event = Event;

Expand Down
1 change: 0 additions & 1 deletion gui/src/launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use liana_ui::{
color,
component::{badge, button, card, modal::Modal, notification, text::*},
icon, image, theme,
util::*,
widget::*,
};

Expand Down
1 change: 0 additions & 1 deletion gui/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use liana_ui::{
color,
component::{button, notification, text::*},
icon,
util::Collection,
widget::*,
};

Expand Down
18 changes: 9 additions & 9 deletions gui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use std::{error::Error, io::Write, path::PathBuf, process, str::FromStr};
use iced::{
event::{self, Event},
executor,
keyboard::{self, KeyCode},
subscription,
keyboard::{self},
widget::{focus_next, focus_previous},
window::settings::PlatformSpecific,
Application, Command, Settings, Subscription,
};
use tracing::{error, info};
Expand Down Expand Up @@ -180,14 +180,14 @@ impl Application for GUI {
fn update(&mut self, message: Self::Message) -> Command<Self::Message> {
match (&mut self.state, message) {
(_, Message::CtrlC)
| (_, Message::Event(iced::Event::Window(iced::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(),
State::Installer(s) => s.stop(),
State::App(s) => s.stop(),
};
iced::window::close()
iced::window::close(iced::window::Id::MAIN)
}
(_, Message::KeyPressed(Key::Tab(shift))) => {
log::debug!("Tab pressed!");
Expand Down Expand Up @@ -286,17 +286,17 @@ 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))),
},
subscription::events_with(|event, status| match (&event, status) {
iced::event::listen_with(|event, status| match (&event, status) {
(
Event::Keyboard(keyboard::Event::KeyPressed {
key_code: KeyCode::Tab,
key: iced::keyboard::Key::Named(iced::keyboard::key::Named::Tab),
modifiers,
..
}),
event::Status::Ignored,
) => Some(Message::KeyPressed(Key::Tab(modifiers.shift()))),
(
iced::Event::Window(iced::window::Event::CloseRequested),
iced::Event::Window(_, iced::window::Event::CloseRequested),
event::Status::Ignored,
) => Some(Message::Event(event)),
_ => None,
Expand Down Expand Up @@ -436,13 +436,13 @@ fn main() -> Result<(), Box<dyn Error>> {
settings.window.icon = Some(image::liana_app_icon());
settings.default_text_size = text::P1_SIZE.into();
settings.default_font = liana_ui::font::REGULAR;
settings.exit_on_close_request = false;
settings.window.exit_on_close_request = false;

settings.id = Some("Liana".to_string());

#[cfg(target_os = "linux")]
{
settings.window.platform_specific = iced::window::PlatformSpecific {
settings.window.platform_specific = PlatformSpecific {
application_id: "Liana".to_string(),
};
}
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.12.1", default-features = false, features = ["svg", "image", "lazy", "qr_code", "advanced", "webgl"] }
bitcoin = "0.31"
chrono = "0.4"
2 changes: 1 addition & 1 deletion gui/ui/src/component/amount.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub use bitcoin::Amount;

use crate::{color, component::text::*, util::Collection, widget::*};
use crate::{color, component::text::*, widget::*};

pub fn amount<'a, T: 'a>(a: &Amount) -> Row<'a, T> {
amount_with_size(a, P1_SIZE)
Expand Down
2 changes: 1 addition & 1 deletion gui/ui/src/component/card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn error<'a, T: 'a>(message: &'static str, error: String) -> Container<'a, T
.align_items(iced::Alignment::Center)
.push(icon::warning_icon().style(color::RED))
.push(text(message).style(color::RED)),
error,
Text::new(error),
iced::widget::tooltip::Position::Bottom,
)
.style(theme::Container::Card(theme::Card::Error)),
Expand Down
Loading

0 comments on commit ed7eafd

Please sign in to comment.