Commit bb4518c4 authored by Jose Blaya's avatar Jose Blaya
Browse files

- Update redeem controllers to adapt views to PIAX.

- Update progress controllers to adapt views to PIAX design.
parent ea245e90
......@@ -2,17 +2,7 @@
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "image-redeem-success@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "image-redeem-success@3x.png",
"scale" : "3x"
"filename" : "07IllustrationRedeemCompleted.pdf"
}
],
"info" : {
......
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="VHM-bG-giz">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="VHM-bG-giz">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
......@@ -1143,7 +1143,7 @@ You will not be charged during this process.</string>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9Ah-aP-Yc5" customClass="TPKeyboardAvoidingScrollView">
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" scrollEnabled="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9Ah-aP-Yc5" customClass="TPKeyboardAvoidingScrollView">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hwf-bV-ShO">
......
......@@ -12,8 +12,8 @@
"success.title" = "Purchase complete";
"success.message_format" = "Thank you for signing up with us. We have sent your account username and password at your email address at %@";
"success.redeem.title" = "Completed!";
"success.redeem.message" = "You will also receive an email shortly with your username and password.";
"success.redeem.title" = "Card redeemed successfully";
"success.redeem.message" = "You will receive an email shortly with your username and password.\n\nYour login details";
"success.username.caption" = "Username";
"success.password.caption" = "Password";
"success.submit" = "GET STARTED";
......
......@@ -38,6 +38,7 @@
"redeem.submit" = "SUBMIT";
"redeem.error.title" = "Redeem";
"redeem.error.code" = "Code must be %lu numeric digits.";
"redeem.error.allfields"="Please type in your email and card PIN.";
"redeem.error.qrcode.invalid" = "Invalid QR code sequence. Please try again.";
"redeem.accessibility.back" = "Back";
"redeem.scanqr" = "Scan QR";
......
......@@ -20,10 +20,22 @@ public class PIAButton: UIButton {
private var isButtonImage = false
private var edgesHaveBeenSet = false
private var renderingModeHasBeenSet = false
private var buttonWidth: CGFloat!
private var borderColor: UIColor!
private var style: TextStyle!
private var currentBackgroundColor: UIColor!
override open var isHighlighted: Bool {
didSet {
if currentBackgroundColor == nil {
currentBackgroundColor = backgroundColor
}
backgroundColor = isHighlighted && currentBackgroundColor != nil ?
currentBackgroundColor.withAlphaComponent(0.8) : currentBackgroundColor
}
}
public var status: PIAButtonStatus = .normal {
didSet { reloadButtonStatus() }
}
......@@ -81,10 +93,14 @@ public class PIAButton: UIButton {
self.isButtonImage = true
}
private func resetEdges() {
self.edgesHaveBeenSet = false
}
private func reloadButtonStatus() {
checkRenderingMode()
if status == .error {
self.edgesHaveBeenSet = false
self.resetEdges()
if let errorColor = TextStyle.textStyle10.color {
self.layer.borderColor = errorColor.cgColor
self.tintColor = errorColor
......@@ -120,18 +136,25 @@ extension PIAButton {
override public func layoutSubviews() {
super.layoutSubviews()
if self.isButtonImage,
!self.edgesHaveBeenSet,
let imageView = imageView {
imageEdgeInsets = UIEdgeInsets(top: 5, left: 5, bottom: 5, right: imageView.frame.width + 10)
titleEdgeInsets = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 5)
self.edgesHaveBeenSet = true
for const in self.constraints {
if const.firstAttribute == .width {
const.constant += imageView.frame.width
self.layoutIfNeeded()
if !self.edgesHaveBeenSet {
const.constant += imageView.frame.width
buttonWidth = const.constant
self.edgesHaveBeenSet = true
break
} else {
const.constant = buttonWidth
break
}
}
}
}
}
}
......@@ -60,9 +60,9 @@ internal enum L10n {
internal static let caption = L10n.tr("Signup", "success.password.caption")
}
internal enum Redeem {
/// You will also receive an email shortly with your username and password.
/// You will receive an email shortly with your username and password.
internal static let message = L10n.tr("Signup", "success.redeem.message")
/// Completed!
/// Card redeemed successfully
internal static let title = L10n.tr("Signup", "success.redeem.title")
}
internal enum Username {
......@@ -252,6 +252,8 @@ internal enum L10n {
internal static let placeholder = L10n.tr("Welcome", "redeem.email.placeholder")
}
internal enum Error {
/// Please type in your email and card PIN.
internal static let allfields = L10n.tr("Welcome", "redeem.error.allfields")
/// Code must be %lu numeric digits.
internal static func code(_ p1: Int) -> String {
return L10n.tr("Welcome", "redeem.error.code", p1)
......
......@@ -20,7 +20,7 @@ extension Theme.Palette {
palette.textfieldButtonBackgroundColor = .white
palette.navigationBarBackIcon = Asset.iconBack.image
palette.brandBackground = Macros.color(hex: 0x009a18, alpha: 0xff)
palette.lightBackground = .groupTableViewBackground
palette.lightBackground = UIColor.piaGrey1
palette.lineColor = .piaGreenDark20
palette.subtitleColor = .piaGrey8
palette.emphasis = Macros.color(hex: 0x29cc41, alpha: 0xff)
......
......@@ -381,7 +381,9 @@ public class Theme {
/// :nodoc:
public func applySubtitle(_ label: UILabel) {
let textAlignment = label.textAlignment
label.style(style: TextStyle.textStyle8)
label.textAlignment = textAlignment
}
/// :nodoc:
......
......@@ -101,7 +101,6 @@ class RedeemViewController: AutolayoutViewController, WelcomeChild {
labelLogin1.text = L10n.Welcome.Purchase.Login.footer
labelLogin2.text = L10n.Welcome.Purchase.Login.button
styleRedeemButton()
viewLogin.accessibilityLabel = "\(labelLogin1.text!) \(labelLogin2.text!)"
textEmail.text = preset.redeemEmail
if let code = preset.redeemCode {
......@@ -112,6 +111,7 @@ class RedeemViewController: AutolayoutViewController, WelcomeChild {
labelSubtitle.textAlignment = .center
configureCameraButton()
styleRedeemButton()
}
......@@ -125,14 +125,29 @@ class RedeemViewController: AutolayoutViewController, WelcomeChild {
scrollView.isScrollEnabled = (traitCollection.verticalSizeClass == .compact)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
cameraButton.backgroundColor = Theme.current.palette.textfieldButtonBackgroundColor
}
// MARK: Actions
@IBAction private func redeem(_ sender: Any?) {
//guard !buttonRedeem.isRunningActivity else {
// return
//}
if textEmail.text?.trimmed().count == 0,
textCode.text?.trimmed().count == 0 {
Macros.displayImageNote(withImage: Asset.iconWarning.image,
message: L10n.Welcome.Redeem.Error.allfields)
self.status = .error(element: textEmail)
self.status = .error(element: textCode)
self.cameraButton.status = .error
return
}
guard let email = textEmail.text?.trimmed(), Validator.validate(email: email) else {
guard let email = textEmail.text?.trimmed(),
Validator.validate(email: email) else {
Macros.displayImageNote(withImage: Asset.iconWarning.image,
message: L10n.Welcome.Purchase.Error.validation)
self.status = .error(element: textEmail)
......@@ -141,7 +156,8 @@ class RedeemViewController: AutolayoutViewController, WelcomeChild {
self.status = .restore(element: textEmail)
guard let code = redeemCode?.trimmed(), Validator.validate(giftCode: code) else {
guard let code = redeemCode?.trimmed(),
Validator.validate(giftCode: code) else {
Macros.displayImageNote(withImage: Asset.iconWarning.image,
message: L10n.Welcome.Redeem.Error.code(RedeemViewController.codeLength))
self.status = .error(element: textCode)
......@@ -222,8 +238,7 @@ class RedeemViewController: AutolayoutViewController, WelcomeChild {
cameraButton.setRounded()
cameraButton.setBorder(withSize: 1,
andStyle: TextStyle.textStyle8)
cameraButton.style(style: TextStyle.textStyle8,
for: [])
cameraButton.style(style: TextStyle.textStyle8)
cameraButton.setTitle(L10n.Welcome.Redeem.scanqr.uppercased(),
for: [])
cameraButton.tintColor = TextStyle.textStyle8.color
......@@ -262,7 +277,7 @@ class RedeemViewController: AutolayoutViewController, WelcomeChild {
private func styleRedeemButton() {
buttonRedeem.setRounded()
buttonRedeem.style(style: TextStyle.Buttons.piaGreenButton)
buttonRedeem.setTitle(L10n.Welcome.Redeem.title,
buttonRedeem.setTitle(L10n.Welcome.Redeem.title.uppercased(),
for: [])
}
......
......@@ -8,18 +8,16 @@
import UIKit
class SignupFailureViewController: AutolayoutViewController {
@IBOutlet private weak var imvPicture: UIImageView!
public class SignupFailureViewController: AutolayoutViewController, BrandableNavigationBar {
@IBOutlet private weak var imvPicture: UIImageView!
@IBOutlet private weak var labelTitle: UILabel!
@IBOutlet private weak var labelMessage: UILabel!
@IBOutlet private weak var buttonSubmit: ActivityButton!
@IBOutlet private weak var buttonSubmit: PIAButton!
var error: Error?
override func viewDidLoad() {
override public func viewDidLoad() {
super.viewDidLoad()
navigationItem.hidesBackButton = true
......@@ -50,7 +48,7 @@ class SignupFailureViewController: AutolayoutViewController {
}
}
buttonSubmit.title = L10n.Signup.Failure.submit.uppercased()
self.styleSubmitButton()
}
@IBAction private func submit() {
......@@ -59,11 +57,22 @@ class SignupFailureViewController: AutolayoutViewController {
// MARK: Restylable
override func viewShouldRestyle() {
override public func viewShouldRestyle() {
super.viewShouldRestyle()
navigationItem.titleView = NavigationLogoView()
Theme.current.applyNavigationBarStyle(to: self)
Theme.current.applyLightBackground(view)
Theme.current.applyLightBackground(viewContainer!)
Theme.current.applyTitle(labelTitle, appearance: .dark)
Theme.current.applyBody1(labelMessage, appearance: .dark)
Theme.current.applyActionButton(buttonSubmit)
Theme.current.applySubtitle(labelMessage)
Theme.current.applyTitle(labelTitle, appearance: .dark)
}
private func styleSubmitButton() {
buttonSubmit.setRounded()
buttonSubmit.style(style: TextStyle.Buttons.piaGreenButton)
buttonSubmit.setTitle(L10n.Signup.Failure.submit.uppercased(),
for: [])
}
}
......@@ -11,9 +11,10 @@ import SwiftyBeaver
private let log = SwiftyBeaver.self
class SignupInProgressViewController: AutolayoutViewController {
public class SignupInProgressViewController: AutolayoutViewController, BrandableNavigationBar {
@IBOutlet private weak var progressView: CircleProgressView!
@IBOutlet private weak var titleMessage: UILabel!
@IBOutlet private weak var labelMessage: UILabel!
var signupRequest: SignupRequest?
......@@ -30,14 +31,14 @@ class SignupInProgressViewController: AutolayoutViewController {
private var error: Error?
override func viewDidLoad() {
override public func viewDidLoad() {
super.viewDidLoad()
title = metadata?.title
labelMessage.text = metadata?.bodySubtitle
titleMessage.text = metadata?.title
}
override func viewWillAppear(_ animated: Bool) {
override public func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
progressView.startAnimating()
......@@ -107,7 +108,7 @@ class SignupInProgressViewController: AutolayoutViewController {
}
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
override public func prepare(for segue: UIStoryboardSegue, sender: Any?) {
guard let identifier = segue.identifier, let segueType = StoryboardSegue.Signup(rawValue: identifier) else {
return
}
......@@ -151,10 +152,14 @@ class SignupInProgressViewController: AutolayoutViewController {
// MARK: Restylable
override func viewShouldRestyle() {
override public func viewShouldRestyle() {
super.viewShouldRestyle()
Theme.current.applyBody1(labelMessage, appearance: .dark)
navigationItem.titleView = NavigationLogoView()
Theme.current.applyNavigationBarStyle(to: self)
Theme.current.applyLightBackground(view)
Theme.current.applyLightBackground(viewContainer!)
Theme.current.applyTitle(titleMessage, appearance: .dark)
Theme.current.applySubtitle(labelMessage)
Theme.current.applyCircleProgressView(progressView)
}
}
......@@ -11,32 +11,26 @@ import SwiftyBeaver
private let log = SwiftyBeaver.self
class SignupSuccessViewController: AutolayoutViewController {
@IBOutlet private weak var imvBackground: UIImageView!
public class SignupSuccessViewController: AutolayoutViewController, BrandableNavigationBar {
@IBOutlet private weak var imvPicture: UIImageView!
@IBOutlet private weak var labelTitle: UILabel!
@IBOutlet private weak var labelMessage: UILabel!
@IBOutlet private weak var labelUsernameCaption: UILabel!
@IBOutlet private weak var labelUsername: UILabel!
@IBOutlet private weak var labelPasswordCaption: UILabel!
@IBOutlet private weak var labelPassword: UILabel!
@IBOutlet private weak var buttonSubmit: PIAButton!
@IBOutlet private weak var usernameContainer: UIView!
@IBOutlet private weak var passwordContainer: UIView!
@IBOutlet private weak var buttonSubmit: ActivityButton!
@IBOutlet private weak var constraintPictureXOffset: NSLayoutConstraint!
var metadata: SignupMetadata?
weak var completionDelegate: WelcomeCompletionDelegate?
override func viewDidLoad() {
override public func viewDidLoad() {
super.viewDidLoad()
guard let metadata = metadata else {
......@@ -57,16 +51,9 @@ class SignupSuccessViewController: AutolayoutViewController {
labelUsername.text = metadata.user?.credentials.username
labelPasswordCaption.text = L10n.Signup.Success.Password.caption
labelPassword.text = metadata.user?.credentials.password
buttonSubmit.title = L10n.Signup.Success.submit.uppercased()
var backgroundImage = Asset.imageReceiptBackground.image
backgroundImage = backgroundImage.withRenderingMode(.alwaysTemplate)
backgroundImage = backgroundImage.resizableImage(
withCapInsets: UIEdgeInsets(top: 0.0, left: 0.0, bottom: 60.0, right: 0.0),
resizingMode: .tile
)
imvBackground.contentMode = .scaleToFill
imvBackground.image = backgroundImage
self.styleSubmitButton()
self.styleContainers()
}
@IBAction private func submit() {
......@@ -78,16 +65,39 @@ class SignupSuccessViewController: AutolayoutViewController {
// MARK: Restylable
override func viewShouldRestyle() {
override public func viewShouldRestyle() {
super.viewShouldRestyle()
navigationItem.titleView = NavigationLogoView()
Theme.current.applyNavigationBarStyle(to: self)
Theme.current.applyLightBackground(view)
Theme.current.applyLightBackground(viewContainer!)
Theme.current.applyLightTint(imvBackground)
Theme.current.applyTitle(labelTitle, appearance: .dark)
Theme.current.applyBody1(labelMessage, appearance: .dark)
Theme.current.applyCaption(labelUsernameCaption, appearance: .dark)
Theme.current.applyBody1(labelUsername, appearance: .dark)
Theme.current.applyCaption(labelPasswordCaption, appearance: .dark)
Theme.current.applyBody1(labelPassword, appearance: .dark)
Theme.current.applyActionButton(buttonSubmit)
Theme.current.applySubtitle(labelMessage)
Theme.current.applySubtitle(labelUsernameCaption)
Theme.current.applyTitle(labelUsername, appearance: .dark)
Theme.current.applySubtitle(labelPasswordCaption)
Theme.current.applyTitle(labelPassword, appearance: .dark)
}
private func styleSubmitButton() {
buttonSubmit.setRounded()
buttonSubmit.style(style: TextStyle.Buttons.piaGreenButton)
buttonSubmit.setTitle(L10n.Signup.Success.submit.uppercased(),
for: [])
}
private func styleContainers() {
self.styleContainerView(usernameContainer)
self.styleContainerView(passwordContainer)
}
func styleContainerView(_ view: UIView) {
view.layer.cornerRadius = 6.0
view.clipsToBounds = true
view.layer.borderWidth = 0.5
view.layer.borderColor = UIColor.piaGrey4.cgColor
}
}
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