Skip to content

Keep grid item badges and labels attached to the cell - #17540

Open
sandbranch wants to merge 1 commit into
nextcloud:masterfrom
sandbranch:grid-item-badge-anchoring
Open

Keep grid item badges and labels attached to the cell#17540
sandbranch wants to merge 1 commit into
nextcloud:masterfrom
sandbranch:grid-item-badge-anchoring

Conversation

@sandbranch

Copy link
Copy Markdown

Problem

In grid view the file feature badges (shared, favorite, video, live photo, synced) drift away from the thumbnail as the cell gets wider, and the overflow button drifts away from the file name it belongs to.

The thumbnail is a 1:1 SquareImageView whose resolved size is bounded by the cell height, so when a cell is wider than it is tall the drawn image is narrower than the cell. The badge cluster was positioned against the cell:

app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.85"

so the 0.85 bias applied across the full cell width rather than across the image, pushing the badges into the empty space to the right of the thumbnail.

The file name had the matching problem from the other side: it was given 75% of the cell and centred, with the overflow button placed in the leftover gap, so on a wide cell the button drifted away from the label.

This is only visible when cells are wide, which is why it shows on tablets and in landscape on phones while looking correct in portrait on a phone, where the cell width is close to the image width.

Fix

Anchor the badge cluster to the thumbnail so it stays on the image at any cell width, and let the file name take the width the overflow button does not need, which keeps the two together and leaves more room for the name.

Only grid_item.xml changes; no behaviour or code changes.

Testing

Checked on a Samsung S23 and a Lenovo Tab P11 Pro (2nd gen), portrait and landscape, light and dark.

In grid view the file feature badges (shared, favorite, video, live
photo, synced) were positioned against the whole grid cell rather than
against the thumbnail image.

The thumbnail is a 1:1 SquareImageView whose resolved size is bounded by
the cell height, so when a cell is wider than it is tall the drawn image
is narrower than the cell. Because the badge cluster used

    layout_constraintStart_toStartOf="parent"
    layout_constraintEnd_toEndOf="parent"
    layout_constraintHorizontal_bias="0.85"

the 0.85 bias was applied across the full cell width instead of across
the image, which pushed the badges into the empty space to the right of
the thumbnail. Anchor them to the thumbnail so they stay on the image at
any cell width.

The file name had the matching problem from the other direction: it was
given 75% of the cell and centred, with the overflow button placed in
the leftover gap, so on a wide cell the button drifted away from the
label it belongs to. Let the name take the width the overflow button
does not need, which both keeps the two together and leaves more room
for the name itself.

This is only noticeable when cells are wide, which is why it shows up on
tablets and in landscape on phones while looking correct in portrait on
a phone, where the cell width is close to the image width.

Signed-off-by: David Sandquist <sandquist@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant