Skip to content

Commit

Permalink
feat(account): update AccountView.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajhilje committed Sep 10, 2024
1 parent 5e3a9d9 commit bd9c622
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 1 addition & 2 deletions IVPNClient/Scenes/AccountScreen/AccountViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class AccountViewController: UITableViewController {

@IBAction func toggleAccountHidden(_ sender: Any) {
let hidden = UserDefaults.shared.isAccountHidden
accountView.toggleAccountVisibility(hide: hidden)
accountView.toggleAccountVisibility(hide: !hidden)
UserDefaults.shared.set(!hidden, forKey: UserDefaults.Key.isAccountHidden)
}

Expand All @@ -96,7 +96,6 @@ class AccountViewController: UITableViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
accountView.initQRCode(viewModel: viewModel)
accountView.toggleAccountVisibility(hide: UserDefaults.shared.isAccountHidden)
sessionManager.getSessionStatus()
}

Expand Down
16 changes: 10 additions & 6 deletions IVPNClient/Scenes/AccountScreen/View/AccountView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,29 @@ class AccountView: UITableView {
header.frame = CGRect(x: 0, y: 0, width: Int(header.frame.width), height: headerHeight)
reloadData()
layoutIfNeeded()
toggleAccountVisibility(hide: UserDefaults.shared.isAccountHidden)
}

func initQRCode(viewModel: AccountViewModel) {
qrCodeImage.image = UIImage.generateQRCode(from: viewModel.accountId)
toggleAccountVisibility(hide: UserDefaults.shared.isAccountHidden)
}

func toggleAccountVisibility(hide: Bool) {
if hide {
hideAccountButton.setImage(UIImage.init(systemName: "eye.fill"), for: .normal)
accountIdLabel.removeBlur()
accountIdLabel.alpha = 1
qrCodeImage.removeBlur()
qrCodeImage.alpha = 1
} else {
hideAccountButton.setImage(UIImage.init(systemName: "eye.slash.fill"), for: .normal)
accountIdLabel.removeBlur()
accountIdLabel.addBlur(2)
accountIdLabel.alpha = 0.7
qrCodeImage.removeBlur()
qrCodeImage.addBlur(2)
qrCodeImage.alpha = 0.5
} else {
hideAccountButton.setImage(UIImage.init(systemName: "eye.fill"), for: .normal)
accountIdLabel.removeBlur()
accountIdLabel.alpha = 1
qrCodeImage.removeBlur()
qrCodeImage.alpha = 1
}
}

Expand Down

0 comments on commit bd9c622

Please sign in to comment.