Skip to content
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.

Commit

Permalink
Update list design.
Browse files Browse the repository at this point in the history
  • Loading branch information
naz013 committed Feb 20, 2019
1 parent 5825d4c commit dfd24ed
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 27 deletions.
20 changes: 15 additions & 5 deletions data/com.github.naz013.tasks.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,21 @@
</screenshot>
</screenshots>
<releases>
<release version="1.0.0" date="2019-02-11">
<description>
<p>Simple reminder application</p>
</description>
</release>
<release version="1.0.2" date="2019-02-20">
<description>
<p>Update list design</p>
</description>
</release>
<release version="1.0.1" date="2019-02-18">
<description>
<p>Update create panel design</p>
</description>
</release>
<release version="1.0.0" date="2019-02-11">
<description>
<p>Simple reminder application</p>
</description>
</release>
</releases>
<custom>
<value key="x-appcenter-color-primary">#E6AB6A</value>
Expand Down
5 changes: 5 additions & 0 deletions data/com.github.naz013.tasks.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,10 @@
<summary>Screen fullscreen</summary>
<description>Save if was screen fullscreen</description>
</key>
<key name="is-multi" type="b">
<default>false</default>
<summary>Multicolumn View</summary>
<description>Save if Multicolumn View enabled</description>
</key>
</schema>
</schemalist>
6 changes: 6 additions & 0 deletions src/TasksWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,12 @@ namespace Tasks {
init_theme(theme);
update_theme();
});
settings_view.multi_changed.connect((is_multi) => {
AppSettings.get_default().is_multi = is_multi;
if (main_view != null) {
main_view.refresh_list(tasks);
}
});
settings_view.show_all();

