diff --git a/ios/engine/KMEI/KeymanEngine/Classes/InputViewController.swift b/ios/engine/KMEI/KeymanEngine/Classes/InputViewController.swift index 4b72fa1dad..d1a9df66bf 100644 --- a/ios/engine/KMEI/KeymanEngine/Classes/InputViewController.swift +++ b/ios/engine/KMEI/KeymanEngine/Classes/InputViewController.swift @@ -253,6 +253,7 @@ open class InputViewController: UIInputViewController, KeymanWebDelegate { if #available(iOSApplicationExtension 11.0, *) { topBar.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true topBar.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor).isActive = true + topBar.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor).isActive = true // Allow this one to be broken if/as necessary to resolve layout issues. let topBarWidthConstraint = topBar.widthAnchor.constraint(equalTo: view.safeAreaLayoutGuide.widthAnchor) @@ -261,10 +262,11 @@ open class InputViewController: UIInputViewController, KeymanWebDelegate { } else { topBar.topAnchor.constraint(equalTo: view.layoutMarginsGuide.topAnchor).isActive = true topBar.leftAnchor.constraint(equalTo: view.layoutMarginsGuide.leftAnchor).isActive = true + topBar.rightAnchor.constraint(equalTo: view.layoutMarginsGuide.rightAnchor).isActive = true // Allow this one to be broken if/as necessary to resolve layout issues. let topBarWidthConstraint = topBar.widthAnchor.constraint(equalTo: view.layoutMarginsGuide.widthAnchor) - //topBarWidthConstraint.priority = UILayoutPriority(rawValue: 999) + topBarWidthConstraint.priority = UILayoutPriority(rawValue: 999) topBarWidthConstraint.isActive = true } @@ -276,18 +278,55 @@ open class InputViewController: UIInputViewController, KeymanWebDelegate { if #available(iOSApplicationExtension 11.0, *) { container.bottomAnchor.constraint(equalTo:view.safeAreaLayoutGuide.bottomAnchor).isActive = true - container.widthAnchor.constraint(equalTo:view.safeAreaLayoutGuide.widthAnchor).isActive = true container.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor).isActive = true + container.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor).isActive = true + + // Allow these to be broken if/as necessary to resolve layout issues. + let kbdWidthConstraint = container.widthAnchor.constraint(equalTo: view.safeAreaLayoutGuide.widthAnchor) + kbdWidthConstraint.priority = UILayoutPriority(rawValue: 999) + kbdWidthConstraint.isActive = true + + let kbdHeightConstraint = container.heightAnchor.constraint(equalToConstant: CGFloat(200))//container.heightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.heightAnchor) + // Cannot be met, but helps to 'force' height for the system keyboard. + kbdHeightConstraint.priority = UILayoutPriority(rawValue: 999) + kbdHeightConstraint.isActive = true; } else { // Fallback on earlier versions container.bottomAnchor.constraint(equalTo:view.layoutMarginsGuide.bottomAnchor).isActive = true - container.widthAnchor.constraint(equalTo:view.layoutMarginsGuide.widthAnchor).isActive = true container.leftAnchor.constraint(equalTo:view.layoutMarginsGuide.leftAnchor).isActive = true + container.rightAnchor.constraint(equalTo:view.layoutMarginsGuide.rightAnchor).isActive = true + + // Allow these to be broken if/as necessary to resolve layout issues. + let kbdWidthConstraint = container.widthAnchor.constraint(equalTo: view.layoutMarginsGuide.widthAnchor) + kbdWidthConstraint.priority = UILayoutPriority(rawValue: 999) + kbdWidthConstraint.isActive = true + + let kbdHeightConstraint = container.heightAnchor.constraint(equalToConstant: CGFloat(200))//container.heightAnchor.constraint(equalTo: view.layoutMarginsGuide.heightAnchor) + // Cannot be met, but helps to 'force' height for the system keyboard. + kbdHeightConstraint.priority = UILayoutPriority(rawValue: 999) + kbdHeightConstraint.isActive = true; } + fixLayout() + } + + func fixLayout() { view.setNeedsLayout() view.layoutIfNeeded() } + + open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { + super.viewWillTransition(to: size, with: coordinator) + + coordinator.animateAlongsideTransition(in: nil, animation: { + _ in + self.fixLayout() + }, completion: { + _ in + self.fixLayout() + self.updateViewConstraints() + }) + } @objc func enableInputClickSound() { isInputClickSoundEnabled = true diff --git a/ios/engine/KMEI/KeymanEngine/Classes/KeymanWebViewController.swift b/ios/engine/KMEI/KeymanEngine/Classes/KeymanWebViewController.swift index c8f9165e97..8158b485d1 100644 --- a/ios/engine/KMEI/KeymanEngine/Classes/KeymanWebViewController.swift +++ b/ios/engine/KMEI/KeymanEngine/Classes/KeymanWebViewController.swift @@ -63,9 +63,12 @@ class KeymanWebViewController: UIViewController { func fixLayout() { view.setNeedsLayout() view.layoutIfNeeded() - + setOskWidth(Int(view.bounds.size.width)) setOskHeight(Int(view.bounds.size.height)) + + log.info("Setting keyboard width: \(view.bounds.size.width)") + log.info("Setting keyboard height: \(view.bounds.size.height)") } open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { diff --git a/ios/keyman/Keyman/Keyman.xcodeproj/project.pbxproj b/ios/keyman/Keyman/Keyman.xcodeproj/project.pbxproj index f5bac9da36..c0bb98e50b 100644 --- a/ios/keyman/Keyman/Keyman.xcodeproj/project.pbxproj +++ b/ios/keyman/Keyman/Keyman.xcodeproj/project.pbxproj @@ -1073,7 +1073,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if which swiftlint >/dev/null; then\n swiftlint --config ../../.swiftlint.yml\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi"; + shellScript = "if which swiftlint >/dev/null; then\n swiftlint --config ../../.swiftlint.yml\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/ios/keyman/Keyman/Keyman.xcodeproj/xcshareddata/xcschemes/SWKeyboard.xcscheme b/ios/keyman/Keyman/Keyman.xcodeproj/xcshareddata/xcschemes/SWKeyboard.xcscheme new file mode 100644 index 0000000000..5c3891afc0 --- /dev/null +++ b/ios/keyman/Keyman/Keyman.xcodeproj/xcshareddata/xcschemes/SWKeyboard.xcscheme @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +