From 3bfa31fcd2b1169e6bdf933b80771b4938e3e8c3 Mon Sep 17 00:00:00 2001 From: KeksNino Date: Wed, 29 Apr 2026 18:09:03 +0200 Subject: [PATCH] feat: add search bar --- Cargo.lock | 1 + Cargo.toml | 1 + src/main.rs | 10 +++------- ui/app-window.slint | 30 ++++++++++++++++++------------ 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a3aae21..75258b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4644,6 +4644,7 @@ dependencies = [ "reqwest", "slint", "slint-build", + "tokio", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 751923f..2cf8663 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ edition = "2021" [dependencies] reqwest = "0.13.3" slint = "1.14.1" +tokio = "1.52.1" [build-dependencies] slint-build = "1.14.1" diff --git a/src/main.rs b/src/main.rs index 8ec3b28..84f9793 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,15 +6,11 @@ mod rutracker; slint::include_modules!(); fn main() -> Result<(), Box> { - rutracker::main(); let ui = AppWindow::new()?; - ui.on_request_increase_value({ - let ui_handle = ui.as_weak(); - move || { - let ui = ui_handle.unwrap(); - ui.set_counter(ui.get_counter() + 1); - } + ui.on_request_text_input(|text| { + let text = text.trim(); + println!("User input: {}", text); }); ui.run()?; diff --git a/ui/app-window.slint b/ui/app-window.slint index 5174ada..7a5cdf9 100644 --- a/ui/app-window.slint +++ b/ui/app-window.slint @@ -1,22 +1,28 @@ import { Button, LineEdit, VerticalBox } from "std-widgets.slint"; export component AppWindow inherits Window { - in-out property counter: 42; - callback request-increase-value(); + // in-out property counter: 42; + // callback request-increase-value(); + width: 200px; + height: 60px; + + in-out property search-text: ""; + callback request-text-input(string); VerticalBox { - Text { - text: "Counter: \{root.counter}"; - } LineEdit { - placeholder-text: "Search for Software" + placeholder-text: "Search for Software"; + accepted(text) => { + // debug("Accepted: ", text); + root.request-text-input(self.text); + } } - Button { - text: "Increase value"; - clicked => { - root.request-increase-value(); - } - } + // Button { + // text: "Increase value"; + // clicked => { + // root.request-increase-value(); + // } + // } } }