Added first project implementation
This commit is contained in:
73
qml/Controls/Switch.qml
Normal file
73
qml/Controls/Switch.qml
Normal file
@@ -0,0 +1,73 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as Controls
|
||||
import QtQuick.Layouts 1.12
|
||||
|
||||
import Palette 1.0
|
||||
|
||||
Controls.Switch {
|
||||
id: control
|
||||
|
||||
implicitHeight: 128
|
||||
padding: 12
|
||||
|
||||
property string firstStateDescription
|
||||
property string secondStateDescription
|
||||
|
||||
indicator: Item {
|
||||
anchors.fill: control
|
||||
anchors.margins: control.padding
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
spacing: 0
|
||||
|
||||
Controls.Label {
|
||||
id: firstLabel
|
||||
|
||||
text: control.firstStateDescription
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
|
||||
font.family: "Roboto"
|
||||
font.pixelSize: 72
|
||||
font.weight: Font.Bold
|
||||
|
||||
color: control.checked ? Palette.labelTextColor : Palette.alternativeLabelTextColor
|
||||
Layout.preferredWidth: (parent.width -parent.spacing) / 2
|
||||
}
|
||||
|
||||
Controls.Label {
|
||||
id: secondLabel
|
||||
|
||||
text: control.secondStateDescription
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
|
||||
font.family: "Roboto"
|
||||
font.pixelSize: 72
|
||||
font.weight: Font.Bold
|
||||
|
||||
color: control.checked ? Palette.alternativeLabelTextColor : Palette.labelTextColor
|
||||
Layout.preferredWidth: (parent.width -parent.spacing) / 2
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
color: Palette.switchActiveBackgroundColor
|
||||
radius: 24
|
||||
|
||||
width: control.checked ? secondLabel.width : firstLabel.width
|
||||
height: parent.height
|
||||
x: control.checked ? secondLabel.x : firstLabel.x
|
||||
z: -1
|
||||
}
|
||||
}
|
||||
|
||||
contentItem: Item {
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: Palette.switchBackgroundColor
|
||||
radius: 32
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user