mirror of
https://github.com/mastodon/mastodon-ios.git
synced 2025-01-21 21:25:56 +01:00
feat: make share extension supports URL item
This commit is contained in:
parent
ffea4b1438
commit
54bd9dcb39
@ -26,6 +26,8 @@
|
||||
<dict>
|
||||
<key>NSExtensionActivationRule</key>
|
||||
<dict>
|
||||
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
|
||||
<integer>1</integer>
|
||||
<key>NSExtensionActivationSupportsImageWithMaxCount</key>
|
||||
<integer>4</integer>
|
||||
<key>NSExtensionActivationSupportsMovieWithMaxCount</key>
|
||||
|
@ -259,16 +259,28 @@ extension ShareViewModel {
|
||||
for item in inputItems {
|
||||
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: [])
|
||||
})
|
||||
}
|
||||
|
||||
let imageProviders = itemProviders.filter { provider in
|
||||
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([
|
||||
StatusAttachmentViewModel(itemProvider: movieProvider)
|
||||
])
|
||||
|
Loading…
Reference in New Issue
Block a user