Skip to content

Commit

Permalink
#67 #68 #69 Add keys for French and Portuguese and add symbol hold-to…
Browse files Browse the repository at this point in the history
…-select
  • Loading branch information
andrewtavis committed Dec 3, 2021
1 parent 7a61db6 commit 3923b42
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 53 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@ Emojis for the following are chosen based on [gitmoji](https://gitmoji.dev/).

### 🚀 Deployment

- Adds a Russian keyboard.
- Adds baseline Russian, French and Portuguese keyboards.

### ✨ Features

- Adding hold-to-select functionality for symbols.

### 🗃️ Data

<!-- -->

### 🐛 Bug fixes

- Fixed a problem with German keyboards where the dollar sign was shown on the number keys instead of the euro sign.
- Fixed a problem with iPads where semicolon keys also had apostrophes.

## 1.0.1 (WIP)
Expand Down
145 changes: 144 additions & 1 deletion Keyboards/KeyboardsBase/InterfaceVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,28 @@ var symbolKeys = [[String]]()
// View that stores hold-to-select key options and the corresponding key arrays.
var alternatesKeyView: UIView!
var keysWithAlternates = [String]()
// The main currency symbol that will receive the alternates view for iPhones.
var currencySymbol: String = ""
var currencySymbolAlternates = [String]()
let dollarAlternateKeys = ["", "¢", "", "", "¥", "£", ""]
let euroAlternateKeys = ["", "¢", "", "", "¥", "£", "$"]
// Symbol keys that have consistent altnernates for iPhones.
var symbolKeysWithAlternatesLeft = ["/", "?", "!", "%", "&"]
let backslashAlternateKeys = ["\\"]
let questionMarkAlternateKeys = ["¿"]
let exclamationAlternateKeys = ["¡"]
let percentAlternateKeys = [""]
let ampersandAlternateKeys = ["§"]
var symbolKeysWithAlternatesRight = ["'", "\"", "="]
let apostropheAlternateKeys = ["`", "´", "'"]
let quatationAlternateKeys = ["«", "»", "", "", "\""]
let equalSignAlternateKeys = ["", "±", ""]
var keysWithAlternatesLeft = [String]()
var keysWithAlternatesRight = [String]()
var keyAlternatesDict = [String: Array<String>]()
var aAlternateKeys = [String]()
var eAlternateKeys = [String]()
var еAlternateKeys = [String]() // Russian е
var iAlternateKeys = [String]()
var oAlternateKeys = [String]()
var uAlternateKeys = [String]()
Expand Down Expand Up @@ -92,9 +109,72 @@ func checkLandscapeMode() {
}
}

// MARK: French interface variables

public enum FrenchKeyboardConstants {

// Keyboard key layouts.
static let letterKeysPhone = [
["a", "z", "e", "r", "t", "y", "u", "i", "o", "p"],
["q", "s", "d", "f", "g", "h", "j", "k", "l", "m"],
["shift", "w", "x", "c", "v", "b", "n", "'", "delete"],
["123", "selectKeyboard", "espace", "return"] // "undoArrow"
]

static let numberKeysPhone = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
["-", "/", ":", ";", "(", ")", "", "&", "@", "\""],
["#+=", ".", ",", "?", "!", "\'", "delete"],
["ABC", "selectKeyboard", "espace", "return"] // "undoArrow"
]

static let symbolKeysPhone = [
["[", "]", "{", "}", "#", "%", "^", "*", "+", "="],
["_", "\\", "|", "~", "<", ">", "$", "£", "¥", "·"],
["123", ".", ",", "?", "!", "\'", "delete"],
["ABC", "selectKeyboard", "espace", "return"] // "undoArrow"
]

static let letterKeysPad = [
["a", "z", "e", "r", "t", "y", "u", "i", "o", "p", "delete"],
["q", "s", "d", "f", "g", "h", "j", "k", "l", "m", "return"],
["shift", "w", "x", "c", "v", "b", "n", "'", ",", ".", "shift"],
[".?123", "selectKeyboard", "espace", ".?123", "hideKeyboard"] // "undoArrow"
]

static let numberKeysPad = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "delete"],
["@", "#", "&", "\"", "", "(", "!", ")", "-", "*", "return"],
["#+=", "%", "_", "+", "=", "/", ";", ":", ",", ".", "#+="],
["ABC", "selectKeyboard", "espace", "ABC", "hideKeyboard"] // "undoArrow"
]

