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

Commit

Permalink
Ref #8417: Hide "Not Secure" label when tab location view is too small (
Browse files Browse the repository at this point in the history
#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 917f116 commit ed3ad28
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 ed3ad28

Please sign in to comment.