Skip to content

Commit

Permalink
FXIOS-10392 #22779 ⁃ [Menu Redesign] Menu CFR's text is cut off: "Fin…
Browse files Browse the repository at this point in the history
…d what you need faster, fro..."
  • Loading branch information
dicarobinho committed Oct 30, 2024
1 parent 84794fd commit d344ee1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ public class ContextualHintView: UIView, ThemeApplicable {
label.font = FXFontStyles.Regular.headline.scaledFont()
label.textAlignment = .left
label.numberOfLines = 0
label.adjustsFontForContentSizeCategory = true
}

private lazy var descriptionLabel: UILabel = .build { label in
label.font = FXFontStyles.Regular.body.scaledFont()
label.textAlignment = .left
label.numberOfLines = 0
label.adjustsFontForContentSizeCategory = true
}

private lazy var actionButton: LinkButton = .build { button in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ class MainMenuViewController: UIViewController,
FeatureFlaggable {
private struct UX {
static let hintViewCornerRadius: CGFloat = 20
static let hintViewHeight: CGFloat = 120
static let hintViewHeight: CGFloat = 140
static let hintViewMargin: CGFloat = 20
}
typealias SubscriberStateType = MainMenuState

// MARK: - UI/UX elements
private lazy var menuContent: MenuMainView = .build()
private var hintView: ContextualHintView = .build { view in
view.isAccessibilityElement = true
}
private var hintViewHeightConstraint: NSLayoutConstraint?

// MARK: - Properties
var notificationCenter: NotificationProtocol
Expand All @@ -40,8 +44,6 @@ class MainMenuViewController: UIViewController,
private var menuState: MainMenuState
private let logger: Logger

private var hintView: ContextualHintView = .build()

let viewProvider: ContextualHintViewProvider

var currentWindowUUID: UUID? { return windowUUID }
Expand Down Expand Up @@ -203,12 +205,14 @@ class MainMenuViewController: UIViewController,
hintView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: UX.hintViewMargin),
hintView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -UX.hintViewMargin),
hintView.bottomAnchor.constraint(equalTo: menuContent.accountHeaderView.topAnchor,
constant: -UX.hintViewMargin),
hintView.heightAnchor.constraint(equalToConstant: UX.hintViewHeight)
constant: -UX.hintViewMargin)
])
hintViewHeightConstraint = hintView.heightAnchor.constraint(equalToConstant: UX.hintViewHeight)
hintViewHeightConstraint?.isActive = true
}
hintView.layer.cornerRadius = UX.hintViewCornerRadius
hintView.layer.masksToBounds = true
adjustLayout()
}

// MARK: - Redux
Expand Down Expand Up @@ -318,6 +322,20 @@ class MainMenuViewController: UIViewController,

private func adjustLayout() {
menuContent.accountHeaderView.adjustLayout()
if let screenHeight = view.window?.windowScene?.screen.bounds.height {
let isPad = UIDevice.current.userInterfaceIdiom == .pad
let maxHeight: CGFloat = if isPad {
(screenHeight - view.frame.height) / 2 - UX.hintViewMargin * 2
} else {
screenHeight - view.frame.height - UX.hintViewMargin * 4
}
let height = min(UIFontMetrics.default.scaledValue(for: UX.hintViewHeight), maxHeight)
let contentSizeCategory = UIApplication.shared.preferredContentSizeCategory
hintViewHeightConstraint?.constant =
contentSizeCategory.isAccessibilityCategory ? height : UX.hintViewHeight
}
view.setNeedsLayout()
view.layoutIfNeeded()
}

private func shouldDisplayHintView() -> Bool {
Expand Down

0 comments on commit d344ee1

Please sign in to comment.