Skip to content

Commit 4dfa1b1

Browse files
committed
feat: about
1 parent 06a798a commit 4dfa1b1

7 files changed

Lines changed: 135 additions & 2 deletions

File tree

Cargo.lock

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ once_cell = "1.21.3"
3939
dirs = "6.0.0"
4040
serde = { version = "1.0.228", features = ["derive"] }
4141
toml = "0.9.10"
42+
open = "5.3.3"

src/about/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub(crate) mod view;

src/about/view.rs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
use iced::Alignment::Center;
2+
use iced::Element;
3+
use iced::Fill;
4+
use iced::Length;
5+
use iced::Padding;
6+
use iced::widget::Space;
7+
use iced::widget::button;
8+
use iced::widget::column;
9+
use iced::widget::container;
10+
use iced::widget::image;
11+
use iced::widget::row;
12+
use iced::widget::text;
13+
14+
use crate::BDK_ICON_PATH;
15+
use crate::BONSAI_ICON_DARK_PATH;
16+
use crate::BonsaiMessage;
17+
use crate::FLORESTA_ICON_PATH;
18+
use crate::common::interface::button::image_button;
19+
use crate::common::interface::font::BERKELEY_MONO_BOLD;
20+
use crate::node::style::table_cell;
21+
22+
pub(crate) fn view_about<'a>() -> Element<'a, BonsaiMessage> {
23+
let content = column![
24+
container(
25+
image(BONSAI_ICON_DARK_PATH)
26+
.width(Length::Fixed(170.0))
27+
.height(Length::Fixed(170.0))
28+
)
29+
.style(table_cell())
30+
.padding(1),
31+
text("BONSAI").font(BERKELEY_MONO_BOLD).size(36),
32+
Space::new().height(10.0),
33+
text("Bonsai is a desktop wallet with an embbeded node, built as a showcase of `bdk_floresta`, a novel chain-source crate for BDK that leverages Floresta and Utreexo to keep a compact full node running within the application, enabling completely trustless and on-device validation and blockchain data fetching. Zero API calls means better user privacy and sovereignty.").align_x(Center),
34+
Space::new().height(Fill),
35+
text("POWERED BY").font(BERKELEY_MONO_BOLD).size(24),
36+
Space::new().height(15.0),
37+
row![
38+
column![
39+
button(
40+
container(
41+
image(BDK_ICON_PATH)
42+
.width(Length::Fixed(170.0))
43+
.height(Length::Fixed(170.0))
44+
)
45+
)
46+
.on_press(BonsaiMessage::OpenLink("https://bitcoindevkit.org".to_string()))
47+
.padding(0)
48+
.style(image_button()),
49+
text("Bitcoin Dev Kit")
50+
].align_x(Center).spacing(4),
51+
column![
52+
button(
53+
container(
54+
image(FLORESTA_ICON_PATH)
55+
.width(Length::Fixed(170.0))
56+
.height(Length::Fixed(170.0))
57+
)
58+
)
59+
.on_press(BonsaiMessage::OpenLink("https://getfloresta.org".to_string()))
60+
.padding(0)
61+
.style(image_button()),
62+
text("Floresta")
63+
].align_x(Center).spacing(4),
64+
].align_y(Center).spacing(20)
65+
]
66+
.align_x(Center);
67+
68+
container(content)
69+
.width(Length::Fill)
70+
.height(Length::Fill)
71+
.align_x(Center)
72+
.align_y(Center)
73+
.padding(Padding::from([40.0, 150.0]))
74+
.into()
75+
}

src/bonsai.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ pub(crate) const APP_VERSION: &str = concat!("v", env!("CARGO_PKG_VERSION"));
8686
pub(crate) const GEOIP_ASN_DB_PATH: &str = "./assets/geoip/GeoLite2-ASN.mmdb";
8787
pub(crate) const GEOIP_CITY_DB_PATH: &str = "./assets/geoip/GeoLite2-City.mmdb";
8888
pub(crate) const BONSAI_ICON_DARK_PATH: &str = "./assets/icon/bonsai-dark.png";
89+
pub(crate) const FLORESTA_ICON_PATH: &str = "./assets/icon/floresta.png";
90+
pub(crate) const BDK_ICON_PATH: &str = "./assets/icon/bdk.png";
8991
//pub(crate) const BONSAI_ICON_LIGHT_PATH: &str = "./assets/icon/bonsai-light.png";
9092

9193
#[derive(Default, Debug, Clone, Copy, PartialEq)]
@@ -104,6 +106,7 @@ pub(crate) enum Tab {
104106
pub(crate) enum BonsaiMessage {
105107
AnimationTick,
106108
KeyPressed(Key, Modifiers),
109+
OpenLink(String),
107110
SelectTab(Tab),
108111
CloseRequested,
109112
CloseWindow,
@@ -319,7 +322,7 @@ impl Bonsai {
319322

320323
if modifiers.is_empty() {
321324
if let Key::Character(c) = key.as_ref() {
322-
match c.as_ref() {
325+
match c {
323326
"w" => self.active_tab = Tab::Wallet,
324327
"m" => self.active_tab = Tab::NodeMetrics,
325328
"n" => self.active_tab = Tab::NodeNetwork,
@@ -359,6 +362,12 @@ impl Bonsai {
359362
}
360363
Task::none()
361364
}
365+
BonsaiMessage::OpenLink(url) => {
366+
if let Err(e) = open::that(&url) {
367+
error!("Failed to open URL: {}", e);
368+
}
369+
Task::none()
370+
}
362371
BonsaiMessage::AnimationTick => {
363372
self.app_clock = self.app_clock.wrapping_add(1);
364373
Task::none()

src/common/interface/button.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,13 @@ pub(crate) fn sidebar_button(
6767
}
6868
}
6969
}
70+
71+
pub(crate) fn image_button() -> impl Fn(&Theme, ButtonStatus) -> ButtonStyle {
72+
move |_theme, _button_status| ButtonStyle {
73+
border: Border::default(),
74+
background: None,
75+
text_color: Default::default(),
76+
shadow: Shadow::default(),
77+
..Default::default()
78+
}
79+
}

src/settings/bonsai_settings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ impl BonsaiSettings {
443443
self.node_restart_required = true;
444444
}
445445

446-
if let Ok(_) = self.save() {
446+
if self.save().is_ok() {
447447
self.unsaved_changes = false;
448448
}
449449

0 commit comments

Comments
 (0)