Skip to content

Commit

Permalink
提高图片显示清晰度 (#40)
Browse files Browse the repository at this point in the history
* Update VideoDetailView.swift

* Update VideoDetailView.swift

* Update VideoDetailView.swift
  • Loading branch information
WindowsMEMZ committed Oct 12, 2024
1 parent a6d1d88 commit 5acbd55
Showing 1 changed file with 15 additions and 32 deletions.
47 changes: 15 additions & 32 deletions DarockBili Watch App/Video/VideoDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -408,40 +408,23 @@ struct VideoDetailView: View {
var body: some View {
VStack {
Spacer()
CachedAsyncImage(url: URL(string: videoDetails["Pic"]! + "@240w_160h")) { phase in
switch phase {
case .empty:
Image("Placeholder")
.fixedSize()
.frame(width: 120, height: 80)
.redacted(reason: .placeholder)
case .success(let image):
image
.resizable()
.fixedSize()
.frame(width: 120, height: 80)
case .failure(let error):
Image("Placeholder")
.fixedSize()
.frame(width: 120, height: 80)
.redacted(reason: .placeholder)
.onAppear {
debugPrint(error)
}
@unknown default:
Image("Placeholder")
.fixedSize()
WebImage(url: URL(string: videoDetails["Pic"]! + "@240w_160h")!, options: [.progressiveLoad, .scaleDownLargeImages])
.placeholder {
RoundedRectangle(cornerRadius: 14)
.frame(width: 120, height: 80)
.foregroundColor(Color(hex: 0x3D3D3D))
.redacted(reason: .placeholder)
}
}
.cornerRadius(5)
.shadow(color: .black.opacity(0.5), radius: 5, x: 1, y: 2)
.offset(y: 8)
.sheet(isPresented: $isCoverImageViewPresented, content: {ImageViewerView(url: videoDetails["Pic"]!)})
.onTapGesture {
isCoverImageViewPresented = true
}
.resizable()
.scaledToFit()
.frame(width: 120, height: 80)
.cornerRadius(14)
.shadow(color: .black.opacity(0.5), radius: 5, x: 1, y: 2)
.offset(y: 8)
.sheet(isPresented: $isCoverImageViewPresented, content: {ImageViewerView(url: videoDetails["Pic"]!)})
.onTapGesture {
isCoverImageViewPresented = true
}
Spacer()
.frame(height: 20)
HStack {
Expand Down Expand Up @@ -766,7 +749,7 @@ struct VideoDetailView: View {
Text(publishTime)
Spacer()
}
.offset(x: -1, y: publishTimeTextOffset)
.offset(y: publishTimeTextOffset)
.animation(.easeOut(duration: 0.85), value: publishTimeTextOffset)
.onAppear {
publishTimeTextOffset = 0
Expand Down

0 comments on commit 5acbd55

Please sign in to comment.