Skip to content

Commit f4af7fa

Browse files
committed
chore: clean up (#513)
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
1 parent 458644c commit f4af7fa

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

OUDS/Core/Components/Sources/ContentDisplay/BulletList/Internal/BulletListItem.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,12 @@ struct BulletListItem: View {
133133
static func prefixAfter(_ accessibilityLabel: String, for level: OUDSBulletList.NestedLevel, at index: Int) -> String {
134134
let index = UInt8(index)
135135
let currentPrefix = switch level {
136-
case .zero: OrderedBullet.levelZeroBullet(for: index)
137-
case .one: OrderedBullet.levelOneBullet(for: index)
138-
case .two: OrderedBullet.levelTwoBullet(for: index)
136+
case .zero:
137+
OrderedBullet.levelZeroBullet(for: index)
138+
case .one:
139+
OrderedBullet.levelOneBullet(for: index)
140+
case .two:
141+
OrderedBullet.levelTwoBullet(for: index)
139142
}
140143
return "\(accessibilityLabel)\(currentPrefix)"
141144
}

OUDS/Foundations/Sources/OUDSUtils.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ public enum OUDSUtils {
2525
if let preferredLanguage = Locale.preferredLanguages.first, preferredLanguage.hasPrefix("ar") {
2626
return true
2727
}
28-
if Locale.current.languageCode == "ar" {
29-
return true
28+
if #available(iOS 16.0, *) {
29+
if let languageCode = Locale.current.language.languageCode, languageCode.identifier == "ar" {
30+
return true
31+
}
32+
} else {
33+
return Locale.current.languageCode == "ar"
3034
}
3135
return false
3236
}
@@ -37,7 +41,7 @@ public enum OUDSUtils {
3741
///
3842
/// - Parameters:
3943
/// - index: A rank, starting at 0
40-
/// - isUppserCase: True if letter must be upper cased, false otherwise
44+
/// - isUppercase: True if letter must be upper cased, false otherwise
4145
/// - Returns: A letter or group a letters (e.g. 1 to Z, AA to AZ, etc).
4246
public static func cyclicLatinLetter(at index: UInt8, isUppercase: Bool) -> String {
4347
let alphabetSize = 26
@@ -49,7 +53,7 @@ public enum OUDSUtils {
4953
repeat {
5054
let position = idx % alphabetSize
5155
let letter = Character(UnicodeScalar(baseChar + UInt8(position)))
52-
result = String(letter) + result // Ajoute à gauche
56+
result = String(letter) + result
5357
idx = idx / alphabetSize - 1
5458
} while idx >= 0
5559

OUDS/Foundations/Tests/OUDSUtilsTests.swift

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
@testable import OUDSFoundations
1515
import Testing
1616

17+
// swiftlint:disable convenience_type
1718
@Suite("OUDS Utils Alphabet Tests (for OrderedBullet Lists)")
1819
struct OUDSUtilsTests {
1920

@@ -56,7 +57,7 @@ struct OUDSUtilsTests {
5657
(5, "f"),
5758
(10, "k"),
5859
(15, "p"),
59-
(20, "u")
60+
(20, "u"),
6061
])
6162
func middleValues(index: UInt8, expected: String) {
6263
#expect(OUDSUtils.cyclicLatinLetter(at: index, isUppercase: false) == expected)
@@ -68,7 +69,7 @@ struct OUDSUtilsTests {
6869
(35, "aj"),
6970
(40, "ao"),
7071
(45, "at"),
71-
(50, "ay")
72+
(50, "ay"),
7273
])
7374
func doubleLetterProgression(index: UInt8, expected: String) {
7475
#expect(OUDSUtils.cyclicLatinLetter(at: index, isUppercase: false) == expected)
@@ -119,7 +120,7 @@ struct OUDSUtilsTests {
119120
(28, "AC"),
120121
(51, "AZ"),
121122
(52, "BA"),
122-
(53, "BB")
123+
(53, "BB"),
123124
])
124125
func uppercaseProgression(index: UInt8, expected: String) {
125126
#expect(OUDSUtils.cyclicLatinLetter(at: index, isUppercase: true) == expected)
@@ -225,19 +226,25 @@ struct OUDSUtilsTests {
225226
@Test("Sequential indices should produce sequential letters (first 26)")
226227
func sequentialLetters() {
227228
let lowercase = (0 ..< 26).map { OUDSUtils.cyclicLatinLetter(at: $0, isUppercase: false) }
228-
let expected = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
229-
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
229+
let expected = [
230+
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
231+
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
232+
]
230233
#expect(lowercase == expected)
231234
}
232235

233236
@Test("Arabic sequential letters (first 28)")
234237
func arabicSequentialLetters() {
235238
let arabic = (0 ..< 28).map { OUDSUtils.cyclicArabicLetter(at: $0) }
236-
let expected = ["ا", "ب", "ت", "ث", "ج", "ح", "خ", "د",
237-
"ذ", "ر", "ز", "س", "ش", "ص", "ض", "ط",
238-
"ظ", "ع", "غ", "ف", "ق", "ك", "ل", "م",
239-
"ن", "ه", "و", "ي"]
239+
let expected = [
240+
"ا", "ب", "ت", "ث", "ج", "ح", "خ", "د",
241+
"ذ", "ر", "ز", "س", "ش", "ص", "ض", "ط",
242+
"ظ", "ع", "غ", "ف", "ق", "ك", "ل", "م",
243+
"ن", "ه", "و", "ي",
244+
]
240245
#expect(arabic == expected)
241246
}
242247
}
243248
}
249+
250+
// swiftlint:enable convenience_type

0 commit comments

Comments
 (0)