mirror of
https://codeberg.org/vyn/selenite.git
synced 2025-07-02 01:23:23 +00:00
First commit
This commit is contained in:
commit
dd0c8c326a
16 changed files with 534 additions and 0 deletions
48
DatePicker.slint
Normal file
48
DatePicker.slint
Normal file
|
@ -0,0 +1,48 @@
|
|||
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 }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue