mirror of
https://github.com/sudosylabs/vnidrop.git
synced 2026-08-05 02:29:55 +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:
@@ -149,12 +149,9 @@ final class ApprovalCoordinator: ObservableObject {
|
||||
for request in pending where !publishedNotificationIds.contains(request.id) {
|
||||
let receiver = request.receiverName
|
||||
?? request.receiverDeviceName
|
||||
?? String(localized: "approval_nearby_device")
|
||||
let title = String(localized: "approval_connection_request")
|
||||
let body = String(
|
||||
format: String(localized: "approval_request_body"),
|
||||
receiver, request.transferName
|
||||
)
|
||||
?? String(localized: L10n.Approval.nearbyDevice)
|
||||
let title = String(localized: L10n.Approval.connectionRequest)
|
||||
let body = L10n.Approval.requestBody(receiver: receiver, transferName: request.transferName)
|
||||
let result = await notifications.publish(
|
||||
LocalNotification(id: Self.notificationId(request.id), title: title, body: body)
|
||||
)
|
||||
|
||||
@@ -38,32 +38,32 @@ private struct ApprovalSheet: View {
|
||||
|
||||
var body: some View {
|
||||
let busy = state.respondingIds.contains(request.id)
|
||||
let receiver = request.receiverName ?? request.receiverDeviceName ?? String(localized: "approval_nearby_device")
|
||||
let receiver = request.receiverName ?? request.receiverDeviceName ?? String(localized: L10n.Approval.nearbyDevice)
|
||||
VStack(spacing: 16) {
|
||||
Image(systemName: "checkmark.shield.fill")
|
||||
.font(.system(size: 44))
|
||||
.foregroundStyle(.tint)
|
||||
.padding(.top, 12)
|
||||
Text(LocalizedStringKey("approval_connection_request"))
|
||||
Text(String(localized: L10n.Approval.connectionRequest))
|
||||
.font(.title2).fontWeight(.semibold)
|
||||
Text(String(format: String(localized: "approval_request_body"), receiver, request.transferName))
|
||||
Text(L10n.Approval.requestBody(receiver: receiver, transferName: request.transferName))
|
||||
.multilineTextAlignment(.center)
|
||||
Text(String(format: String(localized: "approval_endpoint_id"), request.remoteEndpointId))
|
||||
Text(L10n.Approval.endpointId(deviceId: request.remoteEndpointId))
|
||||
.font(.caption).foregroundStyle(.secondary)
|
||||
.multilineTextAlignment(.center)
|
||||
if state.pending.count > 1 {
|
||||
Text(String(format: String(localized: "approval_pending_count"), state.pending.count))
|
||||
Text(L10n.Approval.pendingCount(count: state.pending.count))
|
||||
.font(.caption).foregroundStyle(.secondary)
|
||||
}
|
||||
Spacer(minLength: 0)
|
||||
if busy { ProgressView() }
|
||||
VStack(spacing: 10) {
|
||||
Button(action: { onAccept(request.id) }) {
|
||||
Text(LocalizedStringKey("button_approve")).frame(maxWidth: .infinity)
|
||||
Text(String(localized: L10n.Button.approve)).frame(maxWidth: .infinity)
|
||||
}
|
||||
.buttonStyle(.borderedProminent).controlSize(.large).disabled(busy)
|
||||
Button(role: .destructive, action: { onRefuse(request.id) }) {
|
||||
Text(LocalizedStringKey("button_refuse")).frame(maxWidth: .infinity)
|
||||
Text(String(localized: L10n.Button.refuse)).frame(maxWidth: .infinity)
|
||||
}
|
||||
.buttonStyle(.bordered).controlSize(.large).disabled(busy)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import SwiftUI
|
||||
|
||||
enum ReceiveMethodAvailability { case available, unavailable, hidden }
|
||||
|
||||
/// Invitation acquisition actions shared by the native Apple feature models.
|
||||
/// Invitation acquisition actions, ported from `ReceiveInvitationActions` (iosMain).
|
||||
@MainActor
|
||||
protocol ReceiveInvitationActions: AnyObject {
|
||||
var fileAvailability: ReceiveMethodAvailability { get }
|
||||
@@ -23,25 +23,25 @@ struct ReceiveMethodPanel: View {
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
Text(LocalizedStringKey("receive_choose_method_title")).font(VniType.titleLarge)
|
||||
Text(LocalizedStringKey("receive_choose_method_body")).foregroundStyle(colors.foregroundLighter)
|
||||
Text(String(localized: L10n.Receive.chooseMethodTitle)).font(VniType.titleLarge)
|
||||
Text(String(localized: L10n.Receive.chooseMethodBody)).foregroundStyle(colors.foregroundLighter)
|
||||
|
||||
MethodRow(
|
||||
icon: "doc", titleKey: "receive_method_file", descKey: "receive_method_file_description",
|
||||
icon: "doc", titleKey: L10n.Receive.methodFile, descKey: L10n.Receive.methodFileDescription,
|
||||
availability: actions.fileAvailability
|
||||
) { actions.pickInvitation { model.onInvitationResult(.invitationFile, $0) } }
|
||||
|
||||
if actions.qrAvailability != .hidden {
|
||||
MethodRow(
|
||||
icon: "qrcode.viewfinder", titleKey: "receive_method_scan", descKey: "receive_method_scan_description",
|
||||
icon: "qrcode.viewfinder", titleKey: L10n.Receive.methodScan, descKey: L10n.Receive.methodScanDescription,
|
||||
availability: actions.qrAvailability
|
||||
) { actions.scanQrCode { model.onInvitationResult(.qrCode, $0) } }
|
||||
}
|
||||
if actions.nfcAvailability != .hidden {
|
||||
MethodRow(
|
||||
icon: "wave.3.right",
|
||||
titleOverride: model.state.isWaitingForNfc ? String(localized: "receive_nfc_waiting") : nil,
|
||||
titleKey: "receive_method_nfc", descKey: "receive_method_nfc_description",
|
||||
titleOverride: model.state.isWaitingForNfc ? String(localized: L10n.Receive.nfcWaiting) : nil,
|
||||
titleKey: L10n.Receive.methodNfc, descKey: L10n.Receive.methodNfcDescription,
|
||||
availability: model.state.isWaitingForNfc ? .unavailable : actions.nfcAvailability
|
||||
) {
|
||||
model.setWaitingForNfc(true)
|
||||
@@ -58,8 +58,8 @@ private struct MethodRow: View {
|
||||
@Environment(\.vniColors) private var colors
|
||||
let icon: String
|
||||
var titleOverride: String? = nil
|
||||
let titleKey: String
|
||||
let descKey: String
|
||||
let titleKey: String.LocalizationValue
|
||||
let descKey: String.LocalizationValue
|
||||
let availability: ReceiveMethodAvailability
|
||||
let onTap: () -> Void
|
||||
|
||||
@@ -74,13 +74,13 @@ private struct MethodRow: View {
|
||||
if let titleOverride {
|
||||
Text(titleOverride).font(VniType.bodyLarge)
|
||||
} else {
|
||||
Text(LocalizedStringKey(titleKey)).font(VniType.bodyLarge)
|
||||
Text(String(localized: titleKey)).font(VniType.bodyLarge)
|
||||
}
|
||||
Text(LocalizedStringKey(descKey)).font(VniType.bodySmall).foregroundStyle(colors.foregroundLighter)
|
||||
Text(String(localized: descKey)).font(VniType.bodySmall).foregroundStyle(colors.foregroundLighter)
|
||||
}
|
||||
Spacer()
|
||||
if availability == .unavailable {
|
||||
Text(LocalizedStringKey("value_unavailable")).font(VniType.labelSmall).foregroundStyle(colors.foregroundLighter)
|
||||
Text(String(localized: L10n.Value.unavailable)).font(VniType.labelSmall).foregroundStyle(colors.foregroundLighter)
|
||||
}
|
||||
}
|
||||
.padding(16)
|
||||
@@ -102,7 +102,7 @@ struct InvitationReviewPanel: View {
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 14) {
|
||||
Text(LocalizedStringKey("receive_review_title")).font(VniType.titleLarge)
|
||||
Text(String(localized: L10n.Receive.reviewTitle)).font(VniType.titleLarge)
|
||||
if state.isInspecting {
|
||||
ProgressView().frame(maxWidth: .infinity).padding(40)
|
||||
}
|
||||
@@ -110,16 +110,16 @@ struct InvitationReviewPanel: View {
|
||||
let metadata = inspection.metadata
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Text(metadata.transferName).font(VniType.bodyLarge).lineLimit(2)
|
||||
Text("\(metadata.fileCount) \(String(localized: "metadata_files").lowercased()) · \(formatBytes(metadata.totalSize))")
|
||||
Text("\(metadata.fileCount) \(String(localized: L10n.Metadata.files).lowercased()) · \(formatBytes(metadata.totalSize))")
|
||||
.foregroundStyle(colors.foregroundLighter)
|
||||
}
|
||||
.padding(16)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.background(colors.backgroundSurface200, in: RoundedRectangle(cornerRadius: 14))
|
||||
|
||||
Field(label: String(localized: "field_receiver_name"),
|
||||
Field(label: String(localized: L10n.Field.receiverName),
|
||||
value: Binding(get: { state.receiverName }, set: { model.setReceiverName($0) }))
|
||||
Text(state.receiveFolder?.displayName ?? String(localized: "value_unavailable"))
|
||||
Text(state.receiveFolder?.displayName ?? String(localized: L10n.Value.unavailable))
|
||||
.font(VniType.bodySmall)
|
||||
.foregroundStyle(state.folderAccessStatus == .writable ? colors.foregroundLight : colors.destructiveDefault)
|
||||
|
||||
@@ -127,11 +127,11 @@ struct InvitationReviewPanel: View {
|
||||
let progressId = state.activeReceiveTransferId
|
||||
?? model.coreState.events.first { $0.direction == "receive" && $0.transferId != nil }?.transferId
|
||||
let progress = progressId.flatMap { progressForTransfer(events: model.coreState.events, transferId: $0) }
|
||||
ProgressRow(labelKey: progress?.labelKey ?? "progress_receiving", progress: progress?.progress, detail: progress?.detail)
|
||||
SecondaryButton(title: String(localized: "button_cancel_receive"), action: model.cancelActiveReceive)
|
||||
ProgressRow(labelKey: progress?.labelKey ?? L10n.Progress.receiving, progress: progress?.progress, detail: progress?.detail)
|
||||
SecondaryButton(title: String(localized: L10n.Button.cancelReceive), action: model.cancelActiveReceive)
|
||||
} else {
|
||||
PrimaryButton(
|
||||
title: String(localized: "button_receive"), action: model.receive,
|
||||
title: String(localized: L10n.Button.receive), action: model.receive,
|
||||
enabled: state.canReceive(coreInitialized: model.coreState.isInitialized)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ final class ReceiveModel: ObservableObject {
|
||||
case .success:
|
||||
state.historyDeleteTarget = nil
|
||||
state.isDeletingHistory = false
|
||||
let key = target == .all ? "receive_history_cleared" : "transfer_deleted"
|
||||
let key = target == .all ? L10n.Receive.historyCleared : L10n.Transfer.deleted
|
||||
messages.tryShow(UiMessage(text: .resource(key), tone: .success))
|
||||
case .failure(let error):
|
||||
state.isDeletingHistory = false
|
||||
@@ -173,9 +173,9 @@ final class ReceiveModel: ObservableObject {
|
||||
resetAcquisition()
|
||||
let canReveal = fileSystemService.canRevealReceiveFolder(folder)
|
||||
messages.tryShow(UiMessage(
|
||||
text: .resource("receive_completed"),
|
||||
text: .resource(L10n.Receive.completed),
|
||||
tone: .success,
|
||||
actionLabel: canReveal ? .resource("button_show_in_files") : nil,
|
||||
actionLabel: canReveal ? .resource(L10n.Button.showInFiles) : nil,
|
||||
onAction: canReveal ? { self.revealReceiveFolder(folder) } : nil
|
||||
))
|
||||
case .failure(let error):
|
||||
@@ -192,8 +192,8 @@ final class ReceiveModel: ObservableObject {
|
||||
messages.tryShow(UiMessage(
|
||||
text: uiText,
|
||||
tone: .error,
|
||||
actionLabel: error.canRetryWithoutChangingInput ? .resource("button_retry") : nil,
|
||||
onAction: error.canRetryWithoutChangingInput ? { self.receive() } : nil
|
||||
actionLabel: .resource(L10n.Button.retry),
|
||||
onAction: { self.receive() }
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -222,14 +222,14 @@ final class ReceiveModel: ObservableObject {
|
||||
Task {
|
||||
let result = await fileSystemService.revealReceiveFolder(folder)
|
||||
if case .failure = result {
|
||||
messages.show(UiMessage(text: .resource("receive_open_files_failed"), tone: .error))
|
||||
messages.show(UiMessage(text: .resource(L10n.Receive.openFilesFailed), tone: .error))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func inspectInvitation(_ method: ReceiveMethod, _ raw: String) {
|
||||
let ticket = raw.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
if ticket.isEmpty { return messages.error(.resource("error_invitation_empty")) }
|
||||
if ticket.isEmpty { return messages.error(.resource(L10n.Error.invitationEmpty)) }
|
||||
state.isAcquisitionOpen = true
|
||||
state.ticket = ticket
|
||||
state.method = method
|
||||
|
||||
@@ -22,17 +22,17 @@ struct ReceiveScreen: View {
|
||||
history
|
||||
}
|
||||
}
|
||||
.navigationTitle(Text(LocalizedStringKey("receive_title")))
|
||||
.navigationTitle(Text(String(localized: L10n.Receive.title)))
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .primaryAction) {
|
||||
Button(action: model.openAcquisition) {
|
||||
Label(String(localized: "button_receive_files"), systemImage: "plus")
|
||||
Label(String(localized: L10n.Button.receiveFiles), systemImage: "plus")
|
||||
}
|
||||
}
|
||||
if !deletable.isEmpty {
|
||||
ToolbarItem(placement: .primaryAction) {
|
||||
Button(role: .destructive, action: model.requestClearHistory) {
|
||||
Label(String(localized: "receive_clear_history"), systemImage: "trash")
|
||||
Label(String(localized: L10n.Receive.clearHistory), systemImage: "trash")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,11 +50,11 @@ struct ReceiveScreen: View {
|
||||
}
|
||||
}
|
||||
.alert(
|
||||
Text(LocalizedStringKey(clearAllPending ? "receive_clear_history_title" : "receive_delete_history_title")),
|
||||
Text(String(localized: clearAllPending ? L10n.Receive.clearHistoryTitle : L10n.Receive.deleteHistoryTitle)),
|
||||
isPresented: Binding(get: { model.state.historyDeleteTarget != nil }, set: { if !$0 { Task { @MainActor in model.dismissHistoryDelete() } } })
|
||||
) {
|
||||
Button(String(localized: "button_cancel"), role: .cancel, action: model.dismissHistoryDelete)
|
||||
Button(String(localized: clearAllPending ? "receive_clear_history" : "button_delete_transfer"),
|
||||
Button(String(localized: L10n.Button.cancel), role: .cancel, action: model.dismissHistoryDelete)
|
||||
Button(String(localized: clearAllPending ? L10n.Receive.clearHistory : L10n.Button.deleteTransfer),
|
||||
role: .destructive, action: model.confirmHistoryDelete)
|
||||
} message: {
|
||||
historyDeleteMessage
|
||||
@@ -74,27 +74,27 @@ struct ReceiveScreen: View {
|
||||
Button(role: .destructive) {
|
||||
model.requestDeleteHistoryItem(transfer.transferId)
|
||||
} label: {
|
||||
Label(String(localized: "button_delete_transfer"), systemImage: "trash")
|
||||
Label(String(localized: L10n.Button.deleteTransfer), systemImage: "trash")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} header: {
|
||||
Text(LocalizedStringKey("receive_history_title"))
|
||||
Text(String(localized: L10n.Receive.historyTitle))
|
||||
} footer: {
|
||||
Text(LocalizedStringKey("receive_new_subtitle"))
|
||||
Text(String(localized: L10n.Receive.newSubtitle))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var emptyState: some View {
|
||||
ContentUnavailableView {
|
||||
Label(String(localized: "receive_empty_title"), systemImage: "tray.and.arrow.down")
|
||||
Label(String(localized: L10n.Receive.emptyTitle), systemImage: "tray.and.arrow.down")
|
||||
} description: {
|
||||
Text(LocalizedStringKey("receive_empty_body"))
|
||||
Text(String(localized: L10n.Receive.emptyBody))
|
||||
} actions: {
|
||||
Button(action: model.openAcquisition) {
|
||||
Label(String(localized: "button_receive_files"), systemImage: "plus")
|
||||
Label(String(localized: L10n.Button.receiveFiles), systemImage: "plus")
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.controlSize(.large)
|
||||
@@ -107,10 +107,10 @@ struct ReceiveScreen: View {
|
||||
private var historyDeleteMessage: some View {
|
||||
if let target = model.state.historyDeleteTarget {
|
||||
if target == .all {
|
||||
Text(LocalizedStringKey("receive_clear_history_description"))
|
||||
Text(String(localized: L10n.Receive.clearHistoryDescription))
|
||||
} else {
|
||||
Text(String(format: String(localized: "receive_delete_history_description"),
|
||||
transferName(for: target) ?? String(localized: "receive_unknown_transfer")))
|
||||
Text(L10n.Receive.deleteHistoryDescription(
|
||||
transferName: transferName(for: target) ?? String(localized: L10n.Receive.unknownTransfer)))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,7 +134,7 @@ private struct ReceiveTransferRow: View {
|
||||
.frame(width: 40, height: 40)
|
||||
.background(.quaternary, in: RoundedRectangle(cornerRadius: 9))
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
Text(transfer.transferName ?? String(localized: "receive_unknown_transfer"))
|
||||
Text(transfer.transferName ?? String(localized: L10n.Receive.unknownTransfer))
|
||||
.font(.body).lineLimit(1)
|
||||
Text("\(formatBytes(transfer.totalSize)) · \(statusLabel(transfer.status))")
|
||||
.font(.caption).foregroundStyle(.secondary)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -11,15 +11,15 @@ enum SettingsSection: Hashable {
|
||||
case about
|
||||
case bugReport
|
||||
|
||||
var titleKey: String {
|
||||
var titleKey: String.LocalizationValue {
|
||||
switch self {
|
||||
case .overview: return "settings_title"
|
||||
case .preferences: return "preferences_title"
|
||||
case .appearance: return "appearance_title"
|
||||
case .notifications: return "notifications_title"
|
||||
case .storage: return "storage_title"
|
||||
case .about: return "about_title"
|
||||
case .bugReport: return "about_bug_report"
|
||||
case .overview: return L10n.Settings.title
|
||||
case .preferences: return L10n.Preferences.title
|
||||
case .appearance: return L10n.Appearance.title
|
||||
case .notifications: return L10n.Notifications.title
|
||||
case .storage: return L10n.Storage.title
|
||||
case .about: return L10n.About.title
|
||||
case .bugReport: return L10n.About.bugReport
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,11 +184,11 @@ final class SettingsModel: ObservableObject {
|
||||
await enableNotifications()
|
||||
} else {
|
||||
preferences.setNotificationsEnabled(false)
|
||||
let key = permission == .unsupported ? "notifications_unsupported" : "notifications_permission_denied"
|
||||
let key = permission == .unsupported ? L10n.Notifications.unsupported : L10n.Notifications.permissionDenied
|
||||
messages.show(UiMessage(
|
||||
text: .resource(key),
|
||||
tone: .warning,
|
||||
actionLabel: permission == .denied ? .resource("button_open_settings") : nil,
|
||||
actionLabel: permission == .denied ? .resource(L10n.Button.openSettings) : nil,
|
||||
onAction: permission == .denied ? { self.openNotificationSettings() } : nil
|
||||
))
|
||||
}
|
||||
@@ -200,7 +200,7 @@ final class SettingsModel: ObservableObject {
|
||||
Task {
|
||||
preferences.setDiagnosticsEnabled(enabled)
|
||||
messages.show(UiMessage(
|
||||
text: .resource(enabled ? "diagnostics_enabled_message" : "diagnostics_disabled_message"),
|
||||
text: .resource(enabled ? L10n.Diagnostics.enabledMessage : L10n.Diagnostics.disabledMessage),
|
||||
tone: .success
|
||||
))
|
||||
}
|
||||
@@ -219,11 +219,11 @@ final class SettingsModel: ObservableObject {
|
||||
let what = snapshot.bugWhatHappened.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
let expected = snapshot.bugExpected.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
if what.isEmpty {
|
||||
messages.show(UiMessage(text: .resource("bug_report_missing_what"), tone: .warning))
|
||||
messages.show(UiMessage(text: .resource(L10n.Bug.reportMissingWhat), tone: .warning))
|
||||
return
|
||||
}
|
||||
if expected.isEmpty {
|
||||
messages.show(UiMessage(text: .resource("bug_report_missing_expected"), tone: .warning))
|
||||
messages.show(UiMessage(text: .resource(L10n.Bug.reportMissingExpected), tone: .warning))
|
||||
return
|
||||
}
|
||||
state.isSubmittingBugReport = true
|
||||
@@ -242,11 +242,11 @@ final class SettingsModel: ObservableObject {
|
||||
state.bugSteps = ""
|
||||
state.bugContact = ""
|
||||
state.bugIncludeLogs = true
|
||||
messages.show(UiMessage(text: .resource("bug_report_submitted"), tone: .success))
|
||||
messages.show(UiMessage(text: .resource(L10n.Bug.reportSubmitted), tone: .success))
|
||||
onSuccess()
|
||||
case .failure:
|
||||
state.isSubmittingBugReport = false
|
||||
messages.show(UiMessage(text: .resource("bug_report_submit_failed"), tone: .error))
|
||||
messages.show(UiMessage(text: .resource(L10n.Bug.reportSubmitFailed), tone: .error))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -257,7 +257,7 @@ final class SettingsModel: ObservableObject {
|
||||
let result = await notifications.openSettings()
|
||||
if case .failure = result {
|
||||
enableNotificationsAfterSettings = false
|
||||
messages.show(UiMessage(text: .resource("notifications_settings_open_failed"), tone: .error))
|
||||
messages.show(UiMessage(text: .resource(L10n.Notifications.settingsOpenFailed), tone: .error))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -278,7 +278,7 @@ final class SettingsModel: ObservableObject {
|
||||
|
||||
private func enableNotifications() async {
|
||||
preferences.setNotificationsEnabled(true)
|
||||
messages.show(UiMessage(text: .resource("notifications_enabled_message"), tone: .success))
|
||||
messages.show(UiMessage(text: .resource(L10n.Notifications.enabledMessage), tone: .success))
|
||||
}
|
||||
|
||||
// MARK: - Storage
|
||||
@@ -328,7 +328,7 @@ final class SettingsModel: ObservableObject {
|
||||
state.isDeletingTransfers = false
|
||||
if failures == 0 {
|
||||
loadStorageUsage()
|
||||
messages.show(UiMessage(text: .resource("storage_transfers_deleted"), tone: .success))
|
||||
messages.show(UiMessage(text: .resource(L10n.Storage.transfersDeleted), tone: .success))
|
||||
} else {
|
||||
messages.error(InvitationError.message("Could not delete \(failures) transfer records"))
|
||||
}
|
||||
|
||||
@@ -25,26 +25,26 @@ struct SettingsScreen: View {
|
||||
Form {
|
||||
Section {
|
||||
NavigationLink(value: SettingsSection.preferences) {
|
||||
SettingsRow(icon: "person.crop.circle", title: String(localized: "preferences_title"), value: model.state.username)
|
||||
SettingsRow(icon: "person.crop.circle", title: String(localized: L10n.Preferences.title), value: model.state.username)
|
||||
}
|
||||
NavigationLink(value: SettingsSection.appearance) {
|
||||
SettingsRow(icon: "sun.max", title: String(localized: "appearance_title"), value: themeModeLabel(model.state.themeMode))
|
||||
SettingsRow(icon: "sun.max", title: String(localized: L10n.Appearance.title), value: themeModeLabel(model.state.themeMode))
|
||||
}
|
||||
}
|
||||
Section {
|
||||
NavigationLink(value: SettingsSection.notifications) {
|
||||
SettingsRow(icon: "bell", title: String(localized: "notifications_title"), value: nil)
|
||||
SettingsRow(icon: "bell", title: String(localized: L10n.Notifications.title), value: nil)
|
||||
}
|
||||
NavigationLink(value: SettingsSection.storage) {
|
||||
SettingsRow(icon: "internaldrive", title: String(localized: "storage_title"), value: nil)
|
||||
SettingsRow(icon: "internaldrive", title: String(localized: L10n.Storage.title), value: nil)
|
||||
}
|
||||
NavigationLink(value: SettingsSection.about) {
|
||||
SettingsRow(icon: "info.circle", title: String(localized: "about_title"), value: nil)
|
||||
SettingsRow(icon: "info.circle", title: String(localized: L10n.About.title), value: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
.formStyle(.grouped)
|
||||
.navigationTitle(Text(LocalizedStringKey("settings_title")))
|
||||
.navigationTitle(Text(String(localized: L10n.Settings.title)))
|
||||
.navigationDestination(for: SettingsSection.self) { section in
|
||||
sectionForm(section)
|
||||
}
|
||||
@@ -57,7 +57,7 @@ struct SettingsScreen: View {
|
||||
SettingsSectionContent(model: model, section: section)
|
||||
}
|
||||
.formStyle(.grouped)
|
||||
.navigationTitle(Text(LocalizedStringKey(section.titleKey)))
|
||||
.navigationTitle(Text(String(localized: section.titleKey)))
|
||||
|
||||
if section == .about {
|
||||
content
|
||||
@@ -69,7 +69,7 @@ struct SettingsScreen: View {
|
||||
Button {
|
||||
showBugReport = true
|
||||
} label: {
|
||||
Label(String(localized: "about_bug_report"), systemImage: "ladybug")
|
||||
Label(String(localized: L10n.About.bugReport), systemImage: "ladybug")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,8 +130,8 @@ struct SettingsRow: View {
|
||||
|
||||
func themeModeLabel(_ mode: ThemeMode) -> String {
|
||||
switch mode {
|
||||
case .system: return String(localized: "appearance_system_mode")
|
||||
case .light: return String(localized: "appearance_light_mode")
|
||||
case .dark: return String(localized: "appearance_dark_mode")
|
||||
case .system: return String(localized: L10n.Appearance.systemMode)
|
||||
case .light: return String(localized: L10n.Appearance.lightMode)
|
||||
case .dark: return String(localized: L10n.Appearance.darkMode)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,16 +7,16 @@ struct PreferencesSettings: View {
|
||||
@ObservedObject var model: SettingsModel
|
||||
|
||||
var body: some View {
|
||||
Section(String(localized: "field_username")) {
|
||||
TextField(String(localized: "field_username"),
|
||||
Section(String(localized: L10n.Field.username)) {
|
||||
TextField(String(localized: L10n.Field.username),
|
||||
text: Binding(get: { model.state.username }, set: { model.setUsername($0) }))
|
||||
}
|
||||
if model.state.supportsCustomReceiveFolders {
|
||||
Section(String(localized: "preferences_receive_folder_title")) {
|
||||
Text(model.state.receiveFolder?.displayName ?? String(localized: "value_unavailable"))
|
||||
Section(String(localized: L10n.Preferences.receiveFolderTitle)) {
|
||||
Text(model.state.receiveFolder?.displayName ?? String(localized: L10n.Value.unavailable))
|
||||
.foregroundStyle(.secondary)
|
||||
Button(String(localized: "button_choose_folder"), action: model.chooseReceiveFolder)
|
||||
Button(String(localized: "button_reset_default"), action: model.resetReceiveFolder)
|
||||
Button(String(localized: L10n.Button.chooseFolder), action: model.chooseReceiveFolder)
|
||||
Button(String(localized: L10n.Button.resetDefault), action: model.resetReceiveFolder)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ struct AppearanceSettings: View {
|
||||
|
||||
var body: some View {
|
||||
Section {
|
||||
Picker(String(localized: "appearance_title"),
|
||||
Picker(String(localized: L10n.Appearance.title),
|
||||
selection: Binding(get: { model.state.themeMode }, set: { model.setThemeMode($0) })) {
|
||||
ForEach(ThemeMode.allCases, id: \.self) { mode in
|
||||
Text(themeModeLabel(mode)).tag(mode)
|
||||
@@ -48,10 +48,10 @@ struct NotificationSettings: View {
|
||||
get: { model.state.notificationsEnabled },
|
||||
set: { model.setNotificationsEnabled($0) }
|
||||
)) {
|
||||
Text(LocalizedStringKey("notifications_local_title"))
|
||||
Text(String(localized: L10n.Notifications.localTitle))
|
||||
}
|
||||
if model.state.notificationPermission == .denied {
|
||||
Button(String(localized: "button_open_settings"), action: model.openNotificationSettings)
|
||||
Button(String(localized: L10n.Button.openSettings), action: model.openNotificationSettings)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,22 +64,22 @@ struct StorageSettings: View {
|
||||
var body: some View {
|
||||
Section {
|
||||
if let storage = model.state.storage {
|
||||
LabeledContent(String(localized: "storage_received_files"), value: formatBytes(storage.receivedFiles))
|
||||
LabeledContent(String(localized: "storage_transfer_data"), value: formatBytes(storage.transferCache))
|
||||
LabeledContent(String(localized: "storage_app_data"), value: formatBytes(storage.appData))
|
||||
LabeledContent(String(localized: "storage_temporary"), value: formatBytes(storage.temporary))
|
||||
LabeledContent(String(localized: "storage_total")) {
|
||||
LabeledContent(String(localized: L10n.Storage.receivedFiles), value: formatBytes(storage.receivedFiles))
|
||||
LabeledContent(String(localized: L10n.Storage.transferData), value: formatBytes(storage.transferCache))
|
||||
LabeledContent(String(localized: L10n.Storage.appData), value: formatBytes(storage.appData))
|
||||
LabeledContent(String(localized: L10n.Storage.temporary), value: formatBytes(storage.temporary))
|
||||
LabeledContent(String(localized: L10n.Storage.total)) {
|
||||
Text(formatBytes(storage.total)).fontWeight(.semibold)
|
||||
}
|
||||
} else {
|
||||
HStack {
|
||||
Text(LocalizedStringKey("storage_calculating")).foregroundStyle(.secondary)
|
||||
Text(String(localized: L10n.Storage.calculating)).foregroundStyle(.secondary)
|
||||
Spacer()
|
||||
ProgressView()
|
||||
}
|
||||
}
|
||||
} footer: {
|
||||
Text(LocalizedStringKey("storage_footer"))
|
||||
Text(String(localized: L10n.Storage.footer))
|
||||
}
|
||||
|
||||
Section {
|
||||
@@ -88,8 +88,8 @@ struct StorageSettings: View {
|
||||
} label: {
|
||||
HStack {
|
||||
Text(model.state.isDeletingTransfers
|
||||
? String(localized: "storage_deleting")
|
||||
: String(localized: "storage_delete_transfers"))
|
||||
? String(localized: L10n.Storage.deleting)
|
||||
: String(localized: L10n.Storage.deleteTransfers))
|
||||
if model.state.isDeletingTransfers {
|
||||
Spacer()
|
||||
ProgressView()
|
||||
@@ -100,16 +100,16 @@ struct StorageSettings: View {
|
||||
}
|
||||
.onAppear { model.loadStorageUsage() }
|
||||
.confirmationDialog(
|
||||
Text(LocalizedStringKey("storage_delete_transfers")),
|
||||
Text(String(localized: L10n.Storage.deleteTransfers)),
|
||||
isPresented: $showDeleteConfirmation,
|
||||
titleVisibility: .visible
|
||||
) {
|
||||
Button(String(localized: "storage_delete_transfers"), role: .destructive) {
|
||||
Button(String(localized: L10n.Storage.deleteTransfers), role: .destructive) {
|
||||
model.deleteAllTransfers()
|
||||
}
|
||||
Button(String(localized: "button_cancel"), role: .cancel) {}
|
||||
Button(String(localized: L10n.Button.cancel), role: .cancel) {}
|
||||
} message: {
|
||||
Text(LocalizedStringKey("storage_delete_transfers_description"))
|
||||
Text(String(localized: L10n.Storage.deleteTransfersDescription))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,40 +121,40 @@ struct AboutSettings: View {
|
||||
|
||||
var body: some View {
|
||||
Section {
|
||||
Text(LocalizedStringKey("about_tagline")).font(.headline)
|
||||
Text(LocalizedStringKey("about_description")).foregroundStyle(.secondary)
|
||||
Text(String(localized: L10n.About.tagline)).font(.headline)
|
||||
Text(String(localized: L10n.About.description)).foregroundStyle(.secondary)
|
||||
}
|
||||
|
||||
Section(String(localized: "about_is_title")) {
|
||||
AboutPoint("about_is_direct", "paperplane")
|
||||
AboutPoint("about_is_no_account", "person.crop.circle.badge.xmark")
|
||||
AboutPoint("about_is_in_control", "checkmark.shield")
|
||||
AboutPoint("about_is_encrypted", "lock")
|
||||
AboutPoint("about_is_open", "chevron.left.forwardslash.chevron.right")
|
||||
Section(String(localized: L10n.About.isTitle)) {
|
||||
AboutPoint(L10n.About.isDirect, "paperplane")
|
||||
AboutPoint(L10n.About.isNoAccount, "person.crop.circle.badge.xmark")
|
||||
AboutPoint(L10n.About.isInControl, "checkmark.shield")
|
||||
AboutPoint(L10n.About.isEncrypted, "lock")
|
||||
AboutPoint(L10n.About.isOpen, "chevron.left.forwardslash.chevron.right")
|
||||
}
|
||||
|
||||
Section(String(localized: "about_isnt_title")) {
|
||||
AboutPoint("about_isnt_cloud", "icloud.slash")
|
||||
AboutPoint("about_isnt_sync", "arrow.triangle.2.circlepath")
|
||||
AboutPoint("about_isnt_public", "megaphone")
|
||||
Section(String(localized: L10n.About.isntTitle)) {
|
||||
AboutPoint(L10n.About.isntCloud, "icloud.slash")
|
||||
AboutPoint(L10n.About.isntSync, "arrow.triangle.2.circlepath")
|
||||
AboutPoint(L10n.About.isntPublic, "megaphone")
|
||||
}
|
||||
|
||||
Section(String(localized: "about_privacy_title")) {
|
||||
AboutPoint("about_privacy_capability", "qrcode")
|
||||
AboutPoint("about_privacy_deny", "hand.raised")
|
||||
AboutPoint("about_privacy_relay", "antenna.radiowaves.left.and.right")
|
||||
AboutPoint("about_privacy_local", "internaldrive")
|
||||
Section(String(localized: L10n.About.privacyTitle)) {
|
||||
AboutPoint(L10n.About.privacyCapability, "qrcode")
|
||||
AboutPoint(L10n.About.privacyDeny, "hand.raised")
|
||||
AboutPoint(L10n.About.privacyRelay, "antenna.radiowaves.left.and.right")
|
||||
AboutPoint(L10n.About.privacyLocal, "internaldrive")
|
||||
}
|
||||
|
||||
Section(String(localized: "about_title")) {
|
||||
LabeledContent(String(localized: "version_title"), value: model.state.appVersion)
|
||||
Section(String(localized: L10n.About.title)) {
|
||||
LabeledContent(String(localized: L10n.Version.title), value: model.state.appVersion)
|
||||
if let device = model.state.deviceInfo {
|
||||
LabeledContent(String(localized: "device_model_title"), value: device.deviceModel ?? "—")
|
||||
LabeledContent(String(localized: "os_version_title"), value: device.operatingSystem)
|
||||
LabeledContent(String(localized: L10n.Device.modelTitle), value: device.deviceModel ?? "—")
|
||||
LabeledContent(String(localized: L10n.Os.versionTitle), value: device.operatingSystem)
|
||||
}
|
||||
LabeledContent(String(localized: "about_license_label"), value: "Apache 2.0")
|
||||
LabeledContent(String(localized: L10n.About.licenseLabel), value: "Apache 2.0")
|
||||
Link(destination: Self.privacyPolicyURL) {
|
||||
Label(String(localized: "about_privacy_policy_label"), systemImage: "hand.raised")
|
||||
Label(String(localized: L10n.About.privacyPolicyLabel), systemImage: "hand.raised")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ struct AboutSettings: View {
|
||||
get: { model.state.diagnosticsEnabled },
|
||||
set: { model.setDiagnosticsEnabled($0) }
|
||||
)) {
|
||||
Text(LocalizedStringKey("diagnostics_title"))
|
||||
Text(String(localized: L10n.Diagnostics.title))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,13 +188,13 @@ struct BugReportSheet: View {
|
||||
BugReportSettings(model: model, onSubmitted: { dismiss() })
|
||||
}
|
||||
.formStyle(.grouped)
|
||||
.navigationTitle(Text(LocalizedStringKey("about_bug_report")))
|
||||
.navigationTitle(Text(String(localized: L10n.About.bugReport)))
|
||||
#if os(iOS)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
#endif
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .cancellationAction) {
|
||||
Button(String(localized: "button_cancel")) { dismiss() }
|
||||
Button(String(localized: L10n.Button.cancel)) { dismiss() }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -204,17 +204,17 @@ struct BugReportSheet: View {
|
||||
|
||||
/// A bullet-style informational row with an SF Symbol and wrapping localized text.
|
||||
private struct AboutPoint: View {
|
||||
let key: String
|
||||
let key: String.LocalizationValue
|
||||
let symbol: String
|
||||
|
||||
init(_ key: String, _ symbol: String) {
|
||||
init(_ key: String.LocalizationValue, _ symbol: String) {
|
||||
self.key = key
|
||||
self.symbol = symbol
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Label {
|
||||
Text(LocalizedStringKey(key))
|
||||
Text(String(localized: key))
|
||||
.font(.subheadline)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
} icon: {
|
||||
@@ -228,36 +228,36 @@ struct BugReportSettings: View {
|
||||
var onSubmitted: () -> Void = {}
|
||||
|
||||
var body: some View {
|
||||
Section(String(localized: "bug_report_what_label")) {
|
||||
Section(String(localized: L10n.Bug.reportWhatLabel)) {
|
||||
TextField("", text: Binding(get: { model.state.bugWhatHappened }, set: { model.setBugWhatHappened($0) }),
|
||||
prompt: Text(LocalizedStringKey("bug_report_what_hint")), axis: .vertical)
|
||||
prompt: Text(String(localized: L10n.Bug.reportWhatHint)), axis: .vertical)
|
||||
.lineLimit(3, reservesSpace: true)
|
||||
.labelsHidden()
|
||||
}
|
||||
Section(String(localized: "bug_report_expected_label")) {
|
||||
Section(String(localized: L10n.Bug.reportExpectedLabel)) {
|
||||
TextField("", text: Binding(get: { model.state.bugExpected }, set: { model.setBugExpected($0) }),
|
||||
prompt: Text(LocalizedStringKey("bug_report_expected_hint")), axis: .vertical)
|
||||
prompt: Text(String(localized: L10n.Bug.reportExpectedHint)), axis: .vertical)
|
||||
.lineLimit(3, reservesSpace: true)
|
||||
.labelsHidden()
|
||||
}
|
||||
Section(String(localized: "bug_report_steps_label")) {
|
||||
Section(String(localized: L10n.Bug.reportStepsLabel)) {
|
||||
TextField("", text: Binding(get: { model.state.bugSteps }, set: { model.setBugSteps($0) }),
|
||||
prompt: Text(LocalizedStringKey("bug_report_steps_hint")), axis: .vertical)
|
||||
prompt: Text(String(localized: L10n.Bug.reportStepsHint)), axis: .vertical)
|
||||
.lineLimit(3, reservesSpace: true)
|
||||
.labelsHidden()
|
||||
}
|
||||
Section(String(localized: "bug_report_contact_label")) {
|
||||
Section(String(localized: L10n.Bug.reportContactLabel)) {
|
||||
TextField("", text: Binding(get: { model.state.bugContact }, set: { model.setBugContact($0) }),
|
||||
prompt: Text(LocalizedStringKey("bug_report_contact_hint")))
|
||||
prompt: Text(String(localized: L10n.Bug.reportContactHint)))
|
||||
.labelsHidden()
|
||||
}
|
||||
Section {
|
||||
Toggle(isOn: Binding(get: { model.state.bugIncludeLogs }, set: { model.setBugIncludeLogs($0) })) {
|
||||
Text(LocalizedStringKey("bug_report_include_logs"))
|
||||
Text(String(localized: L10n.Bug.reportIncludeLogs))
|
||||
}
|
||||
Button(action: { model.submitBugReport(onSuccess: onSubmitted) }) {
|
||||
Text(model.state.isSubmittingBugReport
|
||||
? String(localized: "bug_report_submitting") : String(localized: "bug_report_submit"))
|
||||
? String(localized: L10n.Bug.reportSubmitting) : String(localized: L10n.Bug.reportSubmit))
|
||||
}
|
||||
.disabled(model.state.isSubmittingBugReport)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user