Skip to content

Commit 1271377

Browse files
committed
qml: add looping animation to Estimating state
1 parent c9492c7 commit 1271377

File tree

1 file changed

+75
-14
lines changed

1 file changed

+75
-14
lines changed

src/qml/components/BlockClock.qml

Lines changed: 75 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ Item {
2222
property int headerSize: 32
2323
property bool connected: nodeModel.numOutboundPeers > 0
2424
property bool synced: nodeModel.verificationProgress > 0.999
25+
property string syncProgress: formatProgressPercentage(nodeModel.verificationProgress * 100)
2526
property bool paused: false
27+
property var syncState: formatRemainingSyncTime(nodeModel.remainingSyncTime)
28+
property string syncTime: syncState.text
29+
property bool estimating: syncState.estimating
2630

2731
activeFocusOnTab: true
2832

@@ -82,15 +86,44 @@ Item {
8286
Label {
8387
id: subText
8488
anchors.top: mainText.bottom
89+
property bool estimating: root.estimating
8590
anchors.horizontalCenter: root.horizontalCenter
8691
font.family: "Inter"
8792
font.styleName: "Semi Bold"
8893
font.pixelSize: 18
8994
color: Theme.color.neutral4
9095

91-
Behavior on color {
92-
ColorAnimation { duration: 150 }
96+
Component.onCompleted: {
97+
colorChanged.connect(function() {
98+
if (!subText.estimating) {
99+
themeChange.restart();
100+
}
101+
});
102+
103+
estimatingChanged.connect(function() {
104+
if (subText.estimating) {
105+
estimatingTime.start();
106+
} else {
107+
estimatingTime.stop();
108+
}
109+
});
110+
111+
subText.estimatingChanged(subText.estimating);
112+
}
113+
114+
ColorAnimation on color{
115+
id: themeChange
116+
target: subText
117+
duration: 150
93118
}
119+
120+
SequentialAnimation {
121+
id: estimatingTime
122+
loops: Animation.Infinite
123+
ColorAnimation { target: subText; property: "color"; from: subText.color; to: Theme.color.neutral6; duration: 1000 }
124+
ColorAnimation { target: subText; property: "color"; from: Theme.color.neutral6; to: subText.color; duration: 1000 }
125+
}
126+
94127
}
95128

96129
PeersIndicator {
@@ -119,17 +152,17 @@ Item {
119152
name: "IBD"; when: !synced && !paused && connected
120153
PropertyChanges {
121154
target: root
122-
header: formatProgressPercentage(nodeModel.verificationProgress * 100)
123-
subText: formatRemainingSyncTime(nodeModel.remainingSyncTime)
155+
header: root.syncProgress
156+
subText: root.syncTime
124157
}
125158
},
126-
127159
State {
128160
name: "BLOCKCLOCK"; when: synced && !paused && connected
129161
PropertyChanges {
130162
target: root
131163
header: Number(nodeModel.blockTipHeight).toLocaleString(Qt.locale(), 'f', 0)
132164
subText: "Blocktime"
165+
estimating: false
133166
}
134167
},
135168

@@ -140,6 +173,7 @@ Item {
140173
header: "Paused"
141174
headerSize: 24
142175
subText: "Tap to resume"
176+
estimating: false
143177
}
144178
PropertyChanges {
145179
target: bitcoinIcon
@@ -158,6 +192,7 @@ Item {
158192
header: "Connecting"
159193
headerSize: 24
160194
subText: "Please wait"
195+
estimating: false
161196
}
162197
PropertyChanges {
163198
target: bitcoinIcon
@@ -191,29 +226,55 @@ Item {
191226
minutes %= 1440;
192227
var hours = Math.floor(minutes / 60);
193228
minutes %= 60;
229+
var result = "";
230+
var estimatingStatus = false;
194231

195232
if (weeks > 0) {
196-
return "~" + weeks + (weeks === 1 ? " week" : " weeks") + " left";
233+
return {
234+
text: "~" + weeks + (weeks === 1 ? " week" : " weeks") + " left",
235+
estimating: false
236+
};
197237
}
198238
if (days > 0) {
199-
return "~" + days + (days === 1 ? " day" : " days") + " left";
239+
return {
240+
text: "~" + days + (days === 1 ? " day" : " days") + " left",
241+
estimating: false
242+
};
200243
}
201244
if (hours >= 5) {
202-
return "~" + hours + (hours === 1 ? " hour" : " hours") + " left";
245+
return {
246+
text: "~" + hours + (hours === 1 ? " hour" : " hours") + " left",
247+
estimating: false
248+
};
203249
}
204250
if (hours > 0) {
205-
return "~" + hours + "h " + minutes + "m" + " left";
251+
return {
252+
text: "~" + hours + "h " + minutes + "m" + " left",
253+
estimating: false
254+
};
206255
}
207256
if (minutes >= 5) {
208-
return "~" + minutes + (minutes === 1 ? " minute" : " minutes") + " left";
257+
return {
258+
text: "~" + minutes + (minutes === 1 ? " minute" : " minutes") + " left",
259+
estimating: false
260+
};
209261
}
210262
if (minutes > 0) {
211-
return "~" + minutes + "m " + seconds + "s" + " left";
263+
return {
264+
text: "~" + minutes + "m " + seconds + "s" + " left",
265+
estimating: false
266+
};
212267
}
213268
if (seconds > 0) {
214-
return "~" + seconds + (seconds === 1 ? " second" : " seconds") + " left";
269+
return {
270+
text: "~" + seconds + (seconds === 1 ? " second" : " seconds") + " left",
271+
estimating: false
272+
};
273+
} else {
274+
return {
275+
text: "Estimating",
276+
estimating: true
277+
};
215278
}
216-
217-
return "Estimating";
218279
}
219280
}

0 commit comments

Comments
 (0)