Use the generic signature for ProgressiveStyle

This match Apple's API
This commit is contained in:
DreamPiggy 2022-12-26 18:04:02 +08:00
parent 63e1aebbf6
commit f2a7b99084
2 changed files with 3 additions and 3 deletions

View File

@ -111,7 +111,7 @@ struct DetailView: View {
WebImage(url: URL(string:url), options: [.progressiveLoad, .delayPlaceholder], isAnimating: $isAnimating)
.resizable()
.placeholder(.wifiExclamationmark)
.indicator(.progress)
.indicator(.progress(style: .circular))
.scaledToFit()
}
}

View File

@ -71,7 +71,7 @@ extension Indicator where T == AnyView {
/// Activity Indicator with style
/// - Parameter style: style
public static func activity(style: any ProgressViewStyle) -> Indicator<T> {
public static func activity<S>(style: S) -> Indicator<T> where S: ProgressViewStyle {
Indicator { isAnimating, _ in
AnyView(ProgressView().progressViewStyle(style).opacity(isAnimating.wrappedValue ? 1 : 0))
}
@ -89,7 +89,7 @@ extension Indicator where T == AnyView {
/// Progress Indicator with style
/// - Parameter style: style
public static func progress(style: any ProgressViewStyle) -> Indicator<T> {
public static func progress<S>(style: S) -> Indicator<T> where S: ProgressViewStyle {
Indicator { isAnimating, progress in
AnyView(ProgressView(value: progress.wrappedValue).progressViewStyle(style).opacity(isAnimating.wrappedValue ? 1 : 0))
}