Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Move to Trash says when no size is known

Țugui Dragoșf7454bd5a10e
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 4faaf2f0..4fa7d904 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -5750,6 +5750,352 @@
}
}
},
+ "%@: ^[%lld item](inflect: true), size unknown" : {
+ "localizations" : {
+ "cs" : {
+ "variations" : {
+ "plural" : {
+ "few" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld položky, velikost neznámá"
+ }
+ },
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld položky, velikost neznámá"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld položka, velikost neznámá"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld položek, velikost neznámá"
+ }
+ }
+ }
+ }
+ },
+ "de" : {
+ "variations" : {
+ "plural" : {
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld Objekt, Größe unbekannt"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld Objekte, Größe unbekannt"
+ }
+ }
+ }
+ }
+ },
+ "en" : {
+ "stringUnit" : {
+ "state" : "new",
+ "value" : "%1$@: ^[%2$lld item](inflect: true), size unknown"
+ }
+ },
+ "es" : {
+ "variations" : {
+ "plural" : {
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld de ítems, tamaño desconocido"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld ítem, tamaño desconocido"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld ítems, tamaño desconocido"
+ }
+ }
+ }
+ }
+ },
+ "fr" : {
+ "variations" : {
+ "plural" : {
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ : %lld d’éléments, taille inconnue"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ : %lld élément, taille inconnue"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ : %lld éléments, taille inconnue"
+ }
+ }
+ }
+ }
+ },
+ "it" : {
+ "variations" : {
+ "plural" : {
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld di elementi, dimensioni sconosciute"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld elemento, dimensioni sconosciute"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld elementi, dimensioni sconosciute"
+ }
+ }
+ }
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld項目、サイズ不明"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: 항목 %lld개, 크기 알 수 없음"
+ }
+ },
+ "nl" : {
+ "variations" : {
+ "plural" : {
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld onderdeel, grootte onbekend"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld onderdelen, grootte onbekend"
+ }
+ }
+ }
+ }
+ },
+ "pl" : {
+ "variations" : {
+ "plural" : {
+ "few" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld rzeczy, wielkość nieznana"
+ }
+ },
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld rzeczy, wielkość nieznana"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld rzecz, wielkość nieznana"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld rzeczy, wielkość nieznana"
+ }
+ }
+ }
+ }
+ },
+ "pt" : {
+ "variations" : {
+ "plural" : {
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld de itens, tamanho desconhecido"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld item, tamanho desconhecido"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld itens, tamanho desconhecido"
+ }
+ }
+ }
+ }
+ },
+ "ro" : {
+ "variations" : {
+ "plural" : {
+ "few" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld articole, dimensiune necunoscută"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld articol, dimensiune necunoscută"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld de articole, dimensiune necunoscută"
+ }
+ }
+ }
+ }
+ },
+ "ru" : {
+ "variations" : {
+ "plural" : {
+ "few" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld объекта, размер неизвестен"
+ }
+ },
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld объектов, размер неизвестен"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld объект, размер неизвестен"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld объекта, размер неизвестен"
+ }
+ }
+ }
+ }
+ },
+ "sv" : {
+ "variations" : {
+ "plural" : {
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld objekt, okänd storlek"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld objekt, okänd storlek"
+ }
+ }
+ }
+ }
+ },
+ "tr" : {
+ "variations" : {
+ "plural" : {
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld öğe, büyüklük bilinmiyor"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld öğe, büyüklük bilinmiyor"
+ }
+ }
+ }
+ }
+ },
+ "uk" : {
+ "variations" : {
+ "plural" : {
+ "few" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld елементи, розмір невідомий"
+ }
+ },
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld елементів, розмір невідомий"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld елемент, розмір невідомий"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@: %lld елемента, розмір невідомий"
+ }
+ }
+ }
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@:%lld个项目,大小未知"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@:%lld個項目,大小未知"
+ }
+ }
+ }
+ },
"%@: links" : {
"localizations" : {
"cs" : {
@@ -59592,6 +59938,112 @@
}
}
},
+ "Move %@ (size unknown) to the Trash?" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Přesunout %@ (velikost neznámá) do koše?"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "„%@“ (Größe unbekannt) in den Papierkorb legen?"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "¿Trasladar %@ (tamaño desconocido) a la papelera?"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Placer %@ (taille inconnue) dans la corbeille ?"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Vuoi spostare %@ (dimensioni sconosciute) nel Cestino?"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "“%@”(サイズ不明)をゴミ箱に入れますか?"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "‘%@’(크기 알 수 없음)을(를) 휴지통으로 이동하겠습니까?"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ (grootte onbekend) naar de prullenmand verplaatsen?"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Przenieść %@ (wielkość nieznana) do Kosza?"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Mover %@ (tamanho desconhecido) para o Lixo?"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Mutați %@ (dimensiune necunoscută) în Coș?"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Переместить «%@» (размер неизвестен) в Корзину?"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Vill du flytta %@ (okänd storlek) till papperskorgen?"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ (büyüklük bilinmiyor) Çöp Sepeti’ne taşınsın mı?"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Перемістити «%@» (розмір невідомий) у Смітник?"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "要将“%@”(大小未知)移到废纸篓吗?"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "要將「%@」(大小未知)丟到「垃圾桶」嗎?"
+ }
+ }
+ }
+ },
"Move %@ to the Trash?" : {
"localizations" : {
"cs" : {
@@ -60378,6 +60830,346 @@
}
}
},
+ "Move ^[%lld item](inflect: true) (size unknown) to the Trash?" : {
+ "localizations" : {
+ "cs" : {
+ "variations" : {
+ "plural" : {
+ "few" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Přesunout %lld položky (velikost neznámá) do koše?"
+ }
+ },
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Přesunout %lld položky (velikost neznámá) do koše?"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Přesunout %lld položku (velikost neznámá) do koše?"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Přesunout %lld položek (velikost neznámá) do koše?"
+ }
+ }
+ }
+ }
+ },
+ "de" : {
+ "variations" : {
+ "plural" : {
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld Objekt (Größe unbekannt) in den Papierkorb legen?"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld Objekte (Größe unbekannt) in den Papierkorb legen?"
+ }
+ }
+ }
+ }
+ },
+ "es" : {
+ "variations" : {
+ "plural" : {
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "¿Trasladar %lld de ítems (tamaño desconocido) a la papelera?"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "¿Trasladar %lld ítem (tamaño desconocido) a la papelera?"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "¿Trasladar %lld ítems (tamaño desconocido) a la papelera?"
+ }
+ }
+ }
+ }
+ },
+ "fr" : {
+ "variations" : {
+ "plural" : {
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Placer %lld d’éléments (taille inconnue) dans la corbeille ?"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Placer %lld élément (taille inconnue) dans la corbeille ?"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Placer %lld éléments (taille inconnue) dans la corbeille ?"
+ }
+ }
+ }
+ }
+ },
+ "it" : {
+ "variations" : {
+ "plural" : {
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Vuoi spostare %lld di elementi (dimensioni sconosciute) nel Cestino?"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Vuoi spostare %lld elemento (dimensioni sconosciute) nel Cestino?"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Vuoi spostare %lld elementi (dimensioni sconosciute) nel Cestino?"
+ }
+ }
+ }
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld項目(サイズ不明)をゴミ箱に入れますか?"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "항목 %lld개(크기 알 수 없음)를 휴지통으로 이동하겠습니까?"
+ }
+ },
+ "nl" : {
+ "variations" : {
+ "plural" : {
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld onderdeel (grootte onbekend) naar de prullenmand verplaatsen?"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld onderdelen (grootte onbekend) naar de prullenmand verplaatsen?"
+ }
+ }
+ }
+ }
+ },
+ "pl" : {
+ "variations" : {
+ "plural" : {
+ "few" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Przenieść %lld rzeczy (wielkość nieznana) do Kosza?"
+ }
+ },
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Przenieść %lld rzeczy (wielkość nieznana) do Kosza?"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Przenieść %lld rzecz (wielkość nieznana) do Kosza?"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Przenieść %lld rzeczy (wielkość nieznana) do Kosza?"
+ }
+ }
+ }
+ }
+ },
+ "pt" : {
+ "variations" : {
+ "plural" : {
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Mover %lld de itens (tamanho desconhecido) para o Lixo?"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Mover %lld item (tamanho desconhecido) para o Lixo?"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Mover %lld itens (tamanho desconhecido) para o Lixo?"
+ }
+ }
+ }
+ }
+ },
+ "ro" : {
+ "variations" : {
+ "plural" : {
+ "few" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Mutați %lld articole (dimensiune necunoscută) în Coș?"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Mutați %lld articol (dimensiune necunoscută) în Coș?"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Mutați %lld de articole (dimensiune necunoscută) în Coș?"
+ }
+ }
+ }
+ }
+ },
+ "ru" : {
+ "variations" : {
+ "plural" : {
+ "few" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Переместить %lld объекта (размер неизвестен) в Корзину?"
+ }
+ },
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Переместить %lld объектов (размер неизвестен) в Корзину?"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Переместить %lld объект (размер неизвестен) в Корзину?"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Переместить %lld объекта (размер неизвестен) в Корзину?"
+ }
+ }
+ }
+ }
+ },
+ "sv" : {
+ "variations" : {
+ "plural" : {
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Vill du flytta %lld objekt (okänd storlek) till papperskorgen?"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Vill du flytta %lld objekt (okänd storlek) till papperskorgen?"
+ }
+ }
+ }
+ }
+ },
+ "tr" : {
+ "variations" : {
+ "plural" : {
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld öğe (büyüklük bilinmiyor) Çöp Sepeti’ne taşınsın mı?"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld öğe (büyüklük bilinmiyor) Çöp Sepeti’ne taşınsın mı?"
+ }
+ }
+ }
+ }
+ },
+ "uk" : {
+ "variations" : {
+ "plural" : {
+ "few" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Перемістити %lld елементи (розмір невідомий) у Смітник?"
+ }
+ },
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Перемістити %lld елементів (розмір невідомий) у Смітник?"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Перемістити %lld елемент (розмір невідомий) у Смітник?"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Перемістити %lld елемента (розмір невідомий) у Смітник?"
+ }
+ }
+ }
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "要将%lld个项目(大小未知)移到废纸篓吗?"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "要將%lld個項目(大小未知)丟到「垃圾桶」嗎?"
+ }
+ }
+ }
+ },
"Move ^[%lld item](inflect: true) to the Trash?" : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/Support/SizeTotal.swift b/Packages/PeelCore/Sources/PeelCore/Support/SizeTotal.swift
index b2fdb7f4..a9bb4228 100644
--- a/Packages/PeelCore/Sources/PeelCore/Support/SizeTotal.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Support/SizeTotal.swift
@@ -21,6 +21,18 @@ public struct SizeTotal: Sendable, Hashable, Comparable {
self.init(known: known, isComplete: isComplete)
}
+ /// How the total reads: a size, the least it can be, or nothing known at all.
+ public enum Reading: Sendable, Hashable {
+ case exactly(Int64)
+ case atLeast(Int64)
+ case unknown
+ }
+
+ public var reading: Reading {
+ if isComplete { return .exactly(known) }
+ return known > 0 ? .atLeast(known) : .unknown
+ }
+
/// An incomplete total counts as larger than a complete one, since what ran out of time is most likely the biggest.
public static func < (lhs: SizeTotal, rhs: SizeTotal) -> Bool {
lhs.isComplete != rhs.isComplete ? lhs.isComplete : lhs.known < rhs.known
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/SizeTotalTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/SizeTotalTests.swift
index cd420b76..322a83c2 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/SizeTotalTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/SizeTotalTests.swift
@@ -2,6 +2,14 @@
import Testing
struct SizeTotalTests {
+ /// A total with nothing measured is unknown, never zero: two folders that did not answer are not two empty files.
+ @Test func readsAsExactAtLeastOrUnknown() {
+ #expect(SizeTotal([100, 20]).reading == .exactly(120))
+ #expect(SizeTotal([Int64?]()).reading == .exactly(0))
+ #expect(SizeTotal([100, nil]).reading == .atLeast(100))
+ #expect(SizeTotal([nil, nil]).reading == .unknown)
+ }
+
@Test func addsUpWhatIsKnownAndSaysWhenThatIsNotAll() {
#expect(SizeTotal([100, 20, 3]) == SizeTotal(known: 123, isComplete: true))
#expect(SizeTotal([100, nil, 3]) == SizeTotal(known: 103, isComplete: false))
diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swift
index 948e7b0f..86ad5c63 100644
--- a/Peel/Views/Presentation.swift
+++ b/Peel/Views/Presentation.swift
@@ -343,8 +343,11 @@ extension Int64? {
extension SizeTotal {
var text: String {
- if isComplete { return known.byteCount }
- return known > 0 ? String(localized: "Over \(known.byteCount)") : String(localized: "Unknown")
+ switch reading {
+ case .exactly(let size): size.byteCount
+ case .atLeast(let size): String(localized: "Over \(size.byteCount)")
+ case .unknown: String(localized: "Unknown")
+ }
}
/// The form `text` is in, used as the view's identity: within one form the digits roll, while a change to
diff --git a/Peel/Views/RemovalBar.swift b/Peel/Views/RemovalBar.swift
index 36384a75..05213b7e 100644
--- a/Peel/Views/RemovalBar.swift
+++ b/Peel/Views/RemovalBar.swift
@@ -205,13 +205,16 @@ struct RemovalBar: View {
}
private func line(_ part: CarriedSelection.Part) -> String {
- let total = part.total
- if total.known == 0 {
- return String(inflecting: "\(part.title): ^[\(part.count) item](inflect: true)")
+ switch part.total.reading {
+ case .exactly(0):
+ String(inflecting: "\(part.title): ^[\(part.count) item](inflect: true)")
+ case .exactly(let size):
+ String(inflecting: "\(part.title): ^[\(part.count) item](inflect: true), \(size.byteCount)")
+ case .atLeast(let size):
+ String(inflecting: "\(part.title): ^[\(part.count) item](inflect: true), over \(size.byteCount)")
+ case .unknown:
+ String(inflecting: "\(part.title): ^[\(part.count) item](inflect: true), size unknown")
}
- return total.isComplete
- ? String(inflecting: "\(part.title): ^[\(part.count) item](inflect: true), \(total.known.byteCount)")
- : String(inflecting: "\(part.title): ^[\(part.count) item](inflect: true), over \(total.known.byteCount)")
}
}
diff --git a/Peel/Views/TrashQuestion.swift b/Peel/Views/TrashQuestion.swift
index c965a51b..8f060294 100644
--- a/Peel/Views/TrashQuestion.swift
+++ b/Peel/Views/TrashQuestion.swift
@@ -7,21 +7,24 @@ extension Text {
/// markup unresolved, so the markup is resolved here.
static func movingToTrash(_ count: Int, _ total: SizeTotal) -> Text {
let size = total.known.byteCount
- if total.known == 0 {
- return Text(verbatim: String(inflecting: "Move ^[\(count) item](inflect: true) to the Trash?"))
+ return switch total.reading {
+ case .exactly(0):
+ Text(verbatim: String(inflecting: "Move ^[\(count) item](inflect: true) to the Trash?"))
+ case .exactly:
+ Text(verbatim: String(inflecting: "Move ^[\(count) item](inflect: true) (\(size)) to the Trash?"))
+ case .atLeast:
+ Text(verbatim: String(inflecting: "Move ^[\(count) item](inflect: true) (over \(size)) to the Trash?"))
+ case .unknown:
+ Text(verbatim: String(inflecting: "Move ^[\(count) item](inflect: true) (size unknown) to the Trash?"))
}
- return Text(verbatim: total.isComplete
- ? String(inflecting: "Move ^[\(count) item](inflect: true) (\(size)) to the Trash?")
- : String(inflecting: "Move ^[\(count) item](inflect: true) (over \(size)) to the Trash?"))
}
static func movingToTrash(_ name: String, _ total: SizeTotal) -> Text {
- let size = total.known.byteCount
- if total.known == 0 {
- return Text("Move \(name) to the Trash?")
+ switch total.reading {
+ case .exactly(0): Text("Move \(name) to the Trash?")
+ case .exactly(let size): Text("Move \(name) (\(size.byteCount)) to the Trash?")
+ case .atLeast(let size): Text("Move \(name) (over \(size.byteCount)) to the Trash?")
+ case .unknown: Text("Move \(name) (size unknown) to the Trash?")
}
- return total.isComplete
- ? Text("Move \(name) (\(size)) to the Trash?")
- : Text("Move \(name) (over \(size)) to the Trash?")
}
}