diff --git a/Sources/SimpleKeyboard/Helper/ThemingModifier.swift b/Sources/SimpleKeyboard/Helper/ThemingModifier.swift index fe1b681..58fd8cb 100644 --- a/Sources/SimpleKeyboard/Helper/ThemingModifier.swift +++ b/Sources/SimpleKeyboard/Helper/ThemingModifier.swift @@ -7,22 +7,21 @@ import SwiftUI -struct OuterKeyboardThemingModifier: ViewModifier { +struct OuterKeyboardThemingModifier: ViewModifier { var theme: KeyboardTheme - var backroundColor: Background func body(content: Content) -> some View { - if theme == .system { - content - .padding(10) - .background(backroundColor) - } else if theme == .floating { + if theme == .floating { content .cornerRadius(25, corners: [.bottomLeft, .bottomRight]) .padding(10) - .background(backroundColor) + .background(theme.keyboardBackground) .cornerRadius(25) .padding(10) + } else { + content + .padding(10) + .background(theme.keyboardBackground) } } } diff --git a/Sources/SimpleKeyboard/Helper/View+Background.swift b/Sources/SimpleKeyboard/Helper/View+Background.swift index 4da6051..3ab5ee6 100644 --- a/Sources/SimpleKeyboard/Helper/View+Background.swift +++ b/Sources/SimpleKeyboard/Helper/View+Background.swift @@ -8,7 +8,7 @@ import SwiftUI public enum KeyboardTheme { - case system, floating + case system, floating, clear } protocol ThemeableView { @@ -24,12 +24,15 @@ private typealias PlatformColor = NSColor extension NSColor { static var systemGray3: NSColor { NSColor.systemGray } } #endif -extension View where Self: ThemeableView { +extension KeyboardTheme { + @ViewBuilder var keyboardBackground: some View { - if #available(iOS 15.0, macOS 12.0, *) { - return AnyView(EmptyView().background(.ultraThinMaterial)) + if self == .clear { + Color.clear + } else if #available(iOS 15.0, macOS 12.0, *) { + Rectangle().fill(.clear).background(.ultraThinMaterial) } else { - return AnyView(Color(PlatformColor.systemGray3.withAlphaComponent(0.75))) + Color(PlatformColor.systemGray3.withAlphaComponent(0.75)) } } } diff --git a/Sources/SimpleKeyboard/Models/Language.swift b/Sources/SimpleKeyboard/Models/Language.swift index 587d8e2..13d80ae 100644 --- a/Sources/SimpleKeyboard/Models/Language.swift +++ b/Sources/SimpleKeyboard/Models/Language.swift @@ -22,6 +22,39 @@ public enum Language: CaseIterable { } case english, german, spanish, french, russian, hindi + case swedish, danish, norwegian, finnish + case korean + + /// General purpose layout using QWERTY with the common diacritics + case latinWithAccents + + var alternateKeys: [String: String] { + switch self { + case .german: return ["a": "ä", "o": "ö", "u": "ü"] + // spanish also has ü + case .spanish: return ["e": "é", "a": "á", "i": "í", "o": "ó", "u": "ú", "n": "ñ"] + case .french: return ["e": "é", "a": "à", "u": "ù", "i": "î", "o": "ô", "c": "ç"] + // Nynorsk uses several letters with diacritic signs: é, è, ê, ó, ò, â, and ô. The diacritic signs are not compulsory + // Danish has no compulsory diacritics, but allows the use of an acute accent. Most often, an accent on e. + case .danish, .norwegian: return ["e": "é"] + // Though not in the official alphabet, á is a Swedish (old-fashioned) letter. In native Swedish personal names, ü and è and others are also used. + case .swedish: return ["a":"á", "u":"ü", "e": "è"] + case .finnish: return ["s": "š", "z": "ž"] + case .korean: return ["ㅂ":"ㅃ", "ㅈ":"ㅉ", "ㄷ":"ㄸ", "ㄱ":"ㄲ", "ㅅ":"ㅆ", "ㅐ":"ㅒ", "ㅔ":"ㅖ"] + case .latinWithAccents: + + // 300 = Grave; 301 = Acute; + // 302 = Circumflex; 303 = Tilde; + // 308 = Diaeresis; 30A = Ring; + // 327 = Cedilla; 30C = Caron; + return [ + "\u{0300}": "\u{0301}", + "\u{0302}": "\u{0303}", + "\u{0308}": "\u{030A}", + "\u{0327}": "\u{030C}",] + default: return [:] + } + } func rows(areUppercased: Bool) -> [[String]] { var result = [[String]]() @@ -34,14 +67,14 @@ public enum Language: CaseIterable { ] case .german: result = [ - ["q", "w", "e", "r", "t", "z", "u", "i", "o", "p"], - ["a", "s", "d", "f", "g", "h", "j", "k", "l"], + ["q", "w", "e", "r", "t", "z", "u", "i", "o", "p"], // "ü"], + ["a", "s", "d", "f", "g", "h", "j", "k", "l"], // "ö", "ä"], ["y", "x", "c", "v", "b", "n", "m"] ] case .spanish: result = [ ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"], - ["a", "s", "d", "f", "g", "h", "j", "k", "l", "ñ"], + ["a", "s", "d", "f", "g", "h", "j", "k", "l", "ü"], ["z", "x", "c", "v", "b", "n", "m"] ] case .french: @@ -62,10 +95,44 @@ public enum Language: CaseIterable { ["ो", "े", "्", "ि", "ु", "प", "र", "क", "त", "च"], ["ं", "म", "न", "व", "ल", "स", "य"] ] + case .swedish, .finnish: + result = [ + ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "å"], + ["a", "s", "d", "f", "g", "h", "j", "k", "l", "ö", "ä"], + ["z", "x", "c", "v", "b", "n", "m"] + ] + case .danish: + result = [ + ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "å"], + ["a", "s", "d", "f", "g", "h", "j", "k", "l", "æ", "ø"], + ["z", "x", "c", "v", "b", "n", "m"] + ] + case .norwegian: + result = [ + ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "å"], + ["a", "s", "d", "f", "g", "h", "j", "k", "l", "ø", "æ"], + ["z", "x", "c", "v", "b", "n", "m"] + ] + + case .latinWithAccents: + result = [ + ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "\u{0300}"], + ["a", "s", "d", "f", "g", "h", "j", "k", "l", "\u{0302}", "\u{0308}"], + ["z", "x", "c", "v", "b", "n", "m", "\u{0327}"] + ] + case .korean: + result = [ + ["ㅂ","ㅈ","ㄷ","ㄱ","ㅅ","ㅛ","ㅕ","ㅑ","ㅐ","ㅔ"], + ["ㅁ","ㄴ","ㅇ","ㄹ","ㅎ","ㅗ","ㅓ","ㅏ","ㅣ"], + ["ㅋ","ㅌ","ㅊ","ㅍ","ㅠ","ㅜ","ㅡ"] + ] } if areUppercased { - result = result.map { $0.map { $0.uppercased() } } + result = result.map { $0.map { + let upper = $0.uppercased() + return $0 != upper ? upper : alternateKeys[$0] ?? $0 + } } } return result diff --git a/Sources/SimpleKeyboard/Views/KeyButton.swift b/Sources/SimpleKeyboard/Views/KeyButton.swift index a093b86..54d0d5e 100644 --- a/Sources/SimpleKeyboard/Views/KeyButton.swift +++ b/Sources/SimpleKeyboard/Views/KeyButton.swift @@ -14,16 +14,18 @@ protocol ClickableKey { extension ClickableKey { func didClick() { #if canImport(UIKit) + let generator = UIImpactFeedbackGenerator(style: .light) + generator.impactOccurred() UIDevice.current.playInputClick() #endif } } -struct ShiftKeyButton: View { +struct ShiftKeyButton: View, ClickableKey { @Binding var isUpperCase: Bool! var body: some View { - Button(action: { self.isUpperCase?.toggle() }) { + Button(action: { self.isUpperCase?.toggle(); didClick() }) { if #available(iOS 15, macOS 12, *) { AnyView(Image(systemName: isUpperCase ? "shift.fill" : "shift") .dynamicTypeSize(.large)) @@ -45,13 +47,11 @@ struct ShiftKeyButton: View { struct KeyButton: View, ClickableKey { @Binding var text: String var letter: String + var alternateLetter: String? @Environment(\.colorScheme) var colorScheme var body: some View { - Button(action: { - self.text.append(self.letter) - didClick() - }) { + Button(action: { /* use Gesture */}) { Text(letter) .font(.system(size: 25)) .fixedSize() @@ -64,11 +64,24 @@ struct KeyButton: View, ClickableKey { .cornerRadius(5) .shadow(color: .black, radius: 0, y: 1) } + .highPriorityGesture(TapGesture().onEnded({ _ in + self.text.append(self.letter) + didClick() + })) + .simultaneousGesture(LongPressGesture().onEnded({ _ in + guard let alternateLetter else { return } + self.text.append(alternateLetter) + didClick() + })) } } -struct FRAccentKeyButton: View { +/// Replaces the last typed character with another (special) character. E.g. "a" -> "ä" +@available(*, deprecated, message: "Use `Language.alternateKeys` instead") +struct AccentKeyButton: View, ClickableKey { @Binding var text: String + /// The lookup for modified characters all lowercased. E.g. `["a": "ä"]` + var modifiedLetters: [Character: String] var body: some View { Button(action: { @@ -88,22 +101,17 @@ struct FRAccentKeyButton: View { } internal func action() { - var modified = "" - let suffix = self.text.popLast() - switch suffix { - case "a": modified = "à" - case "e": modified = "é" - case "i": modified = "î" - case "u": modified = "û" - case "o": modified = "ô" - case "c": modified = "ç" - default: - modified = "’" - if let suffix = suffix { - self.text.append(suffix) - } + defer { didClick() } + guard let suffix = self.text.popLast() else { + return text.append("’") } + guard var modified = modifiedLetters[Character(suffix.lowercased())] else { + return text.append(String(suffix) + "’") + } + if suffix.isUppercase { + modified = modified.uppercased() + } text.append(modified) } } @@ -136,13 +144,14 @@ struct SpaceKeyButton: View, ClickableKey { } } -struct DeleteKeyButton: View { +struct DeleteKeyButton: View, ClickableKey { @Binding var text: String var body: some View { Button(action: { guard !self.text.isEmpty else { return } _ = self.text.removeLast() + didClick() }) { if #available(iOS 15, macOS 12, *) { AnyView(Image(systemName: "delete.left").dynamicTypeSize(.large)) @@ -165,7 +174,7 @@ struct DeleteKeyButton: View { } } -struct ActionKeyButton: View { +struct ActionKeyButton: View, ClickableKey { @State var icon: Icon var action: () -> Void @@ -178,7 +187,7 @@ struct ActionKeyButton: View { } var body: some View { - Button(action: self.action) { + Button(action: { self.action(); didClick() }) { iconView .padding() .frame(minWidth: 100, maxWidth: .infinity) @@ -200,7 +209,7 @@ public enum Icon { case .search: if #available(iOS 14, macOS 11, *) { return AnyView(Image(systemName: "magnifyingglass")) - }else { + } else { return AnyView(Text("Search", bundle: .module)) } case .go: return AnyView(Text("Go!", bundle: .module)) diff --git a/Sources/SimpleKeyboard/Views/SimpleKeyboard.swift b/Sources/SimpleKeyboard/Views/SimpleKeyboard.swift index a0e1f27..90175b8 100644 --- a/Sources/SimpleKeyboard/Views/SimpleKeyboard.swift +++ b/Sources/SimpleKeyboard/Views/SimpleKeyboard.swift @@ -40,7 +40,7 @@ public struct SimpleKeyboard: View, ThemeableView { } } HStack { - if let actionButton = actionButton { + if let actionButton { ActionKeyButton(icon: actionButton) { self.action?() } @@ -52,7 +52,7 @@ public struct SimpleKeyboard: View, ThemeableView { public var body: some View { if isShown { - content.modifier(OuterKeyboardThemingModifier(theme: theme, backroundColor: keyboardBackground)) + content.modifier(OuterKeyboardThemingModifier(theme: theme)) } } } diff --git a/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift b/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift index 99d67d3..0145271 100644 --- a/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift +++ b/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift @@ -9,6 +9,15 @@ import SwiftUI public struct SimpleStandardKeyboard: View, ThemeableView { var theme: KeyboardTheme { settings.theme } + + @ViewBuilder + var bgColor: some View { + if #available(iOS 15.0, macOS 12.0, *) { + Rectangle().fill(.clear).background(.ultraThinMaterial) + } else { + Color.clear + } + } @ObservedObject var settings: KeyboardSettings @@ -63,10 +72,6 @@ public struct SimpleStandardKeyboard: View, ThemeableView { Spacer(minLength: 2) .frame(maxWidth: 15) .layoutPriority(2) - if settings.language == .french { - FRAccentKeyButton(text: $settings.text) - Spacer() - } DeleteKeyButton(text: self.$settings.text) } } else if idx == 1 { @@ -82,7 +87,7 @@ public struct SimpleStandardKeyboard: View, ThemeableView { let rows = self.settings.language.rows(areUppercased: settings.isUpperCase ?? false)[index] return ForEach(rows, id: \.self) { key in Spacer(minLength: settings.language.spacing) - KeyButton(text: self.$settings.text, letter: key) + KeyButton(text: self.$settings.text, letter: key, alternateLetter: settings.language.alternateKeys[key]) Spacer(minLength: settings.language.spacing) } } @@ -98,7 +103,7 @@ public struct SimpleStandardKeyboard: View, ThemeableView { spaceRow } .transition(.move(edge: .bottom).combined(with: .opacity)) - .modifier(OuterKeyboardThemingModifier(theme: theme, backroundColor: keyboardBackground)) + .modifier(OuterKeyboardThemingModifier(theme: theme)) } } } @@ -120,9 +125,9 @@ struct SimpleStandardKeyboard_Previews: PreviewProvider { isUpperCase: true)) SimpleStandardKeyboard( settings: KeyboardSettings( - language: .english, + language: .latinWithAccents, textInput: nil, - theme: .system, + theme: .clear, actionButton: .search, showNumbers: true, showSpace: false, diff --git a/Sources/SimpleKeyboard/l10n/da.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/da.lproj/Localizable.strings new file mode 100644 index 0000000..07d16db --- /dev/null +++ b/Sources/SimpleKeyboard/l10n/da.lproj/Localizable.strings @@ -0,0 +1,12 @@ +"space" = "mellemrum"; + +"Up" = "St"; + +"lw" = "sm"; + +"Done!" = "Udført!"; + +"Search" = "Søg"; + +"Go!" = "Gå!"; + diff --git a/Sources/SimpleKeyboard/l10n/de.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/de.lproj/Localizable.strings index 7b2fb6b..7446de8 100644 --- a/Sources/SimpleKeyboard/l10n/de.lproj/Localizable.strings +++ b/Sources/SimpleKeyboard/l10n/de.lproj/Localizable.strings @@ -4,15 +4,15 @@ /* (No Comment) */ "Go!" = "Los!"; -/* lower case */ +/* lowercase abbreviation for button */ "lw" = "kl"; /* (No Comment) */ "Search" = "Suchen"; -/* (No Comment) */ +/* spacebar */ "space" = "Leertaste"; -/* Upper Case */ +/* Uppercase abbreviation for button */ "Up" = "Gr"; diff --git a/Sources/SimpleKeyboard/l10n/en.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/en.lproj/Localizable.strings index 35497c4..7611767 100644 --- a/Sources/SimpleKeyboard/l10n/en.lproj/Localizable.strings +++ b/Sources/SimpleKeyboard/l10n/en.lproj/Localizable.strings @@ -1,7 +1,10 @@ +/* spacebar */ "space" = "space"; +/* Uppercase abbreviation for button */ "Up" = "Up"; +/* lowercase abbreviation for button */ "lw" = "lw"; "Done!" = "Done!"; diff --git a/Sources/SimpleKeyboard/l10n/es.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/es.lproj/Localizable.strings index d9ea0be..844126e 100644 --- a/Sources/SimpleKeyboard/l10n/es.lproj/Localizable.strings +++ b/Sources/SimpleKeyboard/l10n/es.lproj/Localizable.strings @@ -1,18 +1,24 @@ +/* No comment provided by engineer. */ +"´" = "´"; + +/* No comment provided by engineer. */ +"⌫" = "⌫"; + /* (No Comment) */ "Done!" = "¡Hecho!"; /* (No Comment) */ "Go!" = "ir"; -/* lower case */ +/* lowercase abbreviation for button */ "lw" = "mi"; /* (No Comment) */ "Search" = "buscar"; -/* (No Comment) */ +/* spacebar */ "space" = "espacio"; -/* Upper Case */ +/* Uppercase abbreviation for button */ "Up" = "Ma"; diff --git a/Sources/SimpleKeyboard/l10n/fi.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/fi.lproj/Localizable.strings new file mode 100644 index 0000000..9040dbe --- /dev/null +++ b/Sources/SimpleKeyboard/l10n/fi.lproj/Localizable.strings @@ -0,0 +1,11 @@ +"space" = "Väli"; + +"Up" = "Ylös"; + +"lw" = "lk"; + +"Done!" = "Valmis!"; + +"Search" = "Etsi"; + +"Go!" = "Mene!"; diff --git a/Sources/SimpleKeyboard/l10n/fr.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/fr.lproj/Localizable.strings index 24ae804..44fa38f 100644 --- a/Sources/SimpleKeyboard/l10n/fr.lproj/Localizable.strings +++ b/Sources/SimpleKeyboard/l10n/fr.lproj/Localizable.strings @@ -1,11 +1,24 @@ -"space" = "espace"; +/* No comment provided by engineer. */ +"´" = "´"; + +/* No comment provided by engineer. */ +"⌫" = "⌫"; + +/* (No Comment) */ +"Done!" = "Terminé !"; -"Up" = "Ma"; +/* (No Comment) */ +"Go!" = "Allons-y !"; -"lw" = "mi"; +/* lowercase abbreviation for button */ +"lw" = "min"; -"Done!" = "Fait!"; +/* (No Comment) */ +"Search" = "Rechercher"; + +/* spacebar */ +"space" = "espace"; -"Search" = "Recherche"; +/* Uppercase abbreviation for button */ +"Up" = "Haut"; -"Go!" = "Allez!"; diff --git a/Sources/SimpleKeyboard/l10n/hi.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/hi.lproj/Localizable.strings index 29aef02..1792e07 100644 --- a/Sources/SimpleKeyboard/l10n/hi.lproj/Localizable.strings +++ b/Sources/SimpleKeyboard/l10n/hi.lproj/Localizable.strings @@ -1,11 +1,24 @@ -"space" = "अंतरिक्ष बार"; +/* No comment provided by engineer. */ +"´" = "´"; -"Up" = "Up"; +/* No comment provided by engineer. */ +"⌫" = "⌫"; -"lw" = "lw"; +/* (No Comment) */ +"Done!" = "हो गया!"; -"Done!" = "किया हुआ!"; +/* (No Comment) */ +"Go!" = "जाओ!"; + +/* lowercase abbreviation for button */ +"lw" = "लो"; +/* (No Comment) */ "Search" = "खोज"; -"Go!" = "जाओ!"; +/* spacebar */ +"space" = "अंतरिक्ष"; + +/* Uppercase abbreviation for button */ +"Up" = "ऊपर"; + diff --git a/Sources/SimpleKeyboard/l10n/ko.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/ko.lproj/Localizable.strings new file mode 100644 index 0000000..ac00cfd --- /dev/null +++ b/Sources/SimpleKeyboard/l10n/ko.lproj/Localizable.strings @@ -0,0 +1,24 @@ +/* No comment provided by engineer. */ +"´" = "´"; + +/* No comment provided by engineer. */ +"⌫" = "⌫"; + +/* (No Comment) */ +"Done!" = "완료!"; + +/* (No Comment) */ +"Go!" = "진행!"; + +/* lowercase abbreviation for button */ +"lw" = "lw"; + +/* (No Comment) */ +"Search" = "검색"; + +/* spacebar */ +"space" = "공백"; + +/* Uppercase abbreviation for button */ +"Up" = "위"; + diff --git a/Sources/SimpleKeyboard/l10n/nl.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/nl.lproj/Localizable.strings new file mode 100644 index 0000000..6f402a8 --- /dev/null +++ b/Sources/SimpleKeyboard/l10n/nl.lproj/Localizable.strings @@ -0,0 +1,24 @@ +/* No comment provided by engineer. */ +"´" = "´"; + +/* No comment provided by engineer. */ +"⌫" = "⌫"; + +/* (No Comment) */ +"Done!" = "Klaar!"; + +/* (No Comment) */ +"Go!" = "Ga!"; + +/* lowercase abbreviation for button */ +"lw" = "lw"; + +/* (No Comment) */ +"Search" = "Zoeken"; + +/* spacebar */ +"space" = "spatie"; + +/* Uppercase abbreviation for button */ +"Up" = "Bov"; + diff --git a/Sources/SimpleKeyboard/l10n/no.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/no.lproj/Localizable.strings new file mode 100644 index 0000000..83b9e2a --- /dev/null +++ b/Sources/SimpleKeyboard/l10n/no.lproj/Localizable.strings @@ -0,0 +1,11 @@ +"space" = "Mellomrom"; + +"Up" = "Opp"; + +"lw" = "lw"; + +"Done!" = "Ferdig!"; + +"Search" = "Søk"; + +"Go!" = "Gå!"; diff --git a/Sources/SimpleKeyboard/l10n/ru.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/ru.lproj/Localizable.strings index 8fe946a..6073dd7 100644 --- a/Sources/SimpleKeyboard/l10n/ru.lproj/Localizable.strings +++ b/Sources/SimpleKeyboard/l10n/ru.lproj/Localizable.strings @@ -1,11 +1,24 @@ -"space" = "Лертасте"; +/* No comment provided by engineer. */ +"´" = "´"; -"Up" = "Ве"; - -"lw" = "ни"; +/* No comment provided by engineer. */ +"⌫" = "⌫"; +/* (No Comment) */ "Done!" = "Готово!"; +/* (No Comment) */ +"Go!" = "Вперед!"; + +/* lowercase abbreviation for button */ +"lw" = "Лw"; + +/* (No Comment) */ "Search" = "Поиск"; -"Go!" = "Вперед!"; +/* spacebar */ +"space" = "пробел"; + +/* Uppercase abbreviation for button */ +"Up" = "Уп"; + diff --git a/Sources/SimpleKeyboard/l10n/sv.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/sv.lproj/Localizable.strings new file mode 100644 index 0000000..c7cac71 --- /dev/null +++ b/Sources/SimpleKeyboard/l10n/sv.lproj/Localizable.strings @@ -0,0 +1,11 @@ +"space" = "Mellanslag"; + +"Up" = "Upp"; + +"lw" = "lk"; + +"Done!" = "Klart!"; + +"Search" = "Sök"; + +"Go!" = "Gå!"; diff --git a/Tests/SimpleKeyboardTests/SimpleKeyboardTests.swift b/Tests/SimpleKeyboardTests/SimpleKeyboardTests.swift index 31d22c4..685e8ca 100644 --- a/Tests/SimpleKeyboardTests/SimpleKeyboardTests.swift +++ b/Tests/SimpleKeyboardTests/SimpleKeyboardTests.swift @@ -163,17 +163,21 @@ final class SimpleKeyboardTests: XCTestCase { XCTAssertNotNil(SimpleStandardKeyboard_Previews.previews) } - func test_french_accent_key() { - let frButton = FRAccentKeyButton(text: $tester.text) - XCTAssertNotNil(frButton) - - for char in "aeiouc" { - tester.text.append(char) - frButton.action() - let modChar = String(tester.text.suffix(1)) - print(modChar) - XCTAssertNotEqual(modChar, String(char)) - } + func test_accent_key() { + let accButton = AccentKeyButton(text: $tester.text, modifiedLetters: ["a": "à"]) + XCTAssertNotNil(accButton) + + tester.text.append("a") + accButton.action() + let modChar = String(tester.text.suffix(1)) + print(modChar) + XCTAssertEqual(modChar, String("à")) + + tester.text.append("A") + accButton.action() + let modChar2 = String(tester.text.suffix(1)) + print(modChar2) + XCTAssertEqual(modChar2, String("À")) } func test_corner_radius() { @@ -189,10 +193,12 @@ final class SimpleKeyboardTests: XCTestCase { } func test_theming_modifier() { - let mod = OuterKeyboardThemingModifier(theme: .floating, backroundColor: Color.black) - let mod2 = OuterKeyboardThemingModifier(theme: .system, backroundColor: Color.black) + let mod = OuterKeyboardThemingModifier(theme: .floating) + let mod2 = OuterKeyboardThemingModifier(theme: .system) + let mod3 = OuterKeyboardThemingModifier(theme: .clear) XCTAssertNotNil(EmptyView().modifier(mod)) XCTAssertNotNil(EmptyView().modifier(mod2)) + XCTAssertNotNil(EmptyView().modifier(mod3)) } static var allTests = [ @@ -207,7 +213,7 @@ final class SimpleKeyboardTests: XCTestCase { ("standard_keyboard_action_works", test_standard_keyboard_action_works), ("standard_keyboard_works", test_simple_keyboard_works), ("test_keyboard_preview", test_keyboard_preview), - ("test_french_accent_key", test_french_accent_key), + ("test_accent_key", test_accent_key), ("test_corner_radius", test_corner_radius), ("test_theming_modifier", test_theming_modifier) ]