This repository was archived by the owner on Mar 7, 2026. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +47
-23
lines changed
Expand file tree Collapse file tree 2 files changed +47
-23
lines changed Original file line number Diff line number Diff line change @@ -642,29 +642,41 @@ private struct AppRowView: View {
642642 . frame ( width: iconSize. width, height: iconSize. height)
643643
644644 if let iconURL = app. iconURL {
645- RetryAsyncImage (
646- url: iconURL,
647- size: iconSize,
648- maxAttempts: 3 ,
649- content: { image in
650- image
651- . resizable ( )
652- . scaledToFill ( )
653- . frame ( width: iconSize. width, height: iconSize. height)
654- . clipShape ( RoundedRectangle ( cornerRadius: 10 ) )
655- } ,
656- placeholder: {
657- ProgressView ( )
658- . frame ( width: iconSize. width, height: iconSize. height)
659- } ,
660- failure: {
661- Image ( systemName: " app " )
662- . resizable ( )
663- . scaledToFit ( )
664- . frame ( width: 28 , height: 28 )
665- . foregroundColor ( . secondary)
666- }
667- )
645+ if let cached = ImageCache . shared. get ( for: iconURL) {
646+ cached
647+ . resizable ( )
648+ . scaledToFill ( )
649+ . frame ( width: iconSize. width, height: iconSize. height)
650+ . clipShape ( RoundedRectangle ( cornerRadius: 10 ) )
651+ } else {
652+ RetryAsyncImage (
653+ url: iconURL,
654+ size: iconSize,
655+ maxAttempts: 3 ,
656+ content: { image in
657+ if let uiImage = image. asUIImage {
658+ ImageCache . shared. set ( uiImage, for: iconURL)
659+ }
660+
661+ image
662+ . resizable ( )
663+ . scaledToFill ( )
664+ . frame ( width: iconSize. width, height: iconSize. height)
665+ . clipShape ( RoundedRectangle ( cornerRadius: 10 ) )
666+ } ,
667+ placeholder: {
668+ ProgressView ( )
669+ . frame ( width: iconSize. width, height: iconSize. height)
670+ } ,
671+ failure: {
672+ Image ( systemName: " app " )
673+ . resizable ( )
674+ . scaledToFit ( )
675+ . frame ( width: 28 , height: 28 )
676+ . foregroundColor ( . secondary)
677+ }
678+ )
679+ }
668680 } else {
669681 Image ( systemName: " app " )
670682 . resizable ( )
Original file line number Diff line number Diff line change @@ -18,4 +18,16 @@ final class ImageCache {
1818 }
1919 return nil
2020 }
21+ }
22+
23+ extension Image {
24+ var asUIImage : UIImage ? {
25+ let mirror = Mirror ( reflecting: self )
26+ for child in mirror. children {
27+ if let uiImage = child. value as? UIImage {
28+ return uiImage
29+ }
30+ }
31+ return nil
32+ }
2133}
You can’t perform that action at this time.
0 commit comments