Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gui(key modal): make the list of keys/signers scrollable #1426

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 77 additions & 64 deletions gui/src/installer/view/editor/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod template;

use iced::widget::{container, pick_list, slider, Button, Space};
use iced::widget::{container, pick_list, scrollable, slider, Button, Space};
use iced::{Alignment, Length};

use liana::miniscript::bitcoin::Network;
Expand Down Expand Up @@ -264,6 +264,81 @@ pub fn edit_key_modal<'a>(
manually_imported_xpub: bool,
duplicate_master_fg: bool,
) -> Element<'a, Message> {
let key_len = hws.len() + keys.len();
let scrollable_enable = match (chosen_signer.is_some(), manually_imported_xpub, key_len) {
(true, _, _) => true,
(_, true, l) => l > 0,
(false, _, 0) => false,
_ => false,
};
let key_column = Column::new()
.spacing(10)
.push(Column::with_children(hws).spacing(10))
.push(Column::with_children(keys).spacing(10))
.push(
Button::new(if Some(*hot_signer_fingerprint) == chosen_signer {
hw::selected_hot_signer(hot_signer_fingerprint, signer_alias)
} else {
hw::unselected_hot_signer(hot_signer_fingerprint, signer_alias)
})
.width(Length::Fill)
.on_press(Message::UseHotSigner)
.style(theme::Button::Border),
)
.push(if manually_imported_xpub {
card::simple(Column::new()
.spacing(10)
.push(
Row::new()
.align_items(Alignment::Center)
.push(p1_regular("Enter an extended public key:").width(Length::Fill))
.push(image::success_mark_icon().width(Length::Fixed(50.0)))
)
.push(
Row::new()
.push(
form::Form::new_trimmed(
&example_xpub(network),
form_xpub, |msg| {
Message::DefineDescriptor(
message::DefineDescriptor::KeyModal(
message::ImportKeyModal::XPubEdited(msg),),)
})
.warning(if network == bitcoin::Network::Bitcoin {
"Please enter correct xpub with origin and without appended derivation path"
} else {
"Please enter correct tpub with origin and without appended derivation path"
})
.size(text::P1_SIZE)
.padding(10),
)
.spacing(10)
))
} else {
Container::new(
Button::new(
Row::new()
.align_items(Alignment::Center)
.spacing(10)
.push(icon::import_icon())
.push(p1_regular("Enter an extended public key"))
)
.padding(20)
.width(Length::Fill)
.on_press(Message::DefineDescriptor(
message::DefineDescriptor::KeyModal(message::ImportKeyModal::ManuallyImportXpub)
))
.style(theme::Button::Secondary),
)
}
)
.padding(15)
;
let scroll = scrollable(key_column).height(if scrollable_enable {
Length::Fill
} else {
Length::Shrink
});
Column::new()
.padding(25)
.push_maybe(error.map(|e| card::error("Failed to import xpub", e.to_string())))
Expand All @@ -278,69 +353,7 @@ pub fn edit_key_modal<'a>(
.push(h3(title))
.push(p1_regular("Select the signing device for your key"))
.spacing(10)
.push(
Column::with_children(hws).spacing(10)
)
.push(
Column::with_children(keys).spacing(10)
)
.push(
Button::new(if Some(*hot_signer_fingerprint) == chosen_signer {
hw::selected_hot_signer(hot_signer_fingerprint, signer_alias)
} else {
hw::unselected_hot_signer(hot_signer_fingerprint, signer_alias)
})
.width(Length::Fill)
.on_press(Message::UseHotSigner)
.style(theme::Button::Border),
)
.push(if manually_imported_xpub {
card::simple(Column::new()
.spacing(10)
.push(
Row::new()
.align_items(Alignment::Center)
.push(p1_regular("Enter an extended public key:").width(Length::Fill))
.push(image::success_mark_icon().width(Length::Fixed(50.0)))
)
.push(
Row::new()
.push(
form::Form::new_trimmed(
&example_xpub(network),
form_xpub, |msg| {
Message::DefineDescriptor(
message::DefineDescriptor::KeyModal(
message::ImportKeyModal::XPubEdited(msg),),)
})
.warning(if network == bitcoin::Network::Bitcoin {
"Please enter correct xpub with origin and without appended derivation path"
} else {
"Please enter correct tpub with origin and without appended derivation path"
})
.size(text::P1_SIZE)
.padding(10),
)
.spacing(10)
))
} else {
Container::new(
Button::new(
Row::new()
.align_items(Alignment::Center)
.spacing(10)
.push(icon::import_icon())
.push(p1_regular("Enter an extended public key"))
)
.padding(20)
.width(Length::Fill)
.on_press(Message::DefineDescriptor(
message::DefineDescriptor::KeyModal(message::ImportKeyModal::ManuallyImportXpub)
))
.style(theme::Button::Secondary),
)
}
)
.push(scroll)
.width(Length::Fill),
)
.push_maybe(
Expand Down
Loading