static let symbolKeysPad = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "*", "delete"],
["~", "", "[", "]", "{", "}", "^", "$", "£", "¥", "return"],
["123", "§", "<", ">", "|", "\\", "...", "·", "?", "'", "123"],
["ABC", "selectKeyboard", "espace", "ABC", "hideKeyboard"] // "undoArrow"
]

// Alternate key vars.
static let keysWithAlternates = ["a", "e", "s", "y", "c", "u", "i", "o", "n"]
static let keysWithAlternatesLeft = ["a", "e", "s", "y", "c"]
static let keysWithAlternatesRight = ["u", "i", "o", "n"]

static let aAlternateKeys = ["à", "â", "æ", "á", "ä", "ã", "å", "ā", ""]
static let eAlternateKeys = ["é", "è", "ê", "ë", "ę", "ė", "ē"]
static let iAlternateKeys = ["ī", "į", "í", "ì", "ï", "î"]
static let oAlternateKeys = ["", "ō", "ø", "õ", "ó", "ò", "ö", "œ", "ô"]
static let uAlternateKeys = ["ū", "ú", "ü", "ù", "û"]
static let yAlternateKeys = ["ÿ"]
static let cAlternateKeys = ["ç", "ć", "č"]
static let nAlternateKeys = ["ń", "ñ"]
}

// MARK: German interface variables

public enum GermanKeyboardConstants {

// Keyboard key layouts.
static let letterKeysPhone = [
["q", "w", "e", "r", "t", "z", "u", "i", "o", "p", "ü"],
Expand Down Expand Up @@ -154,9 +234,71 @@ public enum GermanKeyboardConstants {
static let nAlternateKeys = ["ń", "ñ"]
}

// MARK: Portuguese interface variables

public enum PortugueseKeyboardConstants {

// Keyboard key layouts.
static let letterKeysPhone = [
["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"],
["a", "s", "d", "f", "g", "h", "j", "k", "l"],
["shift", "z", "x", "c", "v", "b", "n", "m", "delete"],
["123", "selectKeyboard", "espaço", "return"] // "undoArrow"
]

static let numberKeysPhone = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
["-", "/", ":", ";", "(", ")", "", "&", "@", "\""],
["#+=", ".", ",", "?", "!", "\'", "delete"],
["ABC", "selectKeyboard", "espaço", "return"] // "undoArrow"
]

static let symbolKeysPhone = [
["[", "]", "{", "}", "#", "%", "^", "*", "+", "="],
["_", "\\", "|", "~", "<", ">", "$", "£", "¥", "·"],
["123", ".", ",", "?", "!", "\'", "delete"],
["ABC", "selectKeyboard", "espaço", "return"] // "undoArrow"
]

static let letterKeysPad = [
["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "delete"],
["a", "s", "d", "f", "g", "h", "j", "k", "l", "return"],
["shift", "z", "x", "c", "v", "b", "n", "m", "!", "?", "shift"],
[".?123", "selectKeyboard", "espaço", ".?123", "hideKeyboard"] // "undoArrow"
]

static let numberKeysPad = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "delete"],
["@", "#", "$", "&", "*", "(", ")", "'", "\"", "return"],
["#+=", "%", "-", "+", "=", "/", ";", ":", ",", ".", "#+="],
["ABC", "selectKeyboard", "espaço", "ABC", "hideKeyboard"] // "undoArrow"
]

static let symbolKeysPad = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "delete"],
["", "£", "¥", "_", "^", "[", "]", "{", "}", "return"],
["123", "§", "|", "~", "...", "\\", "<", ">", "!", "?", "123"],
["ABC", "selectKeyboard", "espaço", "ABC", "hideKeyboard"] // "undoArrow"
]

// Alternate key vars.
static let keysWithAlternates = ["a", "e", "s", "y", "c", "u", "i", "o", "n"]
static let keysWithAlternatesLeft = ["a", "e", "s", "y", "c"]
static let keysWithAlternatesRight = ["u", "i", "o", "n"]

static let aAlternateKeys = ["á", "ã", "à", "â", "ä", "å", "æ", ""]
static let eAlternateKeys = ["é", "ê", "è", "ę", "ė", "ē", "ë"]
static let iAlternateKeys = ["ī", "į", "ï", "ì", "î", "í"]
static let oAlternateKeys = ["", "ō", "ø", "œ", "ö", "ò", "ô", "õ", "ó"]
static let uAlternateKeys = ["ū", "û", "ù", "ü", "ú"]
static let cAlternateKeys = ["ç"]
static let nAlternateKeys = ["ñ"]
}

// MARK: Russian interface variables

