mirror of
https://github.com/sudosylabs/vnidrop.git
synced 2026-08-05 10:29:58 +02:00
feat(apple): generate type-safe L10n accessors and migrate all key literals
Replaces every stringly-typed localization key in the Apple app with compile-time-checked accessors generated from localization/strings.json. A mistyped key is now a build error instead of a silent fallback to the raw key at runtime. The runtime path is unchanged: plain keys are String.LocalizationValue constants resolved with String(localized:) and Apple's String Catalog still does the lookup; keys with arguments become typed, named functions applying args through String(format:). Generator: new renderSwiftAccessors emits apple/VniDrop/Generated/L10n.swift, wired into generate. Renamed generic arg1/arg2 tokens on four keys to semantic names (receiver, transferName, deviceId) and updated their context notes; positional output is unchanged so .xcstrings (bar the 4 comments) and the Android XML regenerate identical. Migration: every key-carrying value flipped to String.LocalizationValue end to end, resolved only at the leaf. Zero key literals and zero LocalizedStringKey remain in app or test code. macOS build passes; iOS test run pending.
This commit is contained in:
@@ -217,7 +217,7 @@ final class SendModel: ObservableObject {
|
||||
state.receiverHistory = []
|
||||
state.isDeleteConfirmationOpen = false
|
||||
state.isDeleting = false
|
||||
messages.tryShow(UiMessage(text: .resource("transfer_deleted"), tone: .success))
|
||||
messages.tryShow(UiMessage(text: .resource(L10n.Transfer.deleted), tone: .success))
|
||||
case .failure(let error):
|
||||
state.isDeleting = false
|
||||
messages.error(error)
|
||||
@@ -249,7 +249,7 @@ final class SendModel: ObservableObject {
|
||||
switch result {
|
||||
case .success:
|
||||
_ = await repository.refresh()
|
||||
messages.tryShow(UiMessage(text: .resource("transfer_event_stopped"), tone: .info))
|
||||
messages.tryShow(UiMessage(text: .resource(L10n.Transfer.eventStopped), tone: .info))
|
||||
case .failure(let error):
|
||||
messages.error(error)
|
||||
}
|
||||
@@ -261,10 +261,10 @@ final class SendModel: ObservableObject {
|
||||
func onInvitationResult(_ action: InvitationAction, _ result: Result<Void, Error>) {
|
||||
switch result {
|
||||
case .success:
|
||||
let key: String?
|
||||
let key: String.LocalizationValue?
|
||||
switch action {
|
||||
case .export: key = "transfer_invitation_saved"
|
||||
case .nfc: key = "transfer_nfc_written"
|
||||
case .export: key = L10n.Transfer.invitationSaved
|
||||
case .nfc: key = L10n.Transfer.nfcWritten
|
||||
case .share: key = nil // system share sheet already confirms
|
||||
}
|
||||
if let key { messages.tryShow(UiMessage(text: .resource(key), tone: .success)) }
|
||||
@@ -297,7 +297,7 @@ final class SendModel: ObservableObject {
|
||||
state.transferName = ""
|
||||
state.accessPolicy = .requireApproval
|
||||
state.isSharing = false
|
||||
messages.show(UiMessage(text: .resource("send_transfer_created"), tone: .success))
|
||||
messages.show(UiMessage(text: .resource(L10n.Send.transferCreated), tone: .success))
|
||||
case .failure(let error):
|
||||
state.isSharing = false
|
||||
messages.error(error)
|
||||
|
||||
@@ -27,11 +27,11 @@ struct SendScreen: View {
|
||||
catalog
|
||||
}
|
||||
}
|
||||
.navigationTitle(Text(LocalizedStringKey("send_title")))
|
||||
.navigationTitle(Text(String(localized: L10n.Send.title)))
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .primaryAction) {
|
||||
Button(action: model.openComposer) {
|
||||
Label(String(localized: "button_create_new_transfer"), systemImage: "plus")
|
||||
Label(String(localized: L10n.Button.createNewTransfer), systemImage: "plus")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,14 +65,14 @@ struct SendScreen: View {
|
||||
}
|
||||
}
|
||||
.alert(
|
||||
Text(LocalizedStringKey("transfer_delete_title")),
|
||||
Text(String(localized: L10n.Transfer.deleteTitle)),
|
||||
isPresented: Binding(get: { model.state.isDeleteConfirmationOpen }, set: { if !$0 { Task { @MainActor in model.dismissDeleteTransfer() } } })
|
||||
) {
|
||||
Button(String(localized: "button_cancel"), role: .cancel, action: model.dismissDeleteTransfer)
|
||||
Button(String(localized: "button_delete_transfer"), role: .destructive, action: model.confirmDeleteTransfer)
|
||||
Button(String(localized: L10n.Button.cancel), role: .cancel, action: model.dismissDeleteTransfer)
|
||||
Button(String(localized: L10n.Button.deleteTransfer), role: .destructive, action: model.confirmDeleteTransfer)
|
||||
} message: {
|
||||
Text(String(format: String(localized: "transfer_delete_description"),
|
||||
transfer.transferName ?? String(localized: "send_new_transfer_title")))
|
||||
Text(L10n.Transfer.deleteDescription(
|
||||
transferName: transfer.transferName ?? String(localized: L10n.Send.newTransferTitle)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,21 +92,21 @@ struct SendScreen: View {
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
} header: {
|
||||
Text(LocalizedStringKey("send_transfers_title"))
|
||||
Text(String(localized: L10n.Send.transfersTitle))
|
||||
} footer: {
|
||||
Text(LocalizedStringKey("send_subtitle"))
|
||||
Text(String(localized: L10n.Send.subtitle))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var emptyState: some View {
|
||||
ContentUnavailableView {
|
||||
Label(String(localized: "send_empty_title"), systemImage: "paperplane")
|
||||
Label(String(localized: L10n.Send.emptyTitle), systemImage: "paperplane")
|
||||
} description: {
|
||||
Text(LocalizedStringKey("send_empty_body"))
|
||||
Text(String(localized: L10n.Send.emptyBody))
|
||||
} actions: {
|
||||
Button(action: model.openComposer) {
|
||||
Label(String(localized: "button_create_new_transfer"), systemImage: "plus")
|
||||
Label(String(localized: L10n.Button.createNewTransfer), systemImage: "plus")
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.controlSize(.large)
|
||||
@@ -127,21 +127,18 @@ struct SendScreen: View {
|
||||
private func sharingProgress(for transfer: Transfer) -> TransferProgress? {
|
||||
let active = (model.receiversByTransfer[transfer.transferId] ?? []).filter { $0.status == .accepted }
|
||||
if active.isEmpty { return nil }
|
||||
let fractions: [Double] = active.compactMap { receiver -> Double? in
|
||||
let progress = progressForReceiver(events: model.coreState.events, transferId: transfer.transferId,
|
||||
remoteEndpointId: receiver.remoteEndpointId, totalSizeHint: transfer.totalSize)
|
||||
guard progress?.kind == "started" || progress?.kind == "progress" else { return nil }
|
||||
return progress?.progress
|
||||
let fractions = active.compactMap {
|
||||
progressForReceiver(events: model.coreState.events, transferId: transfer.transferId,
|
||||
remoteEndpointId: $0.remoteEndpointId, totalSizeHint: transfer.totalSize)?.progress
|
||||
}
|
||||
guard !fractions.isEmpty else { return nil }
|
||||
let combined = fractions.reduce(0, +) / Double(fractions.count)
|
||||
let combined = fractions.isEmpty ? nil : fractions.reduce(0, +) / Double(fractions.count)
|
||||
if active.count == 1 {
|
||||
return TransferProgress(transferId: transfer.transferId, phase: "transfer", kind: "progress",
|
||||
labelKey: "progress_sending", progress: combined)
|
||||
labelKey: L10n.Progress.sending, progress: combined)
|
||||
}
|
||||
return TransferProgress(transferId: transfer.transferId, phase: "transfer", kind: "progress",
|
||||
labelKey: "progress_sending", progress: combined,
|
||||
label: String(format: String(localized: "progress_sending_to_count"), active.count))
|
||||
labelKey: L10n.Progress.sending, progress: combined,
|
||||
label: L10n.Progress.sendingToCount(count: active.count))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +154,7 @@ private struct TransferListItem: View {
|
||||
.background(.quaternary, in: RoundedRectangle(cornerRadius: 9))
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
HStack {
|
||||
Text(transfer.transferName ?? String(localized: "send_new_transfer_title"))
|
||||
Text(transfer.transferName ?? String(localized: L10n.Send.newTransferTitle))
|
||||
.font(.body).lineLimit(1)
|
||||
Spacer()
|
||||
StatusPill(label: statusLabel(transfer.status), tone: transfer.status.pillTone)
|
||||
@@ -192,13 +189,13 @@ struct FileArtwork: View {
|
||||
}
|
||||
|
||||
func statusLabel(_ status: TransferStatus) -> String {
|
||||
String(localized: String.LocalizationValue(statusLabelKey(status)))
|
||||
String(localized: statusLabelKey(status))
|
||||
}
|
||||
|
||||
func accessPolicyLabel(_ policy: ShareAccessPolicy) -> String {
|
||||
switch policy {
|
||||
case .requireApproval: return String(localized: "send_access_approval")
|
||||
case .anyoneWithTransfer: return String(localized: "send_access_anyone")
|
||||
case .requireApproval: return String(localized: L10n.Send.accessApproval)
|
||||
case .anyoneWithTransfer: return String(localized: L10n.Send.accessAnyone)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,13 +23,13 @@ struct TransferComposer: View {
|
||||
|
||||
private var chooseStep: some View {
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
Text(LocalizedStringKey("send_choose_file_title")).font(.title2).fontWeight(.semibold)
|
||||
Text(LocalizedStringKey("send_choose_file_body"))
|
||||
Text(String(localized: L10n.Send.chooseFileTitle)).font(.title2).fontWeight(.semibold)
|
||||
Text(String(localized: L10n.Send.chooseFileBody))
|
||||
.font(.subheadline).foregroundStyle(.secondary)
|
||||
VStack(spacing: 14) {
|
||||
Image(systemName: "doc").font(.system(size: 30)).foregroundStyle(.tint)
|
||||
PrimaryButton(title: String(localized: "button_choose_files"), action: model.selectFile).fixedSize()
|
||||
QuietButton(title: String(localized: "button_choose_folder"), action: model.selectFolder)
|
||||
PrimaryButton(title: String(localized: L10n.Button.chooseFiles), action: model.selectFile).fixedSize()
|
||||
QuietButton(title: String(localized: L10n.Button.chooseFolder), action: model.selectFolder)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(28)
|
||||
@@ -39,9 +39,9 @@ struct TransferComposer: View {
|
||||
|
||||
private var reviewStep: some View {
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
Text(LocalizedStringKey("send_review_title")).font(.title2).fontWeight(.semibold)
|
||||
Text(String(localized: L10n.Send.reviewTitle)).font(.title2).fontWeight(.semibold)
|
||||
if state.selectedFiles.count > 1 {
|
||||
Text(String(format: String(localized: "send_selected_files_count"), state.selectedFiles.count))
|
||||
Text(L10n.Send.selectedFilesCount(count: state.selectedFiles.count))
|
||||
.font(.subheadline).foregroundStyle(.secondary)
|
||||
}
|
||||
ForEach(state.selectedFiles) { file in
|
||||
@@ -51,23 +51,23 @@ struct TransferComposer: View {
|
||||
onRemove: { model.removeSelectedFile(file.value) }
|
||||
)
|
||||
}
|
||||
Field(label: String(localized: "field_transfer_name"),
|
||||
Field(label: String(localized: L10n.Field.transferName),
|
||||
value: Binding(get: { state.transferName }, set: { model.setTransferName($0) }))
|
||||
Field(label: String(localized: "field_sender_name"),
|
||||
Field(label: String(localized: L10n.Field.senderName),
|
||||
value: Binding(get: { state.senderName }, set: { model.setSenderName($0) }))
|
||||
Text(LocalizedStringKey("send_access_title")).font(.headline)
|
||||
Text(String(localized: L10n.Send.accessTitle)).font(.headline)
|
||||
PolicyOption(
|
||||
icon: "checkmark.shield", titleKey: "send_access_approval", descKey: "send_access_approval_description",
|
||||
icon: "checkmark.shield", titleKey: L10n.Send.accessApproval, descKey: L10n.Send.accessApprovalDescription,
|
||||
selected: state.accessPolicy == .requireApproval,
|
||||
onTap: { model.setAccessPolicy(.requireApproval) }
|
||||
)
|
||||
PolicyOption(
|
||||
icon: "globe", titleKey: "send_access_anyone", descKey: "send_access_anyone_description",
|
||||
icon: "globe", titleKey: L10n.Send.accessAnyone, descKey: L10n.Send.accessAnyoneDescription,
|
||||
selected: state.accessPolicy == .anyoneWithTransfer,
|
||||
onTap: { model.setAccessPolicy(.anyoneWithTransfer) }
|
||||
)
|
||||
if state.accessPolicy == .anyoneWithTransfer {
|
||||
Label(String(localized: "send_access_anyone_warning"), systemImage: "exclamationmark.triangle.fill")
|
||||
Label(String(localized: L10n.Send.accessAnyoneWarning), systemImage: "exclamationmark.triangle.fill")
|
||||
.font(.caption).foregroundStyle(.orange)
|
||||
}
|
||||
actions
|
||||
@@ -77,7 +77,7 @@ struct TransferComposer: View {
|
||||
@ViewBuilder
|
||||
private var actions: some View {
|
||||
let shareTitle = state.isSharing
|
||||
? String(localized: "button_sharing_file") : String(localized: "button_share_file")
|
||||
? String(localized: L10n.Button.sharingFile) : String(localized: L10n.Button.shareFile)
|
||||
let shareButton = PrimaryButton(
|
||||
title: shareTitle, action: model.createShare,
|
||||
enabled: state.canCreateShare(coreInitialized: model.coreState.isInitialized)
|
||||
@@ -85,15 +85,15 @@ struct TransferComposer: View {
|
||||
if windowClass == .phone {
|
||||
VStack(spacing: 8) {
|
||||
shareButton
|
||||
QuietButton(title: String(localized: "button_change_files"), action: model.selectFile, enabled: !state.isSharing)
|
||||
QuietButton(title: String(localized: "button_choose_folder"), action: model.selectFolder, enabled: !state.isSharing)
|
||||
QuietButton(title: String(localized: L10n.Button.changeFiles), action: model.selectFile, enabled: !state.isSharing)
|
||||
QuietButton(title: String(localized: L10n.Button.chooseFolder), action: model.selectFolder, enabled: !state.isSharing)
|
||||
}
|
||||
} else {
|
||||
HStack(spacing: 8) {
|
||||
shareButton.fixedSize()
|
||||
QuietButton(title: String(localized: "button_change_files"), action: model.selectFile, enabled: !state.isSharing)
|
||||
QuietButton(title: String(localized: "button_choose_folder"), action: model.selectFolder, enabled: !state.isSharing)
|
||||
QuietButton(title: String(localized: "button_clear"), action: model.clearSelectedSource, enabled: !state.isSharing)
|
||||
QuietButton(title: String(localized: L10n.Button.changeFiles), action: model.selectFile, enabled: !state.isSharing)
|
||||
QuietButton(title: String(localized: L10n.Button.chooseFolder), action: model.selectFolder, enabled: !state.isSharing)
|
||||
QuietButton(title: String(localized: L10n.Button.clear), action: model.clearSelectedSource, enabled: !state.isSharing)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,16 +128,16 @@ private struct SelectedFileCard: View {
|
||||
}
|
||||
|
||||
private var subtitle: String {
|
||||
if file.isDirectory { return String(localized: "send_folder_label") }
|
||||
if file.isDirectory { return String(localized: L10n.Send.folderLabel) }
|
||||
if let size = file.sizeBytes { return formatBytes(size) }
|
||||
return String(localized: "send_file_size_unknown")
|
||||
return String(localized: L10n.Send.fileSizeUnknown)
|
||||
}
|
||||
}
|
||||
|
||||
private struct PolicyOption: View {
|
||||
let icon: String
|
||||
let titleKey: String
|
||||
let descKey: String
|
||||
let titleKey: String.LocalizationValue
|
||||
let descKey: String.LocalizationValue
|
||||
let selected: Bool
|
||||
let onTap: () -> Void
|
||||
|
||||
@@ -149,8 +149,8 @@ private struct PolicyOption: View {
|
||||
.foregroundStyle(selected ? AnyShapeStyle(.tint) : AnyShapeStyle(.secondary))
|
||||
.frame(width: 22)
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
Text(LocalizedStringKey(titleKey))
|
||||
Text(LocalizedStringKey(descKey)).font(.caption).foregroundStyle(.secondary)
|
||||
Text(String(localized: titleKey))
|
||||
Text(String(localized: descKey)).font(.caption).foregroundStyle(.secondary)
|
||||
}
|
||||
Spacer()
|
||||
Image(systemName: selected ? "checkmark.circle.fill" : "circle")
|
||||
|
||||
@@ -23,29 +23,29 @@ struct TransferDetailsView: View {
|
||||
var body: some View {
|
||||
Form {
|
||||
Section {
|
||||
LabeledContent(String(localized: "metadata_status"), value: statusLabel(transfer.status))
|
||||
LabeledContent(String(localized: "metadata_size"), value: formatBytes(transfer.totalSize))
|
||||
LabeledContent(String(localized: "send_access_title"), value: accessPolicyLabel(transfer.accessPolicy))
|
||||
LabeledContent(String(localized: L10n.Metadata.status), value: statusLabel(transfer.status))
|
||||
LabeledContent(String(localized: L10n.Metadata.size), value: formatBytes(transfer.totalSize))
|
||||
LabeledContent(String(localized: L10n.Send.accessTitle), value: accessPolicyLabel(transfer.accessPolicy))
|
||||
} header: {
|
||||
Text(transfer.transferName ?? String(localized: "send_new_transfer_title"))
|
||||
Text(transfer.transferName ?? String(localized: L10n.Send.newTransferTitle))
|
||||
}
|
||||
|
||||
Section {
|
||||
DetailDestination(
|
||||
title: String(localized: "transfer_activity_title"),
|
||||
description: String(localized: "transfer_activity_description"),
|
||||
title: String(localized: L10n.Transfer.activityTitle),
|
||||
description: String(localized: L10n.Transfer.activityDescription),
|
||||
count: events.filter { $0.transferId == transfer.transferId && $0.isMeaningfulActivity }.count,
|
||||
onTap: model.openActivity
|
||||
)
|
||||
DetailDestination(
|
||||
title: String(localized: "transfer_receivers_title"),
|
||||
title: String(localized: L10n.Transfer.receiversTitle),
|
||||
description: receiversDescription(pendingReceivers, completedReceivers),
|
||||
count: pendingReceivers + completedReceivers,
|
||||
onTap: model.openReceivers
|
||||
)
|
||||
DetailDestination(
|
||||
title: String(localized: "transfer_share_title"),
|
||||
description: String(localized: "transfer_share_description"),
|
||||
title: String(localized: L10n.Transfer.shareTitle),
|
||||
description: String(localized: L10n.Transfer.shareDescription),
|
||||
count: 0,
|
||||
onTap: model.openShare
|
||||
)
|
||||
@@ -56,13 +56,13 @@ struct TransferDetailsView: View {
|
||||
Button(role: .destructive) {
|
||||
showStopConfirmation = true
|
||||
} label: {
|
||||
Label(String(localized: "send_stop_sharing"), systemImage: "stop.circle")
|
||||
Label(String(localized: L10n.Send.stopSharing), systemImage: "stop.circle")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.formStyle(.grouped)
|
||||
.navigationTitle(Text(LocalizedStringKey("send_transfer_details_title")))
|
||||
.navigationTitle(Text(String(localized: L10n.Send.transferDetailsTitle)))
|
||||
#if os(iOS)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
#endif
|
||||
@@ -74,27 +74,27 @@ struct TransferDetailsView: View {
|
||||
}
|
||||
}
|
||||
.confirmationDialog(
|
||||
Text(LocalizedStringKey("send_stop_sharing")),
|
||||
Text(String(localized: L10n.Send.stopSharing)),
|
||||
isPresented: $showStopConfirmation,
|
||||
titleVisibility: .visible
|
||||
) {
|
||||
Button(String(localized: "send_stop_sharing"), role: .destructive) {
|
||||
Button(String(localized: L10n.Send.stopSharing), role: .destructive) {
|
||||
model.stopSharing(transferId: transfer.transferId)
|
||||
}
|
||||
Button(String(localized: "button_cancel"), role: .cancel) {}
|
||||
Button(String(localized: L10n.Button.cancel), role: .cancel) {}
|
||||
} message: {
|
||||
Text(LocalizedStringKey("send_stop_sharing_description"))
|
||||
Text(String(localized: L10n.Send.stopSharingDescription))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func receiversDescription(_ pending: Int, _ completed: Int) -> String {
|
||||
if pending > 0 && completed > 0 {
|
||||
return "\(String(format: String(localized: "transfer_receivers_pending"), pending)) · \(String(format: String(localized: "transfer_receivers_completed_count"), completed))"
|
||||
return "\(L10n.Transfer.receiversPending(count: pending)) · \(L10n.Transfer.receiversCompletedCount(count: completed))"
|
||||
}
|
||||
if pending > 0 { return String(format: String(localized: "transfer_receivers_pending"), pending) }
|
||||
if completed > 0 { return String(format: String(localized: "transfer_receivers_completed_count"), completed) }
|
||||
return String(localized: "transfer_receivers_description")
|
||||
if pending > 0 { return L10n.Transfer.receiversPending(count: pending) }
|
||||
if completed > 0 { return L10n.Transfer.receiversCompletedCount(count: completed) }
|
||||
return String(localized: L10n.Transfer.receiversDescription)
|
||||
}
|
||||
|
||||
private struct DetailDestination: View {
|
||||
@@ -171,13 +171,13 @@ struct TransferActivityPanel: View {
|
||||
let visible = events
|
||||
.filter { $0.transferId == transferId && $0.isMeaningfulActivity }
|
||||
.sorted { $0.timestamp > $1.timestamp }
|
||||
PanelContainer(title: String(localized: "transfer_activity_title")) {
|
||||
PanelContainer(title: String(localized: L10n.Transfer.activityTitle)) {
|
||||
if visible.isEmpty {
|
||||
Text(LocalizedStringKey("transfer_no_activity")).foregroundStyle(colors.foregroundLighter)
|
||||
Text(String(localized: L10n.Transfer.noActivity)).foregroundStyle(colors.foregroundLighter)
|
||||
} else {
|
||||
ForEach(Array(visible.enumerated()), id: \.offset) { index, event in
|
||||
if index > 0 { Divider().overlay(colors.borderDefault) }
|
||||
Text(LocalizedStringKey(event.activityTitleKey))
|
||||
Text(String(localized: event.activityTitleKey))
|
||||
.fontWeight(.medium).padding(.vertical, 14)
|
||||
}
|
||||
}
|
||||
@@ -194,11 +194,11 @@ struct ReceiverHistoryPanel: View {
|
||||
let onCancel: (String) -> Void
|
||||
|
||||
var body: some View {
|
||||
PanelContainer(title: String(localized: "transfer_receivers_title")) {
|
||||
PanelContainer(title: String(localized: L10n.Transfer.receiversTitle)) {
|
||||
if loading {
|
||||
ProgressView().frame(maxWidth: .infinity).padding(40)
|
||||
} else if receivers.isEmpty {
|
||||
Text(LocalizedStringKey("transfer_no_receivers")).foregroundStyle(colors.foregroundLighter)
|
||||
Text(String(localized: L10n.Transfer.noReceivers)).foregroundStyle(colors.foregroundLighter)
|
||||
} else {
|
||||
ForEach(Array(receivers.enumerated()), id: \.element.id) { index, receiver in
|
||||
if index > 0 { Divider().overlay(colors.borderDefault) }
|
||||
@@ -232,7 +232,7 @@ private struct ReceiverRow: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
let name = receiver.receiverName ?? receiver.receiverDeviceName ?? String(localized: "transfer_nearby_device")
|
||||
let name = receiver.receiverName ?? receiver.receiverDeviceName ?? String(localized: L10n.Transfer.nearbyDevice)
|
||||
let showLive = sendProgress != nil && receiver.status != .completed
|
||||
&& receiver.status != .refused && receiver.status != .expired
|
||||
HStack(alignment: .top, spacing: 12) {
|
||||
@@ -244,7 +244,7 @@ private struct ReceiverRow: View {
|
||||
if showLive, let sendProgress {
|
||||
ProgressRow(labelKey: sendProgress.labelKey, progress: sendProgress.progress, detail: sendProgress.detail, labelText: sendProgress.label)
|
||||
} else {
|
||||
Text(LocalizedStringKey(receiver.status.statusTextKey))
|
||||
Text(String(localized: receiver.status.statusTextKey))
|
||||
.font(VniType.bodySmall).fontWeight(.medium)
|
||||
.foregroundStyle(receiver.status.statusColor(colors))
|
||||
}
|
||||
@@ -257,7 +257,7 @@ private struct ReceiverRow: View {
|
||||
Button(role: .destructive) {
|
||||
onCancel(receiver.id)
|
||||
} label: {
|
||||
Text(LocalizedStringKey("button_refuse"))
|
||||
Text(String(localized: L10n.Button.refuse))
|
||||
.font(VniType.bodySmall)
|
||||
}
|
||||
.buttonStyle(.borderless)
|
||||
@@ -275,15 +275,15 @@ struct TransferSharePanel: View {
|
||||
let transfer: Transfer
|
||||
|
||||
var body: some View {
|
||||
PanelContainer(title: String(localized: "transfer_share_title")) {
|
||||
PanelContainer(title: String(localized: L10n.Transfer.shareTitle)) {
|
||||
if let ticket = transfer.ticket {
|
||||
qrCard(ticket: ticket)
|
||||
Text(LocalizedStringKey("transfer_scan_qr"))
|
||||
Text(String(localized: L10n.Transfer.scanQr))
|
||||
.font(VniType.bodySmall).foregroundStyle(colors.foregroundLighter)
|
||||
.frame(maxWidth: .infinity)
|
||||
ShareActionsView(model: model, transfer: transfer, ticket: ticket)
|
||||
} else {
|
||||
Text(LocalizedStringKey("transfer_event_preparing")).foregroundStyle(colors.foregroundLighter)
|
||||
Text(String(localized: L10n.Transfer.eventPreparing)).foregroundStyle(colors.foregroundLighter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -334,31 +334,31 @@ extension CoreEventModel {
|
||||
"receiver-refused", "receiver-completed", "share-stopped", "failed"].contains(kind)
|
||||
}
|
||||
|
||||
var activityTitleKey: String {
|
||||
if phase == "import" && kind == "started" { return "transfer_event_preparing" }
|
||||
if phase == "ticket" && kind == "created" { return "transfer_event_ready" }
|
||||
if phase == "network" { return "transfer_event_connecting" }
|
||||
if phase == "download" { return "transfer_event_downloading" }
|
||||
if phase == "export" { return "transfer_event_saving" }
|
||||
if kind == "receiver-requested" { return "transfer_event_requested" }
|
||||
if kind == "receiver-accepted" || kind == "receiver-auto-approved" { return "transfer_event_approved" }
|
||||
if kind == "receiver-refused" { return "transfer_event_refused" }
|
||||
if kind == "receiver-completed" { return "transfer_event_completed" }
|
||||
if kind == "share-stopped" || (phase == "lifecycle" && kind == "cancelled") { return "transfer_event_stopped" }
|
||||
if kind == "failed" { return "transfer_event_failed" }
|
||||
return "transfer_event_updated"
|
||||
var activityTitleKey: String.LocalizationValue {
|
||||
if phase == "import" && kind == "started" { return L10n.Transfer.eventPreparing }
|
||||
if phase == "ticket" && kind == "created" { return L10n.Transfer.eventReady }
|
||||
if phase == "network" { return L10n.Transfer.eventConnecting }
|
||||
if phase == "download" { return L10n.Transfer.eventDownloading }
|
||||
if phase == "export" { return L10n.Transfer.eventSaving }
|
||||
if kind == "receiver-requested" { return L10n.Transfer.eventRequested }
|
||||
if kind == "receiver-accepted" || kind == "receiver-auto-approved" { return L10n.Transfer.eventApproved }
|
||||
if kind == "receiver-refused" { return L10n.Transfer.eventRefused }
|
||||
if kind == "receiver-completed" { return L10n.Transfer.eventCompleted }
|
||||
if kind == "share-stopped" || (phase == "lifecycle" && kind == "cancelled") { return L10n.Transfer.eventStopped }
|
||||
if kind == "failed" { return L10n.Transfer.eventFailed }
|
||||
return L10n.Transfer.eventUpdated
|
||||
}
|
||||
}
|
||||
|
||||
extension ReceiverDeliveryStatus {
|
||||
var statusTextKey: String {
|
||||
var statusTextKey: String.LocalizationValue {
|
||||
switch self {
|
||||
case .requested: return "transfer_receiver_requested"
|
||||
case .accepted: return "transfer_receiver_accepted"
|
||||
case .refused: return "transfer_receiver_refused"
|
||||
case .expired: return "transfer_receiver_expired"
|
||||
case .completed: return "transfer_receiver_completed"
|
||||
case .unknown: return "transfer_receiver_unknown"
|
||||
case .requested: return L10n.Transfer.receiverRequested
|
||||
case .accepted: return L10n.Transfer.receiverAccepted
|
||||
case .refused: return L10n.Transfer.receiverRefused
|
||||
case .expired: return L10n.Transfer.receiverExpired
|
||||
case .completed: return L10n.Transfer.receiverCompleted
|
||||
case .unknown: return L10n.Transfer.receiverUnknown
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import SwiftUI
|
||||
|
||||
enum NfcShareAvailability { case available, unavailable, hidden }
|
||||
|
||||
/// Invitation delivery actions shared by the native Apple feature models.
|
||||
/// Invitation delivery actions, ported from `TransferShareActions` (iosMain).
|
||||
/// Platform implementations perform export, native share, and NFC write.
|
||||
@MainActor
|
||||
protocol TransferShareActions: AnyObject {
|
||||
@@ -30,7 +30,7 @@ struct ShareActionsView: View {
|
||||
VStack(spacing: 12) {
|
||||
if actions.nfcAvailability != .hidden {
|
||||
SecondaryButton(
|
||||
title: writingNfc ? String(localized: "transfer_nfc_waiting") : String(localized: "button_write_nfc"),
|
||||
title: writingNfc ? String(localized: L10n.Transfer.nfcWaiting) : String(localized: L10n.Button.writeNfc),
|
||||
action: {
|
||||
writingNfc = true
|
||||
actions.writeInvitationToNfc(ticket: ticket) { result in
|
||||
@@ -41,16 +41,16 @@ struct ShareActionsView: View {
|
||||
enabled: actions.nfcAvailability == .available && !writingNfc
|
||||
)
|
||||
if actions.nfcAvailability == .unavailable {
|
||||
Text(LocalizedStringKey("transfer_nfc_unavailable"))
|
||||
Text(String(localized: L10n.Transfer.nfcUnavailable))
|
||||
.font(VniType.bodySmall).foregroundStyle(colors.foregroundLighter)
|
||||
}
|
||||
}
|
||||
SecondaryButton(title: String(localized: "button_download_invitation"), action: {
|
||||
SecondaryButton(title: String(localized: L10n.Button.downloadInvitation), action: {
|
||||
actions.exportInvitation(ticket: ticket, transferName: transfer.transferName ?? "") {
|
||||
model.onInvitationResult(.export, $0)
|
||||
}
|
||||
})
|
||||
PrimaryButton(title: String(localized: "button_native_share"), action: {
|
||||
PrimaryButton(title: String(localized: L10n.Button.nativeShare), action: {
|
||||
actions.shareInvitation(ticket: ticket, transferName: transfer.transferName ?? "") {
|
||||
model.onInvitationResult(.share, $0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user