Skip to content

Commit

Permalink
[scribe-org#371] Apply PR feedback
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
damien-rivet committed Oct 30, 2023
1 parent 03fa49c commit 77f3b5c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
10 changes: 9 additions & 1 deletion Keyboards/KeyboardsBase/KeyboardKeys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand All @@ -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
}
Expand All @@ -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:
Expand Down
25 changes: 15 additions & 10 deletions Keyboards/KeyboardsBase/ScribeFunctionality/Annotate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 77f3b5c

Please sign in to comment.