diff --git a/dimensionhub/Assets.xcassets/ph_img_big.imageset/Contents.json b/dimensionhub/Assets.xcassets/ph_img_big.imageset/Contents.json new file mode 100644 index 0000000..527e892 --- /dev/null +++ b/dimensionhub/Assets.xcassets/ph_img_big.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "ph_img_big.jpg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/dimensionhub/Assets.xcassets/ph_img_big.imageset/ph_img_big.jpg b/dimensionhub/Assets.xcassets/ph_img_big.imageset/ph_img_big.jpg new file mode 100644 index 0000000..3303e68 Binary files /dev/null and b/dimensionhub/Assets.xcassets/ph_img_big.imageset/ph_img_big.jpg differ diff --git a/dimensionhub/Assets.xcassets/ph_img_medium.imageset/Contents.json b/dimensionhub/Assets.xcassets/ph_img_medium.imageset/Contents.json new file mode 100644 index 0000000..201fbf2 --- /dev/null +++ b/dimensionhub/Assets.xcassets/ph_img_medium.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "ph_img_medium.jpg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/dimensionhub/Assets.xcassets/ph_img_medium.imageset/ph_img_medium.jpg b/dimensionhub/Assets.xcassets/ph_img_medium.imageset/ph_img_medium.jpg new file mode 100644 index 0000000..61abe73 Binary files /dev/null and b/dimensionhub/Assets.xcassets/ph_img_medium.imageset/ph_img_medium.jpg differ diff --git a/dimensionhub/Assets.xcassets/ph_img_small.imageset/Contents.json b/dimensionhub/Assets.xcassets/ph_img_small.imageset/Contents.json new file mode 100644 index 0000000..4364426 --- /dev/null +++ b/dimensionhub/Assets.xcassets/ph_img_small.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "ph_img_small.jpg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/dimensionhub/Assets.xcassets/ph_img_small.imageset/ph_img_small.jpg b/dimensionhub/Assets.xcassets/ph_img_small.imageset/ph_img_small.jpg new file mode 100644 index 0000000..a63be99 Binary files /dev/null and b/dimensionhub/Assets.xcassets/ph_img_small.imageset/ph_img_small.jpg differ diff --git a/dimensionhub/Views/DetailView.swift b/dimensionhub/Views/DetailView.swift index 86e5476..fbd07d6 100644 --- a/dimensionhub/Views/DetailView.swift +++ b/dimensionhub/Views/DetailView.swift @@ -291,14 +291,24 @@ extension DetailView { var body: some View { VStack(alignment: .center) { - AsyncImage(url: URL(string: episode.thumb)) { image in - image - .resizable() - .aspectRatio(contentMode: .fill) - .frame(width: 90, height: 70) - .clipped() - } placeholder: { - ProgressView() + + AsyncImage(url: URL(string: episode.thumb)) { phase in + switch phase { + case .empty: + ProgressView() + case .success(let image): + image + .resizable() + .aspectRatio(contentMode: .fill) + .frame(width: 90, height: 70) + .clipped() + default: + Image("ph_img_small") + .resizable() + .aspectRatio(contentMode: .fill) + .clipped() + } + } .frame(width: 90, height: 70) .overlay(alignment: .topLeading) { diff --git a/dimensionhub/Views/IndexView.swift b/dimensionhub/Views/IndexView.swift index b5ef34b..2d0a89f 100644 --- a/dimensionhub/Views/IndexView.swift +++ b/dimensionhub/Views/IndexView.swift @@ -397,13 +397,22 @@ extension IndexView { ForEach(dramaItem.episodes) { item in VStack(alignment: .center) { GeometryReader { geometry in - AsyncImage(url: URL(string: item.thumb)) { image in - image - .resizable() - .aspectRatio(contentMode: .fill) - .clipped() - } placeholder: { - ProgressView() + + AsyncImage(url: URL(string: item.thumb)) { phase in + switch phase { + case .empty: + ProgressView() + case .success(let image): + image + .resizable() + .aspectRatio(contentMode: .fill) + .clipped() + default: + Image("ph_img_medium") + .resizable() + .aspectRatio(contentMode: .fill) + .clipped() + } } .frame(width: geometry.frame(in: .local).width, height: 80) .overlay(alignment: .topLeading) { @@ -463,14 +472,23 @@ extension IndexView { ForEach(group.items, id: \.id) { item in NavigationLink(destination: DetailView(id: item.id)) { - AsyncImage(url: URL(string: item.thumb)) { image in - image - .resizable() - .aspectRatio(contentMode: .fill) - .frame(width: 370, height: 180) - .clipped() - } placeholder: { - ProgressView() + AsyncImage(url: URL(string: item.thumb)) { phase in + switch phase { + case .empty: + ProgressView() + case .success(let image): + image + .resizable() + .aspectRatio(contentMode: .fill) + .frame(width: 370, height: 180) + .clipped() + default: + Image("ph_img_big") + .resizable() + .aspectRatio(contentMode: .fill) + .clipped() + } + } .frame(width: 370, height: 180) .overlay(alignment: .topLeading) { diff --git a/dimensionhub/Views/ListView.swift b/dimensionhub/Views/ListView.swift index e93317c..b5c0a94 100644 --- a/dimensionhub/Views/ListView.swift +++ b/dimensionhub/Views/ListView.swift @@ -148,14 +148,24 @@ extension ListView { var body: some View { HStack(alignment: .center) { - AsyncImage(url: URL(string: episode.thumb)) { image in - image - .resizable() - .aspectRatio(contentMode: .fill) - .frame(width: 90, height: 60) - .clipped() - } placeholder: { - ProgressView() + + AsyncImage(url: URL(string: episode.thumb)) { phase in + switch phase { + case .empty: + ProgressView() + case .success(let image): + image + .resizable() + .aspectRatio(contentMode: .fill) + .frame(width: 90, height: 60) + .clipped() + default: + Image("ph_img_medium") + .resizable() + .aspectRatio(contentMode: .fill) + .clipped() + } + } .frame(width: 90, height: 60)