From 53db0429259fd01c5902e508cb738f3709b5e2de Mon Sep 17 00:00:00 2001 From: henrikth93 Date: Fri, 22 Dec 2023 16:29:19 +0100 Subject: [PATCH 1/2] Made separate functions for key width and key padding, and adjusted the layout of the expanded keyboard. Issue #362 --- .../KeyboardsBase/InterfaceVariables.swift | 6 +- Keyboards/KeyboardsBase/KeyboardKeys.swift | 71 ++- .../KeyboardViewController.swift | 533 +++++++++--------- 3 files changed, 339 insertions(+), 271 deletions(-) diff --git a/Keyboards/KeyboardsBase/InterfaceVariables.swift b/Keyboards/KeyboardsBase/InterfaceVariables.swift index f2e0f38a..5d441f34 100644 --- a/Keyboards/KeyboardsBase/InterfaceVariables.swift +++ b/Keyboards/KeyboardsBase/InterfaceVariables.swift @@ -26,7 +26,7 @@ var keyWidth = CGFloat(0) var letterKeyWidth = CGFloat(0) var numSymKeyWidth = CGFloat(0) var isFirstKeyboardLoad = false - +var disableAccentCharacters = false; // Constants for scaling key widths and heights. let scalarAlternatesBtnYPad = 0.2 let scalarAlternatesBtnYPhone = 0.15 @@ -46,6 +46,10 @@ let scalarFontPhone = 0.435 let scalarLetterNumSymKeyWidth = 0.9 let scalarLetterNumSymKeyWidthLandscapeViewPad = 1.2 let scalarLetterNumSymKeyWidthLandscapeViewPhone = 1.5 +var scalarSpecialKeysWidth = disableAccentCharacters ? 2.2 : 1.0 +let scalarIndentKeyWidth = 1.7 +let scalarShiftKeyWidth = 1.4 +var scalarReturnKeyWidth = disableAccentCharacters ? 2.2 : 1.0 // Keyboard elements. var spaceBar = String() diff --git a/Keyboards/KeyboardsBase/KeyboardKeys.swift b/Keyboards/KeyboardsBase/KeyboardKeys.swift index ddbb6f3e..07f95ffd 100644 --- a/Keyboards/KeyboardsBase/KeyboardKeys.swift +++ b/Keyboards/KeyboardsBase/KeyboardKeys.swift @@ -253,28 +253,69 @@ class KeyboardKey: UIButton { /// Adjusts the width of a key if it's one of the special characters on the iPad keyboard. func adjustPadKeyWidth() { - if key == "ABC" || key == "АБВ" { - layer.setValue(true, forKey: "isSpecial") - widthAnchor.constraint(equalToConstant: numSymKeyWidth * 1).isActive = true - } else if ["delete", "#+=", "shift", "selectKeyboard", SpecialKeys.indent, SpecialKeys.capsLock].contains(key) { + if (usingExpandedKeyboard) + { + scalarSpecialKeysWidth = (disableAccentCharacters && keyboardState != .symbols) ? 2.2 : 1.0 + scalarReturnKeyWidth = (disableAccentCharacters && keyboardState != .symbols) ? 2.2 : 1.0 + if key == "ABC" || key == "АБВ" { + layer.setValue(true, forKey: "isSpecial") + widthAnchor.constraint(equalToConstant: numSymKeyWidth * 1).isActive = true + } else if ["delete", "#+=", "selectKeyboard", SpecialKeys.capsLock].contains(key) { + layer.setValue(true, forKey: "isSpecial") + widthAnchor.constraint(equalToConstant: numSymKeyWidth * scalarSpecialKeysWidth).isActive = true //*2 scalarSpecialKeysWidth = 1 + } else if [SpecialKeys.indent].contains(key) { + layer.setValue(true, forKey: "isSpecial") + widthAnchor.constraint(equalToConstant: numSymKeyWidth * scalarIndentKeyWidth).isActive = true // scalarIndentKeyWidth + } else if ["shift"].contains(key) { + layer.setValue(true, forKey: "isSpecial") + widthAnchor.constraint(equalToConstant: numSymKeyWidth * scalarShiftKeyWidth).isActive = true // scalarShiftKeyWidth + } else if ["return"].contains(key) { layer.setValue(true, forKey: "isSpecial") - widthAnchor.constraint(equalToConstant: numSymKeyWidth * 1).isActive = true - } else if ["123", ".?123", "return", "hideKeyboard"].contains(key) { - if key == "return" - && (controllerLanguage == "Portuguese" || controllerLanguage == "Italian" || commandState == .translate) - && row == 1 - && DeviceType.isPad - { + widthAnchor.constraint(equalToConstant: numSymKeyWidth * scalarReturnKeyWidth).isActive = true // scalarReturnKeyWidth + } + else if ["123", ".?123", "return", "hideKeyboard"].contains(key) { + if key == "return" + && (controllerLanguage == "Portuguese" || controllerLanguage == "Italian" || commandState == .translate) + && row == 1 + && DeviceType.isPad + { + layer.setValue(true, forKey: "isSpecial") + widthAnchor.constraint(equalToConstant: numSymKeyWidth * 1.5).isActive = true + } else { + layer.setValue(true, forKey: "isSpecial") + widthAnchor.constraint(equalToConstant: numSymKeyWidth * 1).isActive = true + } + } else if key != spaceBar && key != languageTextForSpaceBar { + widthAnchor.constraint(equalToConstant: keyWidth).isActive = true + } + } + else + { + if key == "ABC" || key == "АБВ" { layer.setValue(true, forKey: "isSpecial") - widthAnchor.constraint(equalToConstant: numSymKeyWidth * 1.5).isActive = true - } else { + widthAnchor.constraint(equalToConstant: numSymKeyWidth * 1).isActive = true + } else if ["delete", "#+=", "shift", "selectKeyboard", SpecialKeys.indent, SpecialKeys.capsLock].contains(key) { layer.setValue(true, forKey: "isSpecial") widthAnchor.constraint(equalToConstant: numSymKeyWidth * 1).isActive = true + } else if ["123", ".?123", "return", "hideKeyboard"].contains(key) { + if key == "return" + && (controllerLanguage == "Portuguese" || controllerLanguage == "Italian" || commandState == .translate) + && row == 1 + && DeviceType.isPad + { + layer.setValue(true, forKey: "isSpecial") + widthAnchor.constraint(equalToConstant: numSymKeyWidth * 1.5).isActive = true + } else { + layer.setValue(true, forKey: "isSpecial") + widthAnchor.constraint(equalToConstant: numSymKeyWidth * 1).isActive = true + } + } else if key != spaceBar && key != languageTextForSpaceBar { + widthAnchor.constraint(equalToConstant: keyWidth).isActive = true } - } else if key != spaceBar && key != languageTextForSpaceBar { - widthAnchor.constraint(equalToConstant: keyWidth).isActive = true } } + + /// Adjusts the width of a key if it's one of the special characters on the keyboard. func adjustKeyWidth() { diff --git a/Keyboards/KeyboardsBase/KeyboardViewController.swift b/Keyboards/KeyboardsBase/KeyboardViewController.swift index faa83caf..146378f5 100644 --- a/Keyboards/KeyboardsBase/KeyboardViewController.swift +++ b/Keyboards/KeyboardsBase/KeyboardViewController.swift @@ -31,7 +31,7 @@ class KeyboardViewController: UIInputViewController { } else if DeviceType.isPad { // Update the size of the numbers row to add it to the view. if usingExpandedKeyboard { - let numbersRowHeight = scribeKey.frame.height + let numbersRowHeight = scribeKey.frame.height * 1.8 view.addConstraint( NSLayoutConstraint( item: stackViewNum!, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .height, multiplier: 1, constant: numbersRowHeight @@ -1541,13 +1541,285 @@ class KeyboardViewController: UIInputViewController { } } + + func setKeywidth() { + // keyWidth determined per keyboard by the top row. + if isLandscapeView { + if DeviceType.isPhone { + letterKeyWidth = (UIScreen.main.bounds.height - 5) / CGFloat(letterKeys[0].count) * scalarLetterNumSymKeyWidthLandscapeViewPhone + numSymKeyWidth = (UIScreen.main.bounds.height - 5) / CGFloat(numberKeys[0].count) * scalarLetterNumSymKeyWidthLandscapeViewPhone + } else if DeviceType.isPad { + letterKeyWidth = (UIScreen.main.bounds.height - 5) / CGFloat(letterKeys[0].count) * scalarLetterNumSymKeyWidthLandscapeViewPad + if (!usingExpandedKeyboard) { + numSymKeyWidth = (UIScreen.main.bounds.height - 5) / CGFloat(numberKeys[0].count) * scalarLetterNumSymKeyWidthLandscapeViewPad + } + } + } else { + letterKeyWidth = (UIScreen.main.bounds.width - 6) / CGFloat(letterKeys[0].count) * scalarLetterNumSymKeyWidth + numSymKeyWidth = (UIScreen.main.bounds.width - 6) / CGFloat(symbolKeys[0].count) * scalarLetterNumSymKeyWidth + } + } + + func setKeyPadding() { + let numRows = keyboard.count + for row in 0 ..< numRows { + for idx in 0 ..< keyboard[row].count { + // Set up button as a key with its values and properties. + let btn = KeyboardKey(type: .custom) + btn.row = row + btn.idx = idx + btn.style() + btn.setChar() + btn.setCharSize() + + let key: String = btn.key + + // Pad before key is added. + var leftPadding = CGFloat(0) + if DeviceType.isPhone + && key == "y" + && ["German", "Swedish"].contains(controllerLanguage) + && commandState != .translate + { + leftPadding = keyWidth / 3 + addPadding(to: stackView2, width: leftPadding, key: "y") + } + if DeviceType.isPhone + && key == "a" + && (controllerLanguage == "Portuguese" + || controllerLanguage == "Italian" + || commandState == .translate) + { + leftPadding = keyWidth / 4 + addPadding(to: stackView1, width: leftPadding, key: "a") + } + if DeviceType.isPad + && key == "a" + && (controllerLanguage == "Portuguese" + || controllerLanguage == "Italian" + || commandState == .translate) + { + leftPadding = keyWidth / 3 + addPadding(to: stackView1, width: leftPadding, key: "a") + } + if DeviceType.isPad + && key == "@" + && (controllerLanguage == "Portuguese" + || controllerLanguage == "Italian" + || commandState == .translate) + { + leftPadding = keyWidth / 3 + addPadding(to: stackView1, width: leftPadding, key: "@") + } + if DeviceType.isPad + && key == "$" + && controllerLanguage == "Italian" + { + leftPadding = keyWidth / 3 + addPadding(to: stackView1, width: leftPadding, key: "$") + } + if DeviceType.isPad + && key == "€" + && (controllerLanguage == "Portuguese" + || commandState == .translate) + { + leftPadding = keyWidth / 3 + addPadding(to: stackView1, width: leftPadding, key: "€") + } + //} + + keyboardKeys.append(btn) + if !usingExpandedKeyboard { + switch row { + case 0: stackView0.addArrangedSubview(btn) + case 1: stackView1.addArrangedSubview(btn) + case 2: stackView2.addArrangedSubview(btn) + case 3: stackView3.addArrangedSubview(btn) + default: + break + } + } else { + switch row { + case 0: stackViewNum.addArrangedSubview(btn) + case 1: stackView0.addArrangedSubview(btn) + case 2: stackView1.addArrangedSubview(btn) + case 3: stackView2.addArrangedSubview(btn) + case 4: stackView3.addArrangedSubview(btn) + default: + break + } + } + + // Special key styling. + if key == "delete" { + let deleteLongPressRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(deleteLongPressed(_:))) + btn.addGestureRecognizer(deleteLongPressRecognizer) + } + + if key == "selectKeyboard" { + selectKeyboardButton = btn + selectKeyboardButton.addTarget( + self, + action: #selector(handleInputModeList(from:with:)), + for: .allTouchEvents + ) + styleIconBtn(btn: btn, color: keyCharColor, iconName: "globe") + } + + if key == "hideKeyboard" { + styleIconBtn(btn: btn, color: keyCharColor, iconName: "keyboard.chevron.compact.down") + } + + if key == SpecialKeys.indent { + styleIconBtn(btn: btn, color: keyCharColor, iconName: "arrow.forward.to.line") + } + + if key == SpecialKeys.capsLock { + styleIconBtn(btn: btn, color: keyCharColor, iconName: "capslock") + } + + if key == "shift" { + styleIconBtn(btn: btn, color: keyCharColor, iconName: "shift") + } + + if key == "return" { + if [.translate, .conjugate, .plural].contains(commandState) { + styleIconBtn(btn: btn, color: keyCharColor, iconName: "arrowtriangle.right.fill") + } else { + styleIconBtn(btn: btn, color: keyCharColor, iconName: "arrow.turn.down.left") + } + } + + if key == "delete" { + styleIconBtn(btn: btn, color: keyCharColor, iconName: "delete.left") + } + + // Setting key pop functionality. + let keyHoldPop = UILongPressGestureRecognizer( + target: self, + action: #selector(genHoldPopUpView(sender:)) + ) + keyHoldPop.minimumPressDuration = 0.125 + + if allNonSpecialKeys.contains(key) { + btn.addTarget(self, action: #selector(genPopUpView), for: .touchDown) + btn.addGestureRecognizer(keyHoldPop) + } + + // Pad after key is added. + var rightPadding = CGFloat(0) + if DeviceType.isPhone + && key == "m" + && ["German", "Swedish"].contains(controllerLanguage) + && commandState != .translate + { + rightPadding = keyWidth / 3 + addPadding(to: stackView2, width: rightPadding, key: "m") + } + if DeviceType.isPhone + && key == "l" + && (controllerLanguage == "Portuguese" + || controllerLanguage == "Italian" + || commandState == .translate) + { + rightPadding = keyWidth / 4 + addPadding(to: stackView1, width: rightPadding, key: "l") + } + + // Set the width of the key given device and the given key. + btn.adjustKeyWidth() + + // Update the button style. + btn.adjustButtonStyle() + + if key == "return" && proxy.keyboardType == .webSearch && ![.translate, .conjugate, .plural].contains(commandState) { + // Override background color from adjustKeyWidth for "search" blue for web searches. + styleIconBtn(btn: btn, color: .white.withAlphaComponent(0.9), iconName: "arrow.turn.down.left") + btn.backgroundColor = UIColor(red: 0.0 / 255.0, green: 121.0 / 255.0, blue: 251.0 / 255.0, alpha: 1.0) + } + + // Extend button touch areas. + var widthOfSpacing = CGFloat(0) + if keyboardState == .letters { + widthOfSpacing = ( + (UIScreen.main.bounds.width - 6.0) + - (CGFloat(letterKeys[0].count) * keyWidth) + ) / (CGFloat(letterKeys[0].count) + - 1.0 + ) + } else { + widthOfSpacing = ( + (UIScreen.main.bounds.width - 6.0) + - (CGFloat(usingExpandedKeyboard == true ? symbolKeys[0].count : numberKeys[0].count) * numSymKeyWidth) + ) / (CGFloat(letterKeys[0].count) + - 1.0 + ) + } + + switch row { + case 0: + btn.topShift = -5 + btn.bottomShift = -6 + case 1: + btn.topShift = -6 + btn.bottomShift = -6 + case 2: + btn.topShift = -6 + btn.bottomShift = -6 + case 3: + btn.topShift = -6 + btn.bottomShift = -5 + default: + break + } + + // Pad left and right based on if the button has been shifted. + if leftPadding == CGFloat(0) { + btn.leftShift = -(widthOfSpacing / 2) + } else { + btn.leftShift = -leftPadding + } + if rightPadding == CGFloat(0) { + btn.rightShift = -(widthOfSpacing / 2) + } else { + btn.rightShift = -rightPadding + } + + // Activate keyboard interface buttons. + activateBtn(btn: btn) + if key == "shift" || key == spaceBar || key == languageTextForSpaceBar { + btn.addTarget(self, action: #selector(keyMultiPress(_:event:)), for: .touchDownRepeat) + } + } + } + + // End padding. + switch keyboardState { + case .letters: + break + case .numbers: + break + case .symbols: + break + } + + } + // MARK: Load Keys /// Loads the keys given the current constraints. func loadKeys() { // The name of the language keyboard that's referencing KeyboardViewController. controllerLanguage = classForCoder.description().components(separatedBy: ".KeyboardViewController")[0] + let userDefaults = UserDefaults(suiteName: "group.scribe.userDefaultsContainer")! + if userDefaults.bool(forKey: "svAccentCharacters") { + disableAccentCharacters = true + } + else { + disableAccentCharacters = false + } + // Actions to be done only on initial loads. if isFirstKeyboardLoad { shiftButtonState = .shift @@ -1618,6 +1890,7 @@ class KeyboardViewController: UIInputViewController { setCommandBtns() setConjugationBtns() + // Clear annotation state if a keyboard state change dictates it. if !annotationState { annotationBtns.forEach { $0.removeFromSuperview() } @@ -1630,19 +1903,8 @@ class KeyboardViewController: UIInputViewController { keyboardKeys.forEach { $0.removeFromSuperview() } paddingViews.forEach { $0.removeFromSuperview() } - // keyWidth determined per keyboard by the top row. - if isLandscapeView { - if DeviceType.isPhone { - letterKeyWidth = (UIScreen.main.bounds.height - 5) / CGFloat(letterKeys[0].count) * scalarLetterNumSymKeyWidthLandscapeViewPhone - numSymKeyWidth = (UIScreen.main.bounds.height - 5) / CGFloat(numberKeys[0].count) * scalarLetterNumSymKeyWidthLandscapeViewPhone - } else if DeviceType.isPad { - letterKeyWidth = (UIScreen.main.bounds.height - 5) / CGFloat(letterKeys[0].count) * scalarLetterNumSymKeyWidthLandscapeViewPad - numSymKeyWidth = (UIScreen.main.bounds.height - 5) / CGFloat(numberKeys[0].count) * scalarLetterNumSymKeyWidthLandscapeViewPad - } - } else { - letterKeyWidth = (UIScreen.main.bounds.width - 6) / CGFloat(letterKeys[0].count) * scalarLetterNumSymKeyWidth - numSymKeyWidth = (UIScreen.main.bounds.width - 6) / CGFloat(symbolKeys[0].count) * scalarLetterNumSymKeyWidth - } + setKeywidth() + // Derive keyboard given current states and set widths. switch keyboardState { @@ -1770,247 +2032,8 @@ class KeyboardViewController: UIInputViewController { } } } - - let numRows = keyboard.count - for row in 0 ..< numRows { - for idx in 0 ..< keyboard[row].count { - // Set up button as a key with its values and properties. - let btn = KeyboardKey(type: .custom) - btn.row = row - btn.idx = idx - btn.style() - btn.setChar() - btn.setCharSize() - - let key: String = btn.key - - // Pad before key is added. - var leftPadding = CGFloat(0) - if DeviceType.isPhone - && key == "y" - && ["German", "Swedish"].contains(controllerLanguage) - && commandState != .translate - { - leftPadding = keyWidth / 3 - addPadding(to: stackView2, width: leftPadding, key: "y") - } - if DeviceType.isPhone - && key == "a" - && (controllerLanguage == "Portuguese" - || controllerLanguage == "Italian" - || commandState == .translate) - { - leftPadding = keyWidth / 4 - addPadding(to: stackView1, width: leftPadding, key: "a") - } - if DeviceType.isPad - && key == "a" - && (controllerLanguage == "Portuguese" - || controllerLanguage == "Italian" - || commandState == .translate) - { - leftPadding = keyWidth / 3 - addPadding(to: stackView1, width: leftPadding, key: "a") - } - if DeviceType.isPad - && key == "@" - && (controllerLanguage == "Portuguese" - || controllerLanguage == "Italian" - || commandState == .translate) - { - leftPadding = keyWidth / 3 - addPadding(to: stackView1, width: leftPadding, key: "@") - } - if DeviceType.isPad - && key == "$" - && controllerLanguage == "Italian" - { - leftPadding = keyWidth / 3 - addPadding(to: stackView1, width: leftPadding, key: "$") - } - if DeviceType.isPad - && key == "€" - && (controllerLanguage == "Portuguese" - || commandState == .translate) - { - leftPadding = keyWidth / 3 - addPadding(to: stackView1, width: leftPadding, key: "€") - } - - keyboardKeys.append(btn) - if !usingExpandedKeyboard { - switch row { - case 0: stackView0.addArrangedSubview(btn) - case 1: stackView1.addArrangedSubview(btn) - case 2: stackView2.addArrangedSubview(btn) - case 3: stackView3.addArrangedSubview(btn) - default: - break - } - } else { - switch row { - case 0: stackViewNum.addArrangedSubview(btn) - case 1: stackView0.addArrangedSubview(btn) - case 2: stackView1.addArrangedSubview(btn) - case 3: stackView2.addArrangedSubview(btn) - case 4: stackView3.addArrangedSubview(btn) - default: - break - } - } - - // Special key styling. - if key == "delete" { - let deleteLongPressRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(deleteLongPressed(_:))) - btn.addGestureRecognizer(deleteLongPressRecognizer) - } - - if key == "selectKeyboard" { - selectKeyboardButton = btn - selectKeyboardButton.addTarget( - self, - action: #selector(handleInputModeList(from:with:)), - for: .allTouchEvents - ) - styleIconBtn(btn: btn, color: keyCharColor, iconName: "globe") - } - - if key == "hideKeyboard" { - styleIconBtn(btn: btn, color: keyCharColor, iconName: "keyboard.chevron.compact.down") - } - - if key == SpecialKeys.indent { - styleIconBtn(btn: btn, color: keyCharColor, iconName: "arrow.forward.to.line") - } - - if key == SpecialKeys.capsLock { - styleIconBtn(btn: btn, color: keyCharColor, iconName: "capslock") - } - - if key == "shift" { - styleIconBtn(btn: btn, color: keyCharColor, iconName: "shift") - } - - if key == "return" { - if [.translate, .conjugate, .plural].contains(commandState) { - styleIconBtn(btn: btn, color: keyCharColor, iconName: "arrowtriangle.right.fill") - } else { - styleIconBtn(btn: btn, color: keyCharColor, iconName: "arrow.turn.down.left") - } - } - - if key == "delete" { - styleIconBtn(btn: btn, color: keyCharColor, iconName: "delete.left") - } - - // Setting key pop functionality. - let keyHoldPop = UILongPressGestureRecognizer( - target: self, - action: #selector(genHoldPopUpView(sender:)) - ) - keyHoldPop.minimumPressDuration = 0.125 - - if allNonSpecialKeys.contains(key) { - btn.addTarget(self, action: #selector(genPopUpView), for: .touchDown) - btn.addGestureRecognizer(keyHoldPop) - } - - // Pad after key is added. - var rightPadding = CGFloat(0) - if DeviceType.isPhone - && key == "m" - && ["German", "Swedish"].contains(controllerLanguage) - && commandState != .translate - { - rightPadding = keyWidth / 3 - addPadding(to: stackView2, width: rightPadding, key: "m") - } - if DeviceType.isPhone - && key == "l" - && (controllerLanguage == "Portuguese" - || controllerLanguage == "Italian" - || commandState == .translate) - { - rightPadding = keyWidth / 4 - addPadding(to: stackView1, width: rightPadding, key: "l") - } - - // Set the width of the key given device and the given key. - btn.adjustKeyWidth() - - // Update the button style. - btn.adjustButtonStyle() - - if key == "return" && proxy.keyboardType == .webSearch && ![.translate, .conjugate, .plural].contains(commandState) { - // Override background color from adjustKeyWidth for "search" blue for web searches. - styleIconBtn(btn: btn, color: .white.withAlphaComponent(0.9), iconName: "arrow.turn.down.left") - btn.backgroundColor = UIColor(red: 0.0 / 255.0, green: 121.0 / 255.0, blue: 251.0 / 255.0, alpha: 1.0) - } - - // Extend button touch areas. - var widthOfSpacing = CGFloat(0) - if keyboardState == .letters { - widthOfSpacing = ( - (UIScreen.main.bounds.width - 6.0) - - (CGFloat(letterKeys[0].count) * keyWidth) - ) / (CGFloat(letterKeys[0].count) - - 1.0 - ) - } else { - widthOfSpacing = ( - (UIScreen.main.bounds.width - 6.0) - - (CGFloat(usingExpandedKeyboard == true ? symbolKeys[0].count : numberKeys[0].count) * numSymKeyWidth) - ) / (CGFloat(letterKeys[0].count) - - 1.0 - ) - } - - switch row { - case 0: - btn.topShift = -5 - btn.bottomShift = -6 - case 1: - btn.topShift = -6 - btn.bottomShift = -6 - case 2: - btn.topShift = -6 - btn.bottomShift = -6 - case 3: - btn.topShift = -6 - btn.bottomShift = -5 - default: - break - } - - // Pad left and right based on if the button has been shifted. - if leftPadding == CGFloat(0) { - btn.leftShift = -(widthOfSpacing / 2) - } else { - btn.leftShift = -leftPadding - } - if rightPadding == CGFloat(0) { - btn.rightShift = -(widthOfSpacing / 2) - } else { - btn.rightShift = -rightPadding - } - - // Activate keyboard interface buttons. - activateBtn(btn: btn) - if key == "shift" || key == spaceBar || key == languageTextForSpaceBar { - btn.addTarget(self, action: #selector(keyMultiPress(_:event:)), for: .touchDownRepeat) - } - } - } - - // End padding. - switch keyboardState { - case .letters: - break - case .numbers: - break - case .symbols: - break - } + + setKeyPadding() } else { // Load conjugation view. From d26d9d0eba939e4307e397367ef4ab22df349507 Mon Sep 17 00:00:00 2001 From: henrikth93 Date: Mon, 25 Dec 2023 11:04:03 +0100 Subject: [PATCH 2/2] Update InterfaceVariables.swift Removed trailing semicolon --- Keyboards/KeyboardsBase/InterfaceVariables.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Keyboards/KeyboardsBase/InterfaceVariables.swift b/Keyboards/KeyboardsBase/InterfaceVariables.swift index 5d441f34..98d91b88 100644 --- a/Keyboards/KeyboardsBase/InterfaceVariables.swift +++ b/Keyboards/KeyboardsBase/InterfaceVariables.swift @@ -26,7 +26,7 @@ var keyWidth = CGFloat(0) var letterKeyWidth = CGFloat(0) var numSymKeyWidth = CGFloat(0) var isFirstKeyboardLoad = false -var disableAccentCharacters = false; +var disableAccentCharacters = false // Constants for scaling key widths and heights. let scalarAlternatesBtnYPad = 0.2 let scalarAlternatesBtnYPhone = 0.15