mirror of
https://github.com/keymanapp/keyman.git
synced 2026-11-03 09:37:47 +00:00
fix(ios): Fixes online help link versioning
This commit is contained in:
parent
3fa975ee37
commit
a67eb966c4
3 changed files with 31 additions and 2 deletions
|
|
@ -40,6 +40,26 @@ public struct Version: Comparable {
|
|||
self.components = components
|
||||
}
|
||||
|
||||
public init?(_ components: [Int]) {
|
||||
if components.count == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var string = ""
|
||||
|
||||
for i in components {
|
||||
guard i >= 0 else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let dot = (string == "" ? "" : ".")
|
||||
string = "\(string)\(dot)\(i)"
|
||||
}
|
||||
|
||||
self.string = string
|
||||
self.components = components // Swift arrays are value types, not reference types!
|
||||
}
|
||||
|
||||
public static func <(lhs: Version, rhs: Version) -> Bool {
|
||||
let len = max(lhs.components.count, rhs.components.count)
|
||||
for i in 0..<len {
|
||||
|
|
@ -63,4 +83,13 @@ public struct Version: Comparable {
|
|||
public var description: String {
|
||||
return self.string
|
||||
}
|
||||
|
||||
public var majorMinor: Version {
|
||||
if(self.components.count >= 2) {
|
||||
return Version([self.components[0], self.components[1]])!
|
||||
} else {
|
||||
// If we somehow have just a major version, append a simple '0'.
|
||||
return Version([self.components[0], 0])!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class InfoViewController: UIViewController, UIWebViewDelegate {
|
|||
}
|
||||
|
||||
private func loadFromServer() {
|
||||
let appVersion = Version.current
|
||||
let appVersion = Version.current.majorMinor
|
||||
let url = "https://help.keyman.com/products/iphone-and-ipad/\(appVersion.string)/?embed=ios"
|
||||
webView.loadRequest(URLRequest(url: URL(string: url)!))
|
||||
log.debug("Info page URL: \(url)")
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class SetUpViewController: UIViewController, UIWebViewDelegate {
|
|||
}
|
||||
|
||||
private func loadFromServer() {
|
||||
let appVersion = Version.current
|
||||
let appVersion = Version.current.majorMinor
|
||||
let url = "https://help.keyman.com/products/iphone-and-ipad/\(appVersion.string)"
|
||||
+ "/installing-system-keyboard.php?embed=ios"
|
||||
webView.loadRequest(URLRequest(url: URL(string: url)!))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue