feat: make share extension supports URL item
This commit is contained in:
parent
ffea4b1438
commit
54bd9dcb39
|
@ -26,6 +26,8 @@
|
||||||
<dict>
|
<dict>
|
||||||
<key>NSExtensionActivationRule</key>
|
<key>NSExtensionActivationRule</key>
|
||||||
<dict>
|
<dict>
|
||||||
|
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
|
||||||
|
<integer>1</integer>
|
||||||
<key>NSExtensionActivationSupportsImageWithMaxCount</key>
|
<key>NSExtensionActivationSupportsImageWithMaxCount</key>
|
||||||
<integer>4</integer>
|
<integer>4</integer>
|
||||||
<key>NSExtensionActivationSupportsMovieWithMaxCount</key>
|
<key>NSExtensionActivationSupportsMovieWithMaxCount</key>
|
||||||
|
|
|
@ -259,16 +259,28 @@ extension ShareViewModel {
|
||||||
for item in inputItems {
|
for item in inputItems {
|
||||||
itemProviders.append(contentsOf: item.attachments ?? [])
|
itemProviders.append(contentsOf: item.attachments ?? [])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let _urlProvider = itemProviders.first { provider in
|
||||||
|
return provider.hasRepresentationConforming(toTypeIdentifier: UTType.url.identifier, fileOptions: [])
|
||||||
|
}
|
||||||
|
|
||||||
let _movieProvider = itemProviders.first(where: { provider in
|
let _movieProvider = itemProviders.first { provider in
|
||||||
return provider.hasRepresentationConforming(toTypeIdentifier: UTType.movie.identifier, fileOptions: [])
|
return provider.hasRepresentationConforming(toTypeIdentifier: UTType.movie.identifier, fileOptions: [])
|
||||||
})
|
}
|
||||||
|
|
||||||
let imageProviders = itemProviders.filter { provider in
|
let imageProviders = itemProviders.filter { provider in
|
||||||
return provider.hasRepresentationConforming(toTypeIdentifier: UTType.image.identifier, fileOptions: [])
|
return provider.hasRepresentationConforming(toTypeIdentifier: UTType.image.identifier, fileOptions: [])
|
||||||
}
|
}
|
||||||
|
|
||||||
if let movieProvider = _movieProvider {
|
if let urlProvider = _urlProvider {
|
||||||
|
urlProvider.loadItem(forTypeIdentifier: UTType.url.identifier) { [weak self] item, error in
|
||||||
|
guard let self = self else { return }
|
||||||
|
guard let url = item as? URL else { return }
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.composeViewModel.statusContent = "\(url.absoluteString) "
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if let movieProvider = _movieProvider {
|
||||||
composeViewModel.setupAttachmentViewModels([
|
composeViewModel.setupAttachmentViewModels([
|
||||||
StatusAttachmentViewModel(itemProvider: movieProvider)
|
StatusAttachmentViewModel(itemProvider: movieProvider)
|
||||||
])
|
])
|
||||||
|
|
Loading…
Reference in New Issue