public enum RussianKeyboardConstants {

// Keyboard key layouts.
static let letterKeysPhone = [
["й", "ц", "у", "к", "е", "н", "г", "ш", "щ", "з", "х"],
Expand Down Expand Up @@ -205,13 +347,14 @@ public enum RussianKeyboardConstants {
static let keysWithAlternatesLeft = ["е"]
static let keysWithAlternatesRight = ["ь"]

static let eAlternateKeys = ["ë"]
static let еAlternateKeys = ["ë"]
static let ьAlternateKeys = ["Ъ"]
}

// MARK: Spanish interface variables

public class SpanishKeyboardConstants {

// Keyboard key layouts.
static let letterKeysPhone = [
["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"],
Expand Down
115 changes: 65 additions & 50 deletions Keyboards/KeyboardsBase/KeyboardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,21 @@ class KeyboardViewController: UIInputViewController {
// German, Russian or Spanish
controllerLanguage = classForCoder.description().components(separatedBy: ".KeyboardViewController")[0]

if controllerLanguage == "German" {
if controllerLanguage == "French" {
keysWithAlternates = FrenchKeyboardConstants.keysWithAlternates
keysWithAlternatesLeft = FrenchKeyboardConstants.keysWithAlternatesLeft
keysWithAlternatesRight = FrenchKeyboardConstants.keysWithAlternatesRight
aAlternateKeys = FrenchKeyboardConstants.aAlternateKeys
eAlternateKeys = FrenchKeyboardConstants.eAlternateKeys
iAlternateKeys = FrenchKeyboardConstants.iAlternateKeys
oAlternateKeys = FrenchKeyboardConstants.oAlternateKeys
uAlternateKeys = FrenchKeyboardConstants.uAlternateKeys
yAlternateKeys = FrenchKeyboardConstants.yAlternateKeys
cAlternateKeys = FrenchKeyboardConstants.cAlternateKeys
nAlternateKeys = FrenchKeyboardConstants.nAlternateKeys
currencySymbol = ""
currencySymbolAlternates = euroAlternateKeys
} else if controllerLanguage == "German" {
keysWithAlternates = GermanKeyboardConstants.keysWithAlternates
keysWithAlternatesLeft = GermanKeyboardConstants.keysWithAlternatesLeft
keysWithAlternatesRight = GermanKeyboardConstants.keysWithAlternatesRight
Expand All @@ -452,9 +466,29 @@ class KeyboardViewController: UIInputViewController {
sAlternateKeys = GermanKeyboardConstants.sAlternateKeys
cAlternateKeys = GermanKeyboardConstants.cAlternateKeys
nAlternateKeys = GermanKeyboardConstants.nAlternateKeys
currencySymbol = ""
currencySymbolAlternates = euroAlternateKeys
} else if controllerLanguage == "Portuguese" {
keysWithAlternates = PortugueseKeyboardConstants.keysWithAlternates
keysWithAlternatesLeft = PortugueseKeyboardConstants.keysWithAlternatesLeft
keysWithAlternatesRight = PortugueseKeyboardConstants.keysWithAlternatesRight
aAlternateKeys = PortugueseKeyboardConstants.aAlternateKeys
eAlternateKeys = PortugueseKeyboardConstants.eAlternateKeys
iAlternateKeys = PortugueseKeyboardConstants.iAlternateKeys
oAlternateKeys = PortugueseKeyboardConstants.oAlternateKeys
uAlternateKeys = PortugueseKeyboardConstants.uAlternateKeys
cAlternateKeys = PortugueseKeyboardConstants.cAlternateKeys
nAlternateKeys = PortugueseKeyboardConstants.nAlternateKeys
currencySymbol = "$"
currencySymbolAlternates = dollarAlternateKeys
} else if controllerLanguage == "Russian" {
eAlternateKeys = RussianKeyboardConstants.eAlternateKeys
keysWithAlternates = RussianKeyboardConstants.keysWithAlternates
keysWithAlternatesLeft = RussianKeyboardConstants.keysWithAlternatesLeft
keysWithAlternatesRight = RussianKeyboardConstants.keysWithAlternatesRight
еAlternateKeys = RussianKeyboardConstants.еAlternateKeys
ьAlternateKeys = RussianKeyboardConstants.ьAlternateKeys
currencySymbol = ""
currencySymbolAlternates = euroAlternateKeys
} else if controllerLanguage == "Spanish" {
keysWithAlternates = SpanishKeyboardConstants.keysWithAlternates
keysWithAlternatesLeft = SpanishKeyboardConstants.keysWithAlternatesLeft
Expand All @@ -468,10 +502,22 @@ class KeyboardViewController: UIInputViewController {
dAlternateKeys = SpanishKeyboardConstants.dAlternateKeys
cAlternateKeys = SpanishKeyboardConstants.cAlternateKeys
nAlternateKeys = SpanishKeyboardConstants.nAlternateKeys
currencySymbol = "$"
currencySymbolAlternates = dollarAlternateKeys
}

if DeviceType.isPhone {
keysWithAlternates += symbolKeysWithAlternatesLeft
keysWithAlternates += symbolKeysWithAlternatesRight
keysWithAlternates.append(currencySymbol)
keysWithAlternatesLeft += symbolKeysWithAlternatesLeft
keysWithAlternatesRight += symbolKeysWithAlternatesRight
keysWithAlternatesRight.append(currencySymbol)
}

keyAlternatesDict = ["a": aAlternateKeys,
"e": eAlternateKeys,
"е": еAlternateKeys, // Russian е
"i": iAlternateKeys,
"o": oAlternateKeys,
"u": uAlternateKeys,
Expand All @@ -480,7 +526,16 @@ class KeyboardViewController: UIInputViewController {
"d": dAlternateKeys,
"c": cAlternateKeys,
"n": nAlternateKeys,
"ь": ьAlternateKeys]
"ь": ьAlternateKeys,
"/": backslashAlternateKeys,
"?": questionMarkAlternateKeys,
"!": exclamationAlternateKeys,
"%": percentAlternateKeys,
"&": ampersandAlternateKeys,
"'": apostropheAlternateKeys,
"\"": quatationAlternateKeys,
"=": equalSignAlternateKeys,
currencySymbol: currencySymbolAlternates]

checkLandscapeMode()
checkDarkModeSetColors()
Expand Down Expand Up @@ -675,6 +730,9 @@ class KeyboardViewController: UIInputViewController {
if DeviceType.isPhone && key == "y" && controllerLanguage == "German" {
addPadding(to: stackView3, width: buttonWidth / 3, key: "y")
}
if DeviceType.isPhone && key == "a" && controllerLanguage == "Portuguese" {
addPadding(to: stackView3, width: buttonWidth / 3, key: "a")
}

keys.append(btn)
switch row {
Expand Down Expand Up @@ -718,60 +776,17 @@ class KeyboardViewController: UIInputViewController {
let longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(setAlternatesView(sender:)))
longPressGesture.minimumPressDuration = 1.2

if key == "a" {
btn.addGestureRecognizer(longPressGesture)
}

if key == "e" {
btn.addGestureRecognizer(longPressGesture)
}

if key == "i" {
btn.addGestureRecognizer(longPressGesture)
}

if key == "o" {
btn.addGestureRecognizer(longPressGesture)
}

if key == "u" {
btn.addGestureRecognizer(longPressGesture)
}

if key == "y" {
if controllerLanguage == "German" {
btn.addGestureRecognizer(longPressGesture)
}
}

if key == "s" {
btn.addGestureRecognizer(longPressGesture)
}

if key == "d" {
if controllerLanguage == "Spanish" {
btn.addGestureRecognizer(longPressGesture)
}
}

if key == "c" {
btn.addGestureRecognizer(longPressGesture)
}

if key == "n" {
if keysWithAlternates.contains(key) {
btn.addGestureRecognizer(longPressGesture)
}

if key == "ь" {
if controllerLanguage == "Russian" {
btn.addGestureRecognizer(longPressGesture)
}
}

// Pad after key is added.
if DeviceType.isPhone && key == "m" && controllerLanguage == "German" {
addPadding(to: stackView3, width: buttonWidth / 3, key: "m")
}
if DeviceType.isPhone && key == "l" && controllerLanguage == "Portuguese" {
addPadding(to: stackView3, width: buttonWidth / 3, key: "l")
}

// specialKey styling.
if key == "ABC" || key == "АБВ" {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ The goal is for Scribe to have all the functionality of system keyboards. See th
- The double space period shortcut
- Typing `'` returns to the alphabetic keyboard
- Typing `,`, `?` or `!` and then `space` returns to the alphabetic keyboards
- Hold-to-select characters [(WIP - see project)](https://github.com/scribe-org/Scribe-iOS/projects/2)
- Hold-to-select characters for letters and symbols[(WIP - see project)](https://github.com/scribe-org/Scribe-iOS/projects/2)

</p>
</details>
Expand Down

0 comments on commit 3923b42

Please sign in to comment.