slint/demos/energy-monitor/ui/widgets/item.slint
Simon Hausmann a98d4709be Move printer demo and energy-monitor into new top-level demos/ folder
These are showing off use-cases for Slint, but they're not examples showing individual Slint features.

Also removed the old printerdemo while at it.
2024-10-25 12:09:32 +02:00

74 lines
1.9 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: MIT
import { StateLayer } from "../components/state_layer.slint";
import { ScrollView } from "scroll_view.slint";
import { Theme } from "../theme.slint";
import { StateLayer } from "../components/state_layer.slint";
export component Item {
in property <string> text <=> i-text.text;
in property <bool> has-separator;
callback clicked <=> i-touch-area.clicked;
min-height: 40px;
i-container := Rectangle {
background: Theme.palette.dark-deep-blue;
border-radius: 4px;
}
i-touch-area := TouchArea {}
HorizontalLayout {
padding-left: Theme.spaces.medium;
padding-top: Theme.spaces.medium;
padding-bottom: Theme.spaces.medium;
padding-right: Theme.spaces.medium;
spacing: Theme.spaces.medium;
i-text := Text {
horizontal-stretch: 1;
color: Theme.palette.white;
font-size: Theme.typo.description.size;
font-weight: Theme.typo.description.weight;
vertical-alignment: center;
}
@children
}
if (has-separator) : Rectangle {
width: parent.width - 2 * Theme.spaces.medium;
height: 1px;
x: Theme.spaces.medium;
y: parent.height - self.height;
background: Theme.palette.slint-blue-300;
opacity: 0.25;
}
}
export component ItemGroupBox {
in property <string> title <=> i-title.text;
VerticalLayout {
HorizontalLayout {
padding: Theme.spaces.medium;
i-title := Text {
color: Theme.palette.white;
font-size: Theme.typo.header.size;
font-weight: Theme.typo.header.weight;
}
}
Rectangle {
background: Theme.palette.dark-deep-blue;
border-radius: 4px;
VerticalLayout {
@children
}
}
}
}