Add installer dropdown for advanced settings
This commit is contained in:
parent
59a4b181c1
commit
b7f35c0330
@ -193,11 +193,12 @@ impl Setup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct DefineDescriptor {
|
pub struct DefineDescriptor {
|
||||||
|
data_dir: Option<PathBuf>,
|
||||||
|
setup: HashMap<Network, Setup>,
|
||||||
|
|
||||||
network: Network,
|
network: Network,
|
||||||
network_valid: bool,
|
network_valid: bool,
|
||||||
use_taproot: bool,
|
use_taproot: bool,
|
||||||
data_dir: Option<PathBuf>,
|
|
||||||
setup: HashMap<Network, Setup>,
|
|
||||||
|
|
||||||
modal: Option<Box<dyn DescriptorEditModal>>,
|
modal: Option<Box<dyn DescriptorEditModal>>,
|
||||||
signer: Arc<Mutex<Signer>>,
|
signer: Arc<Mutex<Signer>>,
|
||||||
@ -213,7 +214,6 @@ impl DefineDescriptor {
|
|||||||
setup: HashMap::from([(Network::Bitcoin, Setup::new())]),
|
setup: HashMap::from([(Network::Bitcoin, Setup::new())]),
|
||||||
data_dir: None,
|
data_dir: None,
|
||||||
network_valid: true,
|
network_valid: true,
|
||||||
|
|
||||||
modal: None,
|
modal: None,
|
||||||
signer,
|
signer,
|
||||||
error: None,
|
error: None,
|
||||||
|
|||||||
@ -175,21 +175,87 @@ pub fn welcome<'a>() -> Element<'a, Message> {
|
|||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum DescriptorKind {
|
pub enum DescriptorKind {
|
||||||
Legacy,
|
P2WSH,
|
||||||
Taproot,
|
Taproot,
|
||||||
}
|
}
|
||||||
|
|
||||||
const DESCRIPTOR_KINDS: [DescriptorKind; 2] = [DescriptorKind::Legacy, DescriptorKind::Taproot];
|
const DESCRIPTOR_KINDS: [DescriptorKind; 2] = [DescriptorKind::P2WSH, DescriptorKind::Taproot];
|
||||||
|
|
||||||
impl std::fmt::Display for DescriptorKind {
|
impl std::fmt::Display for DescriptorKind {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Self::Legacy => write!(f, "Default"),
|
Self::P2WSH => write!(f, "P2WSH"),
|
||||||
Self::Taproot => write!(f, "Taproot"),
|
Self::Taproot => write!(f, "Taproot"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
pub fn define_descriptor_advanced_settings<'a>(
|
||||||
|
network: bitcoin::Network,
|
||||||
|
network_valid: bool,
|
||||||
|
use_taproot: bool,
|
||||||
|
) -> Element<'a, Message> {
|
||||||
|
let col_network = Column::new()
|
||||||
|
.spacing(10)
|
||||||
|
.push(text("Network").bold())
|
||||||
|
.push(container(
|
||||||
|
pick_list(&NETWORKS[..], Some(Network::from(network)), |net| {
|
||||||
|
Message::Network(net.into())
|
||||||
|
})
|
||||||
|
.style(if network_valid {
|
||||||
|
theme::PickList::Secondary
|
||||||
|
} else {
|
||||||
|
theme::PickList::Invalid
|
||||||
|
})
|
||||||
|
.padding(10),
|
||||||
|
))
|
||||||
|
.push_maybe(if network_valid {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(text("A data directory already exists for this network").style(color::RED))
|
||||||
|
});
|
||||||
|
|
||||||
|
let col_wallet = Column::new()
|
||||||
|
.spacing(10)
|
||||||
|
.push(text("Descriptor type").bold())
|
||||||
|
.push(container(
|
||||||
|
pick_list(
|
||||||
|
&DESCRIPTOR_KINDS[..],
|
||||||
|
Some(if use_taproot {
|
||||||
|
DescriptorKind::Taproot
|
||||||
|
} else {
|
||||||
|
DescriptorKind::P2WSH
|
||||||
|
}),
|
||||||
|
|kind| Message::CreateTaprootDescriptor(kind == DescriptorKind::Taproot),
|
||||||
|
)
|
||||||
|
.style(theme::PickList::Secondary)
|
||||||
|
.padding(10),
|
||||||
|
));
|
||||||
|
|
||||||
|
container(
|
||||||
|
Column::new()
|
||||||
|
.spacing(20)
|
||||||
|
.push(Space::with_height(0))
|
||||||
|
.push(separation().width(500))
|
||||||
|
.push(
|
||||||
|
Row::new()
|
||||||
|
.push(col_network)
|
||||||
|
.push(Space::with_width(100))
|
||||||
|
.push(col_wallet),
|
||||||
|
)
|
||||||
|
.push_maybe(if use_taproot {
|
||||||
|
Some(
|
||||||
|
p1_regular("Taproot is only supported by Liana version 5.0 and above")
|
||||||
|
.style(color::GREY_2),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.into()
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn define_descriptor<'a>(
|
pub fn define_descriptor<'a>(
|
||||||
progress: (usize, usize),
|
progress: (usize, usize),
|
||||||
@ -202,43 +268,6 @@ pub fn define_descriptor<'a>(
|
|||||||
valid: bool,
|
valid: bool,
|
||||||
error: Option<&String>,
|
error: Option<&String>,
|
||||||
) -> Element<'a, Message> {
|
) -> Element<'a, Message> {
|
||||||
let col_network = Column::new()
|
|
||||||
.spacing(10)
|
|
||||||
.push(text("Network").bold())
|
|
||||||
.push(container(
|
|
||||||
pick_list(&NETWORKS[..], Some(Network::from(network)), |net| {
|
|
||||||
Message::Network(net.into())
|
|
||||||
})
|
|
||||||
.style(if network_valid {
|
|
||||||
theme::PickList::Simple
|
|
||||||
} else {
|
|
||||||
theme::PickList::Invalid
|
|
||||||
})
|
|
||||||
.padding(10),
|
|
||||||
))
|
|
||||||
.push_maybe(if network_valid {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(text("A data directory already exists for this network").style(color::RED))
|
|
||||||
});
|
|
||||||
|
|
||||||
let col_wallet = Column::new()
|
|
||||||
.spacing(10)
|
|
||||||
.push(text("Wallet").bold())
|
|
||||||
.push(container(
|
|
||||||
pick_list(
|
|
||||||
&DESCRIPTOR_KINDS[..],
|
|
||||||
Some(if use_taproot {
|
|
||||||
DescriptorKind::Taproot
|
|
||||||
} else {
|
|
||||||
DescriptorKind::Legacy
|
|
||||||
}),
|
|
||||||
|kind| Message::CreateTaprootDescriptor(kind == DescriptorKind::Taproot),
|
|
||||||
)
|
|
||||||
.style(theme::PickList::Secondary)
|
|
||||||
.padding(10),
|
|
||||||
));
|
|
||||||
|
|
||||||
let col_spending_keys = Column::new()
|
let col_spending_keys = Column::new()
|
||||||
.push(
|
.push(
|
||||||
Row::new()
|
Row::new()
|
||||||
@ -298,16 +327,32 @@ pub fn define_descriptor<'a>(
|
|||||||
progress,
|
progress,
|
||||||
"Create the wallet",
|
"Create the wallet",
|
||||||
Column::new()
|
Column::new()
|
||||||
|
.push(collapse::Collapse::new(
|
||||||
|
|| {
|
||||||
|
Button::new(
|
||||||
|
Row::new()
|
||||||
|
.align_items(Alignment::Center)
|
||||||
|
.spacing(10)
|
||||||
|
.push(text("Advanced settings").small().bold())
|
||||||
|
.push(icon::collapse_icon()),
|
||||||
|
)
|
||||||
|
.style(theme::Button::Transparent)
|
||||||
|
},
|
||||||
|
|| {
|
||||||
|
Button::new(
|
||||||
|
Row::new()
|
||||||
|
.align_items(Alignment::Center)
|
||||||
|
.spacing(10)
|
||||||
|
.push(text("Advanced settings").small().bold())
|
||||||
|
.push(icon::collapsed_icon()),
|
||||||
|
)
|
||||||
|
.style(theme::Button::Transparent)
|
||||||
|
},
|
||||||
|
move || define_descriptor_advanced_settings(network, network_valid, use_taproot),
|
||||||
|
))
|
||||||
.push(
|
.push(
|
||||||
Column::new()
|
Column::new()
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.push(
|
|
||||||
Row::new()
|
|
||||||
.push(col_network)
|
|
||||||
.push(Space::with_width(Length::Fixed(100.0)))
|
|
||||||
.push(col_wallet)
|
|
||||||
.align_items(Alignment::Start),
|
|
||||||
)
|
|
||||||
.push(
|
.push(
|
||||||
Column::new()
|
Column::new()
|
||||||
.spacing(25)
|
.spacing(25)
|
||||||
|
|||||||
@ -473,7 +473,7 @@ impl pick_list::StyleSheet for Theme {
|
|||||||
border_width: 1.0,
|
border_width: 1.0,
|
||||||
border_color: color::GREY_3,
|
border_color: color::GREY_3,
|
||||||
border_radius: 25.0,
|
border_radius: 25.0,
|
||||||
text_color: color::GREY_3,
|
text_color: color::GREY_2,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user