Skip to content

Commit

Permalink
fix: better handling of plural and singular titles (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba authored Nov 29, 2024
1 parent 9f6b3fc commit 9e5c3b4
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 18 deletions.
18 changes: 15 additions & 3 deletions Sources/Screens/File/FileCopy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ struct FileCopy: View {
VStack {
if isProcessing, !errorIsPresented {
VOSheetProgressView()
Text("Copying \(fileStore.selection.count) item(s).")
if fileStore.selection.count > 1 {
Text("Copying (\(fileStore.selection.count)) items.")
} else {
Text("Copying item.")
}
} else if errorIsPresented, errorSeverity == .full {
VOErrorIcon()
if let errorMessage {
Expand Down Expand Up @@ -74,7 +78,11 @@ struct FileCopy: View {
if result.failed.isEmpty {
return true
} else {
errorMessage = "Failed to copy \(result.failed.count) item(s)."
if result.failed.count > 1 {
errorMessage = "Failed to copy (\(result.failed.count)) items."
} else {
errorMessage = "Failed to copy item."
}
if result.failed.count < fileStore.selection.count {
errorSeverity = .partial
} else if result.failed.count == fileStore.selection.count {
Expand All @@ -88,7 +96,11 @@ struct FileCopy: View {
errorIsPresented = false
dismiss()
} failure: { _ in
errorMessage = "Failed to copy \(fileStore.selection.count) item(s)."
if fileStore.selection.count > 1 {
errorMessage = "Failed to copy (\(fileStore.selection.count)) items."
} else {
errorMessage = "Failed to copy item."
}
errorSeverity = .full
errorIsPresented = true
} anyways: {
Expand Down
18 changes: 15 additions & 3 deletions Sources/Screens/File/FileDelete.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ struct FileDelete: View {
VStack {
if isProcessing, !errorIsPresented {
VOSheetProgressView()
Text("Deleting \(fileStore.selection.count) item(s).")
if fileStore.selection.count > 1 {
Text("Deleting (\(fileStore.selection.count)) items.")
} else {
Text("Deleting item.")
}
} else if errorIsPresented, errorSeverity == .full {
VOErrorIcon()
if let errorMessage {
Expand Down Expand Up @@ -70,7 +74,11 @@ struct FileDelete: View {
if result.failed.isEmpty {
return true
} else {
errorMessage = "Failed to delete \(result.failed.count) item(s)."
if result.failed.count > 1 {
errorMessage = "Failed to delete (\(result.failed.count)) items."
} else {
errorMessage = "Failed to delete item."
}
if result.failed.count < fileStore.selection.count {
errorSeverity = .partial
} else if result.failed.count == fileStore.selection.count {
Expand All @@ -84,7 +92,11 @@ struct FileDelete: View {
errorIsPresented = false
dismiss()
} failure: { _ in
errorMessage = "Failed to delete \(fileStore.selection.count) item(s)."
if fileStore.selection.count > 1 {
errorMessage = "Failed to delete (\(fileStore.selection.count)) items."
} else {
errorMessage = "Failed to delete item."
}
errorSeverity = .full
errorIsPresented = true
} anyways: {
Expand Down
13 changes: 11 additions & 2 deletions Sources/Screens/File/FileDownload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ struct FileDownload: View {
VStack {
if isProcessing, !errorIsPresented {
VOSheetProgressView()
Text("Downloading \(fileStore.selectionFiles.count) item(s).")
if fileStore.selectionFiles.count > 1 {
Text("Downloading (\(fileStore.selectionFiles.count)) items.")
} else {
Text("Downloading item.")
}
} else if errorIsPresented, errorSeverity == .full {
VOErrorIcon()
if let errorMessage {
Expand Down Expand Up @@ -72,6 +76,7 @@ struct FileDownload: View {
.presentationDetents([.fraction(0.25)])
}

// swiftlint:disable:next function_body_length
private func performDownload() {
let dispatchGroup = DispatchGroup()
urls.removeAll()
Expand Down Expand Up @@ -110,7 +115,11 @@ struct FileDownload: View {
dismiss()
} else {
let count = fileStore.selection.count - urls.count
errorMessage = "Failed to download \(count) item(s)."
if count > 1 {
errorMessage = "Failed to download (\(count)) items."
} else {
errorMessage = "Failed to download item."
}
if count < fileStore.selection.count {
errorSeverity = .partial
} else {
Expand Down
18 changes: 15 additions & 3 deletions Sources/Screens/File/FileMove.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ struct FileMove: View {
VStack {
if isProcessing, !errorIsPresented {
VOSheetProgressView()
Text("Moving \(fileStore.selection.count) item(s).")
if fileStore.selection.count > 1 {
Text("Moving (\(fileStore.selection.count)) items.")
} else {
Text("Moving item.")
}
} else if errorIsPresented, errorSeverity == .full {
VOErrorIcon()
if let errorMessage {
Expand Down Expand Up @@ -72,7 +76,11 @@ struct FileMove: View {
if result.failed.isEmpty {
return true
} else {
errorMessage = "Failed to move \(result.failed.count) item(s)."
if result.failed.count > 1 {
errorMessage = "Failed to move (\(result.failed.count)) items."
} else {
errorMessage = "Failed to move item."
}
if result.failed.count < fileStore.selection.count {
errorSeverity = .partial
} else if result.failed.count == fileStore.selection.count {
Expand All @@ -86,7 +94,11 @@ struct FileMove: View {
errorIsPresented = false
dismiss()
} failure: { _ in
errorMessage = "Failed to move \(fileStore.selection.count) item(s)."
if fileStore.selection.count > 1 {
errorMessage = "Failed to move (\(fileStore.selection.count)) items."
} else {
errorMessage = "Failed to move item."
}
errorSeverity = .full
errorIsPresented = true
} anyways: {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Screens/File/FileStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class FileStore: ObservableObject {
}

@Published var renameIsPresented = false
@Published var deleteIsPresented = false
@Published var deleteConfirmationIsPresented = false
@Published var downloadIsPresented = false
@Published var browserForMoveIsPresented = false
@Published var browserForCopyIsPresented = false
Expand Down
12 changes: 10 additions & 2 deletions Sources/Screens/File/FileUpload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ struct FileUpload: View {
VStack {
if isProcessing, !errorIsPresented {
VOSheetProgressView()
Text("Uploading \(urls.count) item(s).")
if urls.count > 1 {
Text("Uploading (\(urls.count)) items.")
} else {
Text("Uploading item.")
}
} else if errorIsPresented, errorSeverity == .full {
VOErrorIcon()
if let errorMessage {
Expand Down Expand Up @@ -94,7 +98,11 @@ struct FileUpload: View {
errorIsPresented = false
dismiss()
} else {
errorMessage = "Failed to upload \(failedCount) item(s)."
if failedCount > 1 {
errorMessage = "Failed to upload (\(failedCount)) items."
} else {
errorMessage = "Failed to upload item."
}
if failedCount == urls.count {
errorSeverity = .full
} else if failedCount < urls.count {
Expand Down
2 changes: 0 additions & 2 deletions Sources/Screens/Sharing/SharingBatch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ struct SharingBatch: View, TokenDistributing {
}
}
}
.navigationBarTitleDisplayMode(.inline)
.navigationTitle("Sharing")
.onAppear {
if let token = tokenStore.token {
assignTokenToStores(token)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Screens/Sharing/SharingGroupPermission.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ struct SharingGroupPermission: View, FormValidatable, ErrorPresentable {
}
}
.navigationBarTitleDisplayMode(.inline)
.navigationTitle("Group Permission")
.navigationTitle(fileIDs.count > 1 ? "Sharing (\(fileIDs.count)) Items" : "Sharing")
.toolbar {
if enableCancel {
ToolbarItem(placement: .topBarLeading) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Screens/Sharing/SharingUserPermission.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ struct SharingUserPermission: View, FormValidatable, ErrorPresentable {
}
}
.navigationBarTitleDisplayMode(.inline)
.navigationTitle("User Permission")
.navigationTitle(fileIDs.count > 1 ? "Sharing (\(fileIDs.count)) Items" : "Sharing")
.toolbar {
if enableCancel {
ToolbarItem(placement: .topBarLeading) {
Expand Down

0 comments on commit 9e5c3b4

Please sign in to comment.