@@ -18,25 +18,32 @@ class KeyboardViewController: UIInputViewController {
18
18
@IBOutlet var stackView2 : UIStackView !
19
19
@IBOutlet var stackView3 : UIStackView !
20
20
21
-
22
21
private var tipView : ToolTipView ?
23
22
24
23
/// Changes the height of `stackViewNum` depending on device type and size.
25
24
func conditionallyShowTopNumbersRow( ) {
26
25
if DeviceType . isPhone {
27
26
view. addConstraint (
28
27
NSLayoutConstraint (
29
- item: stackViewNum!, attribute: . height, relatedBy: . equal, toItem: nil , attribute: . height, multiplier: 0 , constant: 0
28
+ item: stackViewNum!, attribute: . height, relatedBy: . equal, toItem: nil , attribute: . height, multiplier: 1 , constant: 0
30
29
)
31
30
)
32
31
} else if DeviceType . isPad {
33
32
// Update the size of the numbers row to add it to the view.
34
- // let numbersRowHeight = self.scribeKey.frame.height
35
- view. addConstraint (
36
- NSLayoutConstraint (
37
- item: stackViewNum!, attribute: . height, relatedBy: . equal, toItem: nil , attribute: . height, multiplier: 0 , constant: 0
33
+ if usingExpandedKeyboard {
34
+ let numbersRowHeight = scribeKey. frame. height
35
+ view. addConstraint (
36
+ NSLayoutConstraint (
37
+ item: stackViewNum!, attribute: . height, relatedBy: . equal, toItem: nil , attribute: . height, multiplier: 1 , constant: numbersRowHeight
38
+ )
38
39
)
39
- )
40
+ } else {
41
+ view. addConstraint (
42
+ NSLayoutConstraint (
43
+ item: stackViewNum!, attribute: . height, relatedBy: . equal, toItem: nil , attribute: . height, multiplier: 1 , constant: 0
44
+ )
45
+ )
46
+ }
40
47
}
41
48
}
42
49
@@ -1545,6 +1552,15 @@ class KeyboardViewController: UIInputViewController {
1545
1552
keyboardView. backgroundColor? = keyboardBgColor
1546
1553
allNonSpecialKeys = allKeys. filter { !specialKeys. contains ( $0) }
1547
1554
1555
+ // Check if the device has a home button and is large enough so we should use an expanded keyboard.
1556
+ if DeviceType . isPad {
1557
+ if UIScreen . main. bounds. width > 768 {
1558
+ usingExpandedKeyboard = true
1559
+ } else {
1560
+ usingExpandedKeyboard = false
1561
+ }
1562
+ }
1563
+
1548
1564
linkShadowBlendElements ( )
1549
1565
setAutoActionPartitions ( )
1550
1566
conditionallyShowTopNumbersRow ( )
@@ -1592,18 +1608,6 @@ class KeyboardViewController: UIInputViewController {
1592
1608
} catch { }
1593
1609
}
1594
1610
1595
- //Check if ipad device meets the criteria for expanded keyboard
1596
- if DeviceType . isPad {
1597
- //Check if device has home button, this will be used later to determine if we should use expanded keypad or not.
1598
- if #available( iOS 13 . 0 , * ) , ( keyboardView. safeAreaInsets. bottom <= 0 && UIScreen . main. bounds. width > 768 ) {
1599
- usingExpandedKeyboard = true ;
1600
- }
1601
- else
1602
- {
1603
- usingExpandedKeyboard = false ;
1604
- }
1605
- }
1606
-
1607
1611
setKeyboard ( )
1608
1612
setCommaAndPeriodKeysConditionally ( )
1609
1613
setCommandBackground ( )
@@ -1633,8 +1637,7 @@ class KeyboardViewController: UIInputViewController {
1633
1637
}
1634
1638
} else {
1635
1639
letterKeyWidth = ( UIScreen . main. bounds. width - 6 ) / CGFloat( letterKeys [ 0 ] . count) * 0.9
1636
- //If we are using expanded keys the numberKeys array is empty, we use symbolKeys
1637
- numSymKeyWidth = ( UIScreen . main. bounds. width - 6 ) / CGFloat( ( usingExpandedKeyboard) == true ? symbolKeys [ 0 ] . count: numberKeys [ 0 ] . count) * 0.9
1640
+ numSymKeyWidth = ( UIScreen . main. bounds. width - 6 ) / CGFloat( symbolKeys [ 0 ] . count) * 0.9
1638
1641
}
1639
1642
1640
1643
// Derive keyboard given current states and set widths.
@@ -1673,13 +1676,17 @@ class KeyboardViewController: UIInputViewController {
1673
1676
}
1674
1677
}
1675
1678
1676
- if ![ . selectVerbConjugation, . selectCaseDeclension, . displayInformation] . contains ( commandState) { // normal keyboard view
1677
- for view in [ stackView0, stackView1, stackView2, stackView3] {
1679
+ if ![
1680
+ . selectVerbConjugation, . selectCaseDeclension, . displayInformation
1681
+ ] . contains ( commandState) { // normal keyboard view
1682
+ for view in [ stackViewNum, stackView0, stackView1, stackView2, stackView3] {
1678
1683
view? . isUserInteractionEnabled = true
1679
1684
view? . isLayoutMarginsRelativeArrangement = true
1680
1685
1681
1686
// Set edge insets for stack views to provide vertical key spacing.
1682
- if view == stackView0 {
1687
+ if view == stackViewNum {
1688
+ view? . layoutMargins = UIEdgeInsets ( top: 3 , left: 0 , bottom: 4 , right: 0 )
1689
+ } else if view == stackView0 {
1683
1690
view? . layoutMargins = UIEdgeInsets ( top: 3 , left: 0 , bottom: 8 , right: 0 )
1684
1691
} else if view == stackView1 {
1685
1692
view? . layoutMargins = UIEdgeInsets ( top: 5 , left: 0 , bottom: 6 , right: 0 )
@@ -1827,13 +1834,25 @@ class KeyboardViewController: UIInputViewController {
1827
1834
}
1828
1835
1829
1836
keyboardKeys. append ( btn)
1830
- switch row {
1831
- case 0 : stackView0. addArrangedSubview ( btn)
1832
- case 1 : stackView1. addArrangedSubview ( btn)
1833
- case 2 : stackView2. addArrangedSubview ( btn)
1834
- case 3 : stackView3. addArrangedSubview ( btn)
1835
- default :
1836
- break
1837
+ if !usingExpandedKeyboard {
1838
+ switch row {
1839
+ case 0 : stackView0. addArrangedSubview ( btn)
1840
+ case 1 : stackView1. addArrangedSubview ( btn)
1841
+ case 2 : stackView2. addArrangedSubview ( btn)
1842
+ case 3 : stackView3. addArrangedSubview ( btn)
1843
+ default :
1844
+ break
1845
+ }
1846
+ } else {
1847
+ switch row {
1848
+ case 0 : stackViewNum. addArrangedSubview ( btn)
1849
+ case 1 : stackView0. addArrangedSubview ( btn)
1850
+ case 2 : stackView1. addArrangedSubview ( btn)
1851
+ case 3 : stackView2. addArrangedSubview ( btn)
1852
+ case 4 : stackView3. addArrangedSubview ( btn)
1853
+ default :
1854
+ break
1855
+ }
1837
1856
}
1838
1857
1839
1858
// Special key styling.
@@ -1924,7 +1943,7 @@ class KeyboardViewController: UIInputViewController {
1924
1943
} else {
1925
1944
widthOfSpacing = (
1926
1945
( UIScreen . main. bounds. width - 6.0 )
1927
- - ( CGFloat ( ( usingExpandedKeyboard) == true ? symbolKeys [ 0 ] . count : numberKeys [ 0 ] . count) * numSymKeyWidth)
1946
+ - ( CGFloat ( usingExpandedKeyboard == true ? symbolKeys [ 0 ] . count : numberKeys [ 0 ] . count) * numSymKeyWidth)
1928
1947
) / ( CGFloat ( letterKeys [ 0 ] . count)
1929
1948
- 1.0
1930
1949
)
@@ -1979,7 +1998,7 @@ class KeyboardViewController: UIInputViewController {
1979
1998
1980
1999
} else {
1981
2000
// Load conjugation view.
1982
- for view in [ stackView0, stackView1, stackView2, stackView3] {
2001
+ for view in [ stackViewNum , stackView0, stackView1, stackView2, stackView3] {
1983
2002
view? . isUserInteractionEnabled = false
1984
2003
}
1985
2004
@@ -2031,9 +2050,9 @@ class KeyboardViewController: UIInputViewController {
2031
2050
let letterKeysHaveCommaPeriod = userDefaults. bool ( forKey: dictionaryKey)
2032
2051
2033
2052
if letterKeysHaveCommaPeriod {
2034
- letterKeys [ 3 ] = [ " 123 " , " selectKeyboard " , " , " , " space " , " . " , " return " ]
2035
- } else {
2036
- letterKeys [ 3 ] = [ " 123 " , " selectKeyboard " , " space " , " return " ]
2053
+ let spaceIndex = letterKeys [ 3 ] . firstIndex ( where : { $0 == " space " } )
2054
+ letterKeys [ 3 ] . insert ( " , " , at : spaceIndex! )
2055
+ letterKeys [ 3 ] . insert ( " . " , at : spaceIndex! + 2 )
2037
2056
}
2038
2057
}
2039
2058
@@ -2468,8 +2487,7 @@ class KeyboardViewController: UIInputViewController {
2468
2487
capsLockPossible = true
2469
2488
2470
2489
case " 123 " , " .?123 " :
2471
- ( usingExpandedKeyboard) == true ? changeKeyboardToSymbolKeys ( ) : changeKeyboardToNumberKeys ( )
2472
-
2490
+ usingExpandedKeyboard == true ? changeKeyboardToSymbolKeys ( ) : changeKeyboardToNumberKeys ( )
2473
2491
2474
2492
case " #+= " :
2475
2493
changeKeyboardToSymbolKeys ( )
0 commit comments