Skip to content

Commit

Permalink
Refactor: Reuse He.ViewTitle instance to update appbar titles
Browse files Browse the repository at this point in the history
- Introduced a single `He.ViewTitle` instance for updating the appbar titles.
- Simplified the code by removing redundant instantiations of `He.ViewTitle`.
- Updated the title labels directly on the existing `He.ViewTitle` instance.
  • Loading branch information
lainsce committed Sep 3, 2024
1 parent f158625 commit ab19027
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -128,23 +128,23 @@ public class Mondai.MainWindow : He.ApplicationWindow {
actions.add_action_entries (ACTION_ENTRIES, this);
insert_action_group ("win", actions);

var title = new He.ViewTitle ();

stack.visible_child_name = "select";
appbar.viewtitle_widget = null;
appbar.viewtitle_widget = new He.ViewTitle () { label = _("Select Component") };
appbar.viewtitle_widget = title;
title.label = _("Select Component");
appbar.show_back = false;
appbar.scroller = s;

to_describe.clicked.connect (() => {
stack.visible_child_name = "describe";
appbar.viewtitle_widget = null;
appbar.viewtitle_widget = new He.ViewTitle () { label = _("Describe Issue") };
title.label = _("Describe Issue");
appbar.scroller = s1;
appbar.show_back = true;

appbar.back_button.clicked.connect (() => {
stack.visible_child_name = "select";
appbar.viewtitle_widget = null;
appbar.viewtitle_widget = new He.ViewTitle () { label = _("Select Component") };
title.label = _("Select Component");
appbar.show_back = false;
appbar.scroller = s;
});
Expand All @@ -153,14 +153,12 @@ public class Mondai.MainWindow : He.ApplicationWindow {
submit.clicked.connect (() => {
submit_report.begin (() => {
stack.visible_child_name = "submitted";
appbar.viewtitle_widget = null;
appbar.viewtitle_widget = new He.ViewTitle () { label = _("Report submitted!") };
title.label = _("Report submitted!");
appbar.scroller = s2;

appbar.back_button.clicked.connect (() => {
stack.visible_child_name = "describe";
appbar.viewtitle_widget = null;
appbar.viewtitle_widget = new He.ViewTitle () { label = _("Select Component") };
title.label = _("Select Component");
appbar.scroller = s1;
});
});
Expand Down

0 comments on commit ab19027

Please sign in to comment.