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

stat-window: Fix empty StatWindow #73

Merged
merged 1 commit into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
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