Skip to content

Commit

Permalink
PIA-675: Moved UI related code from PIALibrary
Browse files Browse the repository at this point in the history
  • Loading branch information
Waleed Mahmood authored and kp-said-rehouni committed Nov 22, 2023
1 parent cc600bd commit 8fedc67
Show file tree
Hide file tree
Showing 248 changed files with 16,447 additions and 2,576 deletions.
484 changes: 435 additions & 49 deletions PIA VPN.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions PIA VPN.xcodeproj/xcshareddata/xcschemes/PIA VPN.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@
ReferencedContainer = "container:PIA VPN.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "69B70AAF2ACBF51C0072A09D"
BuildableName = "PIA-VPN_E2E_Tests.xctest"
BlueprintName = "PIA-VPN_E2E_Tests"
ReferencedContainer = "container:PIA VPN.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
6 changes: 3 additions & 3 deletions PIA VPN/AboutComponentCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,17 @@ class AboutLicenseCell: UITableViewCell, Restylable {

var moreImage: UIImage?
if isExpanded {
moreImage = Asset.buttonUp.image
moreImage = Asset.Images.buttonUp.image
textLicense.isScrollEnabled = true
} else {
moreImage = Asset.buttonDown.image
moreImage = Asset.Images.buttonDown.image
textLicense.isScrollEnabled = false
}
buttonMore.setImage(moreImage, for: .normal)

buttonName.accessibilityTraits = UIAccessibilityTraits.none
buttonName.accessibilityLabel = component.name
buttonName.accessibilityHint = L10n.About.Accessibility.Component.expand
buttonName.accessibilityHint = L10n.Localizable.About.Accessibility.Component.expand
}

