Commit 46ef788a authored by Thomas Markiewicz's avatar Thomas Markiewicz

Merge branch 'l1_branding_2' into 'master'

Updates for Librem One

See merge request !1
parents 82674ee6 14f4a781
......@@ -2,7 +2,7 @@
"images" : [
{
"idiom" : "universal",
"filename" : "piaWhiteCopy.pdf"
"filename" : "nav-logo-white@3x"
}
],
"info" : {
......
......@@ -2,7 +2,7 @@
"images" : [
{
"idiom" : "universal",
"filename" : "piaDark2Copy2.pdf"
"filename" : "nav-logo@3x.png"
}
],
"info" : {
......
......@@ -2,7 +2,7 @@
"images" : [
{
"idiom" : "universal",
"filename" : "piaDark2Copy2.pdf"
"filename" : "nav-logo@3x.png"
}
],
"info" : {
......
......@@ -9,18 +9,19 @@
"login.title" = "Sign in to your account";
"login.username.placeholder" = "Username (p1234567)";
"login.password.placeholder" = "Password";
"login.username.l1Placeholder" = "Librem One address";
"login.password.l1Placeholder" = "Passphrase";
"login.submit" = "LOGIN";
"login.restore.button" = "Didn't receive account details?";
"login.error.title" = "Log in";
"login.error.validation" = "You must enter a username and password.";
"login.error.unauthorized" = "Your username or password is incorrect.";
"login.error.validation" = "You must enter a username and passphrase.";
"login.error.unauthorized" = "Your username or passphrase is incorrect.";
"login.error.throttled" = "Too many failed login attempts with this username. Please try again later.";
"login.receipt.button" = "Login using purchase receipt";
"login.magic.link.title" = "Login using magic email link";
"login.magic.link.response" = "Please check your e-mail for a login link.";
"login.magic.link.send" = "Send Link";
"login.magic.link.invalid.email" = "Invalid email. Please try again.";
"purchase.title" = "Select a VPN plan";
"purchase.subtitle" = "30-day money back guarantee";
"purchase.email.placeholder" = "Email address";
......
......@@ -68,7 +68,8 @@ internal struct ImageAsset {
#if os(iOS) || os(tvOS)
let image = Image(named: name, in: bundle, compatibleWith: nil)
#elseif os(macOS)
let image = bundle.image(forResource: NSImage.Name(name))
let name = NSImage.Name(self.name)
let image = (bundle == .main) ? NSImage(named: name) : bundle.image(forResource: name)
#elseif os(watchOS)
let image = Image(named: name)
#endif
......@@ -97,7 +98,11 @@ internal extension ImageAsset.Image {
// swiftlint:disable convenience_type
private final class BundleToken {
static let bundle: Bundle = {
Bundle(for: BundleToken.self)
#if SWIFT_PACKAGE
return Bundle.module
#else
return Bundle(for: BundleToken.self)
#endif
}()
}
// swiftlint:enable convenience_type
......@@ -8,7 +8,7 @@ import Foundation
// MARK: - Strings
// swiftlint:disable explicit_type_interface function_parameter_count identifier_name line_length
// swiftlint:disable nesting type_body_length type_name
// swiftlint:disable nesting type_body_length type_name vertical_whitespace_opening_braces
internal enum L10n {
internal enum Signup {
internal enum Failure {
......@@ -263,9 +263,9 @@ internal enum L10n {
internal static let throttled = L10n.tr("Welcome", "login.error.throttled")
/// Log in
internal static let title = L10n.tr("Welcome", "login.error.title")
/// Your username or password is incorrect.
/// Your username or passphrase is incorrect.
internal static let unauthorized = L10n.tr("Welcome", "login.error.unauthorized")
/// You must enter a username and password.
/// You must enter a username and passphrase.
internal static let validation = L10n.tr("Welcome", "login.error.validation")
}
internal enum Magic {
......@@ -283,6 +283,8 @@ internal enum L10n {
}
}
internal enum Password {
/// Passphrase
internal static let l1Placeholder = L10n.tr("Welcome", "login.password.l1Placeholder")
/// Password
internal static let placeholder = L10n.tr("Welcome", "login.password.placeholder")
}
......@@ -295,6 +297,8 @@ internal enum L10n {
internal static let button = L10n.tr("Welcome", "login.restore.button")
}
internal enum Username {
/// Librem One address
internal static let l1Placeholder = L10n.tr("Welcome", "login.username.l1Placeholder")
/// Username (p1234567)
internal static let placeholder = L10n.tr("Welcome", "login.username.placeholder")
}
......@@ -424,7 +428,7 @@ internal enum L10n {
}
}
// swiftlint:enable explicit_type_interface function_parameter_count identifier_name line_length
// swiftlint:enable nesting type_body_length type_name
// swiftlint:enable nesting type_body_length type_name vertical_whitespace_opening_braces
// MARK: - Implementation Details
......@@ -438,7 +442,11 @@ extension L10n {
// swiftlint:disable convenience_type
private final class BundleToken {
static let bundle: Bundle = {
Bundle(for: BundleToken.self)
#if SWIFT_PACKAGE
return Bundle.module
#else
return Bundle(for: BundleToken.self)
#endif
}()
}
// swiftlint:enable convenience_type
......@@ -27,7 +27,7 @@ public class GetStartedViewController: PIAWelcomeViewController {
private static let smallDeviceMaxViewHeight: CGFloat = 520
private static let maxViewHeight: CGFloat = 500
private static let extraViewButtonsHeight: CGFloat = 48
private static let defaultViewHeight: CGFloat = 276
private static let defaultViewHeight: CGFloat = 100
@IBOutlet private weak var spinner: UIActivityIndicatorView!
......@@ -120,9 +120,12 @@ public class GetStartedViewController: PIAWelcomeViewController {
pageControl.numberOfPages = allData.count
visualEffectView.clipsToBounds = true
visualEffectView.layer.cornerRadius = 15
visualEffectView.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMinXMinYCorner]
/* Removed for L1
//visualEffectView.layer.cornerRadius = 15
//visualEffectView.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMinXMinYCorner]
*/
let swipeDown = UISwipeGestureRecognizer(target: self, action: #selector(self.respondToSwipeGesture))
swipeDown.direction = UISwipeGestureRecognizer.Direction.down
self.view.addGestureRecognizer(swipeDown)
......@@ -136,7 +139,7 @@ public class GetStartedViewController: PIAWelcomeViewController {
}
@objc func respondToSwipeGesture(gesture: UIGestureRecognizer) {
/* Removed for L1
if let swipeGesture = gesture as? UISwipeGestureRecognizer {
switch swipeGesture.direction {
......@@ -148,7 +151,7 @@ public class GetStartedViewController: PIAWelcomeViewController {
break
}
}
*/
}
override public func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
......
......@@ -71,8 +71,8 @@ class LoginViewController: AutolayoutViewController, WelcomeChild {
NotificationCenter.default.addObserver(self, selector: #selector(finishLoginWithMagicLink), name: .PIAFinishLoginWithMagicLink, object: nil)
labelTitle.text = L10n.Welcome.Login.title
textUsername.placeholder = L10n.Welcome.Login.Username.placeholder
textPassword.placeholder = L10n.Welcome.Login.Password.placeholder
textUsername.placeholder = L10n.Welcome.Login.Username.l1Placeholder
textPassword.placeholder = L10n.Welcome.Login.Password.l1Placeholder
textUsername.text = preset.loginUsername
textPassword.text = preset.loginPassword
......@@ -256,8 +256,6 @@ class LoginViewController: AutolayoutViewController, WelcomeChild {
/* START Librem One specific */
// assume here for now that 'username' is in a form of an email
// if there is no @ sign, should I assume it's just the "username" part? (I think so...)
let emailParts = username.split(separator: "@")
let librem_username = emailParts[0]
let librem_domain = emailParts.count > 1 ? emailParts[1] : "librem.one";
......@@ -270,6 +268,8 @@ class LoginViewController: AutolayoutViewController, WelcomeChild {
Alamofire.request(libremOneAccountUrl, headers: headers).responseJSON { response in
var errorMessage: String?
if let result = response.result.value {
// got some result successfully - get PIA username and password out of it
......@@ -282,6 +282,9 @@ class LoginViewController: AutolayoutViewController, WelcomeChild {
self.logInToPIA(tunnelUser, tunnelPassword, username)
} else {
log.error("Failed to obtain valid PIA username and password from Librem One");
errorMessage = L10n.Welcome.Login.Error.unauthorized
Macros.displayImageNote(withImage: Asset.iconWarning.image,
message: errorMessage ?? L10n.Welcome.Login.Error.title)
self.enableInteractions(true)
self.hideLoadingAnimation()
}
......@@ -289,6 +292,9 @@ class LoginViewController: AutolayoutViewController, WelcomeChild {
log.error("Failed to obtain a response from Librem One login attempt");
self.enableInteractions(true)
self.hideLoadingAnimation()
Macros.displayImageNote(withImage: Asset.iconWarning.image,
message: L10n.Welcome.Login.Error.title)
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment