Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit60f8964

Browse files
committed
fix: start coder connect progress indicator immediately
1 parent50e4a63 commit60f8964

File tree

2 files changed

+39
-10
lines changed

2 files changed

+39
-10
lines changed

‎Coder-Desktop/Coder-Desktop/VPN/VPNProgress.swift‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ struct VPNProgressView: View {
1313
varbody:someView{
1414
VStack{
1515
CircularProgressView(value: value)
16-
// We estimatethatthelast half takes 8 seconds
16+
// We estimate theduration of the last 40%
1717
// so it doesn't appear stuck
18-
.autoComplete(threshold:0.5, duration:8)
18+
.autoComplete(threshold:0.6, duration:2.8)
19+
// We estimate the duration of the first 15% (spawning Helper)
20+
// so it doesn't appear stuck
21+
.autoStart(to:0.15, duration:1.8)
1922
Text(progressMessage)
2023
.multilineTextAlignment(.center)
2124
}
@@ -51,13 +54,13 @@ struct VPNProgressView: View {
5154
// 35MB if the server doesn't give us the expected size
5255
lettotalBytes= downloadProgress.totalBytesToWrite??35_000_000
5356
letdownloadPercent=min(1.0,Float(downloadProgress.totalBytesWritten)/ Float(totalBytes))
54-
return0.4* downloadPercent
57+
return0.15+(0.35* downloadPercent)
5558
case.validating:
56-
return0.43
59+
return0.53
5760
case.removingQuarantine:
58-
return0.46
61+
return0.56
5962
case.startingTunnel:
60-
return0.50
63+
return0.60
6164
}
6265
}
6366
}

‎Coder-Desktop/Coder-Desktop/Views/CircularProgressView.swift‎

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ struct CircularProgressView: View {
1111
varautoCompleteThreshold:Float?
1212
varautoCompleteDuration:TimeInterval?
1313

14+
varautoStartValue:Float?
15+
varautoStartDuration:TimeInterval?
16+
17+
@StateprivatevarcurrentProgress:Float=0
18+
1419
varbody:someView{
1520
ZStack{
1621
iflet value{
@@ -19,13 +24,23 @@ struct CircularProgressView: View {
1924
.stroke(backgroundColor, style:StrokeStyle(lineWidth: strokeWidth, lineCap:.round))
2025

2126
Circle()
22-
.trim(from:0, to:CGFloat(displayValue(for:value)))
27+
.trim(from:0, to:CGFloat(displayValue(for:currentProgress)))
2328
.stroke(primaryColor, style:StrokeStyle(lineWidth: strokeWidth, lineCap:.round))
2429
.rotationEffect(.degrees(-90))
25-
.animation(autoCompleteAnimation(for: value), value: value)
2630
}
2731
.frame(width: diameter, height: diameter)
28-
32+
.onAppear{
33+
iflet autoStartValue,let autoStartDuration, value==0{
34+
withAnimation(.easeOut(duration: autoStartDuration)){
35+
currentProgress= autoStartValue
36+
}
37+
}
38+
}
39+
.onChange(of: value){
40+
withAnimation(currentAnimation(for: value)){
41+
currentProgress= value
42+
}
43+
}
2944
}else{
3045
IndeterminateSpinnerView(
3146
diameter: diameter,
@@ -48,11 +63,15 @@ struct CircularProgressView: View {
4863
return value
4964
}
5065

51-
privatefuncautoCompleteAnimation(for value:Float)->Animation?{
66+
privatefunccurrentAnimation(for value:Float)->Animation{
5267
guardlet threshold= autoCompleteThreshold,
5368
let duration= autoCompleteDuration,
5469
value>= threshold, value<1.0
5570
else{
71+
// Use the auto-start animation if it's running, otherwise default.
72+
iflet autoStartDuration, value<(autoStartValue??0){
73+
return.easeOut(duration: autoStartDuration)
74+
}
5675
return.default
5776
}
5877

@@ -67,6 +86,13 @@ extension CircularProgressView {
6786
view.autoCompleteDuration= duration
6887
return view
6988
}
89+
90+
func autoStart(to value:Float, duration:TimeInterval)->CircularProgressView{
91+
varview=self
92+
view.autoStartValue= value
93+
view.autoStartDuration= duration
94+
return view
95+
}
7096
}
7197

7298
// We note a constant >10% CPU usage when using a SwiftUI rotation animation that

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp