Skip to content

Commit

Permalink
Allow for swiping between conjugation and declension views scribe-org…
Browse files Browse the repository at this point in the history
  • Loading branch information
Taufi authored and SaurabhJamadagni committed Apr 18, 2024
1 parent de075b8 commit 1b7390f
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions Keyboards/KeyboardsBase/KeyboardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,13 @@ class KeyboardViewController: UIInputViewController {

/// Sets up all buttons and labels for the conjugation view given constraints to determine the dimensions.
func setConjugationBtns() {
// add swipe functionality to the conjugation and declension views
let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(shiftLeft))
keyboardView.addGestureRecognizer(swipeRight)
let swipeLeft = UISwipeGestureRecognizer(target: self, action: #selector(shiftRight))
swipeLeft.direction = .left
keyboardView.addGestureRecognizer(swipeLeft)

// Set the conjugation view to 2x2 for Swedish and Russian past tense.
if controllerLanguage == "Swedish" {
formsDisplayDimensions = .view2x2
Expand Down Expand Up @@ -1572,6 +1579,24 @@ class KeyboardViewController: UIInputViewController {
typedWordAnnotation(KVC: self)
}
}

@objc func shiftLeft() {
if commandState == .displayInformation {
tipView?.updatePrevious()
} else {
conjugationStateLeft()
loadKeys()
}
}

@objc func shiftRight() {
if commandState == .displayInformation {
tipView?.updateNext()
} else {
conjugationStateRight()
loadKeys()
}
}

func setKeywidth() {
// keyWidth determined per keyboard by the top row.
Expand Down Expand Up @@ -2256,20 +2281,10 @@ class KeyboardViewController: UIInputViewController {
commandBar.attributedText = pluralPromptAndColorPlaceholder

case "shiftFormsDisplayLeft":
if commandState == .displayInformation {
tipView?.updatePrevious()
} else {
conjugationStateLeft()
loadKeys()
}
shiftLeft()

case "shiftFormsDisplayRight":
if commandState == .displayInformation {
tipView?.updateNext()
} else {
conjugationStateRight()
loadKeys()
}
shiftRight()

case "firstPersonSingular":
returnConjugation(keyPressed: sender, requestedForm: formFPS)
Expand Down

0 comments on commit 1b7390f

Please sign in to comment.