Merge #1432: gui(settings): add a button to copy auth fields & mask password

9679f0f2926e2bc90ba7b8b61f138dcabaf22451 gui(settings): add a copy button for electrum server address (pythcoiner)
46cb154b94b69de87941dd61855e24545003e6cc gui(settings): replace node password by stars(*) (pythcoiner)
523bcbdb1f1e2ca43894e8d5b380178e90bd75be gui(settings): add a copy button to auth fields (pythcoiner)

Pull request description:

  fixes #1160
  ![image](https://github.com/user-attachments/assets/e508010a-4fb1-443d-a615-0dff402eb3e0)

ACKs for top commit:
  jp1ac4:
    Tested ACK 9679f0f2926e2bc90ba7b8b61f138dcabaf22451.

Tree-SHA512: 880e35ade18b614e25b5add8fbc17615504e0b7c35a0cd2e9fbc7861b8d24765a2b2a91bcb68d0d4c6f15bbc41ddccf78fd61890aafd33fd6f5d35355f9725e0
This commit is contained in:
edouardparis 2024-12-20 16:08:00 +01:00
commit ecce76ab3f
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F
3 changed files with 27 additions and 5 deletions

View File

@ -5,7 +5,7 @@ use std::str::FromStr;
use std::sync::Arc;
use chrono::{NaiveDate, Utc};
use iced::Command;
use iced::{clipboard, Command};
use tracing::info;
use liana::miniscript::bitcoin::Network;
@ -361,6 +361,7 @@ impl BitcoindSettings {
});
}
}
view::SettingsEditMessage::Clipboard(text) => return clipboard::write(text),
};
Command::none()
}
@ -468,6 +469,7 @@ impl ElectrumSettings {
});
}
}
view::SettingsEditMessage::Clipboard(text) => return clipboard::write(text),
_ => {}
};
Command::none()

View File

@ -91,6 +91,7 @@ pub enum SettingsEditMessage {
BitcoindRpcAuthTypeSelected(RpcAuthType),
Cancel,
Confirm,
Clipboard(String),
}
#[derive(Debug, Clone)]

View File

@ -504,11 +504,23 @@ pub fn bitcoind<'a>(
let mut col_fields = Column::new();
for (k, v) in rows {
col_fields = col_fields.push(
col_fields = col_fields.push({
let t = if k == "Password:" {
"*".to_string().repeat(v.len())
} else {
v.clone()
};
Row::new()
.push(Container::new(text(k).bold().small()).width(Length::Fill))
.push(text(v).small()),
);
.push(text(t).small())
.push(Space::with_width(10))
.push(
Button::new(icon::clipboard_icon())
.style(theme::Button::TransparentBorder)
.on_press(SettingsEditMessage::Clipboard(v.to_string())),
)
.align_items(Alignment::Center)
});
}
card::simple(Container::new(
@ -685,7 +697,14 @@ pub fn electrum<'a>(
col_fields = col_fields.push(
Row::new()
.push(Container::new(text(k).bold().small()).width(Length::Fill))
.push(text(v).small()),
.push(text(v.clone()).small())
.push(Space::with_width(10))
.push(
Button::new(icon::clipboard_icon())
.style(theme::Button::TransparentBorder)
.on_press(SettingsEditMessage::Clipboard(v.to_string())),
)
.align_items(Alignment::Center),
);
}