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

+25 -15
View File
@@ -10,11 +10,9 @@ import LUI
struct ContentView: View {
var attachments: AttachmentDetails? = nil
var body: some View {
AppRootView(isPlus: .constant(true), phoneView: {
DeviceListView(attachments: attachments)
DeviceListView()
}, settingsView: {
EmptyView()
})
@@ -23,29 +21,41 @@ struct ContentView: View {
struct DeviceListView: View {
var attachments: AttachmentDetails? = nil
@StateObject var sendModel = SendModel()
#if !EXTENSION
@StateObject var receiveModel = ReceiveModel()
#endif
@ObservedObject var nearbyConnectionManager = NearbyConnectionManager.shared
var body: some View {
NavigationSubView(header: "QuickDrop ") {
// "You're visible as"
VStack(alignment: .leading, spacing: 8) {
FooterView(text: "YouAreVisibleAs")
Text(NearbyConnectionManager.shared.deviceInfo.name ?? "Unknown".localized())
.fontWeight(.bold)
.padding(.horizontal, 16)
.padding(.vertical, 6)
.background(Color.defaultForegroundColor)
.cornerRadius(24)
.padding(.horizontal)
let attachments = nearbyConnectionManager.attachments
FooterView(text: attachments == nil ? "YouAreVisibleAs".localized() : "YouAreSending".localized())
HStack {
if let image = attachments?.previewImage {
image
.resizable()
.scaledToFill()
.frame(width: 10, height: 10)
}
Text(attachments?.shortDescription ?? NearbyConnectionManager.shared.deviceInfo.name ?? "Unknown".localized())
.fontWeight(.bold)
}
.padding(.horizontal, 16)
.padding(.vertical, 6)
.background(Color.defaultForegroundColor)
.cornerRadius(24)
.padding(.horizontal)
}
.padding(.top, 8)
.frame(maxWidth: .infinity, alignment: .leading)
@@ -72,7 +82,7 @@ struct DeviceListView: View {
let isSelected = sendModel.selectedDevice == device
ZStack {
if let attachments = attachments {
if let attachments = NearbyConnectionManager.shared.attachments {
LUIButton {
sendModel.urls = attachments.urls
sendModel.textToSend = attachments.textToSend
+9 -3
View File
@@ -138,10 +138,19 @@ class ReceiveModel: ObservableObject, InboundAppDelegate {
func finish() {
if let error = error {
#if os(iOS)
errorVibration()
#endif
controlPlusScreen(false)
ErrorAlertHandler.shared.showErrorAlert(for: device.name ?? "Android", error: error)
} else {
#if os(iOS)
doubleVibration()
#endif
if wasPlainTextTransfer {
showCopiedToClipboardAlert()
}
@@ -165,9 +174,6 @@ class ReceiveModel: ObservableObject, InboundAppDelegate {
DispatchQueue.main.async {
BezelNotification.show(messageText: "InsertedIntoClipboard".localized(), icon: .clipboard)
}
#else
// iOS
doubleVibration()
#endif
}
+14
View File
@@ -6,6 +6,9 @@
//
import SwiftUI
#if os(iOS)
import LUI
#endif
class SendModel: ObservableObject, OutboundAppDelegate {
@@ -47,6 +50,10 @@ class SendModel: ObservableObject, OutboundAppDelegate {
func connectionFailed(with error: any Error) {
#if os(iOS)
errorVibration()
#endif
ErrorAlertHandler.shared.showErrorAlert(for: selectedDevice?.name ?? "?", error: error)
progressValue = nil
@@ -62,9 +69,16 @@ class SendModel: ObservableObject, OutboundAppDelegate {
}
func transferFinished() {
#if os(iOS)
doubleVibration()
#endif
progressValue = 0
selectedDevice = nil
progressState = "TransferFinished".localized()
NearbyConnectionManager.shared.attachments?.closeView?()
}
func startTransferWithQrCode(device: RemoteDeviceInfo) {