idk what I did last

This commit is contained in:
Ide
2026-06-12 19:24:39 +02:00
parent c00e3205cd
commit b3dd373403
6 changed files with 147 additions and 13 deletions
+34 -6
View File
@@ -7,9 +7,11 @@ import {
CheckBox,
ScrollView,
GridBox,
HorizontalBox,
ComboBox,
} from "std-widgets.slint";
import { SettingsView } from "settings.slint";
import { State, SItem } from "state.slint";
import { State, SItem, SButtonItem } from "state.slint";
export { State, SItem }
@@ -177,25 +179,24 @@ component GoodsListAdd {
}
component GoodButtons inherits ScrollView {
in property <[string]> favorites: ["Mjölk", "Ost", "Ägg", "Bullens", "Oboy", "Mjöl", "Havregryn", "KrosTom"];
in property <int> button-width: 100;
in property <int> button-height: 60;
in property <int> button-spacing: 10;
property <int> count-x: floor(root.width / 1pt / (button-width + button-spacing));
property <int> count-y: ceil(favorites.length / count-x);
property <int> count-y: ceil(State.favorites.length / count-x);
viewport-height: (count-y * (button-height + button-spacing)) * 1pt;
mouse-drag-pan-enabled: true;
for item[idx] in favorites: Button {
for item[idx] in State.favorites: Button {
x: floor(mod(idx, count-x)) * (root.button-width + root.button-spacing) * 1pt;
y: floor(idx / count-x) * (root.button-height + root.button-spacing) * 1pt;
width: root.button-width * 1pt;
height: root.button-height * 1pt;
text: item;
text: item.name;
clicked => {
State.add-to-list(item);
State.add-to-list(item.name);
}
}
}
@@ -278,6 +279,26 @@ component ShopView inherits VerticalLayout {
}
}
component CatItem inherits HorizontalBox {
in-out property <SButtonItem> item;
Text {
text: item.name;
}
ComboBox {
model: ["kyl", "skafferi", "frys", "övrigt"];
current-value: item.category;
}
}
component CatView inherits VerticalLayout {
in-out property <[SButtonItem]> cats;
for item in cats: CatItem {
item: item;
}
}
export component App inherits Window {
preferred-height: 700px;
@@ -297,6 +318,13 @@ export component App inherits Window {
}
}
Tab {
title: "Categories";
CatView {
cats <=> State.favorites;
}
}
Tab {
title: "Settings";
SettingsView { }