mirror of
https://github.com/ninxsoft/Mist.git
synced 2025-05-21 18:55:24 -04:00
Fix scrolling to current task in download view
This commit is contained in:
parent
5491ae6cf5
commit
b816ca257f
1 changed files with 23 additions and 12 deletions
|
@ -26,6 +26,7 @@ struct DownloadView: View {
|
|||
var beta: Bool
|
||||
var destinationURL: URL?
|
||||
@ObservedObject var taskManager: TaskManager
|
||||
@State private var currentTaskId: String?
|
||||
@State private var value: Double = 0
|
||||
@State private var showAlert: Bool = false
|
||||
@State private var alertType: ProgressAlertType = .cancel
|
||||
|
@ -44,9 +45,11 @@ struct DownloadView: View {
|
|||
}
|
||||
|
||||
var body: some View {
|
||||
// swiftlint:disable:next closure_body_length
|
||||
VStack(spacing: 0) {
|
||||
DownloadHeaderView(imageName: imageName, name: name, version: version, build: build, beta: beta)
|
||||
Divider()
|
||||
ScrollViewReader { proxy in
|
||||
List {
|
||||
ForEach(taskManager.taskGroups, id: \.section) { taskGroup in
|
||||
Section(header: DownloadSectionHeaderView(section: taskGroup.section)) {
|
||||
|
@ -61,10 +64,17 @@ struct DownloadView: View {
|
|||
Divider()
|
||||
}
|
||||
}
|
||||
.id("\(taskGroup.section.id).\(index)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: currentTaskId) { id in
|
||||
withAnimation(.easeOut(duration: 1.0)) {
|
||||
proxy.scrollTo(id, anchor: .center)
|
||||
}
|
||||
}
|
||||
}
|
||||
Divider()
|
||||
HStack {
|
||||
Toggle("Show in Finder upon completion", isOn: $showInFinder)
|
||||
|
@ -111,6 +121,7 @@ struct DownloadView: View {
|
|||
|
||||
for taskGroupIndex in taskManager.taskGroups.indices {
|
||||
for taskIndex in taskManager.taskGroups[taskGroupIndex].tasks.indices {
|
||||
currentTaskId = "\(taskManager.taskGroups[taskGroupIndex].section.id).\(taskIndex)"
|
||||
degrees = 0
|
||||
taskManager.taskGroups[taskGroupIndex].tasks[taskIndex].state = .inProgress
|
||||
timer = timer.upstream.autoconnect()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue