Compare commits
8
Commits
ac4aaeaa9d
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fddcbc7d77
|
||
|
|
2f925849a7
|
||
|
|
c4a21d8d9c
|
||
|
|
231f964ac8 | ||
|
|
f11cb56c12
|
||
|
|
e6024a06f6
|
||
|
|
05a7158ca1 | ||
|
|
3278169897 |
No files matched your search
Generated
+1005
-1326
File diff suppressed because it is too large.
Load diff
@@ -5,3 +5,12 @@ members = [
|
||||
"srv",
|
||||
"gui",
|
||||
]
|
||||
|
||||
# Enable max optimizations for dependencies, but not for our code:
|
||||
# Very helpful when developing in Slint.
|
||||
[profile.dev.package."*"]
|
||||
opt-level = 3
|
||||
|
||||
# Enable only a small amount of optimization in debug mode
|
||||
[profile.dev]
|
||||
opt-level = 1
|
||||
+2
-3
@@ -39,7 +39,7 @@ serde_json = "1.0.148"
|
||||
anyhow = "1.0.100"
|
||||
|
||||
[dependencies.slint]
|
||||
version = "1.17.1"
|
||||
version = "1.18.0"
|
||||
default-features = false
|
||||
features = [
|
||||
"live-preview",
|
||||
@@ -49,7 +49,6 @@ features = [
|
||||
"backend-android-activity-06",
|
||||
]
|
||||
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
tokio = { version = "1.48.0", default-features = false, features = ["fs", "rt-multi-thread"] }
|
||||
xdg = "3.0.0"
|
||||
@@ -63,4 +62,4 @@ wasm-bindgen-futures = "0.4.56"
|
||||
web-sys = "0.3.83"
|
||||
|
||||
[build-dependencies]
|
||||
slint-build = "1.17.1"
|
||||
slint-build = "1.18.0"
|
||||
@@ -93,6 +93,7 @@ fn update_slint_list(new_list: Vec<Item>, list: &VecModel<ui::SItem>) {
|
||||
name: item.name.to_shared_string(),
|
||||
checked: item.data.checked,
|
||||
amount: item.data.amount as i32,
|
||||
just_added: false,
|
||||
})
|
||||
.for_each(|item| list.push(item));
|
||||
}
|
||||
@@ -196,6 +197,7 @@ pub fn run() -> Result<(), anyhow::Error> {
|
||||
checked: false,
|
||||
name: item.clone(),
|
||||
amount: 1,
|
||||
just_added: true,
|
||||
});
|
||||
let conf = conf.clone();
|
||||
io.spawn(async move || {
|
||||
|
||||
+61
-36
@@ -9,12 +9,13 @@ import {
|
||||
GridBox,
|
||||
HorizontalBox,
|
||||
ComboBox,
|
||||
Palette, Spinner, SpinBox,
|
||||
Palette,
|
||||
Spinner,
|
||||
SpinBox,
|
||||
} from "std-widgets.slint";
|
||||
import { SettingsView } from "settings.slint";
|
||||
import { ConnectionStatus, State, SItem, SButtonItem } from "state.slint";
|
||||
export { ConnectionStatus, State, SItem }
|
||||
|
||||
component GoodListItem inherits Rectangle {
|
||||
in-out property <SItem> item;
|
||||
background: Palette.alternate-background;
|
||||
@@ -112,6 +113,23 @@ component PlusMinus inherits HorizontalLayout {
|
||||
|
||||
component GoodListItemAdd inherits Rectangle {
|
||||
in-out property <SItem> item;
|
||||
// Animate when this item appears.
|
||||
transform-scale: item.just-added ? 90% : 100%;
|
||||
opacity: item.just-added ? 0 : 100%;
|
||||
init => {
|
||||
self.transform-scale = 100%;
|
||||
self.opacity = 100%;
|
||||
item.just-added = false;
|
||||
}
|
||||
animate transform-scale {
|
||||
duration: 500ms;
|
||||
easing: ease-out-bounce;
|
||||
}
|
||||
animate opacity {
|
||||
duration: 300ms;
|
||||
easing: ease-out;
|
||||
}
|
||||
|
||||
background: Palette.alternate-background;
|
||||
border-radius: 8pt;
|
||||
border-width: 10pt;
|
||||
@@ -168,7 +186,7 @@ component GoodsListAdd {
|
||||
|
||||
for item in items: VerticalLayout {
|
||||
GoodListItemAdd {
|
||||
item: item;
|
||||
item <=> item;
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
@@ -185,19 +203,21 @@ component GoodButtons inherits ScrollView {
|
||||
|
||||
property <int> count-x: floor(root.width / (button-min-width + button-spacing));
|
||||
property <int> count-y: ceil(State.favorites.length / count-x);
|
||||
property <length> button-width: ((self.width + button-spacing ) / count-x) - button-spacing;
|
||||
property <length> button-width: ((root.width + button-spacing) / count-x) - button-spacing;
|
||||
|
||||
viewport-height: (count-y * (button-height + button-spacing));
|
||||
content-height: (count-y * (button-height + button-spacing));
|
||||
mouse-drag-pan-enabled: true;
|
||||
vertical-scrollbar-policy: always-off;
|
||||
|
||||
for item[idx] in State.favorites: Button {
|
||||
x: floor(mod(idx, count-x)) * (root.button-width + root.button-spacing);
|
||||
y: floor(idx / count-x) * (root.button-height + root.button-spacing);
|
||||
width: root.button-width;
|
||||
height: root.button-height;
|
||||
text: item.name;
|
||||
clicked => {
|
||||
State.add-to-list(item.name);
|
||||
FlexboxLayout {
|
||||
spacing: button-spacing;
|
||||
for item in State.favorites: Button {
|
||||
width: root.button-width;
|
||||
height: root.button-height;
|
||||
text: item.name;
|
||||
clicked => {
|
||||
State.add-to-list(item.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,7 +245,7 @@ component ConnStatusIndicator inherits Rectangle {
|
||||
}
|
||||
|
||||
component RefreshButton inherits HorizontalLayout {
|
||||
spacing: 8px;
|
||||
spacing: 8px;
|
||||
alignment: center;
|
||||
Button {
|
||||
text: "Refresh";
|
||||
@@ -234,6 +254,7 @@ component RefreshButton inherits HorizontalLayout {
|
||||
State.refresh-list();
|
||||
}
|
||||
}
|
||||
|
||||
ConnStatusIndicator { }
|
||||
}
|
||||
|
||||
@@ -243,7 +264,7 @@ component AddView inherits VerticalLayout {
|
||||
padding: 8px;
|
||||
spacing: 8px;
|
||||
|
||||
RefreshButton {}
|
||||
RefreshButton { }
|
||||
|
||||
goods := GoodsListAdd {
|
||||
items <=> list;
|
||||
@@ -281,24 +302,25 @@ component AddView inherits VerticalLayout {
|
||||
GoodButtons { }
|
||||
}
|
||||
|
||||
component ShopView inherits VerticalLayout {
|
||||
component ShopView inherits ScrollView {
|
||||
in property <[SItem]> list;
|
||||
mouse-drag-pan-enabled: true;
|
||||
VerticalLayout {
|
||||
RefreshButton { }
|
||||
|
||||
padding: 8px;
|
||||
spacing: 8px;
|
||||
padding: 8px;
|
||||
spacing: 8px;
|
||||
goods := GoodsList {
|
||||
items <=> list;
|
||||
}
|
||||
|
||||
RefreshButton { }
|
||||
|
||||
goods := GoodsList {
|
||||
items <=> list;
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
padding: 12px;
|
||||
Button {
|
||||
text: "I am done hehe";
|
||||
clicked => {
|
||||
State.delete-checked();
|
||||
HorizontalLayout {
|
||||
padding: 12px;
|
||||
Button {
|
||||
text: "I am done hehe";
|
||||
clicked => {
|
||||
State.delete-checked();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -322,23 +344,26 @@ component CatItem inherits HorizontalBox {
|
||||
}
|
||||
|
||||
|
||||
component CatView inherits VerticalLayout {
|
||||
component CatView inherits ScrollView {
|
||||
in-out property <[SButtonItem]> cats;
|
||||
|
||||
for item in cats: CatItem {
|
||||
item: item;
|
||||
mouse-drag-pan-enabled: true;
|
||||
VerticalLayout {
|
||||
for item in cats: CatItem {
|
||||
item: item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export component App inherits Window {
|
||||
|
||||
in property <int> prefered-start-tab: 0;
|
||||
title: "Inköpslista";
|
||||
icon: @image-url("../images/icon.svg");
|
||||
|
||||
preferred-height: 700px;
|
||||
preferred-width: 480px;
|
||||
|
||||
TabWidget {
|
||||
tabs := TabWidget {
|
||||
current-index: prefered-start-tab;
|
||||
Tab {
|
||||
title: "Add";
|
||||
AddView {
|
||||
|
||||
@@ -2,6 +2,10 @@ export struct SItem {
|
||||
name: string,
|
||||
checked: bool,
|
||||
amount: int,
|
||||
|
||||
/// Whether the item was just added by the user.
|
||||
/// Determines whether the add-animation plays.
|
||||
just_added: bool,
|
||||
}
|
||||
|
||||
export struct SButtonItem{
|
||||
|
||||
Reference in new issue
Block a user