Skip to content

Commit

Permalink
Ref brave/brave-ios#8417: Hide "Not Secure" label when tab location v…
Browse files Browse the repository at this point in the history
…iew is too small (brave/brave-ios#8488)

Also shrinks the placeholder label to fit since it can sometimes get truncated in compact configurations
  • Loading branch information
kylehickinson authored Nov 27, 2023
1 parent cff1d5e commit 7ca9990
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class TabLocationView: UIView {
var title = AttributedString(Strings.tabToolbarNotSecureTitle)
title.font = .preferredFont(forTextStyle: .subheadline, compatibleWith: clampedTraitCollection)

let isTitleVisible = !traitCollection.preferredContentSizeCategory.isAccessibilityCategory
let isTitleVisible = !traitCollection.preferredContentSizeCategory.isAccessibilityCategory && bounds.width > 200

switch secureContentState {
case .localhost, .secure:
Expand Down Expand Up @@ -226,6 +226,8 @@ class TabLocationView: UIView {
private let placeholderLabel = UILabel().then {
$0.text = Strings.tabToolbarSearchAddressPlaceholderText
$0.isHidden = true
$0.adjustsFontSizeToFitWidth = true
$0.minimumScaleFactor = 0.5
}

// A layout guide defining the available space for the URL itself
Expand Down Expand Up @@ -366,6 +368,12 @@ class TabLocationView: UIView {
}
}

override func layoutSubviews() {
super.layoutSubviews()

secureContentStateButton?.setNeedsUpdateConfiguration()
}

private func updateForTraitCollection() {
let clampedTraitCollection = traitCollection.clampingSizeCategory(maximum: .accessibilityLarge)
let toolbarTraitCollection = UITraitCollection(preferredContentSizeCategory: traitCollection.toolbarButtonContentSizeCategory)
Expand Down

0 comments on commit 7ca9990

Please sign in to comment.