blob: b9f5f02e7fd11edf3dedfc2ada880b31cc88d8b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
//
// AccountViewController.swift
// MullvadVPN
//
// Created by pronebird on 20/03/2019.
// Copyright © 2019 Amagicom AB. All rights reserved.
//
import UIKit
class AccountViewController: UIViewController {
@IBOutlet var accountLabel: UILabel!
@IBOutlet var expiryLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
updateView()
}
// MARK: - Actions
@IBAction func doBuyCredits() {
UIApplication.shared.open(WebLinks.purchaseURL, options: [:])
}
@IBAction func doLogout() {
Account.logout()
performSegue(withIdentifier: SegueIdentifier.Account.logout.rawValue, sender: self)
}
// MARK: - Private
private func updateView() {
accountLabel.text = Account.token
if let expiryDate = Account.expiry {
let accountExpiry = AccountExpiry(date: expiryDate)
if accountExpiry.isExpired {
expiryLabel.text = NSLocalizedString("OUT OF TIME", tableName: "Settings", comment: "")
expiryLabel.textColor = .dangerColor
} else {
expiryLabel.text = accountExpiry.formattedDate
expiryLabel.textColor = .white
}
}
}
}
|