Skip to content

Commit 98372a7

Browse files
authored
Merge pull request #166 from SDWebImage/update_watchOS_demo_progressView
Update watchOS demo to watchOS 7, remove the custom indicator sample and use `ProgressView` instead
2 parents de29f0b + 75a1b2c commit 98372a7

File tree

6 files changed

+32
-311
lines changed

6 files changed

+32
-311
lines changed

Example/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ target 'SDWebImageSwiftUIDemo-tvOS' do
2323
end
2424

2525
target 'SDWebImageSwiftUIDemo-watchOS WatchKit Extension' do
26-
platform :watchos, '6.0'
26+
platform :watchos, '7.0'
2727
all_pods
2828
end

Example/SDWebImageSwiftUI.xcodeproj/project.pbxproj

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
320CDC3222FADB45007CF858 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 320CDC3122FADB45007CF858 /* Assets.xcassets */; };
1515
320CDC3522FADB45007CF858 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 320CDC3422FADB45007CF858 /* Preview Assets.xcassets */; };
1616
320CDC3822FADB45007CF858 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 320CDC3622FADB45007CF858 /* LaunchScreen.storyboard */; };
17-
3243598423E05C3D006DF9C5 /* Espera.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3243598323E05C3D006DF9C5 /* Espera.swift */; };
18-
3243598523E05C3D006DF9C5 /* Espera.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3243598323E05C3D006DF9C5 /* Espera.swift */; };
19-
3243598623E05C3D006DF9C5 /* Espera.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3243598323E05C3D006DF9C5 /* Espera.swift */; };
20-
3243598723E05C3D006DF9C5 /* Espera.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3243598323E05C3D006DF9C5 /* Espera.swift */; };
2117
326B0D712345C01900D28269 /* DetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326B0D702345C01900D28269 /* DetailView.swift */; };
2218
32E5290C2348A0C700EA46FF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32E5290B2348A0C700EA46FF /* AppDelegate.swift */; };
2319
32E529102348A0C900EA46FF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 32E5290F2348A0C900EA46FF /* Assets.xcassets */; };
@@ -98,7 +94,6 @@
9894
320CDC3422FADB45007CF858 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
9995
320CDC3722FADB45007CF858 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
10096
320CDC3922FADB45007CF858 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
101-
3243598323E05C3D006DF9C5 /* Espera.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Espera.swift; sourceTree = "<group>"; };
10297
326B0D702345C01900D28269 /* DetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailView.swift; sourceTree = "<group>"; };
10398
32E529092348A0C700EA46FF /* SDWebImageSwiftUIDemo-macOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "SDWebImageSwiftUIDemo-macOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
10499
32E5290B2348A0C700EA46FF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@@ -212,7 +207,6 @@
212207
320CDC2D22FADB44007CF858 /* SceneDelegate.swift */,
213208
320CDC2F22FADB44007CF858 /* ContentView.swift */,
214209
326B0D702345C01900D28269 /* DetailView.swift */,
215-
3243598323E05C3D006DF9C5 /* Espera.swift */,
216210
320CDC3122FADB45007CF858 /* Assets.xcassets */,
217211
320CDC3622FADB45007CF858 /* LaunchScreen.storyboard */,
218212
320CDC3922FADB45007CF858 /* Info.plist */,
@@ -792,7 +786,6 @@
792786
320CDC2C22FADB44007CF858 /* AppDelegate.swift in Sources */,
793787
326B0D712345C01900D28269 /* DetailView.swift in Sources */,
794788
320CDC2E22FADB44007CF858 /* SceneDelegate.swift in Sources */,
795-
3243598423E05C3D006DF9C5 /* Espera.swift in Sources */,
796789
320CDC3022FADB44007CF858 /* ContentView.swift in Sources */,
797790
);
798791
runOnlyForDeploymentPostprocessing = 0;
@@ -804,7 +797,6 @@
804797
32E529622348A10B00EA46FF /* ContentView.swift in Sources */,
805798
32E529632348A10B00EA46FF /* DetailView.swift in Sources */,
806799
32E5290C2348A0C700EA46FF /* AppDelegate.swift in Sources */,
807-
3243598523E05C3D006DF9C5 /* Espera.swift in Sources */,
808800
);
809801
runOnlyForDeploymentPostprocessing = 0;
810802
};
@@ -815,7 +807,6 @@
815807
32E529652348A10B00EA46FF /* ContentView.swift in Sources */,
816808
32E529662348A10B00EA46FF /* DetailView.swift in Sources */,
817809
32E529232348A0D300EA46FF /* AppDelegate.swift in Sources */,
818-
3243598623E05C3D006DF9C5 /* Espera.swift in Sources */,
819810
);
820811
runOnlyForDeploymentPostprocessing = 0;
821812
};
@@ -826,7 +817,6 @@
826817
32E5294E2348A0DE00EA46FF /* HostingController.swift in Sources */,
827818
32E529692348A10C00EA46FF /* DetailView.swift in Sources */,
828819
32E529502348A0DE00EA46FF /* ExtensionDelegate.swift in Sources */,
829-
3243598723E05C3D006DF9C5 /* Espera.swift in Sources */,
830820
32E529682348A10C00EA46FF /* ContentView.swift in Sources */,
831821
);
832822
runOnlyForDeploymentPostprocessing = 0;
@@ -1102,7 +1092,7 @@
11021092
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
11031093
SWIFT_VERSION = 5.0;
11041094
TARGETED_DEVICE_FAMILY = 4;
1105-
WATCHOS_DEPLOYMENT_TARGET = 6.0;
1095+
WATCHOS_DEPLOYMENT_TARGET = 7.0;
11061096
};
11071097
name = Debug;
11081098
};
@@ -1132,7 +1122,7 @@
11321122
SKIP_INSTALL = YES;
11331123
SWIFT_VERSION = 5.0;
11341124
TARGETED_DEVICE_FAMILY = 4;
1135-
WATCHOS_DEPLOYMENT_TARGET = 6.0;
1125+
WATCHOS_DEPLOYMENT_TARGET = 7.0;
11361126
};
11371127
name = Release;
11381128
};
@@ -1163,7 +1153,7 @@
11631153
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
11641154
SWIFT_VERSION = 5.0;
11651155
TARGETED_DEVICE_FAMILY = 4;
1166-
WATCHOS_DEPLOYMENT_TARGET = 6.0;
1156+
WATCHOS_DEPLOYMENT_TARGET = 7.0;
11671157
};
11681158
name = Debug;
11691159
};
@@ -1191,7 +1181,7 @@
11911181
SKIP_INSTALL = YES;
11921182
SWIFT_VERSION = 5.0;
11931183
TARGETED_DEVICE_FAMILY = 4;
1194-
WATCHOS_DEPLOYMENT_TARGET = 6.0;
1184+
WATCHOS_DEPLOYMENT_TARGET = 7.0;
11951185
};
11961186
name = Release;
11971187
};
@@ -1217,6 +1207,7 @@
12171207
PRODUCT_NAME = "$(TARGET_NAME)";
12181208
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
12191209
SWIFT_VERSION = 5.0;
1210+
WATCHOS_DEPLOYMENT_TARGET = 7.0;
12201211
};
12211212
name = Debug;
12221213
};
@@ -1239,6 +1230,7 @@
12391230
PRODUCT_BUNDLE_IDENTIFIER = "com.dreampiggy.SDWebImageSwiftUIDemo-watchOS";
12401231
PRODUCT_NAME = "$(TARGET_NAME)";
12411232
SWIFT_VERSION = 5.0;
1233+
WATCHOS_DEPLOYMENT_TARGET = 7.0;
12421234
};
12431235
name = Release;
12441236
};
@@ -1287,7 +1279,6 @@
12871279
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
12881280
GCC_WARN_UNUSED_FUNCTION = YES;
12891281
GCC_WARN_UNUSED_VARIABLE = YES;
1290-
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
12911282
MTL_ENABLE_DEBUG_INFO = YES;
12921283
ONLY_ACTIVE_ARCH = YES;
12931284
SDKROOT = iphoneos;
@@ -1333,7 +1324,6 @@
13331324
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
13341325
GCC_WARN_UNUSED_FUNCTION = YES;
13351326
GCC_WARN_UNUSED_VARIABLE = YES;
1336-
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
13371327
MTL_ENABLE_DEBUG_INFO = NO;
13381328
SDKROOT = iphoneos;
13391329
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";

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

