From 77f3b5cdfa6783fdc8e9cdb48e356a998f8e3c4b Mon Sep 17 00:00:00 2001 From: Damien Rivet Date: Mon, 30 Oct 2023 17:48:17 +0100 Subject: [PATCH] [#371] Apply PR feedback Fixed issue with CapsLock state not showing on iPhone. Added a missing period in a description. Fixed an issue with the Return key having the wrong color in some cases. Fixed a crash in Command mode when no input is supplied by the user. --- Keyboards/KeyboardsBase/KeyboardKeys.swift | 10 +++++++- .../ScribeFunctionality/Annotate.swift | 25 +++++++++++-------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Keyboards/KeyboardsBase/KeyboardKeys.swift b/Keyboards/KeyboardsBase/KeyboardKeys.swift index 53013552..d60541c6 100644 --- a/Keyboards/KeyboardsBase/KeyboardKeys.swift +++ b/Keyboards/KeyboardsBase/KeyboardKeys.swift @@ -285,7 +285,7 @@ class KeyboardKey: UIButton { } } - /// Adjusts the style of the button based on different states + /// Adjusts the style of the button based on different states. func adjustButtonStyle() { guard let isSpecial = layer.value(forKey: "isSpecial") as? Bool else { return } @@ -308,7 +308,13 @@ class KeyboardKey: UIButton { case "shift": if shiftButtonState == .shift { backgroundColor = keyPressedColor + styleIconBtn(btn: self, color: UIColor.label, iconName: "shift.fill") + } else if DeviceType.isPhone && capsLockButtonState == .locked { + // We need to style the SHIFT button instead of the CAPSLOCK since the keyboard is smaller + backgroundColor = keyPressedColor + + styleIconBtn(btn: self, color: UIColor.label, iconName: "capslock.fill") } else { backgroundColor = specialKeyColor } @@ -317,6 +323,8 @@ class KeyboardKey: UIButton { if [.translate, .conjugate, .plural].contains(commandState) { // Color the return key depending on if it's being used as enter for commands. backgroundColor = commandKeyColor + } else { + backgroundColor = specialKeyColor } default: diff --git a/Keyboards/KeyboardsBase/ScribeFunctionality/Annotate.swift b/Keyboards/KeyboardsBase/ScribeFunctionality/Annotate.swift index a2c765dd..fa6009c4 100644 --- a/Keyboards/KeyboardsBase/ScribeFunctionality/Annotate.swift +++ b/Keyboards/KeyboardsBase/ScribeFunctionality/Annotate.swift @@ -229,18 +229,23 @@ func selectedWordAnnotation(KVC: KeyboardViewController) { /// - Parameters /// - KVC: the keyboard view controller. func typedWordAnnotation(KVC: KeyboardViewController) { - if proxy.documentContextBeforeInput?.count != 0 { - wordsTyped = proxy.documentContextBeforeInput!.components(separatedBy: " ") - let lastWordTyped = wordsTyped.secondToLast() - if !languagesWithCapitalizedNouns.contains(controllerLanguage) { - wordToCheck = lastWordTyped!.lowercased() - } else { - wordToCheck = lastWordTyped! - } - wordAnnotation(wordToAnnotate: wordToCheck, KVC: KVC) - } else { + guard let documentContextBeforeInput = proxy.documentContextBeforeInput, !documentContextBeforeInput.isEmpty else { + return + } + + wordsTyped = documentContextBeforeInput.components(separatedBy: " ") + + guard let lastWordTyped = wordsTyped.secondToLast() else { return } + + if !languagesWithCapitalizedNouns.contains(controllerLanguage) { + wordToCheck = lastWordTyped.lowercased() + } else { + wordToCheck = lastWordTyped + } + + wordAnnotation(wordToAnnotate: wordToCheck, KVC: KVC) } /// Annotates nouns during autocomplete and autosuggest.