Fix issue with disappearing avatar in context menu

This commit is contained in:
Marcin Czachursk 2023-04-15 15:05:05 +02:00
parent 383eb5230b
commit 6a1db0f001
2 changed files with 34 additions and 32 deletions

View File

@ -43,6 +43,7 @@ struct ImageRowItem: View {
ZStack { ZStack {
ContentWarning(spoilerText: self.status.spoilerText) { ContentWarning(spoilerText: self.status.spoilerText) {
self.imageContainerView(uiImage: uiImage) self.imageContainerView(uiImage: uiImage)
.imageContextMenu(statusData: self.status)
} blurred: { } blurred: {
ZStack { ZStack {
BlurredImage(blurhash: attachmentData.blurhash) BlurredImage(blurhash: attachmentData.blurhash)
@ -60,15 +61,14 @@ struct ImageRowItem: View {
} }
} }
} else { } else {
ZStack { self.imageContainerView(uiImage: uiImage)
self.imageContainerView(uiImage: uiImage) .imageContextMenu(statusData: self.status)
} .opacity(self.opacity)
.opacity(self.opacity) .onAppear {
.onAppear { withAnimation {
withAnimation { self.opacity = 1.0
self.opacity = 1.0 }
} }
}
} }
} else { } else {
if cancelled { if cancelled {
@ -99,11 +99,13 @@ struct ImageRowItem: View {
@ViewBuilder @ViewBuilder
private func imageContainerView(uiImage: UIImage) -> some View { private func imageContainerView(uiImage: UIImage) -> some View {
self.imageView(uiImage: uiImage) ZStack {
self.imageView(uiImage: uiImage)
ImageAvatar(displayName: self.status.accountDisplayName, avatarUrl: self.status.accountAvatar) ImageAvatar(displayName: self.status.accountDisplayName, avatarUrl: self.status.accountAvatar)
ImageFavourite(isFavourited: $isFavourited) ImageFavourite(isFavourited: $isFavourited)
FavouriteTouch(showFavouriteAnimation: $showThumbImage) FavouriteTouch(showFavouriteAnimation: $showThumbImage)
}
} }
@ViewBuilder @ViewBuilder
@ -134,7 +136,6 @@ struct ImageRowItem: View {
.onTapGesture { .onTapGesture {
self.navigateToStatus() self.navigateToStatus()
} }
.imageContextMenu(statusData: self.status)
.onAppear { .onAppear {
self.isFavourited = self.status.favourited self.isFavourited = self.status.favourited
} }

View File

@ -43,6 +43,7 @@ struct ImageRowItemAsync: View {
ZStack { ZStack {
ContentWarning(spoilerText: self.statusViewModel.spoilerText) { ContentWarning(spoilerText: self.statusViewModel.spoilerText) {
self.imageContainerView(image: image) self.imageContainerView(image: image)
.imageContextMenu(statusModel: self.statusViewModel)
} blurred: { } blurred: {
ZStack { ZStack {
BlurredImage(blurhash: attachment.blurhash) BlurredImage(blurhash: attachment.blurhash)
@ -65,19 +66,18 @@ struct ImageRowItemAsync: View {
} }
} }
} else { } else {
ZStack { self.imageContainerView(image: image)
self.imageContainerView(image: image) .imageContextMenu(statusModel: self.statusViewModel)
} .opacity(self.opacity)
.opacity(self.opacity) .onAppear {
.onAppear { if let uiImage = state.imageResponse?.image {
if let uiImage = state.imageResponse?.image { self.recalculateSizeOfDownloadedImage(uiImage: uiImage)
self.recalculateSizeOfDownloadedImage(uiImage: uiImage) }
}
withAnimation { withAnimation {
self.opacity = 1.0 self.opacity = 1.0
}
} }
}
} }
} else if state.error != nil { } else if state.error != nil {
ZStack { ZStack {
@ -106,15 +106,17 @@ struct ImageRowItemAsync: View {
@ViewBuilder @ViewBuilder
private func imageContainerView(image: Image) -> some View { private func imageContainerView(image: Image) -> some View {
self.imageView(image: image) ZStack {
self.imageView(image: image)
if self.showAvatar { if self.showAvatar {
ImageAvatar(displayName: self.statusViewModel.account.displayNameWithoutEmojis, ImageAvatar(displayName: self.statusViewModel.account.displayNameWithoutEmojis,
avatarUrl: self.statusViewModel.account.avatar) avatarUrl: self.statusViewModel.account.avatar)
}
ImageFavourite(isFavourited: $isFavourited)
FavouriteTouch(showFavouriteAnimation: $showThumbImage)
} }
ImageFavourite(isFavourited: $isFavourited)
FavouriteTouch(showFavouriteAnimation: $showThumbImage)
} }
@ViewBuilder @ViewBuilder
@ -141,7 +143,6 @@ struct ImageRowItemAsync: View {
.onTapGesture { .onTapGesture {
self.navigateToStatus() self.navigateToStatus()
} }
.imageContextMenu(statusModel: self.statusViewModel)
.onAppear { .onAppear {
self.isFavourited = self.statusViewModel.favourited self.isFavourited = self.statusViewModel.favourited
} }