Add the example to use SVG and PDF vector image
This commit is contained in:
parent
a6b8ba49e9
commit
d5fc42ccea
|
@ -1,25 +1,28 @@
|
|||
use_frameworks!
|
||||
|
||||
def all_pods
|
||||
pod 'SDWebImageSwiftUI', :path => '../'
|
||||
pod 'SDWebImageWebPCoder'
|
||||
pod 'SDWebImageSVGCoder'
|
||||
pod 'SDWebImagePDFCoder'
|
||||
end
|
||||
|
||||
target 'SDWebImageSwiftUIDemo' do
|
||||
platform :ios, '13.0'
|
||||
pod 'SDWebImageSwiftUI', :path => '../'
|
||||
pod 'SDWebImageWebPCoder'
|
||||
all_pods
|
||||
end
|
||||
|
||||
target 'SDWebImageSwiftUIDemo-macOS' do
|
||||
platform :osx, '10.15'
|
||||
pod 'SDWebImageSwiftUI', :path => '../'
|
||||
pod 'SDWebImageWebPCoder'
|
||||
all_pods
|
||||
end
|
||||
|
||||
target 'SDWebImageSwiftUIDemo-tvOS' do
|
||||
platform :tvos, '13.0'
|
||||
pod 'SDWebImageSwiftUI', :path => '../'
|
||||
pod 'SDWebImageWebPCoder'
|
||||
all_pods
|
||||
end
|
||||
|
||||
target 'SDWebImageSwiftUIDemo-watchOS WatchKit Extension' do
|
||||
platform :watchos, '6.0'
|
||||
pod 'SDWebImageSwiftUI', :path => '../'
|
||||
pod 'SDWebImageWebPCoder'
|
||||
all_pods
|
||||
end
|
|
@ -622,6 +622,8 @@
|
|||
inputPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-SDWebImageSwiftUIDemo-tvOS/Pods-SDWebImageSwiftUIDemo-tvOS-frameworks.sh",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImage-tvOS/SDWebImage.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImagePDFCoder-tvOS/SDWebImagePDFCoder.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImageSVGCoder-tvOS/SDWebImageSVGCoder.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImageSwiftUI-tvOS/SDWebImageSwiftUI.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImageWebPCoder-tvOS/SDWebImageWebPCoder.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/libwebp-tvOS/libwebp.framework",
|
||||
|
@ -629,6 +631,8 @@
|
|||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImagePDFCoder.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageSVGCoder.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageSwiftUI.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageWebPCoder.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libwebp.framework",
|
||||
|
@ -646,6 +650,8 @@
|
|||
inputPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-SDWebImageSwiftUIDemo-macOS/Pods-SDWebImageSwiftUIDemo-macOS-frameworks.sh",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImage-macOS/SDWebImage.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImagePDFCoder-macOS/SDWebImagePDFCoder.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImageSVGCoder-macOS/SDWebImageSVGCoder.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImageSwiftUI-macOS/SDWebImageSwiftUI.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImageWebPCoder-macOS/SDWebImageWebPCoder.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/libwebp-macOS/libwebp.framework",
|
||||
|
@ -653,6 +659,8 @@
|
|||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImagePDFCoder.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageSVGCoder.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageSwiftUI.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageWebPCoder.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libwebp.framework",
|
||||
|
@ -670,6 +678,8 @@
|
|||
inputPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-SDWebImageSwiftUIDemo/Pods-SDWebImageSwiftUIDemo-frameworks.sh",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImage-iOS/SDWebImage.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImagePDFCoder-iOS/SDWebImagePDFCoder.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImageSVGCoder-iOS/SDWebImageSVGCoder.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImageSwiftUI-iOS/SDWebImageSwiftUI.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImageWebPCoder-iOS/SDWebImageWebPCoder.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/libwebp-iOS/libwebp.framework",
|
||||
|
@ -677,6 +687,8 @@
|
|||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImagePDFCoder.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageSVGCoder.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageSwiftUI.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageWebPCoder.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libwebp.framework",
|
||||
|
@ -716,6 +728,8 @@
|
|||
inputPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-SDWebImageSwiftUIDemo-watchOS WatchKit Extension/Pods-SDWebImageSwiftUIDemo-watchOS WatchKit Extension-frameworks.sh",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImage-watchOS/SDWebImage.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImagePDFCoder-watchOS/SDWebImagePDFCoder.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImageSVGCoder-watchOS/SDWebImageSVGCoder.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImageSwiftUI-watchOS/SDWebImageSwiftUI.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/SDWebImageWebPCoder-watchOS/SDWebImageWebPCoder.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/libwebp-watchOS/libwebp.framework",
|
||||
|
@ -723,6 +737,8 @@
|
|||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImagePDFCoder.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageSVGCoder.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageSwiftUI.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageWebPCoder.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libwebp.framework",
|
||||
|
|
|
@ -10,6 +10,8 @@ import Cocoa
|
|||
import SwiftUI
|
||||
import SDWebImage
|
||||
import SDWebImageWebPCoder
|
||||
import SDWebImageSVGCoder
|
||||
import SDWebImagePDFCoder
|
||||
|
||||
@NSApplicationMain
|
||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
@ -30,8 +32,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
window.setFrameAutosaveName("Main Window")
|
||||
window.contentView = NSHostingView(rootView: contentView)
|
||||
window.makeKeyAndOrderFront(nil)
|
||||
// Add WebP support
|
||||
// Add WebP/SVG/PDF support
|
||||
SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)
|
||||
SDImageCodersManager.shared.addCoder(SDImageSVGCoder.shared)
|
||||
SDImageCodersManager.shared.addCoder(SDImagePDFCoder.shared)
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ aNotification: Notification) {
|
||||
|
|
|
@ -10,6 +10,8 @@ import UIKit
|
|||
import SwiftUI
|
||||
import SDWebImage
|
||||
import SDWebImageWebPCoder
|
||||
import SDWebImageSVGCoder
|
||||
import SDWebImagePDFCoder
|
||||
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
@ -27,8 +29,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||
window.rootViewController = UIHostingController(rootView: contentView)
|
||||
self.window = window
|
||||
window.makeKeyAndVisible()
|
||||
// Add WebP support
|
||||
// Add WebP/SVG/PDF support
|
||||
SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)
|
||||
SDImageCodersManager.shared.addCoder(SDImageSVGCoder.shared)
|
||||
SDImageCodersManager.shared.addCoder(SDImagePDFCoder.shared)
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -9,13 +9,17 @@
|
|||
import WatchKit
|
||||
import SDWebImage
|
||||
import SDWebImageWebPCoder
|
||||
import SDWebImageSVGCoder
|
||||
import SDWebImagePDFCoder
|
||||
|
||||
class ExtensionDelegate: NSObject, WKExtensionDelegate {
|
||||
|
||||
func applicationDidFinishLaunching() {
|
||||
// Perform any final initialization of your application.
|
||||
// Add WebP support
|
||||
// Add WebP/SVG/PDF support
|
||||
SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)
|
||||
SDImageCodersManager.shared.addCoder(SDImageSVGCoder.shared)
|
||||
SDImageCodersManager.shared.addCoder(SDImagePDFCoder.shared)
|
||||
}
|
||||
|
||||
func applicationDidBecomeActive() {
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
import UIKit
|
||||
import SDWebImage
|
||||
import SDWebImageWebPCoder
|
||||
import SDWebImageSVGCoder
|
||||
import SDWebImagePDFCoder
|
||||
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
@ -17,8 +19,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
// Override point for customization after application launch.
|
||||
// Add WebP support
|
||||
// Add WebP/SVG/PDF support
|
||||
SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)
|
||||
SDImageCodersManager.shared.addCoder(SDImageSVGCoder.shared)
|
||||
SDImageCodersManager.shared.addCoder(SDImagePDFCoder.shared)
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,12 @@ struct ContentView: View {
|
|||
"https://www.sample-videos.com/img/Sample-png-image-1mb.png",
|
||||
"https://nr-platform.s3.amazonaws.com/uploads/platform/published_extension/branding_icon/275/AmazonS3.png",
|
||||
"https://raw.githubusercontent.com/ibireme/YYImage/master/Demo/YYImageDemo/mew_baseline.jpg",
|
||||
"http://via.placeholder.com/200x200.jpg"]
|
||||
"http://via.placeholder.com/200x200.jpg",
|
||||
"https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/w3c.svg",
|
||||
"https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/wikimedia.svg",
|
||||
"https://raw.githubusercontent.com/icons8/flat-color-icons/master/pdf/stack_of_photos.pdf",
|
||||
"https://raw.githubusercontent.com/icons8/flat-color-icons/master/pdf/smartphone_tablet.pdf"
|
||||
]
|
||||
@State var animated: Bool = false // You can change between WebImage/AnimatedImage
|
||||
|
||||
var body: some View {
|
||||
|
|
|
@ -25,7 +25,7 @@ Since SDWebImageSwiftUI is built on top of SDWebImage, it provide both the out-o
|
|||
- [x] Multiple caches system, query from different source
|
||||
- [x] Multiple loaders system, load from different resource
|
||||
|
||||
You can also get all benefits from the existing community around with SDWebImage. You can have massive image format support (GIF/APNG/WebP/HEIF/AVIF) via [Coder Plugins](https://github.com/SDWebImage/SDWebImage/wiki/Coder-Plugin-List), PhotoKit support via [SDWebImagePhotosPlugin](https://github.com/SDWebImage/SDWebImagePhotosPlugin), Firebase integration via [FirebaseUI](https://github.com/firebase/FirebaseUI-iOS), etc.
|
||||
You can also get all benefits from the existing community around with SDWebImage. You can have massive image format support (GIF/APNG/WebP/HEIF/AVIF/SVG/PDF) via [Coder Plugins](https://github.com/SDWebImage/SDWebImage/wiki/Coder-Plugin-List), PhotoKit support via [SDWebImagePhotosPlugin](https://github.com/SDWebImage/SDWebImagePhotosPlugin), Firebase integration via [FirebaseUI](https://github.com/firebase/FirebaseUI-iOS), etc.
|
||||
|
||||
Besides all these features, we do optimization for SwiftUI, like Binding, View Modifier, using the same design pattern to become a good SwiftUI citizen.
|
||||
|
||||
|
@ -107,11 +107,12 @@ var body: some View {
|
|||
}
|
||||
```
|
||||
|
||||
Note: This `WebImage` using `Image` for internal implementation, which is the best compatible for SwiftUI layout and animation system. But it supports static image format only, because unlike `UIImageView` in UIKit, SwiftUI's `Image` does not support animation.
|
||||
Note: This `WebImage` using `Image` for internal implementation, which is the best compatible for SwiftUI layout and animation system. But it supports static image format only, because unlike `UIImageView` in UIKit, SwiftUI's `Image` does not support animated image and vector image.
|
||||
|
||||
### Using `AnimatedImage` to play animation
|
||||
|
||||
- [x] Supports network image as well as local data and bundle image
|
||||
- [x] Supports animated image format as well as vector image format
|
||||
- [x] Supports animated progressive image loading (like web browser)
|
||||
- [x] Supports animation control using the SwiftUI Binding
|
||||
- [x] Supports indicator and transition, powered by SDWebImage and Core Animation
|
||||
|
|
Loading…
Reference in New Issue