Skip to content

Commit

Permalink
feat(HashtagBar): show all if MAX + 1
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr committed Oct 25, 2024
1 parent 3f38e4f commit 7740544
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Widgets/HashtagBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,21 @@ public class Tuba.Widgets.HashtagBar : Adw.Bin {
}

public HashtagBar (TagExtractor.Tag[] tags) {
bool should_show_all = tags.length <= MAX_VISIBLE_TAGS + 1;

for (int i = 0; i < tags.length; i++) {
flowbox.append (
new Gtk.FlowBoxChild () {
child = new HashtagButton (tags [i]),
visible = i < MAX_VISIBLE_TAGS,
visible = should_show_all || i < MAX_VISIBLE_TAGS,
focusable = false
}
);
}

if (tags.length > MAX_VISIBLE_TAGS) {
if (!should_show_all) {
// translators: the variable is a number. This is used in a button that shows
// all post hashtags when clicked.
show_more = new Gtk.Button.with_label (_("Show %d More").printf (tags.length - MAX_VISIBLE_TAGS)) {
css_classes = { "flat", "profile-role-border-radius", "hashtag-bar-hashtag" }
};
Expand Down

0 comments on commit 7740544

Please sign in to comment.