popover = new Gtk.Popover (null);
Expand Down
1 change: 1 addition & 0 deletions src/config/AppSettings.vala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Tasks {
public uint last_id { get; set; }
public bool is_maximized { get; set; }
public bool is_fullscreen { get; set; }
public bool is_multi { get; set; }

public static unowned AppSettings get_default () {
if (instance == null) {
Expand Down
18 changes: 7 additions & 11 deletions src/ui/CssData.vala
Original file line number Diff line number Diff line change
Expand Up @@ -581,18 +581,14 @@ namespace Tasks {
background: transparent;
}
.material_fab horizontal {
background: transparent;
background-blend-mode: multiply;
}
.material_fab {
border-radius: 25px;
color: #fff;
border: 0px;
padding-top: 8px;
padding-bottom: 8px;
background-color: @accentColor;
background-blend-mode: screen;
box-shadow: 0 1px 2px @shadowColor, 0 1px 2px @shadowOutColor;
transition: all 0.1s ease-in-out;
}
Expand All @@ -604,6 +600,7 @@ namespace Tasks {
padding-top: 8px;
padding-bottom: 8px;
background-color: @accentColor;
background-blend-mode: screen;
box-shadow: 0 1px 3px @shadowColor, 0 1px 3px @shadowOutColor;
}
Expand All @@ -614,6 +611,7 @@ namespace Tasks {
padding-top: 8px;
padding-bottom: 8px;
background-color: @accentColor;
background-blend-mode: screen;
box-shadow: 0 1px 4px @shadowColor, 0 1px 4px @shadowOutColor;
}
Expand All @@ -622,6 +620,7 @@ namespace Tasks {
color: @textColorDisabled;
border: 0px;
background-color: @buttonDisabledColor;
background-blend-mode: screen;
box-shadow: none;
}
Expand Down Expand Up @@ -836,21 +835,18 @@ namespace Tasks {
}
.mainwindow {
background: linear-gradient(@bgTopColor, @bgBottomColor);
background-blend-mode: multiply;
background: @bgColor;
box-shadow: @shadowColor;
}
.popover {
background: linear-gradient(@bgColor, @bgColor);
background: @bgColor;
box-shadow: @shadowColor;
background-blend-mode: multiply;
}
.window textview.view text,
.window headerbar {
background: @bgTopColor;
background-blend-mode: multiply;
background: @bgColor;
box-shadow: none;
}
""");
Expand Down
124 changes: 114 additions & 10 deletions src/ui/ListView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ namespace Tasks {
public signal void on_copy(Event task);

private Gtk.ListBox list_box;
private Gtk.Popover? popover;
private int state = 1;
private Gee.ArrayList<Event> m_tasks;

public ListView(Gee.ArrayList<Event> tasks) {
Gtk.ScrolledWindow scrolled = new Gtk.ScrolledWindow (null, null);
Expand All @@ -25,18 +28,97 @@ namespace Tasks {

refresh_list(tasks);
scrolled.show_all();
size_allocate.connect((allocation) => {
if (is_multi()) {
update_state(allocation.width);
}
});
add(scrolled);
}

private bool is_multi() {
return AppSettings.get_default().is_multi;
}

public void refresh_view() {
if (m_tasks != null) {
refresh_list(m_tasks);
}
}

public void update_state(int width) {
int _state = new_state(width);
if (_state != state) {
state = _state;
refresh_view();
}
}

public void refresh_list(Gee.ArrayList<Event> tasks) {
list_box.forall ((element) => list_box.remove (element));
m_tasks = tasks;
list_box.foreach ((element) => list_box.remove (element));
tasks.sort(comparator);
Event? prev_task = null;
for (int i = 0; i < tasks.size; i++) {
Event task = tasks.get(i);
list_box.add(get_row(task, prev_task, i == tasks.size - 1));
prev_task = new Event.full_copy(task);
if (!is_multi() || state == 1) {
Event? prev_task = null;
for (int i = 0; i < tasks.size; i++) {
Event task = tasks.get(i);
list_box.add(get_row(task, prev_task, i == tasks.size - 1, true));
prev_task = new Event.full_copy(task);
}
} else {
Event? prev_task = null;
int count = 0;
Gtk.Grid grid = new_grid();
for (int i = 0; i < tasks.size; i++) {
Event task = tasks.get(i);
var row = get_row(task, prev_task, i == tasks.size - 1, false);
count++;
if (is_same(task, prev_task)) {
grid.add(row);
Logger.log(@"refresh_list: same");
if (count == state) {
Logger.log(@"refresh_list: 1");
list_box.add(pack_grid(add_empty(grid, count)));
grid = new_grid();
count = 0;
}
} else {
Logger.log(@"refresh_list: not same");
if (i != 0) {
Logger.log(@"refresh_list: 2");
list_box.add(pack_grid(add_empty(grid, count - 1)));
count = 0;
}
list_box.add(pack_grid(get_header(task)));
grid = new_grid();
grid.add(row);
if (i == tasks.size - 1) {
Logger.log(@"refresh_list: 3");
list_box.add(pack_grid(add_empty(grid, 1)));
count = 0;
}
}

prev_task = new Event.full_copy(task);
}
}
}

private Gtk.Grid add_empty(Gtk.Grid grid, int count) {
if (count == state) return grid;
Logger.log(@"add_empty: $count, $state");
for (int i = count; i < state; i++) {
grid.add(new_grid());
}
return grid;
}

private Gtk.Grid new_grid() {
Gtk.Grid grid = new Gtk.Grid();
grid.hexpand = true;
grid.set_column_homogeneous(true);
grid.orientation = Gtk.Orientation.HORIZONTAL;
return grid;
}

public int comparator (Event a, Event b) {
Expand Down Expand Up @@ -65,6 +147,20 @@ namespace Tasks {
}
}

private int new_state(int width) {
if (width < 650) return 1;
else if (width < 1300) return 2;
else if (width < 1950) return 3;
else if (width < 2600) return 4;
else if (width < 3250) return 5;
else return 6;
}

private bool is_same(Event task, Event? prev) {
if (prev == null) return false;
else return task.is_active == prev.is_active;
}

private Gtk.Widget? get_header_view(Event task, Event? prev) {
if (prev != null) {
if (task.is_active == prev.is_active) {
Expand Down Expand Up @@ -105,8 +201,6 @@ namespace Tasks {
return view;
}

private Gtk.Popover? popover;

private void hide_popover() {
if (popover != null) {
popover.popdown();
Expand Down Expand Up @@ -165,7 +259,17 @@ namespace Tasks {
return button;
}

private Gtk.ListBoxRow get_row(Event task, Event? prev, bool is_last) {
private Gtk.ListBoxRow pack_grid(Gtk.Widget grid) {
var row = new Gtk.ListBoxRow();
row.hexpand = true;
row.vexpand = false;
row.set_selectable(false);
row.add(grid);
row.show_all();
return row;
}

private Gtk.ListBoxRow get_row(Event task, Event? prev, bool is_last, bool add_header) {
var row = new Gtk.ListBoxRow();
row.hexpand = true;
row.vexpand = false;
Expand All @@ -176,7 +280,7 @@ namespace Tasks {
grid.hexpand = true;

var header_view = get_header_view(task, prev);
if (header_view != null) {
if (add_header && header_view != null) {
grid.add(header_view);
}

Expand Down
44 changes: 43 additions & 1 deletion src/ui/SettingsView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Tasks {
public class SettingsView : Gtk.EventBox {

public signal void theme_selected(int theme);
public signal void multi_changed(bool is_multi);

public SettingsView() {
var color_button_light = new Gtk.RadioButton (null);
Expand Down Expand Up @@ -107,7 +108,48 @@ namespace Tasks {
theme_button_click(color_button_green_gradient, 5);
theme_button_click(color_button_sunset, 6);

add(menu_grid);
var multi_switch = new Gtk.Switch();
multi_switch.vexpand = false;
multi_switch.active = AppSettings.get_default().is_multi;
multi_switch.notify["active"].connect (() => {
multi_changed(multi_switch.active);
});
multi_switch.get_style_context().add_class(CssData.MATERIAL_SWITCH);

var multi_label = new Gtk.Button.with_label (_("Multicolumn View"));
multi_label.clicked.connect (() => {
multi_switch.active = !multi_switch.active;
});
multi_label.get_style_context().add_class(CssData.MATERIAL_BUTTON_FLAT);

var box = new Gtk.Fixed();
box.hexpand = true;
box.vexpand = false;

var box1 = new Gtk.Fixed();
box1.hexpand = true;
box1.vexpand = false;

var multi_grid = new Gtk.Grid ();
multi_grid.column_spacing = 8;
multi_grid.hexpand = true;
multi_grid.orientation = Gtk.Orientation.HORIZONTAL;
multi_grid.add(box);
multi_grid.add(multi_label);
multi_grid.add(multi_switch);
multi_grid.add(box1);

var grid = new Gtk.Grid ();
grid.margin_bottom = 3;
grid.column_spacing = 12;
grid.margin = 12;
grid.orientation = Gtk.Orientation.VERTICAL;

grid.add(multi_grid);
grid.add(menu_grid);
grid.show_all();

add(grid);
}

private void theme_button_click(Gtk.RadioButton button, int theme) {
Expand Down

0 comments on commit dfd24ed

Please sign in to comment.