-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ImageCreationView now uses LinkPresentation
- Loading branch information
1 parent
fbc9129
commit 9898058
Showing
2 changed files
with
35 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// LinkPreview.swift | ||
// DemoChat | ||
// | ||
// Created by Aled Samuel on 25/04/2023. | ||
// | ||
|
||
import SwiftUI | ||
import LinkPresentation | ||
|
||
struct LinkPreview: UIViewRepresentable { | ||
typealias UIViewType = LPLinkView | ||
|
||
var previewURL: URL | ||
|
||
func makeUIView(context: Context) -> LPLinkView { | ||
LPLinkView(url: previewURL) | ||
} | ||
|
||
func updateUIView(_ uiView: UIViewType, context: Context) { | ||
LPMetadataProvider().startFetchingMetadata(for: previewURL) { metadata, error in | ||
if let error = error { | ||
print(error.localizedDescription) | ||
return | ||
} | ||
guard let metadata = metadata else { | ||
print("Metadata missing for \(previewURL.absoluteString)") | ||
return | ||
} | ||
uiView.metadata = metadata | ||
} | ||
} | ||
} |