mirror of
https://github.com/yattee/yattee.git
synced 2025-12-30 16:32:30 +00:00
Replace URLImage with AsyncImage
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
import URLImage
|
||||
import URLImageStore
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct VideoCellView: View {
|
||||
@@ -12,13 +9,14 @@ struct VideoCellView: View {
|
||||
Button(action: { navigationState.playVideo(video) }) {
|
||||
VStack(alignment: .leading) {
|
||||
ZStack {
|
||||
if let thumbnail = video.thumbnailURL(quality: .high) {
|
||||
// to replace with AsyncImage when it is fixed with lazy views
|
||||
URLImage(thumbnail) { image in
|
||||
if let url = video.thumbnailURL(quality: .high) {
|
||||
AsyncImage(url: url) { image in
|
||||
image
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: 550, height: 310)
|
||||
} placeholder: {
|
||||
ProgressView()
|
||||
}
|
||||
.mask(RoundedRectangle(cornerRadius: 12))
|
||||
} else {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import Defaults
|
||||
import Siesta
|
||||
import SwiftUI
|
||||
import URLImage
|
||||
|
||||
struct VideoDetailsView: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@@ -36,13 +35,14 @@ struct VideoDetailsView: View {
|
||||
VStack(alignment: .center) {
|
||||
ZStack(alignment: .bottom) {
|
||||
Group {
|
||||
if let thumbnail = video.thumbnailURL(quality: .maxres) {
|
||||
// to replace with AsyncImage when it is fixed with lazy views
|
||||
URLImage(thumbnail) { image in
|
||||
if let url = video.thumbnailURL(quality: .maxres) {
|
||||
AsyncImage(url: url) { image in
|
||||
image
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: 1600, height: 800)
|
||||
} placeholder: {
|
||||
ProgressView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import SwiftUI
|
||||
import URLImage
|
||||
import URLImageStore
|
||||
|
||||
struct VideoListRowView: View {
|
||||
@EnvironmentObject<NavigationState> private var navigationState
|
||||
@@ -166,20 +164,13 @@ struct VideoListRowView: View {
|
||||
) -> some View {
|
||||
Group {
|
||||
if let url = video.thumbnailURL(quality: quality) {
|
||||
URLImage(url) {
|
||||
EmptyView()
|
||||
} inProgress: { _ in
|
||||
ProgressView()
|
||||
.progressViewStyle(CircularProgressViewStyle())
|
||||
} failure: { _, retry in
|
||||
VStack {
|
||||
Button("Retry", action: retry)
|
||||
}
|
||||
} content: { image in
|
||||
AsyncImage(url: url) { image in
|
||||
image
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(minWidth: minWidth, maxWidth: maxWidth, minHeight: minHeight, maxHeight: maxHeight)
|
||||
} placeholder: {
|
||||
ProgressView()
|
||||
}
|
||||
.mask(RoundedRectangle(cornerRadius: 12))
|
||||
} else {
|
||||
@@ -201,3 +192,24 @@ struct VideoListRowView: View {
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
struct VideoListRowPreview: PreviewProvider {
|
||||
static var previews: some View {
|
||||
List {
|
||||
VideoListRowView(video: Video.fixture)
|
||||
VideoListRowView(video: Video.fixtureUpcomingWithoutPublishedOrViews)
|
||||
VideoListRowView(video: Video.fixtureLiveWithoutPublishedOrViews)
|
||||
}
|
||||
.frame(maxWidth: 400)
|
||||
|
||||
#if os(iOS)
|
||||
List {
|
||||
VideoListRowView(video: Video.fixture)
|
||||
VideoListRowView(video: Video.fixtureUpcomingWithoutPublishedOrViews)
|
||||
VideoListRowView(video: Video.fixtureLiveWithoutPublishedOrViews)
|
||||
}
|
||||
.environment(\.verticalSizeClass, .compact)
|
||||
.frame(maxWidth: 800)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user