Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#362 Changed the expanded keyboard for more languages #397

Merged
8 changes: 5 additions & 3 deletions Keyboards/KeyboardsBase/InterfaceVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ let scalarKeyCornerRadiusPad = 9.0
let scalarKeyCornerRadiusPhone = 6.0
let scalarFontPad = 0.475
let scalarFontPhone = 0.435
let scalarIndentKeyWidth = 1.7
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
var scalarShiftKeyWidth = 1.4
var scalarSpecialKeysWidth = disableAccentCharacters ? 2.2 : 1.0
var scalarCapsLockKeyWidth = 1.8


// Keyboard elements.
var spaceBar = String()
Expand Down
45 changes: 37 additions & 8 deletions Keyboards/KeyboardsBase/KeyboardKeys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -254,31 +254,60 @@ class KeyboardKey: UIButton {
/// Adjusts the width of a key if it's one of the special characters on the iPad keyboard.
func adjustPadKeyWidth() {
if usingExpandedKeyboard {
scalarSpecialKeysWidth = (disableAccentCharacters && keyboardState != .symbols) ? 2.2 : 1.0
scalarReturnKeyWidth = (disableAccentCharacters && keyboardState != .symbols) ? 2.2 : 1.0
// Switch case for controller language
switch (controllerLanguage){
case "Spanish":
scalarCapsLockKeyWidth = (disableAccentCharacters && keyboardState != .symbols) ? 2.0 : 1.2
scalarSpecialKeysWidth = (disableAccentCharacters && keyboardState != .symbols) ? 2.2 : 1.0
scalarReturnKeyWidth = (disableAccentCharacters && keyboardState != .symbols) ? 1.7 : 1.3
//scalarReturnKeyWidth = 1.3
scalarShiftKeyWidth = 1.8
case "German", "Swedish":
scalarCapsLockKeyWidth = 1.8
scalarReturnKeyWidth = 1.3
scalarSpecialKeysWidth = (disableAccentCharacters && keyboardState != .symbols) ? 2.2 : 1.0
scalarReturnKeyWidth = (disableAccentCharacters && keyboardState != .symbols) ? 2.2 : 1.0
case "French":
scalarCapsLockKeyWidth = 1.2
scalarReturnKeyWidth = (disableAccentCharacters && keyboardState != .symbols) ? 1.4 : 1.0
scalarShiftKeyWidth = 1.8
case "Italian":
scalarSpecialKeysWidth = (disableAccentCharacters && keyboardState != .symbols) ? 2.2 : 1.0
scalarReturnKeyWidth = (disableAccentCharacters && keyboardState != .symbols) ? 1.5 : 1.0
scalarCapsLockKeyWidth = 1.3
scalarShiftKeyWidth = 1.8
default:
scalarSpecialKeysWidth = (disableAccentCharacters && keyboardState != .symbols) ? 2.2 : 1.0
scalarReturnKeyWidth = (disableAccentCharacters && keyboardState != .symbols) ? 2.2 : 1.0
}
//scalarSpecialKeysWidth = (disableAccentCharacters && keyboardState != .symbols) ? 2.2 : 1.0
//scalarReturnKeyWidth = (disableAccentCharacters && keyboardState != .symbols) ? 2.2 : 1.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit - Would it make sense to already check (disableAccentCharacters && keyboardState != .symbols) just once before and then simply use the boolean result in the switch statement? The boolean statements for the ternary operators here are simply repeated really.

OR..
(can most definitely be a TODO for later but..) would it be possible to abstract the logic for the values to the specific language somewhere else? So that only something like the below is possible with no switch statement needed?

        scalarCapsLockKeyWidth = currentLanguage.scalarCapsLockKeyWidth 
        scalarReturnKeyWidth = currentLanguage.scalarReturnKeyWidth
        scalarSpecialKeysWidth = currentLanguage.scalarSpecialKeysWidth
        scalarReturnKeyWidth = currentLanguage.scalarReturnKeyWidth

Scribe-iOS isn't my domain, so let me know if I'm talking crazy 😆

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either sounds good to me! What are your thoughts on this, @henrikth93?

And all of Scribe is your domain, @wkyoshida 😊🤗

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Will's idea of abstracting it is good, and that is something I can try and solve. @wkyoshida I am not sure I understand what you mean regarding the ternary operators, but do you mean that just checking the statement once would be less consuming? To tell the truth, my understanding of ternary operators and what they do under the hood is lacking.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wkyoshida @andrewtavis I think the logic for setting the values could be moved to interfacevariables maybe

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! 👋

I am not sure I understand what you mean regarding the ternary operators, but do you mean that just checking the statement once would be less consuming?

Oh no, not really 😄 I just meant that since the boolean statements for them is the same, could just write it once, store the result in a variable, then consult the variable in each ternary. It's really just more of a visual suggestion to declutter the code a bit to make it more visually clean - that's all.


Also, regarding the abstraction - I'm good with leaving it for another PR, so no stress (unless you'd really like to tackle it here already, then by all means 😄)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to move that to a new PR/issue or have it be committed here. @henrikth93, let me know which one you'd prefer and I'll get to the review soon if we're leaving as is 😊

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let us move that to a new issue! :)

if key == "ABC" || key == "АБВ" {
layer.setValue(true, forKey: "isSpecial")
widthAnchor.constraint(equalToConstant: numSymKeyWidth * 1).isActive = true
} else if ["delete", "#+=", "selectKeyboard", SpecialKeys.capsLock].contains(key) {
} else if ["delete", "#+=", "selectKeyboard"].contains(key) {
layer.setValue(true, forKey: "isSpecial")
widthAnchor.constraint(equalToConstant: numSymKeyWidth * scalarSpecialKeysWidth).isActive = true
} else if [SpecialKeys.capsLock].contains(key) {
layer.setValue(true, forKey: "isSpecial")
widthAnchor.constraint(equalToConstant: numSymKeyWidth * scalarSpecialKeysWidth).isActive = true // *2 scalarSpecialKeysWidth = 1
widthAnchor.constraint(equalToConstant: numSymKeyWidth * scalarCapsLockKeyWidth).isActive = true
} else if [SpecialKeys.indent].contains(key) {
layer.setValue(true, forKey: "isSpecial")
widthAnchor.constraint(equalToConstant: numSymKeyWidth * scalarIndentKeyWidth).isActive = true // scalarIndentKeyWidth
widthAnchor.constraint(equalToConstant: numSymKeyWidth * scalarIndentKeyWidth).isActive = true
} else if ["shift"].contains(key) {
layer.setValue(true, forKey: "isSpecial")
widthAnchor.constraint(equalToConstant: numSymKeyWidth * scalarShiftKeyWidth).isActive = true // scalarShiftKeyWidth
widthAnchor.constraint(equalToConstant: numSymKeyWidth * scalarShiftKeyWidth).isActive = true
} else if ["return"].contains(key) {
layer.setValue(true, forKey: "isSpecial")
widthAnchor.constraint(equalToConstant: numSymKeyWidth * scalarReturnKeyWidth).isActive = true // scalarReturnKeyWidth
widthAnchor.constraint(equalToConstant: numSymKeyWidth * scalarReturnKeyWidth).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
widthAnchor.constraint(equalToConstant: numSymKeyWidth * scalarReturnKeyWidth).isActive = true
} else {
layer.setValue(true, forKey: "isSpecial")
widthAnchor.constraint(equalToConstant: numSymKeyWidth * 1).isActive = true
Expand Down
8 changes: 5 additions & 3 deletions Keyboards/KeyboardsBase/KeyboardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1585,8 +1585,9 @@ class KeyboardViewController: UIInputViewController {
leftPadding = keyWidth / 4
addPadding(to: stackView1, width: leftPadding, key: "a")
}
if DeviceType.isPad
if DeviceType.isPad
&& key == "a"
&& !usingExpandedKeyboard
&& (controllerLanguage == "Portuguese"
|| controllerLanguage == "Italian"
|| commandState == .translate)
Expand All @@ -1596,20 +1597,21 @@ class KeyboardViewController: UIInputViewController {
}
if DeviceType.isPad
&& key == "@"
&& !usingExpandedKeyboard
&& (controllerLanguage == "Portuguese"
|| controllerLanguage == "Italian"
|| commandState == .translate)
{
leftPadding = keyWidth / 3
addPadding(to: stackView1, width: leftPadding, key: "@")
}
if DeviceType.isPad
/* if DeviceType.isPad
&& key == "$"
&& controllerLanguage == "Italian"
{
leftPadding = keyWidth / 3
addPadding(to: stackView1, width: leftPadding, key: "$")
}
}*/
andrewtavis marked this conversation as resolved.
Show resolved Hide resolved
if DeviceType.isPad
&& key == "€"
&& (controllerLanguage == "Portuguese"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public enum DanishKeyboardConstants {
["`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "<", ">", "delete"],
[SpecialKeys.indent, "[", "]", "{", "}", "#", "%", "^", "*", "+", "=", "\"", "|"],
[SpecialKeys.capsLock, "-", "/", ":", ";", "(", ")", "$", "&", "@", "£", "¥", "~", "return"], // "undo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€"], // "redo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€", "shift"], // "redo"
["selectKeyboard", "ABC", "space", "ABC", "hideKeyboard"], // "microphone", "scribble"
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public enum EnglishKeyboardConstants {
["`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "<", ">", "delete"],
[SpecialKeys.indent, "[", "]", "{", "}", "#", "%", "^", "*", "+", "=", "\"", "~"],
[SpecialKeys.capsLock, "-", "/", ":", ";", "(", ")", "$", "&", "@", "£", "¥", "return"], // "undo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€"], // "redo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€", "shift"], // "redo"
["selectKeyboard", "ABC", "space", "ABC", "hideKeyboard"], // "microphone", "scribble"
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public enum FrenchKeyboardConstants {
["`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "<", ">", "delete"],
[SpecialKeys.indent, "[", "]", "{", "}", "#", "%", "^", "*", "+", "=", "\"", "|", "§"],
[SpecialKeys.capsLock, "-", "/", ":", ";", "(", ")", "$", "&", "@", "£", "¥", "~", "return"], // "undo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€"], // "redo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€", "shift"], // "redo"
["selectKeyboard", "ABC", "space", "ABC", "hideKeyboard"], // "microphone", "scribble"
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public enum FrenchQWERTYKeyboardConstants {
["`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "<", ">", "delete"],
[SpecialKeys.indent, "[", "]", "{", "}", "#", "%", "^", "*", "+", "=", "\"", "|", "~"],
[SpecialKeys.capsLock, "-", "/", ":", ";", "(", ")", "$", "&", "@", "£", "¥", "~", "return"], // "undo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€"], // "redo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€", "shift"], // "redo"
["selectKeyboard", "ABC", "space", "ABC", "hideKeyboard"], // "microphone", "scribble"
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public enum GermanKeyboardConstants {
["`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "<", ">", "delete"],
[SpecialKeys.indent, "[", "]", "{", "}", "#", "%", "^", "*", "+", "=", "\"", "|", "§"],
[SpecialKeys.capsLock, "-", "/", ":", ";", "(", ")", "$", "&", "@", "£", "¥", "~", "return"], // "undo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€"], // "redo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€", "shift"], // "redo"
["selectKeyboard", "ABC", "space", "ABC", "hideKeyboard"], // "microphone", "scribble"
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public enum HebrewKeyboardConstants {
["±", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "<", ">", "delete"],
[SpecialKeys.indent, "[", "]", "{", "}", "#", "%", "^", "*", "+", "=", "\"", "|"],
[SpecialKeys.capsLock, "-", "/", ":", ";", "(", ")", "$", "&", "@", "£", "¥", "~", "return"], // "undo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€"], // "redo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€", "shift"], // "redo"
["selectKeyboard", "ABC", "space", "ABC", "hideKeyboard"], // "microphone", "scribble"
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public enum ItalianKeyboardConstants {
["`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "<", ">", "delete"],
[SpecialKeys.indent, "[", "]", "{", "}", "#", "%", "^", "*", "+", "=", "\"", "|", "§"],
[SpecialKeys.capsLock, "-", "/", ":", ";", "(", ")", "$", "&", "@", "£", "¥", "~", "return"], // "undo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€"], // "shift"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€", "shift"], // "shift"
["selectKeyboard", "ABC", "space", "ABC", "hideKeyboard"], // "microphone", "scribble"
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public enum NorwegianBokmålKeyboardConstants {
["`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "<", ">", "delete"],
[SpecialKeys.indent, "[", "]", "{", "}", "#", "%", "^", "*", "+", "=", "\"", "|"],
[SpecialKeys.capsLock, "-", "/", ":", ";", "(", ")", "$", "&", "@", "£", "¥", "~", "return"], // "undo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€"], // "redo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€", "shift"], // "redo"
["selectKeyboard", "ABC", "space", "ABC", "hideKeyboard"], // "microphone", "scribble"
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public enum PortugueseKeyboardConstants {
["§", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "<", ">", "delete"],
[SpecialKeys.indent, "[", "]", "{", "}", "#", "%", "^", "*", "+", "=", "\"", "|", "~"],
[SpecialKeys.capsLock, "-", "/", ":", ";", "(", ")", "$", "&", "@", "£", "¥", "return"], // "undo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€"], // "redo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€", "shift"], // "redo"
["selectKeyboard", "ABC", "space", "ABC", "hideKeyboard"], // "microphone", "scribble"
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public enum RussianKeyboardConstants {
["§", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "<", ">", "delete"],
[SpecialKeys.indent, "[", "]", "{", "}", "#", "%", "^", "*", "+", "=", "\\", "|", "₽"],
[SpecialKeys.capsLock, "-", "/", ":", ";", "(", ")", "$", "&", "@", "£", "¥", "~", "return"], // "undo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€"], // "redo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€", "shift"], // "redo"
["selectKeyboard", "ABC", "space", "ABC", "hideKeyboard"], // "microphone", "scribble"
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public enum SpanishKeyboardConstants {
["§", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "<", ">", "delete"],
[SpecialKeys.indent, "[", "]", "{", "}", "#", "%", "^", "*", "+", "=", "\"", "|"],
[SpecialKeys.capsLock, "-", "/", ":", ";", "(", ")", "$", "&", "@", "£", "¥", "~", "return"], // "undo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€"], // "redo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€", "shift"], // "redo"
["selectKeyboard", "ABC", "space", "ABC", "hideKeyboard"], // "microphone", "scribble"
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public enum SwedishKeyboardConstants {
["§", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "<", ">", "delete"],
[SpecialKeys.indent, "[", "]", "{", "}", "#", "%", "^", "*", "+", "=", "\"", "|"],
[SpecialKeys.capsLock, "-", "/", ":", ";", "(", ")", "$", "&", "@", "£", "¥", "~", "return"], // "undo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€"], // "redo"
["shift", "...", ".", ",", "?", "!", "'", "\"", "_", "€", "shift"], // "redo"
["selectKeyboard", "ABC", "space", "ABC", "hideKeyboard"], // "microphone", "scribble"
]

Expand Down
Loading