Lines changed: 6 additions & 19 deletions
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

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

20-
#if os(watchOS)
21-
// watchOS does not provide built-in indicator, use Espera's custom indicator
22-
struct ActivityIndicator : View {
23-
@Binding var isAnimating: Bool
24-
var body: some View {
25-
if isAnimating {
26-
return AnyView(LoadingFlowerView()
27-
.frame(width: 30, height: 30))
28-
} else {
29-
return AnyView(EmptyView()
30-
.frame(width: 30, height: 30))
31-
}
32-
}
33-
}
34-
35-
struct ProgressIndicator : View {
36-
@Binding var isAnimating: Bool
37-
@Binding var progress: Double
38-
var body: some View {
39-
if isAnimating {
40-
return AnyView(StretchProgressView(progress: $progress)
41-
.frame(width: 140, height: 10))
42-
} else {
43-
return AnyView(EmptyView()
44-
.frame(width: 140, height: 10))
45-
}
46-
}
47-
}
48-
49-
extension Indicator where T == ActivityIndicator {
50-
/// Activity Indicator
20+
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
21+
extension Indicator where T == ProgressView<EmptyView, EmptyView> {
5122
static var activity: Indicator {
52-
Indicator { isAnimating, _ in
53-
ActivityIndicator(isAnimating: isAnimating)
23+
Indicator { isAnimating, progress in
24+
ProgressView()
5425
}
5526
}
56-
}
57-
58-
extension Indicator where T == ProgressIndicator {
59-
/// Progress Indicator
27+
6028
static var progress: Indicator {
6129
Indicator { isAnimating, progress in
62-
ProgressIndicator(isAnimating: isAnimating, progress: progress)
30+
ProgressView(value: progress.wrappedValue)
6331
}
6432
}
6533
}
66-
#endif
6734

6835
struct ContentView: View {
6936
@State var imageURLs = [

0 commit comments

Comments
 (0)