Skip to content

Commit

Permalink
fix: more listview regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr committed Aug 30, 2023
1 parent e2768a8 commit 3b27f53
Show file tree
Hide file tree
Showing 11 changed files with 215 additions and 220 deletions.
88 changes: 40 additions & 48 deletions data/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,48 +51,6 @@ flowboxchild {
border-radius: 6px;
}

.ttl-view .content row:not(.ttl-post) {
padding: 0px;
}

.ttl-view .small .content {
border: none;
border-radius: 0;
}

.ttl-view .small .content row {
border-left: none;
border-right: none;
border-radius: 0px;
}

/* Hides the top border from the first row of the first listbox */
.ttl-view .small :first-child list row:first-child {
border-top: 0px;
}

.ttl-view:not(.no-transition) .small .content,
.ttl-view:not(.no-transition) clamp>* {
transition: all 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.no-transition {
transition: none;
}

.ttl-view .large {
margin-left: 18px;
margin-right: 18px;
}

.ttl-view .large:first-child {
margin-top: 32px;
}

.ttl-view .large:last-child {
margin-bottom: 32px;
}

.ttl-label-emoji-no-click:hover {
background: transparent;
}
Expand Down Expand Up @@ -468,16 +426,50 @@ video > overlay > revealer > controls {
box-shadow: none;
}

.ttl-view .content {
padding: 15px;
.ttl-view .content :first-child .card.card-spacing {
margin-top: 0px;
}

.ttl-view .content :last-child .card.card-spacing {
margin-bottom: 0px;
}

.ttl-view .small .content row .card {
.ttl-view .small.content row .card {
border-left: none;
border-right: none;
border-radius: 0px;
}

.ttl-view .small .content {

.ttl-view .small.content {
padding: 0px;
}

.ttl-view .content row:not(.ttl-post) {
padding: 0px;
}
}

.ttl-view:not(.no-transition) .large.content,
.ttl-view:not(.no-transition) .small.content {
transition: all 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.no-transition {
transition: none;
}

.ttl-view .large {
padding-left: 18px;
padding-right: 18px;
}

.ttl-view .large:first-child {
padding-top: 32px;
}

.ttl-view .large:last-child {
padding-bottom: 32px;
}

.ttl-view .small .preview_card.explore .preview_card_image {
border-radius: 0px;
}
232 changes: 116 additions & 116 deletions data/ui/views/base.ui

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion data/ui/widgets/status.ui
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@
<child>
<object class="GtkLabel" id="handle_label">
<property name="label" translatable="no">Handle</property>
<property name="ellipsize">end</property>
<property name="single_line_mode">1</property>
<property name="xalign">0</property>
<property name="hexpand">1</property>
<property name="wrap">1</property>
<property name="wrap-mode">word-char</property>
<style>
<class name="body" />
<class name="dim-label" />
Expand Down
3 changes: 3 additions & 0 deletions src/API/List.vala
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ public class Tuba.API.List : Entity, Widgetizable {
return new Views.Lists.Row (this);
}

public override void open () {
app.main_window.open_view (new Views.List (this));
}
}
8 changes: 4 additions & 4 deletions src/Views/Base.vala
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public class Tuba.Views.Base : Gtk.Box {
[GtkChild] protected unowned Gtk.ScrolledWindow scrolled;
[GtkChild] protected unowned Gtk.Overlay scrolled_overlay;
[GtkChild] protected unowned Gtk.Button scroll_to_top;
[GtkChild] protected unowned Gtk.Box view;
[GtkChild] protected unowned Adw.Clamp clamp;
[GtkChild] protected unowned Gtk.Box column_view;
// [GtkChild] protected unowned Gtk.Box view;
// [GtkChild] protected unowned Adw.Clamp clamp;
// [GtkChild] protected unowned Gtk.Box column_view;
[GtkChild] protected unowned Gtk.Stack states;
[GtkChild] protected unowned Gtk.Box content_box;
[GtkChild] protected unowned Adw.ClampScrollable content_box;
[GtkChild] protected unowned Gtk.Button status_button;
[GtkChild] unowned Gtk.Stack status_stack;
[GtkChild] unowned Gtk.Label status_title_label;
Expand Down
4 changes: 2 additions & 2 deletions src/Views/ContentBase.vala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Tuba.Views.ContentBase : Views.Base {
css_classes = { "content", "background" },
single_click_activate = true
};
content_box.append (content);
content_box.child = content;
content.activate.connect (on_content_item_activated);

scrolled.vadjustment.value_changed.connect (() => {
Expand All @@ -42,7 +42,7 @@ public class Tuba.Views.ContentBase : Views.Base {
}

private void bind_listitem_cb (GLib.Object item) {
(item as Gtk.ListItem).child = on_create_model_widget ((item as Gtk.ListItem).item);
((Gtk.ListItem) item).child = on_create_model_widget (((Gtk.ListItem) item).item);
}

public override void dispose () {
Expand Down
12 changes: 2 additions & 10 deletions src/Views/Lists.vala
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ public class Tuba.Views.Lists : Views.Timeline {
action_box.append (edit_button);
action_box.append (delete_button);

this.activated.connect (() => open ());
this.activatable = true;

this.add_suffix (action_box);
this.add_css_class ("card");
this.add_css_class ("card-spacing");
}

public Row (API.List? list) {
Expand Down Expand Up @@ -80,14 +80,6 @@ public class Tuba.Views.Lists : Views.Timeline {
transient_for = app.main_window
};
}

public virtual signal void open () {
if (this.list == null)
return;

var view = new Views.List (list);
app.main_window.open_view (view);
}
}

public new bool empty {
Expand Down
48 changes: 26 additions & 22 deletions src/Views/Profile.vala
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ public class Tuba.Views.Profile : Views.Timeline {
protected SimpleAction ar_list_action;
// protected SimpleAction source_action;

construct {
cover = build_cover ();
cover.rsbtn.rs = this.rs;
column_view.prepend (cover);
}

public Profile (API.Account acc) {
Object (
profile: acc,
Expand All @@ -31,14 +25,31 @@ public class Tuba.Views.Profile : Views.Timeline {
allow_nesting: true,
url: @"/api/v1/accounts/$(acc.id)/statuses"
);
cover.bind (profile);

cover = new Cover (profile);
cover.rsbtn.rs = this.rs;

build_profile_stats (cover.info);
rs.invalidated.connect (on_rs_updated);

var header_factory = new Gtk.SignalListItemFactory ();
header_factory.setup.connect (on_create_header);
content.header_factory = header_factory;
}
~Profile () {
message ("Destroying Profile view");
}

private void on_create_header (Object object) {
unowned var header = (Gtk.ListHeader) object;
header.child = cover;

// FIXME
Timeout.add_once (250, () => {
scrolled.vadjustment.value = 0.0;
});
}

public bool append_pinned () {
if (source == "statuses") {
new Request.GET (@"/api/v1/accounts/$(profile.id)/statuses")
Expand Down Expand Up @@ -100,12 +111,6 @@ public class Tuba.Views.Profile : Views.Timeline {
message ("Destroying Profile Cover");
}

construct {
if (settings.scale_emoji_hover)
note.add_css_class ("lww-scale-emoji-hover");
settings.notify["scale-emoji-hover"].connect (toggle_scale_emoji_hover);
}

void toggle_scale_emoji_hover () {
Tuba.toggle_css (note, settings.scale_emoji_hover, "lww-scale-emoji-hover");
}
Expand Down Expand Up @@ -156,7 +161,11 @@ public class Tuba.Views.Profile : Views.Timeline {
app.main_window.show_media_viewer_single (avi_url, avatar.custom_image);
}

public void bind (API.Account account) {
public Cover (API.Account account) {
if (settings.scale_emoji_hover)
note.add_css_class ("lww-scale-emoji-hover");
settings.notify["scale-emoji-hover"].connect (toggle_scale_emoji_hover);

display_name.instance_emojis = account.emojis_map;
display_name.content = account.display_name;
handle.label = account.handle;
Expand Down Expand Up @@ -316,7 +325,7 @@ public class Tuba.Views.Profile : Views.Timeline {
private void on_edit_save () {
if (profile.is_self ()) {
rs.invalidated.disconnect (on_rs_updated);
column_view.remove (cover);
// column_view.remove (cover);
cover = null;

for (uint i = 0; i < model.get_n_items (); i++) {
Expand All @@ -326,21 +335,16 @@ public class Tuba.Views.Profile : Views.Timeline {
}
}

cover = build_cover ();
cover = new Cover (accounts.active);
cover.rsbtn.rs = this.rs;
column_view.prepend (cover);
cover.bind (accounts.active);
// column_view.prepend (cover);
build_profile_stats (cover.info);
rs.invalidated.connect (on_rs_updated);

on_refresh ();
}
}

protected virtual Cover build_cover () {
return new Cover ();
}

protected override void build_actions () {
base.build_actions ();

Expand Down
27 changes: 12 additions & 15 deletions src/Views/TabbedBase.vala
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ public class Tuba.Views.TabbedBase : Views.Base {
construct {
base_status = null;

var states_box = states.get_parent () as Gtk.Box;
if (states_box != null)
states_box.remove (states);
view.remove_css_class ("ttl-view");
// var states_box = states.get_parent () as Gtk.Box;
// if (states_box != null)
// states_box.remove (states);
// view.remove_css_class ("ttl-view");

scrolled_overlay.child = null;

var scrolled_overlay_box = scrolled_overlay.get_parent () as Gtk.Box;
if (scrolled_overlay_box != null)
Expand All @@ -24,7 +26,7 @@ public class Tuba.Views.TabbedBase : Views.Base {

stack = new Adw.ViewStack ();
stack.notify["visible-child"].connect (on_view_switched);
content_box.append (stack);
scrolled.child = stack;

switcher_bar.stack = switcher_title.stack = stack;
}
Expand Down Expand Up @@ -52,7 +54,7 @@ public class Tuba.Views.TabbedBase : Views.Base {

public void add_tab (Views.Base view) {
id_counter++;
view.view.add_css_class ("no-transition");
view.content_box.add_css_class ("no-transition");
views += view;
var page = stack.add_titled (view, id_counter.to_string (), view.label);
view.bind_property ("icon", page, "icon-name", BindingFlags.SYNC_CREATE);
Expand Down Expand Up @@ -129,15 +131,10 @@ public class Tuba.Views.TabbedBase : Views.Base {

void on_view_switched () {
var view = stack.visible_child as Views.Base;
if (view.view.has_css_class ("no-transition")) {
// Timeout.add_once // glib 2.7.4
uint timeout = 0;
timeout = Timeout.add (200, () => {
last_view.view.remove_css_class ("no-transition");
GLib.Source.remove (timeout);

return true;
}, Priority.LOW);
if (view.content_box.has_css_class ("no-transition")) {
Timeout.add_once (200, () => {
last_view.content_box.remove_css_class ("no-transition");
});
}

if (last_view != null) {
Expand Down
8 changes: 7 additions & 1 deletion src/Views/Thread.vala
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,13 @@ public class Tuba.Views.Thread : Views.ContentBase, AccountHolder {
on_content_changed ();

#if GTK_4_12
content.scroll_to (to_add_ancestors.length, Gtk.ListScrollFlags.FOCUS, null);
uint timeout = 0;
timeout = Timeout.add (1000, () => {
content.scroll_to (to_add_ancestors.length, Gtk.ListScrollFlags.FOCUS, null);

GLib.Source.remove (timeout);
return true;
}, Priority.LOW);
#endif
})
.exec ();
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/PreviewCard.vala
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class Tuba.Widgets.PreviewCard : Gtk.Button {

if (card_obj.kind == "link" && card_obj.history != null && card_obj.history.size > 0) {
this.remove_css_class ("frame");
// this.add_css_class ("explore");
this.add_css_class ("explore");
this.add_css_class ("card-spacing");
this.add_css_class ("card");
this.add_css_class ("activatable");
Expand Down

0 comments on commit 3b27f53

Please sign in to comment.