Skip to content

Commit 300d522

Browse files
committed
Remove the legacy ActivityIndicator/ProgressIndicator, use ProrgessView
1 parent 70a97d4 commit 300d522

File tree

4 files changed

+12
-226
lines changed

4 files changed

+12
-226
lines changed

Example/SDWebImageSwiftUIDemo/ContentView.swift

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,6 @@ class UserSettings: ObservableObject {
1717
#endif
1818
}
1919

20-
#if os(watchOS)
21-
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
22-
extension Indicator where T == ProgressView<EmptyView, EmptyView> {
23-
static var activity: Indicator {
24-
Indicator { isAnimating, progress in
25-
ProgressView()
26-
}
27-
}
28-
29-
static var progress: Indicator {
30-
Indicator { isAnimating, progress in
31-
ProgressView(value: progress.wrappedValue)
32-
}
33-
}
34-
}
35-
#endif
36-
3720
// Test Switching url using @State
3821
struct ContentView2: View {
3922
@State var imageURLs = [

SDWebImageSwiftUI/Classes/Indicator/ActivityIndicator.swift

Lines changed: 0 additions & 82 deletions
This file was deleted.

SDWebImageSwiftUI/Classes/Indicator/Indicator.swift

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,45 +54,44 @@ public struct IndicatorViewModifier<T> : ViewModifier where T : View {
5454

5555
public func body(content: Content) -> some View {
5656
ZStack {
57-
content.overlay(overlay, alignment: .center)
57+
content
58+
overlay
5859
}
5960
}
6061
}
6162

62-
#if os(macOS) || os(iOS) || os(tvOS)
6363
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
64-
extension Indicator where T == ActivityIndicator {
64+
extension Indicator where T == AnyView {
6565
/// Activity Indicator
66-
public static var activity: Indicator {
66+
public static var activity: Indicator<T> {
6767
Indicator { isAnimating, _ in
68-
ActivityIndicator(isAnimating)
68+
AnyView(ProgressView().opacity(isAnimating.wrappedValue ? 1 : 0))
6969
}
7070
}
7171

7272
/// Activity Indicator with style
7373
/// - Parameter style: style
74-
public static func activity(style: ActivityIndicator.Style) -> Indicator {
74+
public static func activity(configuration: ProgressViewStyleConfiguration) -> Indicator<T> {
7575
Indicator { isAnimating, _ in
76-
ActivityIndicator(isAnimating, style: style)
76+
AnyView(ProgressView(configuration).opacity(isAnimating.wrappedValue ? 1 : 0))
7777
}
7878
}
7979
}
8080

8181
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
82-
extension Indicator where T == ProgressIndicator {
82+
extension Indicator where T == AnyView {
8383
/// Progress Indicator
84-
public static var progress: Indicator {
84+
public static var progress: Indicator<T> {
8585
Indicator { isAnimating, progress in
86-
ProgressIndicator(isAnimating, progress: progress)
86+
AnyView(ProgressView(value: progress.wrappedValue).opacity(isAnimating.wrappedValue ? 1 : 0))
8787
}
8888
}
8989

9090
/// Progress Indicator with style
9191
/// - Parameter style: style
92-
public static func progress(style: ProgressIndicator.Style) -> Indicator {
92+
public static func progress(configuration: ProgressViewStyleConfiguration) -> Indicator<T> {
9393
Indicator { isAnimating, progress in
94-
ProgressIndicator(isAnimating, progress: progress, style: style)
94+
AnyView(ProgressView(configuration).opacity(isAnimating.wrappedValue ? 1 : 0))
9595
}
9696
}
9797
}
98-
#endif

SDWebImageSwiftUI/Classes/Indicator/ProgressIndicator.swift

Lines changed: 0 additions & 114 deletions
This file was deleted.

0 commit comments

Comments
 (0)