mirror of
https://codeberg.org/vyn/selenite.git
synced 2025-07-01 09:13:19 +00:00
48 lines
1.1 KiB
Text
48 lines
1.1 KiB
Text
import { Button, DatePickerPopup, Date, Palette } from "std-widgets.slint";
|
|
import { VLabeledComponent } from "LabeledComponent.slint";
|
|
import { VActionButton } from "ActionButton.slint";
|
|
import { VButton } from "Button.slint";
|
|
import { Svg } from "Svg.slint";
|
|
|
|
export component VDatePicker inherits VLabeledComponent {
|
|
in-out property<Date> date;
|
|
in-out property<string> dateDisplay;
|
|
|
|
pure function formatZeroPadding(number: int) -> string {
|
|
if (number < 10) {
|
|
return "0\{number}";
|
|
}
|
|
return number;
|
|
}
|
|
|
|
pure function getDateDisplay() -> string {
|
|
if (date.year == 0) {
|
|
return "Unscheduled";
|
|
}
|
|
return formatZeroPadding(date.day) + "/" + formatZeroPadding(date.month) + "/" + date.year;
|
|
}
|
|
|
|
function resetDate() {
|
|
date.year = 0;
|
|
date.month = 0;
|
|
date.day = 0;
|
|
}
|
|
|
|
HorizontalLayout {
|
|
VButton {
|
|
text: getDateDisplay();
|
|
enabled: root.enabled;
|
|
clicked => { taskDateInput.show() }
|
|
}
|
|
VActionButton {
|
|
icon-svg: Svg.reset;
|
|
icon-svg-stroke-width: 1px;
|
|
enabled: root.enabled;
|
|
clicked => { resetDate() }
|
|
}
|
|
}
|
|
|
|
taskDateInput := DatePickerPopup {
|
|
accepted(date) => { root.date = date }
|
|
}
|
|
}
|