Better Media viewer
This commit is contained in:
parent
d995b7c996
commit
9d7f93303f
|
@ -14,6 +14,8 @@ struct StatusCardView: View {
|
|||
content: { image in
|
||||
image.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(maxHeight: 200)
|
||||
.clipped()
|
||||
},
|
||||
placeholder: {
|
||||
ProgressView()
|
||||
|
|
|
@ -39,10 +39,10 @@ public struct StatusMediaPreviewView: View {
|
|||
@ViewBuilder
|
||||
private func makePreview(attachement: MediaAttachement) -> some View {
|
||||
if let type = attachement.supportedType {
|
||||
switch type {
|
||||
case .image:
|
||||
Group {
|
||||
GeometryReader { proxy in
|
||||
switch type {
|
||||
case .image:
|
||||
AsyncImage(
|
||||
url: attachement.url,
|
||||
content: { image in
|
||||
|
@ -57,6 +57,11 @@ public struct StatusMediaPreviewView: View {
|
|||
.frame(maxWidth: 80, maxHeight: 80)
|
||||
}
|
||||
)
|
||||
case .gifv:
|
||||
VideoPlayer(player: AVPlayer(url: attachement.url))
|
||||
.frame(width: proxy.frame(in: .local).width)
|
||||
.frame(height: attachements.count > 2 ? 100 : 200)
|
||||
}
|
||||
}
|
||||
.frame(height: attachements.count > 2 ? 100 : 200)
|
||||
}
|
||||
|
@ -64,10 +69,6 @@ public struct StatusMediaPreviewView: View {
|
|||
.onTapGesture {
|
||||
selectedMediaSheetManager.selectedAttachement = attachement
|
||||
}
|
||||
case .gifv:
|
||||
VideoPlayer(player: AVPlayer(url: attachement.url))
|
||||
.frame(maxHeight: attachements.count > 2 ? 100 : 200)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,8 +79,11 @@ public struct StatusMediaPreviewView: View {
|
|||
attachements.insert(selectedAttachement, at: 0)
|
||||
return TabView {
|
||||
ForEach(attachements) { attachement in
|
||||
if let type = attachement.supportedType {
|
||||
VStack {
|
||||
Spacer()
|
||||
switch type {
|
||||
case .image:
|
||||
AsyncImage(
|
||||
url: attachement.url,
|
||||
content: { image in
|
||||
|
@ -92,10 +96,14 @@ public struct StatusMediaPreviewView: View {
|
|||
.frame(maxWidth: 80, maxHeight: 80)
|
||||
}
|
||||
)
|
||||
case .gifv:
|
||||
VideoPlayer(player: AVPlayer(url: attachement.url))
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.tabViewStyle(.page(indexDisplayMode: .always))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue