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(settings): add a button to copy auth fields & mask password #1432

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion liana-gui/src/app/state/settings/bitcoind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -361,6 +361,7 @@ impl BitcoindSettings {
});
}
}
view::SettingsEditMessage::Clipboard(text) => return clipboard::write(text),
pythcoiner marked this conversation as resolved.
Show resolved Hide resolved
};
Command::none()
}
Expand Down Expand Up @@ -468,6 +469,7 @@ impl ElectrumSettings {
});
}
}
view::SettingsEditMessage::Clipboard(text) => return clipboard::write(text),
_ => {}
};
Command::none()
Expand Down
1 change: 1 addition & 0 deletions liana-gui/src/app/view/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ pub enum SettingsEditMessage {
BitcoindRpcAuthTypeSelected(RpcAuthType),
Cancel,
Confirm,
Clipboard(String),
}

#[derive(Debug, Clone)]
Expand Down
27 changes: 23 additions & 4 deletions liana-gui/src/app/view/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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),
);
}

Expand Down
Loading