Skip to content

Commit

Permalink
feat: добавить надпись об отсутствии результатов поиска в `Cassette.S…
Browse files Browse the repository at this point in the history
…tationsView`
  • Loading branch information
Rirusha committed May 18, 2024
1 parent fbf4615 commit a4b242d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
12 changes: 12 additions & 0 deletions data/ui/stations-view.blp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,18 @@ template $CassetteStationsView: $CassetteBaseView {
valign: start;
};
}

StackPage {
name: "no-results";

child: Adw.StatusPage {
vexpand: true;
valign: center;

icon-name: "edit-find-symbolic";
title: _("No stations with that name were found");
};
}
}
}
};
Expand Down
15 changes: 14 additions & 1 deletion src/widgets/views/stations.vala
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class Cassette.StationsView : BaseView {
[GtkChild]
unowned Gtk.FlowBox search_flow_box;

uint visible_search_childs_n = 0;

public override bool can_refresh { get; default = true; }

construct {
Expand All @@ -51,6 +53,7 @@ public class Cassette.StationsView : BaseView {
var action_card = (ActionCardStation) item.child;

if (search_entry.text.down () in action_card.station_info.name.down ()) {
visible_search_childs_n += 1;
return true;
}

Expand All @@ -63,9 +66,19 @@ public class Cassette.StationsView : BaseView {
}

async void search_entry_search_changed_async () {
visible_search_childs_n = 0;

search_flow_box.invalidate_filter ();

stack.visible_child_name = search_entry.text == "" ? "default" : "search";
if (search_entry.text == "") {
stack.visible_child_name = "default";

} else if (visible_search_childs_n != 0) {
stack.visible_child_name = "search";

} else {
stack.visible_child_name = "no-results";
}
}

void clear_all_boxes () {
Expand Down

0 comments on commit a4b242d

Please sign in to comment.