Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Adding Title for Tb Tray Authentication screen
Browse files Browse the repository at this point in the history
  • Loading branch information
soner-yuksel committed Aug 3, 2023
1 parent 60278c8 commit a26d0b0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class TabTrayController: AuthenticationController {
self.tabManager = tabManager
self.braveCore = braveCore

super.init(windowProtection: windowProtection, isCancellable: true)
super.init(windowProtection: windowProtection, isCancellable: true, unlockScreentitle: "Private Browsing is Locked")

if !UIAccessibility.isReduceMotionEnabled {
transitioningDelegate = self
Expand Down
22 changes: 21 additions & 1 deletion Sources/Brave/Frontend/Passcode/WindowProtection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ public class WindowProtection {
private class LockedViewController: UIViewController {
let backgroundView = UIVisualEffectView(effect: UIBlurEffect(style: .systemThickMaterial))
let lockImageView = UIImageView(image: UIImage(named: "browser-lock-icon", in: .module, compatibleWith: nil)!)
let titleLabel = UILabel().then {
$0.font = .preferredFont(for: .title3, weight: .semibold)
$0.adjustsFontForContentSizeCategory = true
$0.textColor = .bravePrimary
$0.numberOfLines = 0
$0.textAlignment = .center
}
let unlockButton = FilledActionButton(type: .system).then {
$0.setTitle(Strings.unlockButtonTitle, for: .normal)
$0.titleLabel?.font = .preferredFont(forTextStyle: .headline)
$0.titleLabel?.adjustsFontForContentSizeCategory = true
$0.backgroundColor = .braveBlurpleTint
$0.isHidden = true
}

let cancelButton = ActionButton(type: .system).then {
$0.setTitle(Strings.cancelButtonTitle, for: .normal)
$0.titleLabel?.font = .preferredFont(forTextStyle: .headline)
Expand All @@ -39,12 +45,19 @@ public class WindowProtection {
super.viewDidLoad()

view.addSubview(backgroundView)
view.addSubview(titleLabel)
view.addSubview(lockImageView)
view.addSubview(unlockButton)
view.addSubview(cancelButton)
backgroundView.snp.makeConstraints {
$0.edges.equalTo(view)
}
titleLabel.snp.makeConstraints {
$0.leading.greaterThanOrEqualToSuperview().offset(20)
$0.trailing.lessThanOrEqualToSuperview().offset(-20)
$0.centerX.equalToSuperview()
$0.bottom.equalTo(lockImageView.snp.top).offset(-40)
}
lockImageView.snp.makeConstraints {
$0.center.equalTo(view)
}
Expand Down Expand Up @@ -103,6 +116,13 @@ public class WindowProtection {
}
}

var unlockScreentitle: String = "" {
didSet {
lockedViewController.titleLabel.isHidden = unlockScreentitle.isEmpty
lockedViewController.titleLabel.text = unlockScreentitle
}
}

private let onCancelPressed = PassthroughSubject<Void, Never>()
private let didFinalizeAuthentication = PassthroughSubject<Bool, Never>()

Expand Down
4 changes: 3 additions & 1 deletion Sources/Brave/Frontend/Widgets/LoadingViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ public class AuthenticationController: LoadingViewController {

init(windowProtection: WindowProtection? = nil,
requiresAuthentication: Bool = false,
isCancellable: Bool = false) {
isCancellable: Bool = false,
unlockScreentitle: String = "") {
self.windowProtection = windowProtection
self.requiresAuthentication = requiresAuthentication

super.init(nibName: nil, bundle: nil)

self.windowProtection?.isCancellable = isCancellable
self.windowProtection?.unlockScreentitle = unlockScreentitle
}

required init?(coder: NSCoder) {
Expand Down

0 comments on commit a26d0b0

Please sign in to comment.