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

feat(Profile): bot badge #336

Merged
merged 2 commits into from
Jul 1, 2023
Merged
Changes from 1 commit
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
Next Next commit
feat(Profile): bot badge
GeopJr committed Jun 30, 2023
commit 32c97a2698d9fabe5cccc46cffd3247b4f767759
1 change: 1 addition & 0 deletions data/gresource.xml
Original file line number Diff line number Diff line change
@@ -62,6 +62,7 @@
<file preprocess="xml-stripblanks">icons/scalable/actions/tuba-explore2-large-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/tuba-text-justify-left-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/tuba-cat-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/tuba-brain-augemnted-symbolic.svg</file>
<!-- <file preprocess="xml-stripblanks">icons/scalable/actions/tuba-language-symbolic.svg</file> -->

<file>gtk/help-overlay.ui</file>
2 changes: 2 additions & 0 deletions data/icons/scalable/actions/tuba-brain-augemnted-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions data/style.css
Original file line number Diff line number Diff line change
@@ -30,6 +30,10 @@ flowboxchild {
margin: 8px;
}

.cover-badge.only-icon {
padding: 6px;
}

.ttl-flat-button {
padding: 0px;
margin: 0px;
25 changes: 19 additions & 6 deletions data/ui/views/profile_header.ui
Original file line number Diff line number Diff line change
@@ -23,18 +23,31 @@
<child>
<object class="GtkOverlay">
<child type="overlay">
<object class="GtkLabel" id="cover_badge">
<property name="label">Follows you</property>
<property name="xalign">0</property>
<object class="GtkBox" id="cover_badge_box">
<property name="halign">end</property>
<property name="valign">start</property>
<property name="margin-bottom">48</property>
<property name="visible">0</property>
<property name="margin-bottom">48</property>
<property name="spacing">6</property>
<child>
<object class="GtkImage" id="cover_bot_badge">
<property name="icon-name">tuba-brain-augemnted-symbolic</property>
<property name="tooltip-text" translatable="yes">Bot</property>
</object>
</child>
<child>
<object class="GtkLabel" id="cover_badge">
<property name="label">Follows you</property>
<property name="xalign">0</property>
<property name="visible">0</property>
</object>
</child>
<style>
<class name="linked" />
<class name="badge"/>
<class name="heading"/>
<class name="osd"/>
<class name="cover-badge"/>
<class name="cover-badge"/>
<class name="only-icon"/>
</style>
</object>
</child>
1 change: 1 addition & 0 deletions src/API/Account.vala
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ public class Tuba.API.Account : Entity, Widgetizable {
public string header { get; set; }
public string avatar { get; set; }
public string url { get; set; }
public bool bot { get; set; default=false; }
public string created_at { get; set; }
public Gee.ArrayList<API.Emoji>? emojis { get; set; }
public int64 followers_count { get; set; }
49 changes: 42 additions & 7 deletions src/Views/Profile.vala
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ public class Tuba.Views.Profile : Views.Timeline {
public string source { get; set; default = "statuses"; }

protected Cover cover;
protected Label cover_badge;
protected MenuButton menu_button;

protected SimpleAction media_action;
@@ -23,7 +22,6 @@ public class Tuba.Views.Profile : Views.Timeline {

construct {
cover = build_cover ();
cover_badge = cover.cover_badge;
cover.rsbtn.rs = this.rs;
column_view.prepend (cover);
}
@@ -78,21 +76,61 @@ public class Tuba.Views.Profile : Views.Timeline {
protected class Cover : Box {

[GtkChild] unowned Widgets.BackgroundWrapper background;
[GtkChild] public unowned Label cover_badge;
[GtkChild] unowned Label cover_badge;
[GtkChild] unowned Image cover_bot_badge;
[GtkChild] unowned Box cover_badge_box;
[GtkChild] public unowned ListBox info;
[GtkChild] unowned Widgets.EmojiLabel display_name;
[GtkChild] unowned Label handle;
[GtkChild] unowned Widgets.Avatar avatar;
[GtkChild] unowned Widgets.MarkupView note;
[GtkChild] public unowned Widgets.RelationshipButton rsbtn;

public string cover_badge_label {
get {
return cover_badge.label;
}

set {
var has_label = value != "";
cover_badge.visible = has_label;
cover_badge.label = value;

update_cover_badge ();
}
}

public bool is_bot {
get {
return cover_bot_badge.visible;
}

set {
cover_bot_badge.visible = value;

update_cover_badge ();
}
}

private void update_cover_badge () {
cover_badge_box.visible = cover_badge.visible || is_bot;

if (is_bot && !cover_badge.visible) {
cover_badge_box.add_css_class ("only-icon");
} else {
cover_badge_box.remove_css_class ("only-icon");
}
}

public void bind (API.Account account) {
display_name.instance_emojis = account.emojis_map;
display_name.content = account.display_name;
handle.label = account.handle;
avatar.account = account;
note.instance_emojis = account.emojis_map;
note.content = account.note;
cover_bot_badge.visible = account.bot;
update_cover_badge ();

if (account.id != accounts.active.id) rsbtn.visible = true;

@@ -298,7 +336,6 @@ public class Tuba.Views.Profile : Views.Timeline {
blocking_action.change_state.connect (v => {
var block = v.get_boolean ();
var q = block ? _("Block \"%s\"?") : _("Unblock \"%s\"?");
warning (q);

var confirmed = app.question (
q.printf (profile.handle),
@@ -382,9 +419,7 @@ public class Tuba.Views.Profile : Views.Timeline {
label = _("Follows you");
}

cover_badge.label = label;
cover_badge.visible = label != "";

cover.cover_badge_label = label;
invalidate_actions (false);
}