From 9148be571899fc136a4eccd2b73a5ec4add78ec8 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Tue, 17 Nov 2020 14:05:18 -0400 Subject: [PATCH] fix: make toggle buttons great again --- ui/shared/status/StatusSwitch.qml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/ui/shared/status/StatusSwitch.qml b/ui/shared/status/StatusSwitch.qml index d3430f20b2..4fb89fed30 100644 --- a/ui/shared/status/StatusSwitch.qml +++ b/ui/shared/status/StatusSwitch.qml @@ -8,6 +8,7 @@ Switch { id: control indicator: Rectangle { + id: oval implicitWidth: 52 implicitHeight: 28 x: control.leftPadding @@ -16,7 +17,7 @@ Switch { color: control.checked ? Style.current.blue : Style.current.grey Rectangle { - x: control.checked ? parent.width - width-4 : 4 + id: circle y: 4 width: 20 height: 20 @@ -32,6 +33,24 @@ Switch { cached: true color: "#22000000" } + + states: [ + State { + name: "on" + when: control.checked + PropertyChanges { target: circle; x: oval.width - circle.width - 4 } + }, + State { + name: "off" + when: !control.checked + PropertyChanges { target: circle; x: 4 } + } + ] + + transitions: Transition { + reversible: true + NumberAnimation { properties: "x"; easing.type: Easing.Linear; duration: 120; } + } } }