SystemKeyboard now takes up actual space, though isn't yet displaying.

This commit is contained in:
Joshua A. Horton 2018-11-30 08:30:52 +07:00
parent 0bce40cd70
commit 0cfd4828fa
4 changed files with 130 additions and 5 deletions

View file

@ -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

View file

@ -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) {

View file

@ -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 */

View file

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1000"
wasCreatedForAppExtension = "YES"
version = "2.0">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "98CD125B19CA85710089385F"
BuildableName = "SWKeyboard.appex"
BlueprintName = "SWKeyboard"
ReferencedContainer = "container:Keyman.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
launchAutomaticallySubstyle = "2">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "98CD125B19CA85710089385F"
BuildableName = "SWKeyboard.appex"
BlueprintName = "SWKeyboard"
ReferencedContainer = "container:Keyman.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
launchAutomaticallySubstyle = "2">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "98CD125B19CA85710089385F"
BuildableName = "SWKeyboard.appex"
BlueprintName = "SWKeyboard"
ReferencedContainer = "container:Keyman.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>