Skip to content

Commit

Permalink
#26 style key pop callouts for keys on the sides of the keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtavis committed Feb 23, 2022
1 parent 97fb8ad commit cd5ad21
Show file tree
Hide file tree
Showing 9 changed files with 220 additions and 126 deletions.
37 changes: 28 additions & 9 deletions Keyboards/KeyboardsBase/InterfaceVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ let keyboardLayoutDict: [String: () -> Void] = [
"Swedish": setSVKeyboardLayout
]

/// Sets the keyboard layout and its alternate keys.
func setKeyboard() {
setKeyboardLayout()
setKeyboardAlternateKeys()
}

/// Sets the keyboard layouts given the chosen keyboard and device type.
func setKeyboardLayout() {
if switchInput {
Expand All @@ -115,6 +121,8 @@ func setKeyboardLayout() {
allPrompts = [translatePromptAndCursor, conjugatePromptAndCursor, pluralPromptAndCursor]
}

// MARK: Alternate Key Variables

/// Sets the alternates for certain keys given the chosen keyboard.
func setKeyboardAlternateKeys() {
if DeviceType.isPhone {
Expand Down Expand Up @@ -155,13 +163,6 @@ func setKeyboardAlternateKeys() {
]
}

/// Sets the keyboard layout and its alternate keys.
func setKeyboard() {
setKeyboardLayout()
setKeyboardAlternateKeys()
}

// MARK: Alternate Key Variables
var alternatesKeyView: UIView!
var keyCancelled = false
var keyPopChar = UILabel()
Expand Down Expand Up @@ -218,6 +219,24 @@ var cAlternateKeys = [String]()
var nAlternateKeys = [String]()
var ьAlternateKeys = [String]()

// MARK: Callout Variables

// Variables that define which keys are positioned on the very left, right or in the center of the keyboard.
// The purpose of these is to define which key pop up functions should be ran.
var centralKeyChars: [String] = [String]()
var leftKeyChars: [String] = [String]()
var rightKeyChars: [String] = [String]()

// Variables for call out positioning.
var horizStart = CGFloat(0)
var vertStart = CGFloat(0)
var widthMultiplier = CGFloat(0)
var maxHeightMultiplier = CGFloat(0)
var maxHeight = CGFloat(0)
var heightBeforeTopCurves = CGFloat(0)
var maxHeightCurveControl = CGFloat(0)
var minHeightCurveControl = CGFloat(0)

// MARK: English Interface Variables
// Note: here only until there is an English keyboard.

Expand Down Expand Up @@ -292,7 +311,7 @@ func getENKeys() {

leftKeyChars = ["q", "1", "-", "[", "_"]
rightKeyChars = ["p", "0", "\"", "=", "·"]
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) || !rightKeyChars.contains($0) }
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) }
} else {
letterKeys = EnglishKeyboardConstants.letterKeysPad
numberKeys = EnglishKeyboardConstants.numberKeysPad
Expand All @@ -301,7 +320,7 @@ func getENKeys() {

leftKeyChars = ["q", "1"]
rightKeyChars = []
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) || !rightKeyChars.contains($0) }
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) }
}

keysWithAlternates = EnglishKeyboardConstants.keysWithAlternates
Expand Down
281 changes: 178 additions & 103 deletions Keyboards/KeyboardsBase/KeyAnimation.swift

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Keyboards/LanguageKeyboards/French/FRInterfaceVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func getFRKeys() {

leftKeyChars = ["a", "q", "1", "-", "[", "_"]
rightKeyChars = ["p", "m", "0", "\"", "=", "·"]
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) || !rightKeyChars.contains($0) }
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) }
} else {
letterKeys = FrenchKeyboardConstants.letterKeysPad
numberKeys = FrenchKeyboardConstants.numberKeysPad
Expand All @@ -83,7 +83,7 @@ func getFRKeys() {

leftKeyChars = ["q", "a", "1", "@", "~"]
rightKeyChars = []
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) || !rightKeyChars.contains($0) }
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) }
}

