feat: add search bar
This commit is contained in:
Generated
+1
@@ -4644,6 +4644,7 @@ dependencies = [
|
|||||||
"reqwest",
|
"reqwest",
|
||||||
"slint",
|
"slint",
|
||||||
"slint-build",
|
"slint-build",
|
||||||
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ edition = "2021"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
reqwest = "0.13.3"
|
reqwest = "0.13.3"
|
||||||
slint = "1.14.1"
|
slint = "1.14.1"
|
||||||
|
tokio = "1.52.1"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
slint-build = "1.14.1"
|
slint-build = "1.14.1"
|
||||||
|
|||||||
+3
-7
@@ -6,15 +6,11 @@ mod rutracker;
|
|||||||
slint::include_modules!();
|
slint::include_modules!();
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
rutracker::main();
|
|
||||||
let ui = AppWindow::new()?;
|
let ui = AppWindow::new()?;
|
||||||
|
|
||||||
ui.on_request_increase_value({
|
ui.on_request_text_input(|text| {
|
||||||
let ui_handle = ui.as_weak();
|
let text = text.trim();
|
||||||
move || {
|
println!("User input: {}", text);
|
||||||
let ui = ui_handle.unwrap();
|
|
||||||
ui.set_counter(ui.get_counter() + 1);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.run()?;
|
ui.run()?;
|
||||||
|
|||||||
+18
-12
@@ -1,22 +1,28 @@
|
|||||||
import { Button, LineEdit, VerticalBox } from "std-widgets.slint";
|
import { Button, LineEdit, VerticalBox } from "std-widgets.slint";
|
||||||
|
|
||||||
export component AppWindow inherits Window {
|
export component AppWindow inherits Window {
|
||||||
in-out property <int> counter: 42;
|
// in-out property <int> counter: 42;
|
||||||
callback request-increase-value();
|
// callback request-increase-value();
|
||||||
|
width: 200px;
|
||||||
|
height: 60px;
|
||||||
|
|
||||||
|
in-out property <string> search-text: "";
|
||||||
|
callback request-text-input(string);
|
||||||
VerticalBox {
|
VerticalBox {
|
||||||
Text {
|
|
||||||
text: "Counter: \{root.counter}";
|
|
||||||
}
|
|
||||||
|
|
||||||
LineEdit {
|
LineEdit {
|
||||||
placeholder-text: "Search for Software"
|
placeholder-text: "Search for Software";
|
||||||
|
accepted(text) => {
|
||||||
|
// debug("Accepted: ", text);
|
||||||
|
root.request-text-input(self.text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
// Button {
|
||||||
text: "Increase value";
|
// text: "Increase value";
|
||||||
clicked => {
|
// clicked => {
|
||||||
root.request-increase-value();
|
// root.request-increase-value();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user