forked from caelestia-dots/shell
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathInputField.qml
More file actions
192 lines (153 loc) · 5.87 KB
/
Copy pathInputField.qml
File metadata and controls
192 lines (153 loc) · 5.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
pragma ComponentBehavior: Bound
import QtQuick
import Quickshell
import M3Shapes
import Caelestia.Config
import qs.components
import qs.services
import qs.modules.lock
Item {
id: root
required property Pam pam
readonly property alias placeholder: placeholder
property string buffer
clip: true
Connections {
function onBufferChanged() {
if (root.pam.buffer.length > root.buffer.length) {
charList.bindImWidth();
} else if (root.pam.buffer.length === 0) {
charList.implicitWidth = charList.implicitWidth;
placeholder.animate = true;
}
root.buffer = root.pam.buffer;
}
target: root.pam
}
StyledText {
id: placeholder
anchors.centerIn: parent
text: {
if (root.pam.passwd.active)
return qsTr("Loading...");
if (root.pam.state === "max")
return qsTr("You have reached the maximum number of tries");
return qsTr("Enter your password");
}
animate: true
color: root.pam.passwd.active ? Colours.palette.m3secondary : Colours.palette.m3outline
font: Tokens.font.mono.medium
opacity: root.buffer ? 0 : 1
Behavior on opacity {
Anim {
type: Anim.DefaultEffects
}
}
}
ListView {
id: charList
readonly property int fullWidth: count * (implicitHeight + spacing) - spacing
function bindImWidth() {
imWidthBehavior.enabled = false;
implicitWidth = Qt.binding(() => fullWidth);
imWidthBehavior.enabled = true;
}
anchors.centerIn: parent
anchors.horizontalCenterOffset: implicitWidth > root.width ? -(implicitWidth - root.width) / 2 : 0
implicitWidth: fullWidth
implicitHeight: Tokens.font.body.medium.pointSize
orientation: Qt.Horizontal
spacing: Tokens.spacing.small
interactive: false
model: ScriptModel {
values: root.buffer.split("")
}
delegate: Item {
id: delegateRoot
implicitWidth: charList.implicitHeight
implicitHeight: charList.implicitHeight
ListView.onRemove: removeAnim.start()
SequentialAnimation {
id: removeAnim
PropertyAction {
target: delegateRoot
property: "ListView.delayRemove"
value: true
}
ParallelAnimation {
Anim {
type: Anim.DefaultEffects
target: delegateRoot
property: "opacity"
to: 0
}
Anim {
target: ch
property: "implicitSize"
to: 0
}
}
PropertyAction {
target: delegateRoot
property: "ListView.delayRemove"
value: false
}
}
MaterialShape {
id: ch
property int initialShape: {
const shapes = [MaterialShape.Square, MaterialShape.Slanted, MaterialShape.Arch, MaterialShape.Fan, MaterialShape.Arrow, MaterialShape.SemiCircle, MaterialShape.Triangle, MaterialShape.Diamond, MaterialShape.ClamShell, MaterialShape.Pentagon, MaterialShape.Gem, MaterialShape.Sunny, MaterialShape.VerySunny, MaterialShape.Cookie4Sided, MaterialShape.Cookie6Sided, MaterialShape.Cookie7Sided, MaterialShape.Cookie9Sided, MaterialShape.Cookie12Sided, MaterialShape.Ghostish, MaterialShape.Clover4Leaf, MaterialShape.Clover8Leaf, MaterialShape.Burst, MaterialShape.SoftBurst, MaterialShape.Boom, MaterialShape.SoftBoom, MaterialShape.Flower, MaterialShape.Puffy, MaterialShape.PuffyDiamond, MaterialShape.Bun, MaterialShape.Heart];
return shapes[Math.floor(Math.random() * shapes.length)];
}
anchors.centerIn: parent
color: Colours.palette.m3onSurface
shape: initialShape
animationDuration: 200
opacity: 0
implicitSize: 0
Component.onCompleted: {
spawnAnim.start();
}
SequentialAnimation {
id: spawnAnim
ParallelAnimation {
NumberAnimation {
target: ch
property: "implicitSize"
from: 0
to: delegateRoot.implicitHeight * 1.5
duration: 250
easing.type: Easing.OutBack
}
NumberAnimation {
target: ch
property: "opacity"
from: 0
to: 1
duration: 100
}
}
PauseAnimation {
duration: 180
}
ScriptAction {
script: ch.shape = MaterialShape.Circle
}
ParallelAnimation {
NumberAnimation {
target: ch
property: "implicitSize"
to: delegateRoot.implicitHeight
duration: 200
easing.type: Easing.InOutQuad
}
}
}
}
}
Behavior on implicitWidth {
id: imWidthBehavior
Anim {}
}
}
}