ios: unblur media on tap, open/play on the second tap; handle link preview errors (#5886)

* ios: unblur media on tap, open/play on the second tap (Xcode 16 regression)

* disable link preview spinner on link loading error
This commit is contained in:
Evgeny 2025-05-11 15:42:09 +01:00 committed by GitHub
parent 8d54acef92
commit e1aa32952e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 33 additions and 26 deletions

View file

@ -31,7 +31,9 @@ struct CIImageView: View {
.if(!smallView) { view in
view.modifier(PrivacyBlur(blurred: $blurred))
}
.simultaneousGesture(TapGesture().onEnded { showFullScreenImage = true })
.if(!blurred) { v in
v.simultaneousGesture(TapGesture().onEnded { showFullScreenImage = true })
}
.onChange(of: m.activeCallViewIsCollapsed) { _ in
showFullScreenImage = false
}

View file

@ -21,15 +21,15 @@ struct CILinkView: View {
.resizable()
.scaledToFit()
.modifier(PrivacyBlur(blurred: $blurred))
.if(!blurred) { v in
v.simultaneousGesture(TapGesture().onEnded {
openBrowserAlert(uri: linkPreview.uri)
})
}
}
VStack(alignment: .leading, spacing: 6) {
Text(linkPreview.title)
.lineLimit(3)
// if linkPreview.description != "" {
// Text(linkPreview.description)
// .font(.subheadline)
// .lineLimit(12)
// }
Text(linkPreview.uri.absoluteString)
.font(.caption)
.lineLimit(1)
@ -37,11 +37,11 @@ struct CILinkView: View {
}
.padding(.horizontal, 12)
.frame(maxWidth: .infinity, alignment: .leading)
}
.simultaneousGesture(TapGesture().onEnded {
openBrowserAlert(uri: linkPreview.uri)
})
}
}
}
func openBrowserAlert(uri: URL) {

View file

@ -193,7 +193,8 @@ struct CIVideoView: View {
}
}
.modifier(PrivacyBlur(enabled: !videoPlaying, blurred: $blurred))
.simultaneousGesture(TapGesture().onEnded {
.if(!blurred) { v in
v.simultaneousGesture(TapGesture().onEnded {
switch player.timeControlStatus {
case .playing:
player.pause()
@ -205,6 +206,7 @@ struct CIVideoView: View {
default: ()
}
})
}
.onChange(of: m.activeCallViewIsCollapsed) { _ in
showFullScreenPlayer = false
}

View file

@ -18,7 +18,7 @@ struct ComposeLinkView: View {
var body: some View {
HStack(alignment: .center, spacing: 8) {
if let linkPreview = linkPreview {
if let linkPreview {
linkPreviewView(linkPreview)
} else {
ProgressView()

View file

@ -1254,12 +1254,15 @@ struct ComposeView: View {
if pendingLinkUrl == url {
composeState = composeState.copy(preview: .linkPreview(linkPreview: nil))
getLinkPreview(url: url) { linkPreview in
if let linkPreview = linkPreview,
pendingLinkUrl == url {
if let linkPreview, pendingLinkUrl == url {
composeState = composeState.copy(preview: .linkPreview(linkPreview: linkPreview))
pendingLinkUrl = nil
} else {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
composeState = composeState.copy(preview: .noPreview)
}
}
pendingLinkUrl = nil
}
}
}

View file

@ -37,9 +37,9 @@ struct PrivacyBlur: ViewModifier {
.overlay {
if (blurred && enabled) {
Color.clear.contentShape(Rectangle())
.onTapGesture {
.simultaneousGesture(TapGesture().onEnded {
blurred = false
}
})
}
}
.onReceive(NotificationCenter.default.publisher(for: .chatViewWillBeginScrolling)) { _ in