routing stack and restoring states ? #11189
Unanswered
moolight-seashell
asked this question in
Q&A
Replies: 2 comments 1 reply
-
|
See if this helps. |
Beta Was this translation helpful? Give feedback.
1 reply
-
Given a custom component:import { Button } from "std-widgets.slint";
export component Counter {
in-out property <int> value: 0;
VerticalLayout {
Text {
text: "Value: " + value;
}
Button {
text: "Increment";
clicked => {
value += 1;
}
}
}
}Approach 1, Using if statmentexport component MainWindow inherits Window {
in-out property <bool> show_counter: true;
VerticalLayout {
Button {
text: show_counter ? "Hide" : "Show";
clicked => {
show_counter = !show_counter;
}
}
if (show_counter) : Counter {
}
}
}Behavior
Approach 2, Using visible propetyexport component MainWindow inherits Window {
in-out property <bool> show_counter1: true;
VerticalLayout {
Button {
text: show_counter1 ? "Show 2" : "Show 1";
clicked => {
show_counter1 = !show_counter1;
}
}
Rectangle {
Counter {
visible: show_counter1;
}
Counter {
visible: !show_counter1;
}
}
Text {
text: "test";
}
}
}Behavior
Drawbacks
While it might be tempting to combine both approaches:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a way to create a router things, to navigate between pages
like for example "a stack" routing like flutter allowing to push new page while be able to restore se state of older page is we pop the current page ?
even with scroll list or event custom lazy loading scrolls list ... ?
because from what i've understand , there is no "components" in the available property types
Beta Was this translation helpful? Give feedback.
All reactions