Skip to content

Commit 50b3cef

Browse files
authored
Merge pull request #18 from SDWebImage/demo_all_platforms
Update the demo to support all Apple platforms, using one codebase
2 parents 9ab29c1 + a27f18c commit 50b3cef

File tree

59 files changed

+2880
-84
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2880
-84
lines changed

Example/Podfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,21 @@ target 'SDWebImageSwiftUIDemo' do
55
pod 'SDWebImageSwiftUI', :path => '../'
66
pod 'SDWebImageWebPCoder'
77
end
8+
9+
target 'SDWebImageSwiftUIDemo-macOS' do
10+
platform :osx, '10.15'
11+
pod 'SDWebImageSwiftUI', :path => '../'
12+
pod 'SDWebImageWebPCoder'
13+
end
14+
15+
target 'SDWebImageSwiftUIDemo-tvOS' do
16+
platform :tvos, '13.0'
17+
pod 'SDWebImageSwiftUI', :path => '../'
18+
pod 'SDWebImageWebPCoder'
19+
end
20+
21+
target 'SDWebImageSwiftUIDemo-watchOS WatchKit Extension' do
22+
platform :watchos, '6.0'
23+
pod 'SDWebImageSwiftUI', :path => '../'
24+
pod 'SDWebImageWebPCoder'
25+
end

Example/Podfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PODS:
1111
- SDWebImage (5.2.2):
1212
- SDWebImage/Core (= 5.2.2)
1313
- SDWebImage/Core (5.2.2)
14-
- SDWebImageSwiftUI (0.1.2):
14+
- SDWebImageSwiftUI (0.3.0):
1515
- SDWebImage (~> 5.1)
1616
- SDWebImageWebPCoder (0.2.5):
1717
- libwebp (~> 1.0)
@@ -34,9 +34,9 @@ EXTERNAL SOURCES:
3434
SPEC CHECKSUMS:
3535
libwebp: 057912d6d0abfb6357d8bb05c0ea470301f5d61e
3636
SDWebImage: 5fcdb02cc35e05fc35791ec514b191d27189f872
37-
SDWebImageSwiftUI: 1026ac69b616d77b3ecb5b34e5b977ca9a165d5f
37+
SDWebImageSwiftUI: 9fa220c3c9a69a383f2db5fabc97748ac4e4b696
3838
SDWebImageWebPCoder: 947093edd1349d820c40afbd9f42acb6cdecd987
3939

40-
PODFILE CHECKSUM: c85d310339d014183658205b527a83237d24f8f2
40+
PODFILE CHECKSUM: 3fb06a5173225e197f3a4bf2be7e5586a693257a
4141

4242
COCOAPODS: 1.7.5

Example/SDWebImageSwiftUI.xcodeproj/project.pbxproj

Lines changed: 972 additions & 32 deletions
Large diffs are not rendered by default.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// AppDelegate.swift
3+
// SDWebImageSwiftUIDemo-macOS
4+
//
5+
// Created by lizhuoli on 2019/10/5.
6+
// Copyright © 2019 CocoaPods. All rights reserved.
7+
//
8+
9+
import Cocoa
10+
import SwiftUI
11+
import SDWebImage
12+
import SDWebImageWebPCoder
13+
14+
@NSApplicationMain
15+
class AppDelegate: NSObject, NSApplicationDelegate {
16+
17+
var window: NSWindow!
18+
19+
20+
func applicationDidFinishLaunching(_ aNotification: Notification) {
21+
// Create the SwiftUI view that provides the window contents.
22+
let contentView = ContentView()
23+
24+
// Create the window and set the content view.
25+
window = NSWindow(
26+
contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),
27+
styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
28+
backing: .buffered, defer: false)
29+
window.center()
30+
window.setFrameAutosaveName("Main Window")
31+
window.contentView = NSHostingView(rootView: contentView)
32+
window.makeKeyAndOrderFront(nil)
33+
// Add WebP support
34+
SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)
35+
}
36+
37+
func applicationWillTerminate(_ aNotification: Notification) {
38+
// Insert code here to tear down your application
39+
}
40+
41+
42+
}
43+
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "mac",
5+
"size" : "16x16",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "mac",
10+
"size" : "16x16",
11+
"scale" : "2x"
12+
},
13+
{
14+
"idiom" : "mac",
15+
"size" : "32x32",
16+
"scale" : "1x"
17+
},
18+
{
19+
"idiom" : "mac",
20+
"size" : "32x32",
21+
"scale" : "2x"
22+
},
23+
{
24+
"idiom" : "mac",
25+
"size" : "128x128",
26+
"scale" : "1x"
27+
},
28+
{
29+
"idiom" : "mac",
30+
"size" : "128x128",
31+
"scale" : "2x"
32+
},
33+
{
34+
"idiom" : "mac",
35+
"size" : "256x256",
36+
"scale" : "1x"
37+
},
38+
{
39+
"idiom" : "mac",
40+
"size" : "256x256",
41+
"scale" : "2x"
42+
},
43+
{
44+
"idiom" : "mac",
45+
"size" : "512x512",
46+
"scale" : "1x"
47+
},
48+
{
49+
"idiom" : "mac",
50+
"size" : "512x512",
51+
"scale" : "2x"
52+
}
53+
],
54+
"info" : {
55+
"version" : 1,
56+
"author" : "xcode"
57+
}
58+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}