keysWithAlternates = FrenchKeyboardConstants.keysWithAlternates
Expand Down
4 changes: 2 additions & 2 deletions Keyboards/LanguageKeyboards/German/DEInterfaceVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func getDEKeys() {

leftKeyChars = ["q", "a", "1", "-", "[", "_"]
rightKeyChars = ["ü", "ä", "0", "\"", "=", "·"]
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) || !rightKeyChars.contains($0) }
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) }
} else {
letterKeys = GermanKeyboardConstants.letterKeysPad
numberKeys = GermanKeyboardConstants.numberKeysPad
Expand All @@ -86,7 +86,7 @@ func getDEKeys() {

leftKeyChars = ["q", "a", "1", "\"", "$"]
rightKeyChars = []
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) || !rightKeyChars.contains($0) }
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) }
}

keysWithAlternates = GermanKeyboardConstants.keysWithAlternates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func getITKeys() {

leftKeyChars = ["q", "1", "-", "[", "_"]
rightKeyChars = ["p", "0", "\"", "=", "·"]
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) || !rightKeyChars.contains($0) }
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) }
} else {
letterKeys = ItalianKeyboardConstants.letterKeysPad
numberKeys = ItalianKeyboardConstants.numberKeysPad
Expand All @@ -83,7 +83,7 @@ func getITKeys() {

leftKeyChars = ["q", "1"]
rightKeyChars = []
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) || !rightKeyChars.contains($0) }
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) }
}

keysWithAlternates = ItalianKeyboardConstants.keysWithAlternates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func getPTKeys() {

leftKeyChars = ["q", "1", "-", "[", "_"]
rightKeyChars = ["p", "0", "\"", "=", "·"]
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) || !rightKeyChars.contains($0) }
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) }
} else {
letterKeys = PortugueseKeyboardConstants.letterKeysPad
numberKeys = PortugueseKeyboardConstants.numberKeysPad
Expand All @@ -82,7 +82,7 @@ func getPTKeys() {

leftKeyChars = ["q", "1"]
rightKeyChars = []
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) || !rightKeyChars.contains($0) }
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) }
}

keysWithAlternates = PortugueseKeyboardConstants.keysWithAlternates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func getRUKeys() {

leftKeyChars = ["й", "ф", "1", "-", "[", "_"]
rightKeyChars = ["х", "э", "0", "\"", "=", "·"]
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) || !rightKeyChars.contains($0) }
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) }
} else {
letterKeys = RussianKeyboardConstants.letterKeysPad
numberKeys = RussianKeyboardConstants.numberKeysPad
Expand All @@ -77,7 +77,7 @@ func getRUKeys() {

leftKeyChars = ["й", "ф", "1", "@", "$"]
rightKeyChars = []
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) || !rightKeyChars.contains($0) }
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) }
}

keysWithAlternates = RussianKeyboardConstants.keysWithAlternates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func getESKeys() {

leftKeyChars = ["q", "a", "1", "-", "[", "_"]
rightKeyChars = ["p", "ñ", "0", "\"", "=", "·"]
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) || !rightKeyChars.contains($0) }
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) }
} else {
letterKeys = SpanishKeyboardConstants.letterKeysPad
numberKeys = SpanishKeyboardConstants.numberKeysPad
Expand All @@ -84,7 +84,7 @@ func getESKeys() {

leftKeyChars = ["q", "a", "1", "@", ""]
rightKeyChars = []
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) || !rightKeyChars.contains($0) }
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) }
}

keysWithAlternates = SpanishKeyboardConstants.keysWithAlternates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func getSVKeys() {

leftKeyChars = ["q", "a", "1", "-", "[", "_"]
rightKeyChars = ["å", "ä", "0", "\"", "=", "·"]
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) || !rightKeyChars.contains($0) }
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) }
} else {
letterKeys = SwedishKeyboardConstants.letterKeysPad
numberKeys = SwedishKeyboardConstants.numberKeysPad
Expand All @@ -85,7 +85,7 @@ func getSVKeys() {

leftKeyChars = ["q", "a", "1", "@", ""]
rightKeyChars = []
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) || !rightKeyChars.contains($0) }
centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) }
}

keysWithAlternates = SwedishKeyboardConstants.keysWithAlternates
Expand Down

0 comments on commit cd5ad21

Please sign in to comment.