Skip to content

Commit

Permalink
display wallet birthday
Browse files Browse the repository at this point in the history
  • Loading branch information
pythcoiner committed Jan 29, 2024
1 parent a34070d commit 37e3888
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
7 changes: 6 additions & 1 deletion gui/src/app/state/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ impl State for SettingsState {
}
Message::View(view::Message::Settings(view::SettingsMessage::EditWalletSettings)) => {
self.setting = Some(
WalletSettingsState::new(self.data_dir.clone(), self.wallet.clone()).into(),
WalletSettingsState::new(
self.data_dir.clone(),
self.wallet.clone(),
daemon.get_info().unwrap().timestamp,
)
.into(),
);
self.setting
.as_mut()
Expand Down
5 changes: 4 additions & 1 deletion gui/src/app/state/settings/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ pub struct WalletSettingsState {
modal: Option<RegisterWalletModal>,
processing: bool,
updated: bool,
creation_date: u32,
}

impl WalletSettingsState {
pub fn new(data_dir: PathBuf, wallet: Arc<Wallet>) -> Self {
pub fn new(data_dir: PathBuf, wallet: Arc<Wallet>, creation_date: u32) -> Self {
WalletSettingsState {
data_dir,
descriptor: wallet.main_descriptor.to_string(),
Expand All @@ -42,6 +43,7 @@ impl WalletSettingsState {
modal: None,
processing: false,
updated: false,
creation_date,
}
}

Expand Down Expand Up @@ -81,6 +83,7 @@ impl State for WalletSettingsState {
&self.keys_aliases,
self.processing,
self.updated,
self.creation_date,
);
if let Some(m) = &self.modal {
modal::Modal::new(content, m.view())
Expand Down
14 changes: 14 additions & 0 deletions gui/src/app/view/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ pub fn wallet_settings<'a>(
keys_aliases: &[(Fingerprint, form::Value<String>)],
processing: bool,
updated: bool,
creation_date: u32,
) -> Element<'a, Message> {
dashboard(
&Menu::Settings,
Expand All @@ -612,6 +613,7 @@ pub fn wallet_settings<'a>(
.on_press(Message::Settings(SettingsMessage::AboutSection)),
),
)
.push_maybe(creation_date_message(creation_date))
.push(card::simple(
Column::new()
.push(text("Wallet descriptor:").bold())
Expand Down Expand Up @@ -738,3 +740,15 @@ pub fn register_wallet_modal<'a>(
.width(Length::Fixed(500.0))
.into()
}

pub fn creation_date_message(creation_date: u32) -> Option<Row<'static, Message>> {
if let Some(datetime) = chrono::NaiveDateTime::from_timestamp_opt(creation_date as i64, 0) {
return Some(
Row::new()
.push(text("Wallet creation date:").bold())
.spacing(10)
.push(text(datetime.format("%m/%d/%Y").to_string())),
);
}
None
}

0 comments on commit 37e3888

Please sign in to comment.