// MARK: Actions
Expand Down
8 changes: 4 additions & 4 deletions PIA VPN/AboutViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class AboutViewController: AutolayoutViewController {
override func viewDidLoad() {
super.viewDidLoad()

let textApp = L10n.About.app
let textApp = L10n.Localizable.About.app
labelIntro.text = "Copyright © \(AppConfiguration.About.copyright) \(AppConfiguration.About.companyName)\n\(textApp) \(Macros.versionFullString()!)"
tableView.scrollsToTop = true

Expand All @@ -67,7 +67,7 @@ class AboutViewController: AutolayoutViewController {

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
styleNavigationBarWithTitle(L10n.Menu.Item.about)
styleNavigationBarWithTitle(L10n.Localizable.Menu.Item.about)
}

override func viewDidLayoutSubviews() {
Expand All @@ -92,7 +92,7 @@ class AboutViewController: AutolayoutViewController {
// MARK: Helpers

@objc private func viewHasRotated() {
styleNavigationBarWithTitle(L10n.Menu.Item.settings)
styleNavigationBarWithTitle(L10n.Localizable.Menu.Item.settings)
}

private func loadLicensesInBackground() {
Expand Down Expand Up @@ -122,7 +122,7 @@ class AboutViewController: AutolayoutViewController {

tableView.separatorInset = UIEdgeInsets(top: 0, left: 30, bottom: 0, right: 0)
Theme.current.applyDividerToSeparator(tableView)
styleNavigationBarWithTitle(L10n.Menu.Item.about)
styleNavigationBarWithTitle(L10n.Localizable.Menu.Item.about)
// XXX: for some reason, UITableView is not affected by appearance updates
if let viewContainer = viewContainer {
Theme.current.applyPrincipalBackground(view)
Expand Down
4 changes: 2 additions & 2 deletions PIA VPN/AccountObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ class AccountObserver {

let note = UNMutableNotificationContent()

note.title = L10n.Expiration.title
note.body = L10n.Expiration.message
note.title = L10n.Localizable.Expiration.title
note.body = L10n.Localizable.Expiration.message
note.userInfo = ["date": date]
note.sound = .default
note.badge = 1
Expand Down
58 changes: 29 additions & 29 deletions PIA VPN/AccountViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ class AccountViewController: AutolayoutViewController {
override func viewDidLoad() {
super.viewDidLoad()

title = L10n.Menu.Item.account
labelUsername.text = L10n.Account.Username.caption
labelRestoreTitle.text = L10n.Account.Restore.title
labelRestoreInfo.text = L10n.Account.Restore.description
title = L10n.Localizable.Menu.Item.account
labelUsername.text = L10n.Localizable.Account.Username.caption
labelRestoreTitle.text = L10n.Localizable.Account.Restore.title
labelRestoreInfo.text = L10n.Localizable.Account.Restore.description
imageViewTrash.image = Theme.current.trashIconImage()
buttonRestore.setTitle(L10n.Account.Restore.button.uppercased(), for: .normal)
buttonRestore.setTitle(L10n.Localizable.Account.Restore.button.uppercased(), for: .normal)
labelSubscriptions.attributedText = Theme.current.textWithColoredLink(
withMessage: L10n.Account.Subscriptions.message,
link: L10n.Account.Subscriptions.linkMessage)
withMessage: L10n.Localizable.Account.Subscriptions.message,
link: L10n.Localizable.Account.Subscriptions.linkMessage)
labelSubscriptions.isUserInteractionEnabled = true

viewSafe.layoutMargins = .zero
Expand All @@ -98,7 +98,7 @@ class AccountViewController: AutolayoutViewController {
super.viewWillAppear(animated)

// update local state immediately
styleNavigationBarWithTitle(L10n.Menu.Item.account)
styleNavigationBarWithTitle(L10n.Localizable.Menu.Item.account)
redisplayAccount()
}

Expand All @@ -114,7 +114,7 @@ class AccountViewController: AutolayoutViewController {
}

@objc private func viewHasRotated() {
styleNavigationBarWithTitle(L10n.Menu.Item.settings)
styleNavigationBarWithTitle(L10n.Localizable.Menu.Item.settings)
}

// MARK: Actions
Expand All @@ -131,11 +131,11 @@ class AccountViewController: AutolayoutViewController {

@IBAction private func deleteUserAccount(_ sender: Any?) {
let sheet = Macros.alert(
L10n.Account.Delete.Alert.title,
L10n.Account.Delete.Alert.message
L10n.Localizable.Account.Delete.Alert.title,
L10n.Localizable.Account.Delete.Alert.message
)
sheet.addCancelAction(L10n.Global.no)
sheet.addDestructiveActionWithTitle(L10n.Global.yes) {
sheet.addCancelAction(L10n.Localizable.Global.no)
sheet.addDestructiveActionWithTitle(L10n.Localizable.Global.yes) {
self.showLoadingAnimation()
log.debug("Account: Deleting...")

Expand All @@ -154,8 +154,8 @@ class AccountViewController: AutolayoutViewController {
}
} else {
self.hideLoadingAnimation()
let sheet = Macros.alert(nil, L10n.Account.Delete.Alert.failureMessage)
sheet.addCancelAction(L10n.Global.ok)
let sheet = Macros.alert(nil, L10n.Localizable.Account.Delete.Alert.failureMessage)
sheet.addCancelAction(L10n.Localizable.Global.ok)
self.present(sheet, animated: true, completion: nil)
log.debug("Account: Deleting failed...")
}
Expand All @@ -180,37 +180,37 @@ class AccountViewController: AutolayoutViewController {
private func handleReceiptFailureWithError(_ error: Error?) {
log.error("IAP: Failed to restore payment receipt (error: \(error?.localizedDescription ?? ""))")

let alert = Macros.alert(L10n.Global.error, error?.localizedDescription)
alert.addDefaultAction(L10n.Global.close)
let alert = Macros.alert(L10n.Localizable.Global.error, error?.localizedDescription)
alert.addDefaultAction(L10n.Localizable.Global.close)
present(alert, animated: true, completion: nil)
}

private func handleReceiptSubmissionWithError(_ error: Error?) {
if let error = error {
let alert = Macros.alert(L10n.Global.error, error.localizedDescription)
alert.addDefaultAction(L10n.Global.close)
let alert = Macros.alert(L10n.Localizable.Global.error, error.localizedDescription)
alert.addDefaultAction(L10n.Localizable.Global.close)
present(alert, animated: true, completion: nil)
return
}

log.debug("Account: Renewal successfully completed")

let alert = Macros.alert(
L10n.Renewal.Success.title,
L10n.Renewal.Success.message
L10n.Localizable.Renewal.Success.title,
L10n.Localizable.Renewal.Success.message
)
alert.addDefaultAction(L10n.Global.close)
alert.addDefaultAction(L10n.Localizable.Global.close)
present(alert, animated: true, completion: nil)

redisplayAccount()
}

private func handleBadReceipt() {
let alert = Macros.alert(
L10n.Account.Restore.Failure.title,
L10n.Account.Restore.Failure.message
L10n.Localizable.Account.Restore.Failure.title,
L10n.Localizable.Account.Restore.Failure.message
)
alert.addDefaultAction(L10n.Global.close)
alert.addDefaultAction(L10n.Localizable.Global.close)
present(alert, animated: true, completion: nil)
}

Expand All @@ -231,9 +231,9 @@ class AccountViewController: AutolayoutViewController {

if let userInfo = currentUser?.info {
if userInfo.isExpired {
labelExpiryInformation.text = L10n.Account.ExpiryDate.expired
labelExpiryInformation.text = L10n.Localizable.Account.ExpiryDate.expired
} else {
labelExpiryInformation.text = L10n.Account.ExpiryDate.information(userInfo.humanReadableExpirationDate())
labelExpiryInformation.text = L10n.Localizable.Account.ExpiryDate.information(userInfo.humanReadableExpirationDate())
}
styleExpirationDate()

Expand Down Expand Up @@ -264,7 +264,7 @@ class AccountViewController: AutolayoutViewController {

self.viewAccountInfo.layer.cornerRadius = 5.0

styleNavigationBarWithTitle(L10n.Menu.Item.account)
styleNavigationBarWithTitle(L10n.Localizable.Menu.Item.account)

if let viewContainer = viewContainer {
Theme.current.applyPrincipalBackground(view)
Expand All @@ -279,7 +279,7 @@ class AccountViewController: AutolayoutViewController {
for label in [labelExpiryInformation!] {
Theme.current.applySubtitle(label)
}
Theme.current.applyUnderline(labelDeleteAccount, with: L10n.Account.delete)
Theme.current.applyUnderline(labelDeleteAccount, with: L10n.Localizable.Account.delete)
Theme.current.applyTitle(labelRestoreTitle, appearance: .dark)
Theme.current.applySubtitle(labelRestoreInfo)
buttonRestore.style(style: TextStyle.textStyle9)
Expand Down
4 changes: 2 additions & 2 deletions PIA VPN/ActiveDedicatedIpHeaderViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class ActiveDedicatedIpHeaderViewCell: UITableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
self.backgroundColor = .clear
self.title.text = L10n.Dedicated.Ip.title
self.subtitle.text = L10n.Dedicated.Ip.Limit.title
self.title.text = L10n.Localizable.Dedicated.Ip.title
self.subtitle.text = L10n.Localizable.Dedicated.Ip.Limit.title
}

func setup() {
Expand Down
Loading

0 comments on commit 8fedc67

Please sign in to comment.