Example/SDWebImageSwiftUIDemo-macOS/Base.lproj/Main.storyboard

Lines changed: 683 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIconFile</key>
10+
<string></string>
11+
<key>CFBundleIdentifier</key>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>$(PRODUCT_NAME)</string>
17+
<key>CFBundlePackageType</key>
18+
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.0</string>
21+
<key>CFBundleVersion</key>
22+
<string>1</string>
23+
<key>LSMinimumSystemVersion</key>
24+
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
25+
<key>NSHumanReadableCopyright</key>
26+
<string>Copyright © 2019 CocoaPods. All rights reserved.</string>
27+
<key>NSMainStoryboardFile</key>
28+
<string>Main</string>
29+
<key>NSPrincipalClass</key>
30+
<string>NSApplication</string>
31+
<key>NSSupportsAutomaticTermination</key>
32+
<true/>
33+
<key>NSSupportsSuddenTermination</key>
34+
<true/>
35+
<key>NSAppTransportSecurity</key>
36+
<dict>
37+
<key>NSAllowsArbitraryLoads</key>
38+
<true/>
39+
</dict>
40+
</dict>
41+
</plist>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.app-sandbox</key>
6+
<true/>
7+
<key>com.apple.security.files.user-selected.read-only</key>
8+
<true/>
9+
<key>com.apple.security.network.client</key>
10+
<true/>
11+
</dict>
12+
</plist>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//
2+
// AppDelegate.swift
3+
// SDWebImageSwiftUIDemo-tvOS
4+
//
5+
// Created by lizhuoli on 2019/10/5.
6+
// Copyright © 2019 CocoaPods. All rights reserved.
7+
//
8+
9+
import UIKit
10+
import SwiftUI
11+
import SDWebImage
12+
import SDWebImageWebPCoder
13+
14+
@UIApplicationMain
15+
class AppDelegate: UIResponder, UIApplicationDelegate {
16+
17+
var window: UIWindow?
18+
19+
20+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
21+
22+
// Create the SwiftUI view that provides the window contents.
23+
let contentView = ContentView()
24+
25+
// Use a UIHostingController as window root view controller.
26+
let window = UIWindow(frame: UIScreen.main.bounds)
27+
window.rootViewController = UIHostingController(rootView: contentView)
28+
self.window = window
29+
window.makeKeyAndVisible()
30+
// Add WebP support
31+
SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)
32+
33+
return true
34+
}
35+
36+
func applicationWillResignActive(_ application: UIApplication) {
37+
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
38+
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
39+
}
40+
41+
func applicationDidEnterBackground(_ application: UIApplication) {
42+
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
43+
}
44+
45+
func applicationWillEnterForeground(_ application: UIApplication) {
46+
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
47+
}
48+
49+
func applicationDidBecomeActive(_ application: UIApplication) {
50+
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
51+
}
52+
53+
54+
}
55+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "tv"
5+
}
6+
],
7+
"info" : {
8+
"version" : 1,
9+
"author" : "xcode"
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"layers" : [
3+
{
4+
"filename" : "Front.imagestacklayer"
5+
},
6+
{
7+
"filename" : "Middle.imagestacklayer"
8+
},
9+
{
10+
"filename" : "Back.imagestacklayer"
11+
}
12+
],
13+
"info" : {
14+
"version" : 1,
15+
"author" : "xcode"
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "tv"
5+
}
6+
],
7+
"info" : {
8+
"version" : 1,
9+
"author" : "xcode"
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "tv"
5+
}
6+
],
7+
"info" : {
8+
"version" : 1,
9+
"author" : "xcode"
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "tv",
5+
"scale" : "1x"
6+
},
7+
{
8+
"idiom" : "tv",
9+
"scale" : "2x"
10+
}
11+
],
12+
"info" : {
13+
"version" : 1,
14+
"author" : "xcode"
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}

0 commit comments

Comments
 (0)