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

- Complete login flow

- Show warning icon in textfields when status is .error
parent acbbe341
......@@ -77,7 +77,7 @@ public class BorderedTextField: UITextField {
/// :nodoc:
public override func awakeFromNib() {
super.awakeFromNib()
rightViewMode = .unlessEditing
borderStyle = .none
textColor = .darkText
self.delegate = self
......@@ -138,6 +138,12 @@ public class BorderedTextField: UITextField {
return UIEdgeInsetsInsetRect(bounds,
UIEdgeInsetsMake(0, 16, 0, 16))
}
public override func rightViewRect(forBounds bounds: CGRect) -> CGRect {
var rightViewRect = super.rightViewRect(forBounds: bounds)
rightViewRect.origin.x -= 16
return rightViewRect
}
}
......
......@@ -122,12 +122,16 @@ open class AutolayoutViewController: UIViewController, ModalController, Restylab
private func restoreFormElementBorder(_ element: UIView) {
if let element = element as? UITextField {
Theme.current.applyInput(element)
element.rightView = nil
}
}
private func updateFormElementBorder(_ element: UIView) {
if let element = element as? UITextField {
Theme.current.applyInputError(element)
let iconWarning = UIImageView(image:Asset.iconWarning.image.withRenderingMode(.alwaysTemplate))
iconWarning.tintColor = .piaRed
element.rightView = iconWarning
}
}
......
......@@ -21,7 +21,9 @@ public class GetStartedViewController: AutolayoutViewController, ConfigurationAc
@IBOutlet private weak var buyButton: PIAButton!
@IBOutlet private weak var redeemButton: UIButton!
@IBOutlet private weak var couldNotGetPlanButton: UIButton!
var preset = Preset()
private weak var delegate: PIAWelcomeViewControllerDelegate?
deinit {
NotificationCenter.default.removeObserver(self)
......@@ -42,18 +44,30 @@ public class GetStartedViewController: AutolayoutViewController, ConfigurationAc
/**
Creates a wrapped `GetStartedViewController` ready for presentation.
- Parameter preset: The optional `Preset` to configure this controller with
- Parameter delegate: The `PIAWelcomeViewControllerDelegate` to handle raised events
*/
public static func create() -> UIViewController {
public static func with(preset: Preset? = nil, delegate: PIAWelcomeViewControllerDelegate? = nil) -> UIViewController {
let nav = StoryboardScene.Welcome.initialScene.instantiate()
let vc = nav.topViewController as! GetStartedViewController
if let customPreset = preset {
vc.preset = customPreset
}
vc.delegate = delegate
return nav
}
public override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
guard let vc = segue.destination as? PIAWelcomeViewController else {
return
}
vc.delegate = self.delegate
vc.preset = self.preset
switch segue.identifier {
case StoryboardSegue.Welcome.redeemGiftCardSegue.rawValue:
vc.preset.pages = .redeem
......
......@@ -19,8 +19,7 @@ public class PIAWelcomeViewController: AutolayoutViewController, WelcomeCompleti
var preset = Preset()
private var pendingSignupRequest: SignupRequest?
private weak var delegate: PIAWelcomeViewControllerDelegate?
weak var delegate: PIAWelcomeViewControllerDelegate?
/// It's `true` if the controller was created with `Preset.isEphemeral`.
///
......
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