Merge #1720: show partial address in collapsed view

78a261da5a5e92f3589403760858105026e6278d show partial address in collapsed view (Michael Mallan)

Pull request description:

  To avoid the need for a scrollbar when showing previous addresses in the collapsed view, we will now show the first and last 16 characters only.

  ![image](https://github.com/user-attachments/assets/3ff7b68c-18e4-4cf5-ab90-8bb80dc57bb0)
  ![image](https://github.com/user-attachments/assets/c02cfed1-f639-4256-804b-b17bf5cb0502)

ACKs for top commit:
  edouardparis:
    utACK 78a261da5a5e92f3589403760858105026e6278d

Tree-SHA512: ca7282e47de3b828a8f8746f710a30650992499b785e5bb766c80ffafb83aa872dc63b5f1d85c2f1394a5eb4c018a2c4feeb772f8bafde021e81f5294811780c
This commit is contained in:
edouardparis 2025-05-23 14:34:16 +02:00
commit 686ac24b9b
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F

View File

@ -102,6 +102,8 @@ pub fn receive<'a>(
is_last_page: bool,
processing: bool,
) -> Element<'a, Message> {
// Number of start and end address characters to show in collapsed view.
const NUM_ADDR_CHARS: usize = 16;
let mut addresses_count = 0; // for counting number of new addresses generated
Column::new()
.push(
@ -163,30 +165,31 @@ pub fn receive<'a>(
col.push(if !selected.contains(address) {
Button::new(
Row::new()
.spacing(30)
.spacing(10)
.push(
Container::new(
scrollable(
Column::new()
.push(Space::with_height(Length::Fixed(10.0)))
.push(
p2_regular(address)
.small()
.style(theme::text::secondary),
{
let addr = address.to_string();
let addr_len = addr.chars().count();
Container::new(
p2_regular(if addr_len > 2 * NUM_ADDR_CHARS {
format!(
"{}...{}",
addr.chars()
.take(NUM_ADDR_CHARS)
.collect::<String>(),
addr.chars()
.skip(addr_len - NUM_ADDR_CHARS)
.collect::<String>(),
)
// Space between the address and the scrollbar
.push(Space::with_height(Length::Fixed(10.0))),
} else {
addr
})
.small()
.style(theme::text::secondary),
)
.direction(
scrollable::Direction::Horizontal(
scrollable::Scrollbar::new()
.width(2)
.scroller_width(2),
),
),
)
}
.padding(10)
.width(Length::FillPortion(13)),
.width(Length::Fixed(350.0)),
)
.push(
Container::new(
@ -215,7 +218,7 @@ pub fn receive<'a>(
),
)
.padding(10)
.width(Length::FillPortion(7)),
.width(Length::Fill),
)
.align_y(Alignment::Center),
)