mirror of
https://github.com/hulthe/inkopslista.git
synced 2026-08-03 23:11:28 +02:00
idk what I did last
This commit is contained in:
+34
-6
@@ -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 { }
|
||||
|
||||
@@ -4,6 +4,10 @@ export struct SItem {
|
||||
amount: int,
|
||||
}
|
||||
|
||||
export struct SButtonItem{
|
||||
name: string,
|
||||
category: string}
|
||||
|
||||
export global State {
|
||||
in-out property <[SItem]> list: [
|
||||
{ name: "Test 1", checked: true },
|
||||
@@ -17,6 +21,11 @@ export global State {
|
||||
callback inc-amount(string);
|
||||
callback dec-amount(string);
|
||||
in-out property <string> server-address;
|
||||
in property <[SButtonItem]> favorites: [
|
||||
{ name: "mjölk", category: "kyl" },
|
||||
{ name: "ost", category: "kyl" },
|
||||
];
|
||||
|
||||
callback set-server-address(string);
|
||||
set-server-address(address) => {
|
||||
server-address = address;
|
||||
|
||||
Reference in New Issue
Block a user