Add new 'Add task/event' bar directly in the main view

This commit is contained in:
Vyn 2024-10-09 17:07:17 +02:00
parent 534da46a26
commit 2aa039e5fc
18 changed files with 399 additions and 51 deletions

49
external/slint-vynui/ActionButton.slint vendored Normal file
View file

@ -0,0 +1,49 @@
import { Palette } from "Palette.slint";
import { VText } from "Text.slint";
export component VActionButton inherits Rectangle {
in property<image> icon-source;
in property<brush> icon-colorize: Palette.foreground;
in property<length> icon-size: 1rem;
in property<string> icon-svg;
in property enabled <=> ta.enabled;
callback clicked;
private property<bool> active: false;
background: enabled ? Palette.control-background : Palette.control-background.darker(0.2);
border-radius: 4px;
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
active = !active;
root.clicked();
}
}
HorizontalLayout {
alignment: center;
spacing: 8px;
padding: 8px;
if root.icon-svg != "" : VerticalLayout {
alignment: center;
Path {
padding: 8px;
commands: root.icon-svg;
stroke: icon-colorize;
stroke-width: 2px;
width: icon-size;
height: icon-size;
fill: icon-colorize;
}
}
if root.icon-source.width != 0 : Image {
padding: 8px;
source: icon-source;
colorize: icon-colorize;
width: icon-size;
}
}
}

9
external/slint-vynui/BurgerIcon.slint vendored Normal file
View file

@ -0,0 +1,9 @@
import { Palette } from "./Palette.slint";
export component BurgerIcon inherits Path {
width: 32px;
height: 32px;
commands: "M3 6h18M3 12h18M3 18h18";
stroke: Palette.foreground;
stroke-width: 2px;
}

View file

@ -5,9 +5,11 @@ export component VButton inherits Rectangle {
in property<string> text;
in property<brush> text-color: Palette.foreground;
in property<length> text-size: 1rem;
in property<image> icon-source;
in property<brush> icon-colorize;
in property<brush> icon-colorize: Palette.foreground;
in property<length> icon-size: 1rem;
in property <string> icon-svg;
in property enabled <=> ta.enabled;
callback clicked;
@ -27,9 +29,20 @@ export component VButton inherits Rectangle {
HorizontalLayout {
alignment: center;
spacing: 8px;
padding: 8px;
padding: 16px;
padding-top: 4px;
padding-bottom: 4px;
if root.icon-svg != "" : VerticalLayout {
alignment: center;
Path {
padding: 8px;
commands: root.icon-svg;
stroke: icon-colorize;
stroke-width: 2px;
width: icon-size;
height: icon-size;
}
}
if root.icon-source.width != 0 : Image {
padding: 8px;
source: icon-source;
@ -39,6 +52,7 @@ export component VButton inherits Rectangle {
if root.text != "" : VerticalLayout {
VText {
text: root.text;
font-size: root.text-size;
color: root.text-color;
horizontal-alignment: center;
}

View file

@ -2,21 +2,59 @@ import { Palette } from "Palette.slint";
import { VText } from "Text.slint";
export component VLabeledComponent {
in property<string> label <=> labelComponent.text;
in property<string> label;
in property<length> label-size: 1rem;
in property <TextHorizontalAlignment> label-alignment: TextHorizontalAlignment.left;
in property<bool> enabled: true;
in property<bool> no-background: false;
function calc-background() -> brush {
if (no-background == true) {
return Palette.control-background.transparentize(1);
}
if (enabled == false) {
return Palette.control-background.darker(0.2);
}
return Palette.control-background;
}
VerticalLayout {
labelComponent := VText {
}
if root.label != "" : VerticalLayout {
padding-left: 4px;
padding-right: 4px;
VText {
text: root.label;
font-size: label-size;
horizontal-alignment: root.label-alignment;
}
}
Rectangle {
background: enabled ? Palette.control-background : Palette.control-background.darker(0.2);
background: calc-background();
border-radius: 4px;
VerticalLayout {
padding: 4px;
@children
}
}
}
}
export component CommonComponentBackground {
in property<bool> enabled: true;
in property<bool> no-background: false;
function calc-background() -> brush {
if (no-background == true) {
return Palette.control-background.transparentize(1);
}
if (enabled == false) {
return Palette.control-background.darker(0.2);
}
return Palette.control-background;
}
Rectangle {
background: calc-background();
@children
}
}

34
external/slint-vynui/Slider.slint vendored Normal file
View file

@ -0,0 +1,34 @@
import { VLabeledComponent } from "LabeledComponent.slint";
import { Palette } from "Palette.slint";
import { Slider } from "std-widgets.slint";
import { VText } from "Text.slint";
export component VSlider inherits VLabeledComponent {
in property <bool> show-value;
in-out property <float> value;
init => {
sliderComponent.value = root.value;
}
pure callback format-value(float) -> string;
format-value(value) => {
return "\{value}";
}
callback released <=> sliderComponent.released;
in property minimum <=> sliderComponent.minimum;
in property maximum <=> sliderComponent.maximum;
VerticalLayout {
spacing: 8px;
VText {
horizontal-alignment: center;
text: format-value(sliderComponent.value);
color: Palette.foreground-hint;
}
sliderComponent := Slider {
}
}
}

View file

@ -1,13 +1,31 @@
import { VLabeledComponent } from "LabeledComponent.slint";
import { Palette } from "Palette.slint";
import { VText } from "Text.slint";
export component VTextInput inherits VLabeledComponent {
in-out property text <=> textInputComponent.text;
out property has-focus <=> textInputComponent.has-focus;
in-out property placeholder <=> textInputComponent.accessible-placeholder-text;
in-out property wrap <=> textInputComponent.wrap;
callback accepted();
textInputComponent := TextInput {
color: Palette.foreground;
accepted => { root.accepted() }
VerticalLayout {
padding: 4px;
padding-left: 8px;
padding-right: 8px;
textInputComponent := TextInput {
color: Palette.foreground;
accepted => { root.accepted() }
HorizontalLayout {
alignment: start;
VText {
visible: textInputComponent.text == "";
color: Palette.foreground-hint;
text: root.placeholder;
}
}
}
}
}

View file

@ -6,9 +6,9 @@ export component ToggleButton inherits Rectangle {
in property text <=> text-component.text;
in property text-color <=> text-component.color;
in property text-alignment <=> text-component.horizontal-alignment;
in property<bool> active: false;
callback clicked;
private property<bool> active: false;
background: root.active ? Palette.control-background
: ta.has-hover ? Palette.control-background.transparentize(0.5)
@ -18,7 +18,6 @@ export component ToggleButton inherits Rectangle {
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
active = !active;
root.clicked();
}
}

View file

@ -1,11 +1,15 @@
export { Palette } from "Palette.slint";
export { VButton } from "Button.slint";
export { VActionButton } from "ActionButton.slint";
export { VText } from "Text.slint";
export { VCheckBox } from "CheckBox.slint";
export { VDatePicker } from "DatePicker.slint";
export { VTimePicker } from "TimePicker.slint";
export { VLabeledComponent } from "LabeledComponent.slint";
export { VLabeledComponent, CommonComponentBackground } from "LabeledComponent.slint";
export { VPopupIconMenu } from "PopupIconMenu.slint";
export { VTag } from "Tag.slint";
export { VTextInput } from "TextInput.slint";
export { VSlider } from "Slider.slint";
export { ToggleButton } from "ToggleButton.slint";
export { BurgerIcon } from "BurgerIcon.slint";