diff --git a/Package.resolved b/Package.resolved index 7c9c5ff5..1ad1e6ca 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "0da1e4bb6b1f40a19b1a311a4da8056b660bb61b6f28d9a75a414b06a47187d3", + "originHash" : "0997dd5a67de5508db332755539bfceccd0c1ce547ea5f5484b928b9c5eb3540", "pins" : [ { "identity" : "bswfoundation", @@ -33,8 +33,8 @@ "kind" : "remoteSourceControl", "location" : "https://source.skip.tools/skip.git", "state" : { - "revision" : "9e88c24b32ab42b03e90e3c8fc484f883690fd9c", - "version" : "1.6.27" + "revision" : "8e0c0421c04b00dd55795c913d94279a71a8c3f9", + "version" : "1.7.0" } }, { diff --git a/Sources/BSWInterfaceKit/SwiftUI/Views/PhotoView.swift b/Sources/BSWInterfaceKit/SwiftUI/Views/PhotoView.swift index d90de771..65ba2898 100644 --- a/Sources/BSWInterfaceKit/SwiftUI/Views/PhotoView.swift +++ b/Sources/BSWInterfaceKit/SwiftUI/Views/PhotoView.swift @@ -72,19 +72,26 @@ public struct PhotoView: View { private var photoView: some View { switch photo.kind { case .url(let url): + #if os(Android) + androidPhotoView(url: url) + #else #if canImport(Nuke) nukePhotoView(url: url) #else AsyncImage(url: url) #endif + #endif case .image(let image): + #if os(Android) + image.photoStyle() + #else image .resizable() + #endif default: placeholder } } - var isRunningTests: Bool { #if canImport(UIKit.UIApplication) UIApplication.shared.isRunningTests @@ -93,6 +100,26 @@ public struct PhotoView: View { #endif } + // MARK: - Android + + #if os(Android) + @ViewBuilder + private func androidPhotoView(url: URL) -> some View { + AsyncImage(url: url) { phase in + switch phase { + case .success(let image): + image.photoStyle() + case .failure(_): + configuration.placeholder.body() + default: + configuration.placeholder.body() + } + } + } + #endif + + // MARK: - iOS + #if canImport(Nuke) @ViewBuilder func nukePhotoView(url: URL) -> some View { @@ -180,6 +207,19 @@ extension PhotoView.Configuration: Sendable {} extension PhotoView.Configuration.Placeholder: Sendable {} extension PhotoView.Configuration.Placeholder.Shape: Sendable {} +// MARK: - Android image styling + +#if os(Android) +private extension Image { + func photoStyle() -> some View { + self + .resizable() + .interpolation(.high) + .antialiased(true) + } +} +#endif + #if canImport(UIKit) private extension PhotoView {