Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the issue when Indicator is hidden, which still preserve the layout on watchOS (have no issues on iOS/tvOS/macOS) #75

Merged
merged 2 commits into from
Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Example/SDWebImageSwiftUIDemo-macOS/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ class AppDelegate: NSObject, NSApplicationDelegate {
SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)
SDImageCodersManager.shared.addCoder(SDImageSVGCoder.shared)
SDImageCodersManager.shared.addCoder(SDImagePDFCoder.shared)
// Dynamic check to support vector format for both WebImage/AnimatedImage
SDWebImageManager.shared.optionsProcessor = SDWebImageOptionsProcessor { url, options, context in
var options = options
var context = context
if let _ = context?[.animatedImageClass] as? SDAnimatedImage.Type {
// AnimatedImage supports vector rendering, should not force decode
options.insert(.avoidDecodeImage)
} else {
// WebImage supports bitmap rendering only
context?[.svgPrefersBitmap] = true
context?[.pdfPrefersBitmap] = true
}
return SDWebImageOptionsResult(options: options, context: context)
}
}

func applicationWillTerminate(_ aNotification: Notification) {
Expand Down
14 changes: 14 additions & 0 deletions Example/SDWebImageSwiftUIDemo-tvOS/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)
SDImageCodersManager.shared.addCoder(SDImageSVGCoder.shared)
SDImageCodersManager.shared.addCoder(SDImagePDFCoder.shared)
// Dynamic check to support vector format for both WebImage/AnimatedImage
SDWebImageManager.shared.optionsProcessor = SDWebImageOptionsProcessor { url, options, context in
var options = options
var context = context
if let _ = context?[.animatedImageClass] as? SDAnimatedImage.Type {
// AnimatedImage supports vector rendering, should not force decode
options.insert(.avoidDecodeImage)
} else {
// WebImage supports bitmap rendering only
context?[.svgPrefersBitmap] = true
context?[.pdfPrefersBitmap] = true
}
return SDWebImageOptionsResult(options: options, context: context)
}

return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ class ExtensionDelegate: NSObject, WKExtensionDelegate {
SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)
SDImageCodersManager.shared.addCoder(SDImageSVGCoder.shared)
SDImageCodersManager.shared.addCoder(SDImagePDFCoder.shared)
// Dynamic check to support vector format for WebImage
SDWebImageManager.shared.optionsProcessor = SDWebImageOptionsProcessor { url, options, context in
var context = context
// WebImage supports bitmap rendering only
context?[.svgPrefersBitmap] = true
context?[.pdfPrefersBitmap] = true
return SDWebImageOptionsResult(options: options, context: context)
}
}

func applicationDidBecomeActive() {
Expand Down
6 changes: 4 additions & 2 deletions Example/SDWebImageSwiftUIDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)
SDImageCodersManager.shared.addCoder(SDImageSVGCoder.shared)
SDImageCodersManager.shared.addCoder(SDImagePDFCoder.shared)
// Dynamic check to support both WebImage/AnimatedImage
// Dynamic check to support vector format for both WebImage/AnimatedImage
SDWebImageManager.shared.optionsProcessor = SDWebImageOptionsProcessor { url, options, context in
var options = options
var context = context
if let _ = context?[.animatedImageClass] as? SDAnimatedImage.Type {
// AnimatedImage supports vector rendering
// AnimatedImage supports vector rendering, should not force decode
options.insert(.avoidDecodeImage)
} else {
// WebImage supports bitmap rendering only
context?[.svgPrefersBitmap] = true
Expand Down
2 changes: 0 additions & 2 deletions SDWebImageSwiftUI/Classes/Indicator/Indicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ struct IndicatorViewModifier<T> : ViewModifier where T : View {
content
if imageManager.isLoading {
indicator.content($imageManager.isLoading, $imageManager.progress)
} else {
indicator.content($imageManager.isLoading, $imageManager.progress).hidden()
}
}
}
Expand Down