Show file name for iOS share extension

This commit is contained in:
Leon Böttger committed 2025-08-17 21:44:28 +02:00
1 parent e808b71446
commit 006f389891
8 files changed
+198 -39

No files matched your search

+23 -19
View File
@@ -22,26 +22,30 @@ class ShareViewController: UIViewController {
self?.extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
}
// Replace with your app’s SwiftUI entry view
let contentView = ContentView(attachments: attachmentDetails)
// Embed SwiftUI inside the extension’s controller
let hostingController = UIHostingController(rootView: contentView)
addChild(hostingController)
hostingController.view.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(hostingController.view)
// Pin to edges
NSLayoutConstraint.activate([
hostingController.view.topAnchor.constraint(equalTo: view.topAnchor),
hostingController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor),
hostingController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
hostingController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor)
])
hostingController.didMove(toParent: self)
DispatchQueue.main.async {
NearbyConnectionManager.shared.attachments = attachmentDetails
}
})
// Replace with your app’s SwiftUI entry view
let contentView = ContentView()
// Embed SwiftUI inside the extension’s controller
let hostingController = UIHostingController(rootView: contentView)
addChild(hostingController)
hostingController.view.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(hostingController.view)
// Pin to edges
NSLayoutConstraint.activate([
hostingController.view.topAnchor.constraint(equalTo: view.topAnchor),
hostingController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor),
hostingController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
hostingController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor)
])
hostingController.didMove(toParent: self)
}
}