From 04755cf05b6c1789921536049e9476e907c9cc63 Mon Sep 17 00:00:00 2001 From: Ku6epXBOCTuK Date: Thu, 7 May 2026 01:36:00 +0500 Subject: [PATCH] feat: separate components --- build.rs | 2 +- ui/browser_item.slint | 38 +++++++++++++++++++++++++ ui/main.slint | 45 ++++++++++++++++++++++++++++++ ui/todo.slint | 64 ------------------------------------------- ui/types.slint | 6 ++++ 5 files changed, 90 insertions(+), 65 deletions(-) create mode 100644 ui/browser_item.slint create mode 100644 ui/main.slint delete mode 100644 ui/todo.slint create mode 100644 ui/types.slint diff --git a/build.rs b/build.rs index c29961a..b56b953 100644 --- a/build.rs +++ b/build.rs @@ -2,5 +2,5 @@ // SPDX-License-Identifier: MIT fn main() { - slint_build::compile("ui/todo.slint").unwrap(); + slint_build::compile("ui/main.slint").unwrap(); } diff --git a/ui/browser_item.slint b/ui/browser_item.slint new file mode 100644 index 0000000..1f83c87 --- /dev/null +++ b/ui/browser_item.slint @@ -0,0 +1,38 @@ +import { + Button, + HorizontalBox, +} from "std-widgets.slint"; + +import { BrowserConfig } from "./types.slint"; + +export component BrowserItem { + height: 80px; + in property browser; + + Rectangle { + height: 100%; + width: 100%; + background: rgba(30, 41, 59, 0.3); + HorizontalBox { + height: 80px; + padding: 8px; + alignment: space-between; + Text { + text: browser.path; + vertical_alignment: center; + } + + Text { + text: browser.flags; + vertical_alignment: center; + } + + VerticalLayout { + alignment: center; + Button { + text: "use"; + } + } + } + } +} diff --git a/ui/main.slint b/ui/main.slint new file mode 100644 index 0000000..32aa706 --- /dev/null +++ b/ui/main.slint @@ -0,0 +1,45 @@ +import { + SpinBox, + Button, + CheckBox, + Slider, + LineEdit, + ScrollView, + ListView, + HorizontalBox, + VerticalBox, + GridBox, + StandardButton, + Palette, +} from "std-widgets.slint"; +import { BrowserItem } from "./browser_item.slint"; + +import { BrowserConfig } from "./types.slint"; + +export component MainWindow inherits Window { + in property <[BrowserConfig]> browser-model: []; + + callback todo-added(string); + callback remove-done(); + callback update_todo(BrowserConfig); + + preferred-width: 400px; + preferred-height: 600px; + + VerticalBox { + x: root.safe-area-insets.left; + y: root.safe-area-insets.top; + width: root.width - root.safe-area-insets.right - root.safe-area-insets.left; + height: root.height - root.safe-area-insets.bottom - root.safe-area-insets.top; + + list-view := ScrollView { + VerticalLayout { + spacing: 10px; + padding: 5px; + for browser in root.browser-model: BrowserItem { + browser: browser; + } + } + } + } +} diff --git a/ui/todo.slint b/ui/todo.slint deleted file mode 100644 index 7656779..0000000 --- a/ui/todo.slint +++ /dev/null @@ -1,64 +0,0 @@ -import { - SpinBox, - Button, - CheckBox, - Slider, - LineEdit, - ScrollView, - ListView, - HorizontalBox, - VerticalBox, - GridBox, - StandardButton, - Palette, -} from "std-widgets.slint"; - -@rust-attr(derive(serde::Serialize, serde::Deserialize)) -export struct BrowserConfig { - path: string, - flags: string, -} - -export component MainWindow inherits Window { - in property <[BrowserConfig]> browser-model: [ - { path: "chrome.exe", flags: "profile 1" }, - { path: "chrome.exe", flags: "profile 2" }, - { path: "zen.exe", flags: "" }, - { path: "edge.exe", flags: "" }, - ]; - - callback todo-added(string); - callback remove-done(); - callback update_todo(BrowserConfig); - - preferred-width: 400px; - preferred-height: 600px; - - VerticalBox { - x: root.safe-area-insets.left; - y: root.safe-area-insets.top; - width: root.width - root.safe-area-insets.right - root.safe-area-insets.left; - height: root.height - root.safe-area-insets.bottom - root.safe-area-insets.top; - - list-view := ListView { - for browser in root.browser-model: HorizontalLayout { - HorizontalBox { - padding: 8px; - alignment: center; - - Text { - text: browser.path; - } - - Text { - text: browser.flags; - } - - Button { - text: "use"; - } - } - } - } - } -} diff --git a/ui/types.slint b/ui/types.slint new file mode 100644 index 0000000..ebfd172 --- /dev/null +++ b/ui/types.slint @@ -0,0 +1,6 @@ + +@rust-attr(derive(serde::Serialize, serde::Deserialize)) +export struct BrowserConfig { + path: string, + flags: string, +}