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