nosignal-shell/components/controls/SwitchRow.qml
2026-04-11 21:18:56 +10:00

46 lines
1.1 KiB
QML

import ".."
import QtQuick
import QtQuick.Layouts
import qs.components
import qs.services
import Caelestia.Config
StyledRect {
id: root
required property string label
required property bool checked
property var onToggled: function (checked) {}
Layout.fillWidth: true
implicitHeight: row.implicitHeight + Tokens.padding.large * 2
radius: Tokens.rounding.normal
color: Colours.layer(Colours.palette.m3surfaceContainer, 2)
Behavior on implicitHeight {
Anim {}
}
RowLayout {
id: row
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.margins: Tokens.padding.large
spacing: Tokens.spacing.normal
StyledText {
Layout.fillWidth: true
text: root.label
}
StyledSwitch {
checked: root.checked
enabled: root.enabled
onToggled: {
root.onToggled(checked); // qmllint disable use-proper-function
}
}
}
}