Skip to content

Commit ea54272

Browse files
committed
#197 #218 fixes and updates to German case annotation
1 parent 7b14543 commit ea54272

File tree

6 files changed

+399
-74
lines changed

6 files changed

+399
-74
lines changed

Keyboards/KeyboardsBase/KeyboardViewController.swift

+28-23
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,11 @@ class KeyboardViewController: UIInputViewController {
581581
conjugateAlternateView = true
582582
} else if controllerLanguage == "Russian" && ruConjugationState == .past {
583583
conjugateAlternateView = true
584+
} else if
585+
commandState == .selectCaseConjugation
586+
&& controllerLanguage == "German"
587+
&& [.accusative, .dative, .genitive].contains(deCaseConjugationState) {
588+
conjugateAlternateView = true
584589
} else {
585590
conjugateAlternateView = false
586591
}
@@ -629,22 +634,22 @@ class KeyboardViewController: UIInputViewController {
629634
activateBtn(btn: conjugateShiftRight)
630635

631636
if conjugateAlternateView == false {
632-
for elem in get3x2ConjButtons() {
633-
activateBtn(btn: elem)
637+
for btn in get3x2ConjButtons() {
638+
activateBtn(btn: btn)
634639
}
635640

636-
for elem in get2x2ConjButtons() {
637-
deactivateBtn(btn: elem)
641+
for btn in get2x2ConjButtons() {
642+
deactivateBtn(btn: btn)
638643
}
639644
}
640645

641646
if conjugateAlternateView == true {
642-
for elem in get3x2ConjButtons() {
643-
deactivateBtn(btn: elem)
647+
for btn in get3x2ConjButtons() {
648+
deactivateBtn(btn: btn)
644649
}
645650

646-
for elem in get2x2ConjButtons() {
647-
activateBtn(btn: elem)
651+
for btn in get2x2ConjButtons() {
652+
activateBtn(btn: btn)
648653
}
649654
}
650655
}
@@ -732,7 +737,7 @@ class KeyboardViewController: UIInputViewController {
732737
svSetConjugationLabels()
733738
}
734739

735-
// Assign labels that have been set by SetConjugationLabels functions.
740+
// Assign labels that have been set by SetConjugationLabels function.
736741
conjugateLblFPS.setTitle(" " + labelFPS, for: .normal)
737742
conjugateLblSPS.setTitle(" " + labelSPS, for: .normal)
738743
conjugateLblTPS.setTitle(" " + labelTPS, for: .normal)
@@ -772,7 +777,7 @@ class KeyboardViewController: UIInputViewController {
772777
func setCaseConjugationState() {
773778
// Set the view title and its labels.
774779
var conjugationTitleFxn: () -> String = deGetCaseConjugationTitle
775-
var conjugationLabelsFxn: () -> Void = deSetConjugationLabels
780+
var conjugationLabelsFxn: () -> Void = deSetCaseConjugationLabels
776781
var conjugationsFxn: () -> Void = deSetCaseConjugations
777782

778783
if controllerLanguage == "Russian" {
@@ -785,16 +790,26 @@ class KeyboardViewController: UIInputViewController {
785790
conjugationLabelsFxn()
786791
conjugationsFxn()
787792

788-
// Assign labels that have been set by SetConjugationLabels functions.
793+
// Assign labels that have been set by SetCaseConjugationLabels function.
789794
conjugateLblFPS.setTitle(" " + labelFPS, for: .normal)
790795
conjugateLblSPS.setTitle(" " + labelSPS, for: .normal)
791796
conjugateLblTPS.setTitle(" " + labelTPS, for: .normal)
792797
conjugateLblFPP.setTitle(" " + labelFPP, for: .normal)
793798
conjugateLblSPP.setTitle(" " + labelSPP, for: .normal)
794799
conjugateLblTPP.setTitle(" " + labelTPP, for: .normal)
795800

796-
allConjugations = [conjFPS, conjSPS, conjTPS, conjFPP, conjSPP, conjTPP]
797-
allConjugationBtns = get3x2ConjButtons()
801+
conjugateLblTL.setTitle(" " + labelTopLeft, for: .normal)
802+
conjugateLblTR.setTitle(" " + labelTopRight, for: .normal)
803+
conjugateLblBL.setTitle(" " + labelBottomLeft, for: .normal)
804+
conjugateLblBR.setTitle(" " + labelBottomRight, for: .normal)
805+
806+
if controllerLanguage == "German" && ![.accusative, .dative, .genitive].contains(deCaseConjugationState) {
807+
allConjugations = [conjFPS, conjSPS, conjTPS, conjFPP, conjSPP, conjTPP]
808+
allConjugationBtns = get3x2ConjButtons()
809+
} else {
810+
allConjugations = [conjTopLeft, conjTopRight, conjBottomLeft, conjBottomRight]
811+
allConjugationBtns = get2x2ConjButtons()
812+
}
798813

799814
// Populate conjugation view buttons.
800815
for index in 0..<allConjugations.count {
@@ -1377,52 +1392,42 @@ class KeyboardViewController: UIInputViewController {
13771392

13781393
case "firstPersonSingular":
13791394
returnConjugation(keyPressed: sender, requestedTense: conjFPS)
1380-
autoActionState = .suggest
13811395
loadKeys()
13821396

13831397
case "secondPersonSingular":
13841398
returnConjugation(keyPressed: sender, requestedTense: conjSPS)
1385-
autoActionState = .suggest
13861399
loadKeys()
13871400

13881401
case "thirdPersonSingular":
13891402
returnConjugation(keyPressed: sender, requestedTense: conjTPS)
1390-
autoActionState = .suggest
13911403
loadKeys()
13921404

13931405
case "firstPersonPlural":
13941406
returnConjugation(keyPressed: sender, requestedTense: conjFPP)
1395-
autoActionState = .suggest
13961407
loadKeys()
13971408

13981409
case "secondPersonPlural":
13991410
returnConjugation(keyPressed: sender, requestedTense: conjSPP)
1400-
autoActionState = .suggest
14011411
loadKeys()
14021412

14031413
case "thirdPersonPlural":
14041414
returnConjugation(keyPressed: sender, requestedTense: conjTPP)
1405-
autoActionState = .suggest
14061415
loadKeys()
14071416

14081417
case "conjugateTopLeft":
14091418
returnConjugation(keyPressed: sender, requestedTense: conjTopLeft)
1410-
autoActionState = .suggest
14111419
loadKeys()
14121420

14131421
case "conjugateTopRight":
14141422
returnConjugation(keyPressed: sender, requestedTense: conjTopRight)
1415-
autoActionState = .suggest
14161423
loadKeys()
14171424

14181425
case "conjugateBottomLeft":
14191426
returnConjugation(keyPressed: sender, requestedTense: conjBottomLeft)
1420-
autoActionState = .suggest
14211427
loadKeys()
14221428

14231429
case "conjugateBottomRight":
14241430
returnConjugation(keyPressed: sender, requestedTense: conjBottomRight)
1425-
autoActionState = .suggest
14261431
loadKeys()
14271432

14281433
case "AutoAction1":

Keyboards/KeyboardsBase/ScribeFunctionality/Annotate.swift

+3-5
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ func selectedWordAnnotation(_ KVC: KeyboardViewController) {
3232
wordToCheck = proxy.selectedText ?? ""
3333
if !languagesWithCapitalizedNouns.contains(controllerLanguage) {
3434
wordToCheck = wordToCheck.lowercased()
35-
} else {
36-
wordToCheck = wordToCheck.capitalize()
3735
}
3836

3937
isNoun = nouns?[wordToCheck] != nil
@@ -88,7 +86,7 @@ func selectedWordAnnotation(_ KVC: KeyboardViewController) {
8886
}
8987

9088
if isPrep {
91-
let prepAnnotationForm: String = prepositions?[wordToCheck.lowercased()] as! String
89+
prepAnnotationForm = prepositions?[wordToCheck.lowercased()] as! String
9290
if prepAnnotationForm != "" {
9391
if !prepAnnotationForm.contains("/") {
9492
annotationsToAssign.append(prepAnnotationForm)
@@ -195,7 +193,7 @@ func typedWordAnnotation(_ KVC: KeyboardViewController) {
195193
if !languagesWithCapitalizedNouns.contains(controllerLanguage) {
196194
wordToCheck = lastWordTyped!.lowercased()
197195
} else {
198-
wordToCheck = lastWordTyped!.capitalize()
196+
wordToCheck = lastWordTyped!
199197
}
200198

201199
isNoun = nouns?[wordToCheck] != nil
@@ -250,7 +248,7 @@ func typedWordAnnotation(_ KVC: KeyboardViewController) {
250248
}
251249

252250
if isPrep {
253-
let prepAnnotationForm: String = prepositions?[wordToCheck.lowercased()] as! String
251+
prepAnnotationForm = prepositions?[wordToCheck.lowercased()] as! String
254252
if prepAnnotationForm != "" {
255253
if !prepAnnotationForm.contains("/") {
256254
annotationsToAssign.append(prepAnnotationForm)

Keyboards/KeyboardsBase/ScribeFunctionality/CommandVariables.swift

+17
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,23 @@ var labelFPP: String = ""
9595
var labelSPP: String = ""
9696
var labelTPP: String = ""
9797

98+
var conjSingle: String = ""
99+
var labelSingle: String = ""
100+
101+
var conjTop: String = ""
102+
var conjMiddle: String = ""
103+
var conjBottom: String = ""
104+
105+
var labelTop: String = ""
106+
var labelMiddle: String = ""
107+
var labelBottom: String = ""
108+
109+
var conjLeft: String = ""
110+
var conjRight: String = ""
111+
112+
var labelLeft: String = ""
113+
var labelRight: String = ""
114+
98115
var conjTopLeft: String = ""
99116
var conjTopRight: String = ""
100117
var conjBottomLeft: String = ""

Keyboards/KeyboardsBase/ScribeFunctionality/Conjugate.swift

+11-5
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,19 @@ func returnConjugation(keyPressed: UIButton, requestedTense: String) {
8383
proxy.insertText(verbs?[verbToConjugate]!["pastParticiple"] as! String + " ")
8484
}
8585
} else if conjugateAlternateView == true {
86-
wordToReturn = verbs?[verbToConjugate]![requestedTense] as! String
87-
if inputWordIsCapitalized == true {
88-
proxy.insertText(wordToReturn.capitalized + " ")
89-
} else {
86+
if commandState == .selectCaseConjugation {
87+
wordToReturn = keyPressed.titleLabel?.text ?? ""
9088
proxy.insertText(wordToReturn + " ")
89+
} else {
90+
wordToReturn = verbs?[verbToConjugate]![requestedTense] as! String
91+
if inputWordIsCapitalized == true {
92+
proxy.insertText(wordToReturn.capitalized + " ")
93+
} else {
94+
proxy.insertText(wordToReturn + " ")
95+
}
9196
}
9297
}
98+
autoActionState = .suggest
9399
commandState = .idle
94100
}
95101

@@ -121,7 +127,7 @@ func resetCaseConjugationState() {
121127
} else if prepAnnotationForm.contains("Dat") {
122128
deCaseConjugationState = .dative
123129
} else {
124-
deCaseConjugationState = .genitivePossesive
130+
deCaseConjugationState = .genitive
125131
}
126132
} else if controllerLanguage == "Russian" {
127133
if prepAnnotationForm.contains("Acc") {

0 commit comments

Comments
 (0)