Skip to content

Commit 39b4c15

Browse files
committed
qml: add ContinueButton interaction color animation states
1 parent d62a49f commit 39b4c15

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

src/qml/controls/ContinueButton.qml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import QtQuick 2.15
66
import QtQuick.Controls 2.15
77

88
Button {
9+
id: root
910
font.family: "Inter"
1011
font.styleName: "Semi Bold"
1112
font.pixelSize: 18
@@ -17,9 +18,47 @@ Button {
1718
verticalAlignment: Text.AlignVCenter
1819
}
1920
background: Rectangle {
21+
id: bg
2022
implicitHeight: 46
2123
implicitWidth: 300
2224
color: Theme.color.orange
2325
radius: 5
26+
state:"DEFAULT"
27+
28+
states: [
29+
State {
30+
name: "DEFAULT"
31+
PropertyChanges { target: bg; color: Theme.color.orange }
32+
},
33+
State {
34+
name: "HOVER"
35+
PropertyChanges { target: bg; color: Theme.color.orangeLight1 }
36+
},
37+
State {
38+
name: "PRESSED"
39+
PropertyChanges { target: bg; color: Theme.color.orangeLight2 }
40+
}
41+
]
42+
43+
Behavior on color {
44+
ColorAnimation { duration: 150 }
45+
}
46+
}
47+
MouseArea {
48+
anchors.fill: parent
49+
hoverEnabled: true
50+
onEntered: {
51+
root.background.state = "HOVER"
52+
}
53+
onExited: {
54+
root.background.state = "DEFAULT"
55+
}
56+
onPressed: {
57+
root.background.state = "PRESSED"
58+
}
59+
onReleased: {
60+
root.background.state = "DEFAULT"
61+
root.clicked()
62+
}
2463
}
2564
}

src/qml/controls/Theme.qml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Control {
1111
required property color white
1212
required property color background
1313
required property color orange
14+
required property color orangeLight1
15+
required property color orangeLight2
1416
required property color red
1517
required property color green
1618
required property color blue
@@ -38,6 +40,8 @@ Control {
3840
white: "#FFFFFF"
3941
background: "black"
4042
orange: "#F89B2A"
43+
orangeLight1: "#FFAD4A"
44+
orangeLight2: "#FFBF72"
4145
red: "#EC6363"
4246
green: "#36B46B"
4347
blue: "#3CA3DE"
@@ -59,6 +63,8 @@ Control {
5963
white: "#FFFFFF"
6064
background: "white"
6165
orange: "#F7931A"
66+
orangeLight1: "#FFAD4A"
67+
orangeLight2: "#FFBF72"
6268
red: "#EB5757"
6369
green: "#27AE60"
6470
blue: "#2D9CDB"

0 commit comments

Comments
 (0)