diff --git a/ui/main.slint b/ui/main.slint index 18e659c..027ccf9 100644 --- a/ui/main.slint +++ b/ui/main.slint @@ -9,6 +9,26 @@ import { Horizontal, Vertical, Switch } from "./material.slint"; import "./fonts/Roboto-VariableFont.ttf"; import { FilledIcons, OutlinedIcons } from "./icons.slint"; +component LightSwitch inherits Horizontal { + in property text: ""; + in property checked: false; + in property enabled: true; + + alignment: end; + Text { + text: root.text; + vertical-alignment: center; + horizontal-alignment: right; + font-size: 18px; + font-weight: root.checked ? 700 : 500; + } + Switch { + enabled: root.enabled; + checked: root.checked; + } +} + + // The window the user interacts with. Edits to the inputs propagate to // the SystemTrayIcon instance via the host language's callbacks. export component MainWindow inherits Window { @@ -101,117 +121,40 @@ export component MainWindow inherits Window { Vertical { alignment: start; - Horizontal { - alignment: end; - Text { - text: "Armory Light"; - vertical-alignment: center; - horizontal-alignment: right; - font-size: 18px; - font-weight: 500; - } - Switch { - checked: false; - } + + LightSwitch { + text: "Armory Light"; } - Horizontal { - alignment: end; - Text { - text: "Bedroom Light"; - vertical-alignment: center; - horizontal-alignment: right; - font-size: 18px; - font-weight: 500; - } - Switch { - checked: false; - } + LightSwitch { + text: "Bedroom Light"; } - Horizontal { - alignment: end; - Text { - text: "Hallway Light"; - vertical-alignment: center; - horizontal-alignment: right; - font-size: 18px; - font-weight: 500; - } - Switch { - checked: false; - } + LightSwitch { + text: "Hallway Light"; } - Horizontal { - alignment: end; - Text { - text: "Kitchen Light"; - vertical-alignment: center; - horizontal-alignment: right; - font-size: 18px; - font-weight: 500; - } - Switch { - checked: false; - } + LightSwitch { + text: "Kitchen Light"; } - Horizontal { - alignment: end; - Text { - text: "Living Room Light"; - vertical-alignment: center; - horizontal-alignment: right; - font-size: 18px; - font-weight: 700; - } - Switch { - checked: true; - } + LightSwitch { + text: "Living Room Light"; + enabled: true; } - Horizontal { - alignment: end; - Text { - text: "Shower Light"; - vertical-alignment: center; - horizontal-alignment: right; - font-size: 18px; - font-weight: 500; - } - Switch { - checked: false; - } + LightSwitch { + text: "Shower Light"; } - Horizontal { - alignment: end; - Text { - text: "Utilities Light"; - vertical-alignment: center; - horizontal-alignment: right; - font-size: 18px; - font-weight: 500; - } - Switch { - enabled: false; - checked: false; - } + LightSwitch { + text: "Utilities Light"; + enabled: false; + checked: false; } - Horizontal { - alignment: end; - Text { - text: "WC Light"; - vertical-alignment: center; - horizontal-alignment: right; - font-size: 18px; - font-weight: 500; - } - Switch { - checked: false; - } + LightSwitch { + text: "WC Light"; } } }