From 7ca9990dbc12d02615c0934cfc76be89a46492ae Mon Sep 17 00:00:00 2001 From: Kyle Hickinson Date: Mon, 27 Nov 2023 13:15:33 -0500 Subject: [PATCH] Ref brave/brave-ios#8417: Hide "Not Secure" label when tab location view is too small (brave/brave-ios#8488) Also shrinks the placeholder label to fit since it can sometimes get truncated in compact configurations --- .../Browser/Toolbars/UrlBar/TabLocationView.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Sources/Brave/Frontend/Browser/Toolbars/UrlBar/TabLocationView.swift b/Sources/Brave/Frontend/Browser/Toolbars/UrlBar/TabLocationView.swift index 1c2c95fe1ddd..d14012d2012a 100644 --- a/Sources/Brave/Frontend/Browser/Toolbars/UrlBar/TabLocationView.swift +++ b/Sources/Brave/Frontend/Browser/Toolbars/UrlBar/TabLocationView.swift @@ -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: @@ -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 @@ -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)