Skip to content

Commit

Permalink
stat-window: Fix empty StatWindow (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego-Ivan authored Oct 7, 2023
2 parents 48195f4 + ab13b13 commit 771ce48
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 53 deletions.
22 changes: 5 additions & 17 deletions src/Widgets/StatsWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ namespace Flowtime {
[GtkChild]
private unowned StatList break_list;
[GtkChild]
private unowned Adw.HeaderBar header_bar;
private unowned Gtk.Button save_button;
[GtkChild]
private unowned Gtk.Stack content_stack;

public StatsWindow (Gtk.Window? parent_window) {
Object (
Expand All @@ -27,7 +29,8 @@ namespace Flowtime {
construct {
var statistics = new Services.Statistics ();
if (statistics.total.worktime == 0) {
empty ();
content_stack.visible_child_name = "empty";
save_button.visible = false;
}

foreach (Models.Day day in statistics.all_days) {
Expand Down Expand Up @@ -82,20 +85,5 @@ namespace Flowtime {
critical (e.message);
}
}

private void empty () {
// Empty Header
header_bar.title_widget = null;
header_bar.add_css_class ("flat");
title = "";

// Status Page
var status = new Adw.StatusPage () {
title = _("Start working to see you progress"),
icon_name = "timer-sand-symbolic"
};
status.add_css_class ("compact");
child = status;
}
}
}
82 changes: 46 additions & 36 deletions src/ui/statwindow.blp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ template $FlowtimeStatsWindow : Adw.Window {
}
}

Adw.ToolbarView {
Adw.ToolbarView main_view {
[top]
Adw.HeaderBar header_bar {
title-widget: Adw.ViewSwitcher switcher_title {
Expand All @@ -32,45 +32,55 @@ template $FlowtimeStatsWindow : Adw.Window {
}
}

Box {
orientation: vertical;
Stack content_stack {
StackPage {
name: "main-content";
child: Adw.Clamp {
Adw.ViewStack view_stack {
Adw.ViewStackPage {
title: _("Work Time");
name: "work";
icon-name: "computer-symbolic";
child: ScrolledWindow {
propagate-natural-height: true;
propagate-natural-width: true;

Adw.Clamp {
Adw.ViewStack view_stack {
Adw.ViewStackPage {
title: _("Work Time");
name: "work";
icon-name: "computer-symbolic";
child: ScrolledWindow {
propagate-natural-height: true;
propagate-natural-width: true;
$FlowtimeStatList work_list {
title: _("Work Time");
margin-top: "12";
margin-start: "12";
margin-end: "12";
}
};
}

$FlowtimeStatList work_list {
title: _("Work Time");
margin-top: "12";
margin-start: "12";
margin-end: "12";
}
};
}

Adw.ViewStackPage {
title: _("Break Time");
name: "break";
icon-name: "cafe-symbolic";
child: ScrolledWindow {
propagate-natural-height: true;
propagate-natural-width: true;
Adw.ViewStackPage {
title: _("Break Time");
name: "break";
icon-name: "cafe-symbolic";
child: ScrolledWindow {
propagate-natural-height: true;
propagate-natural-width: true;

$FlowtimeStatList break_list {
title: _("Break Time");
margin-top: "6";
margin-start: "12";
margin-end: "12";
}
};
$FlowtimeStatList break_list {
title: _("Break Time");
margin-top: "6";
margin-start: "12";
margin-end: "12";
}
};
}
}
}
};
}

StackPage {
name: "empty";
child: Adw.StatusPage {
styles["compact"]
title: _("Start working to see your progress");
icon-name: "timer-sand-symbolic";
};
}
}

Expand Down

0 comments on commit 771ce48

Please sign in to comment.