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

View File

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