Skip to content
Draft
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
20 changes: 15 additions & 5 deletions podcasts/Sharing/ShareImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ struct ShareImageInfo {
let name: String
let title: String
let description: String
let artwork: URL
let gradient: Gradient
let podcastUuid: String?
let episodeUuid: String?
}

enum ShareImageStyle: CaseIterable {
Expand Down Expand Up @@ -136,9 +137,18 @@ struct ShareImageView: View {
}

@ViewBuilder func image() -> some View {
KFImage(info.artwork)
.resizable()
.clipShape(RoundedRectangle(cornerRadius: 8))
if Settings.loadEmbeddedImages,
let episodeUuid = info.episodeUuid,
ImageManager.sharedManager.subscribedPodcastsCache.isCached(forKey: episodeUuid) {
let path = ImageManager.sharedManager.subscribedPodcastsCache.cachePath(forKey: episodeUuid)
KFImage(URL(fileURLWithPath: path))
.resizable()
.clipShape(RoundedRectangle(cornerRadius: 8))
} else if let podcastUuid = info.podcastUuid {
KFImage(ImageManager.sharedManager.podcastUrl(imageSize: .page, uuid: podcastUuid))
.resizable()
.clipShape(RoundedRectangle(cornerRadius: 8))
}
Comment on lines +140 to +151
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bjtitus We have AsyncImageView which wraps the KFImage

}

@ViewBuilder func text(alignment: HorizontalAlignment = .center, textAlignment: TextAlignment = .center, lineLimit: Int = 2) -> some View {
Expand Down Expand Up @@ -201,7 +211,7 @@ extension View {
return itemProvider
}
}
let previewInfo = ShareImageInfo(name: "This American Life", title: "Dylan Field, Figma Co-founder, Talks Design, Economy, and life after failed Adobe acquisitions", description: Date().formatted(), artwork: URL(string: "https://static.pocketcasts.com/discover/images/280/3782b780-0bc5-012e-fb02-00163e1b201c.jpg")!, gradient: Gradient(colors: [Color.red, Color(hex: "620603")]))
let previewInfo = ShareImageInfo(name: "This American Life", title: "Dylan Field, Figma Co-founder, Talks Design, Economy, and life after failed Adobe acquisitions", description: Date().formatted(), gradient: Gradient(colors: [Color.red, Color(hex: "620603")]), podcastUuid: nil, episodeUuid: nil)

#Preview("large") {
ShareImageView(info: previewInfo, style: .large, angle: .constant(0))
Expand Down
7 changes: 4 additions & 3 deletions podcasts/Sharing/SharingModal.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import PocketCastsDataModel
import SwiftUI
import PocketCastsUtils
import AVFoundation

enum SharingModal {

Expand Down Expand Up @@ -189,12 +190,12 @@ extension SharingModal.Option {
Color(uiColor: ColorManager.lightThemeTintForPodcast(podcast)),
Color(uiColor: UIColor.calculateColor(orgColor: UIColor.black, overlayColor: ColorManager.lightThemeTintForPodcast(podcast).withAlphaComponent(0.8))),
])
let artwork = ImageManager.sharedManager.podcastUrl(imageSize: .page, uuid: podcast.uuid)
let imageInfo = ShareImageInfo(name: name ?? "",
title: title ?? "",
description: description ?? "",
artwork: artwork,
gradient: gradient)
gradient: gradient,
podcastUuid: podcast.uuid,
episodeUuid: episode?.uuid)
return imageInfo
}

Expand Down