Add on tap gesture to blurhash images.

This commit is contained in:
Marcin Czachursk 2023-02-12 08:18:05 +01:00
parent f8b996dae9
commit c0566e5ec9
2 changed files with 19 additions and 10 deletions

View File

@ -92,7 +92,7 @@ struct HomeFeedView: View {
self.calculateOpacity(offset: offset)
}
self.newPahotosView()
self.newPhotosView()
.offset(y: self.offset)
.opacity(self.opacity)
}
@ -217,7 +217,7 @@ struct HomeFeedView: View {
}
@ViewBuilder
private func newPahotosView() -> some View {
private func newPhotosView() -> some View {
VStack(alignment: .trailing, spacing: 4) {
HStack {
Image(systemName: "arrow.up")

View File

@ -50,7 +50,9 @@ struct ImageRow: View {
Image(uiImage: uiImage)
.resizable()
.aspectRatio(contentMode: .fit)
.transition(.opacity)
.onTapGesture{
self.navigateToStatus()
}
}
} else {
ZStack {
@ -58,13 +60,7 @@ struct ImageRow: View {
.resizable()
.aspectRatio(contentMode: .fit)
.onTapGesture{
self.routerPath.navigate(to: .status(
id: status.rebloggedStatusId ?? status.id,
blurhash: status.attachments().first?.blurhash,
highestImageUrl: status.attachments().getHighestImage()?.url,
metaImageWidth: status.attachments().first?.metaImageWidth,
metaImageHeight: status.attachments().first?.metaImageHeight
))
self.navigateToStatus()
}
.onLongPressGesture(minimumDuration: 0.2) {
Task {
@ -110,6 +106,9 @@ struct ImageRow: View {
} else {
BlurredImage(blurhash: attachmentData.blurhash)
.frame(width: self.imageWidth, height: self.imageHeight)
.onTapGesture{
self.navigateToStatus()
}
.task {
await self.downloadImage(attachmentData: attachmentData)
}
@ -137,4 +136,14 @@ struct ImageRow: View {
self.error = error
}
}
private func navigateToStatus() {
self.routerPath.navigate(to: .status(
id: status.rebloggedStatusId ?? status.id,
blurhash: status.attachments().first?.blurhash,
highestImageUrl: status.attachments().getHighestImage()?.url,
metaImageWidth: status.attachments().first?.metaImageWidth,
metaImageHeight: status.attachments().first?.metaImageHeight
))
}
}