Skip to content

Commit 63e1aeb

Browse files
committed
Remove the legacy ActivityIndicator/ProgressIndicator, use ProrgessView
1 parent 2909b00 commit 63e1aeb

File tree

5 files changed

+18
-245
lines changed

5 files changed

+18
-245
lines changed

Example/SDWebImageSwiftUI.xcodeproj/xcshareddata/xcschemes/SDWebImageSwiftUIDemo-watchOS WatchKit App.xcscheme

+6-19
Original file line numberDiff line numberDiff line change
@@ -54,46 +54,33 @@
5454
debugDocumentVersioning = "YES"
5555
debugServiceExtension = "internal"
5656
allowLocationSimulation = "YES">
57-
<RemoteRunnable
58-
runnableDebuggingMode = "2"
59-
BundleIdentifier = "com.apple.Carousel"
60-
RemotePath = "/SDWebImageSwiftUIDemo-watchOS WatchKit App">
57+
<BuildableProductRunnable
58+
runnableDebuggingMode = "0">
6159
<BuildableReference
6260
BuildableIdentifier = "primary"
6361
BlueprintIdentifier = "32E529362348A0DD00EA46FF"
6462
BuildableName = "SDWebImageSwiftUIDemo-watchOS WatchKit App.app"
6563
BlueprintName = "SDWebImageSwiftUIDemo-watchOS WatchKit App"
6664
ReferencedContainer = "container:SDWebImageSwiftUI.xcodeproj">
6765
</BuildableReference>
68-
</RemoteRunnable>
66+
</BuildableProductRunnable>
6967
</LaunchAction>
7068
<ProfileAction
7169
buildConfiguration = "Release"
7270
shouldUseLaunchSchemeArgsEnv = "YES"
7371
savedToolIdentifier = ""
7472
useCustomWorkingDirectory = "NO"
7573
debugDocumentVersioning = "YES">
76-
<RemoteRunnable
77-
runnableDebuggingMode = "2"
78-
BundleIdentifier = "com.apple.Carousel"
79-
RemotePath = "/SDWebImageSwiftUIDemo-watchOS WatchKit App">
74+
<BuildableProductRunnable
75+
runnableDebuggingMode = "0">
8076
<BuildableReference
8177
BuildableIdentifier = "primary"
8278
BlueprintIdentifier = "32E529362348A0DD00EA46FF"
8379
BuildableName = "SDWebImageSwiftUIDemo-watchOS WatchKit App.app"
8480
BlueprintName = "SDWebImageSwiftUIDemo-watchOS WatchKit App"
8581
ReferencedContainer = "container:SDWebImageSwiftUI.xcodeproj">
8682
</BuildableReference>
87-
</RemoteRunnable>
88-
<MacroExpansion>
89-
<BuildableReference
90-
BuildableIdentifier = "primary"
91-
BlueprintIdentifier = "32E529362348A0DD00EA46FF"
92-
BuildableName = "SDWebImageSwiftUIDemo-watchOS WatchKit App.app"
93-
BlueprintName = "SDWebImageSwiftUIDemo-watchOS WatchKit App"
94-
ReferencedContainer = "container:SDWebImageSwiftUI.xcodeproj">
95-
</BuildableReference>
96-
</MacroExpansion>
83+
</BuildableProductRunnable>
9784
</ProfileAction>
9885
<AnalyzeAction
9986
buildConfiguration = "Debug">

Example/SDWebImageSwiftUIDemo/ContentView.swift

-17
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

-82
This file was deleted.

SDWebImageSwiftUI/Classes/Indicator/Indicator.swift

+12-13
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(style: any ProgressViewStyle) -> Indicator<T> {
7575
Indicator { isAnimating, _ in
76-
ActivityIndicator(isAnimating, style: style)
76+
AnyView(ProgressView().progressViewStyle(style).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(style: any ProgressViewStyle) -> Indicator<T> {
9393
Indicator { isAnimating, progress in
94-
ProgressIndicator(isAnimating, progress: progress, style: style)
94+
AnyView(ProgressView(value: progress.wrappedValue).progressViewStyle(style).opacity(isAnimating.wrappedValue ? 1 : 0))
9595
}
9696
}
9797
}
98-
#endif

SDWebImageSwiftUI/Classes/Indicator/ProgressIndicator.swift

-114
This file was deleted.

0 commit comments

Comments
 (0)