20
20
*/
21
21
22
22
public class Widgets.ScheduleButton : Gtk .Grid {
23
+ public bool is_board { get ; construct; }
24
+
23
25
private Gtk . Label due_label;
24
26
25
27
private Gtk . Box schedule_box;
@@ -54,13 +56,29 @@ public class Widgets.ScheduleButton : Gtk.Grid {
54
56
55
57
public ScheduleButton () {
56
58
Object (
59
+ is_board: false ,
57
60
valign: Gtk . Align . CENTER ,
58
61
halign: Gtk . Align . CENTER ,
59
62
tooltip_text: _(" Schedule" )
60
63
);
61
64
}
62
65
66
+ public ScheduleButton.for_board () {
67
+ Object (
68
+ is_board: true ,
69
+ tooltip_text: _(" Schedule" )
70
+ );
71
+ }
72
+
63
73
construct {
74
+ if (is_board) {
75
+ build_card_ui ();
76
+ } else {
77
+ build_ui ();
78
+ }
79
+ }
80
+
81
+ private void build_ui () {
64
82
datetime_picker = new Widgets .DateTimePicker .DateTimePicker ();
65
83
66
84
due_image = new Gtk .Image ();
@@ -91,7 +109,7 @@ public class Widgets.ScheduleButton : Gtk.Grid {
91
109
};
92
110
93
111
attach (button, 0 , 0 );
94
- attach (clear_revealer, 1 , 0 );
112
+ attach (clear_revealer, 1 , 0 );
95
113
96
114
datetime_picker. date_changed. connect (() = > {
97
115
datetime = datetime_picker. datetime;
@@ -118,55 +136,118 @@ public class Widgets.ScheduleButton : Gtk.Grid {
118
136
});
119
137
}
120
138
139
+ private void build_card_ui () {
140
+ due_image = new Gtk .Image .from_icon_name (" month-symbolic" );
141
+
142
+ var title_label = new Gtk .Label (_(" Schedule" )) {
143
+ halign = START ,
144
+ css_classes = { " title-4" , " small-label" }
145
+ };
146
+
147
+ due_label = new Gtk .Label (_(" Set a Due Date" )) {
148
+ xalign = 0 ,
149
+ use_markup = true ,
150
+ halign = START ,
151
+ ellipsize = Pango . EllipsizeMode . END ,
152
+ css_classes = { " small-label" }
153
+ };
154
+
155
+ var card_grid = new Gtk .Grid () {
156
+ column_spacing = 12 ,
157
+ margin_start = 12 ,
158
+ margin_end = 6 ,
159
+ margin_top = 6 ,
160
+ margin_bottom = 6 ,
161
+ vexpand = true ,
162
+ hexpand = true
163
+ };
164
+ card_grid. attach (due_image, 0 , 0 , 1 , 2 );
165
+ card_grid. attach (title_label, 1 , 0 , 1 , 1 );
166
+ card_grid. attach (due_label, 1 , 1 , 1 , 1 );
167
+
168
+ datetime_picker = new Widgets .DateTimePicker .DateTimePicker () {
169
+ position = Gtk . PositionType . BOTTOM ,
170
+ has_arrow = true
171
+ };
172
+ datetime_picker. set_parent (card_grid);
173
+
174
+ css_classes = { " card" };
175
+ attach (card_grid, 0 , 0 );
176
+ hexpand = true ;
177
+ vexpand = true ;
178
+
179
+ var click_gesture = new Gtk .GestureClick ();
180
+ card_grid. add_controller (click_gesture);
181
+ click_gesture. pressed. connect ((n_press, x, y) = > {
182
+ datetime_picker. show ();
183
+ });
184
+
185
+ datetime_picker. date_changed. connect (() = > {
186
+ datetime = datetime_picker. datetime;
187
+ date_changed (datetime);
188
+ });
189
+ }
190
+
121
191
public void update_from_item (Objects .Item item ) {
122
- due_label. label = _(" Schedule" );
123
- tooltip_text = _(" Schedule" );
124
- due_image. icon_name = " month-symbolic" ;
125
-
126
- if (item. has_due) {
127
- due_label. label = Util . get_default (). get_relative_date_from_date (item. due. datetime);
128
-
129
- datetime = new GLib .DateTime .local (
130
- item. due. datetime. get_year (),
131
- item. due. datetime. get_month (),
132
- item. due. datetime. get_day_of_month (),
133
- item. due. datetime. get_hour (),
134
- item. due. datetime. get_minute (),
135
- item. due. datetime. get_second ()
136
- );
137
-
138
- if (Util . get_default (). is_today (item. due. datetime)) {
139
- due_image. icon_name = " star-outline-thick-symbolic" ;
140
- } else if (Util . get_default (). is_overdue (item. due. datetime)) {
192
+ if (is_board) {
193
+ due_label. label = _(" Set a Due Date" );
194
+ tooltip_text = _(" Schedule" );
195
+ due_image. icon_name = " month-symbolic" ;
196
+ } else {
197
+ due_label. label = _(" Schedule" );
198
+ tooltip_text = _(" Schedule" );
199
+ due_image. icon_name = " month-symbolic" ;
200
+ }
141
201
142
- } else {
143
- due_image. icon_name = " month-symbolic" ;
144
- }
202
+ if (! item. has_due) {
203
+ return ;
204
+ }
205
+
206
+ due_label. label = Util . get_default (). get_relative_date_from_date (item. due. datetime);
207
+ due_label. tooltip_text = due_label. label;
208
+
209
+ datetime = new GLib .DateTime .local (
210
+ item. due. datetime. get_year (),
211
+ item. due. datetime. get_month (),
212
+ item. due. datetime. get_day_of_month (),
213
+ item. due. datetime. get_hour (),
214
+ item. due. datetime. get_minute (),
215
+ item. due. datetime. get_second ()
216
+ );
217
+
218
+ if (Util . get_default (). is_today (item. due. datetime)) {
219
+ due_image. icon_name = " star-outline-thick-symbolic" ;
220
+ } else if (Util . get_default (). is_tomorrow (item. due. datetime)) {
221
+ due_image. icon_name = " today-calendar-symbolic" ;
222
+ } else if (Util . get_default (). is_overdue (item. due. datetime)) {
223
+ due_image. icon_name = " month-symbolic" ;
224
+ } else {
225
+ due_image. icon_name = " month-symbolic" ;
226
+ }
145
227
146
- if (item. due. is_recurring) {
147
- var end_label = " " ;
148
- if (item. due. end_type == RecurrencyEndType . ON_DATE ) {
149
- var date_label = Util . get_default (). get_default_date_format_from_date (
150
- Util . get_default (). get_format_date (
151
- Utils . Datetime . get_date_from_string (item. due. recurrency_end)
152
- )
153
- );
154
- end_label = _(" until" ) + " " + date_label;
155
- } else if (item. due. end_type == RecurrencyEndType . AFTER ) {
156
- int count = item. due. recurrency_count;
157
- end_label = _(" for" ) + " " + " %d %s " . printf (count, count > 1 ? _(" times" ) : _(" time" ));
158
- }
159
-
160
- due_image. icon_name = " arrow-circular-top-right-symbolic" ;
161
- due_label. label + = " <small>%s </small>" . printf (
162
- Util . get_default (). get_recurrency_weeks (
163
- item. due. recurrency_type,
164
- item. due. recurrency_interval,
165
- item. due. recurrency_weeks,
166
- end_label
228
+ if (item. due. is_recurring) {
229
+ var end_label = " " ;
230
+ if (item. due. end_type == RecurrencyEndType . ON_DATE ) {
231
+ var date_label = Util . get_default (). get_default_date_format_from_date (
232
+ Util . get_default (). get_format_date (
233
+ Utils . Datetime . get_date_from_string (item. due. recurrency_end)
167
234
)
168
- );
235
+ );
236
+ end_label = _(" until" ) + " " + date_label;
237
+ } else if (item. due. end_type == RecurrencyEndType . AFTER ) {
238
+ int count = item. due. recurrency_count;
239
+ end_label = _(" for" ) + " " + " %d %s " . printf (count, count > 1 ? _(" times" ) : _(" time" ));
169
240
}
241
+
242
+ due_image. icon_name = " arrow-circular-top-right-symbolic" ;
243
+ due_label. label + = " <small>%s </small>" . printf (
244
+ Util . get_default (). get_recurrency_weeks (
245
+ item. due. recurrency_type,
246
+ item. due. recurrency_interval,
247
+ item. due. recurrency_weeks,
248
+ end_label
249
+ )
250
+ );
170
251
}
171
252
}
172
253
0 commit comments