15s animation on loading screen

This commit is contained in:
ryanzhao 2023-08-22 11:05:35 +10:00
parent 5f4ecfd4a2
commit 4f3a17670a
1 changed files with 12 additions and 10 deletions

View File

@ -8,13 +8,12 @@ import SignalUtilitiesKit
struct LoadingView: View {
@EnvironmentObject var host: HostWrapper
@State var percentage: Double = 0
@State var percentage: Double = 0.0
private let flow: Onboarding.Flow
public init(flow: Onboarding.Flow) {
self.flow = flow
progress()
}
var body: some View {
@ -35,6 +34,9 @@ struct LoadingView: View {
CircularProgressView($percentage)
.padding(.horizontal, Values.massiveSpacing)
.padding(.bottom, Values.mediumSpacing)
.onAppear {
progress()
}
Text("onboarding_load_account_waiting".localized())
.bold()
@ -54,15 +56,15 @@ struct LoadingView: View {
}
private func progress() {
guard percentage < 1 else { return }
print(percentage)
Timer.scheduledTimer(
Timer.scheduledTimerOnMainThread(
withTimeInterval: 0.15,
repeats: false,
block: { _ in
percentage += 0.01
progress()
})
repeats: true
) { timer in
self.percentage += 0.01
if percentage >= 1 {
timer.invalidate()
}
}
}
}