Add ProgressView as overlay when possible
Instead of replacing view entirely (GenericCreditsView). Make replacement explicit in DebugLogView. Basically drop View extension.
This commit is contained in:
parent
aefbfaa588
commit
96b199425f
|
@ -141,14 +141,18 @@ extension GenericCreditsView {
|
|||
@Binding var content: String?
|
||||
|
||||
var body: some View {
|
||||
content.map { unwrapped in
|
||||
ScrollView {
|
||||
Text(unwrapped)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
||||
.padding()
|
||||
ZStack {
|
||||
content.map { unwrapped in
|
||||
ScrollView {
|
||||
Text(unwrapped)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
}.replacedWithProgress(when: content == nil)
|
||||
.onAppear(perform: loadURL)
|
||||
if content == nil {
|
||||
ProgressView()
|
||||
}
|
||||
}.onAppear(perform: loadURL)
|
||||
}
|
||||
|
||||
private func loadURL() {
|
||||
|
|
|
@ -88,15 +88,6 @@ extension View {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
func replacedWithProgress(when condition: Bool) -> some View {
|
||||
if condition {
|
||||
ProgressView()
|
||||
} else {
|
||||
self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension View {
|
||||
|
|
|
@ -65,11 +65,15 @@ struct DebugLogView: View {
|
|||
.edgesIgnoringSafeArea([.leading, .trailing])
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func toolbar() -> some View {
|
||||
Button(action: shareDebugLog) {
|
||||
themeShareImage.asSystemImage
|
||||
}.replacedWithProgress(when: isSharing)
|
||||
.disabled(logLines.isEmpty)
|
||||
if !isSharing {
|
||||
Button(action: shareDebugLog) {
|
||||
themeShareImage.asSystemImage
|
||||
}.disabled(logLines.isEmpty)
|
||||
} else {
|
||||
ProgressView()
|
||||
}
|
||||
}
|
||||
|
||||
private var contentView: some View {
|
||||
|
|
Loading…
Reference in New Issue