Skip to content

Commit

Permalink
Merge branch 'main' into tc/FXIOS-9860-NIC-integration-with-redux-rel…
Browse files Browse the repository at this point in the history
…oad-button
  • Loading branch information
tusharC95 authored Oct 10, 2024
2 parents 9ed098a + 24cc9ca commit 120eb46
Show file tree
Hide file tree
Showing 607 changed files with 16,790 additions and 2,581 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ python-env/
.*.sw*
buildServer.json
.nvim/
.swiftformat

# IDEA
.idea
Expand Down
24 changes: 12 additions & 12 deletions .mergify.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
queue_rules:
- name: default
conditions:
- name: rebase-queue
queue_conditions:
- check-success=Bitrise
merge_method: rebase
- name: squash-queue
queue_conditions:
- check-success=Bitrise
merge_method: squash

pull_request_rules:
- name: Resolve conflict
Expand All @@ -22,8 +27,7 @@ pull_request_rules:
type: APPROVE
message: Github-action[bot] 💪
queue:
method: rebase
name: default
name: rebase-queue
- name: Rust Component Upgrade - Auto Merge
conditions:
- author=github-actions[bot]
Expand All @@ -35,8 +39,7 @@ pull_request_rules:
type: APPROVE
message: Github-action[bot] 💪
queue:
method: rebase
name: default
name: rebase-queue
- name: L10N - Auto Merge
conditions:
- author=github-actions[bot]
Expand All @@ -48,8 +51,7 @@ pull_request_rules:
type: APPROVE
message: LGTM 😎
queue:
method: rebase
name: default
name: rebase-queue
- name: Needs landing - Rebase
conditions:
- check-success=Bitrise
Expand All @@ -59,8 +61,7 @@ pull_request_rules:
- label!=Do Not Merge ⛔️
actions:
queue:
method: rebase
name: default
name: rebase-queue
- name: Needs landing - Squash
conditions:
- check-success=Bitrise
Expand All @@ -70,5 +71,4 @@ pull_request_rules:
- label!=Do Not Merge ⛔️
actions:
queue:
method: squash
name: default
name: squash-queue
6 changes: 4 additions & 2 deletions BrowserKit/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ let package = Package(
exact: "2.0.0"),
.package(
url: "https://github.com/getsentry/sentry-cocoa.git",
exact: "8.36.0"),
exact: "8.21.0"),
.package(
url: "https://github.com/nbhasin2/GCDWebServer.git",
branch: "master"),
Expand All @@ -74,13 +74,15 @@ let package = Package(
.target(
name: "SiteImageView",
dependencies: ["Fuzi", "Kingfisher", "Common", "SwiftDraw"],
exclude: ["README.md"],
resources: [.process("BundledTopSitesFavicons.xcassets")],
swiftSettings: [.unsafeFlags(["-enable-testing"])]),
.testTarget(
name: "SiteImageViewTests",
dependencies: ["SiteImageView", .product(name: "GCDWebServers", package: "GCDWebServer")],
resources: [
.copy("Resources/mozilla.ico"),
.copy("Resources/hackernews.svg"),
.copy("Resources/hackernews.svg")
]
),
.target(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import Foundation
/// When adding new identifiers, please respect alphabetical order.
/// Sing the song if you must.
public struct StandardImageIdentifiers {
// Icon size 8x8
public struct ExtraSmall {
public static let chevronDown = "chevronDownExtraSmall"
}

// Icon size 16x16
public struct Small {
public static let externalLink = "externalLinkSmall"
Expand All @@ -32,14 +37,15 @@ public struct StandardImageIdentifiers {

// Icon size 24x24
public struct Large {
public static let addToHomeScreen = "addToHomescreenLarge"
public static let addToHomescreen = "addToHomescreenLarge"
public static let appendUpLeft = "appendUpLeftLarge"
public static let appMenu = "appMenuLarge"
public static let arrowClockwise = "arrowClockwiseLarge"
public static let avatarCircle = "avatarCircleLarge"
public static let back = "backLarge"
public static let bookmark = "bookmarkLarge"
public static let bookmarkFill = "bookmarkFillLarge"
public static let bookmarkHalf = "bookmarkHalfLarge"
public static let bookmarkSlash = "bookmarkSlashLarge"
public static let bookmarkTrayFill = "bookmarkTrayFillLarge"
public static let checkmark = "checkmarkLarge"
Expand Down Expand Up @@ -109,13 +115,13 @@ public struct StandardImageIdentifiers {
public static let shieldSlash = "shieldSlashLarge"
public static let shipping = "shippingLarge"
public static let shopping = "shoppingLarge"
public static let socialTracker = "socialMediaLarge"
public static let socialMedia = "socialMediaLarge"
public static let subtract = "subtractLarge"
public static let sync = "syncLarge"
public static let syncTabs = "syncTabsLarge"
public static let tab = "tabLarge"
public static let tabTray = "tabTrayLarge"
public static let tools = "toolLarge"
public static let tool = "toolLarge"
public static let warning = "warningLarge"
public static let warningFill = "warningFillLarge"
public static let whatsNew = "whatsNewLarge"
Expand Down
14 changes: 13 additions & 1 deletion BrowserKit/Sources/Common/Logger/LoggerCategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,25 @@ import Foundation
/// Categories are sorted in alphabetical order.
/// Do not add new categories unless discussing with the team beforehand.
public enum LoggerCategory: String {
/// Related to content (trackers, advertisements) blocking
case adblock

/// Related to address and credit card autofill
case autofill

/// Related to the certificate handler
case certificate

/// Related to coordinator navigation
case coordinator

/// Related to experiments, nimbus and the messaging framework.
case experiments

/// Related to homepage UI and it's data management.
/// Related to old homepage UI and it's data management. To be replaced by the homepage rebuild project.
case legacyHomepage

/// Related to new homepage UI and it's data management for the homepage rebuild project.
case homepage

/// Related to errors around image fetches, and includes all image types (`SiteImageType`, and general images).
Expand Down Expand Up @@ -50,4 +59,7 @@ public enum LoggerCategory: String {

/// Multi-window management on iPad devices
case window

/// Remote settings
case remoteSettings
}
116 changes: 83 additions & 33 deletions BrowserKit/Sources/ComponentLibrary/Headers/HeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public final class HeaderView: UIView, ThemeApplicable {
private struct UX {
static let headerLinesLimit: Int = 2
static let siteDomainLabelsVerticalSpacing: CGFloat = 12
static let faviconImageSize: CGFloat = 40
static let largeFaviconImageSize: CGFloat = 48
static let favIconImageSize: CGFloat = 32
static let smallFaviconImageSize: CGFloat = 20
static let maskFaviconImageSize: CGFloat = 32
static let horizontalMargin: CGFloat = 16
Expand All @@ -20,9 +21,7 @@ public final class HeaderView: UIView, ThemeApplicable {
}

public var closeButtonCallback: (() -> Void)?

private var faviconHeightConstraint: NSLayoutConstraint?
private var faviconWidthConstraint: NSLayoutConstraint?
public var mainButtonCallback: (() -> Void)?

private lazy var headerLabelsContainer: UIStackView = .build { stack in
stack.backgroundColor = .clear
Expand All @@ -43,40 +42,53 @@ public final class HeaderView: UIView, ThemeApplicable {

private let subtitleLabel: UILabel = .build { label in
label.font = FXFontStyles.Regular.caption1.scaledFont()
label.numberOfLines = 0
label.numberOfLines = 2
label.adjustsFontForContentSizeCategory = true
}

private lazy var closeButton: CloseButton = .build { button in
button.layer.cornerRadius = 0.5 * UX.closeButtonSize
button.addTarget(self, action: #selector(self.closeButtonTapped), for: .touchUpInside)
}

private lazy var mainButton: UIButton = .build { button in
button.backgroundColor = .clear
button.addTarget(self, action: #selector(self.mainButtonTapped), for: .touchUpInside)
}

private var iconMask: UIView = .build { view in
view.backgroundColor = .clear
}

private let horizontalLine: UIView = .build()

private var viewConstraints: [NSLayoutConstraint] = []

init() {
super.init(frame: .zero)
setupLayout()
setupViews()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func setupLayout() {
private func setupViews() {
headerLabelsContainer.addArrangedSubview(titleLabel)
headerLabelsContainer.addArrangedSubview(subtitleLabel)
addSubviews(iconMask, favicon, headerLabelsContainer, closeButton, horizontalLine)
NSLayoutConstraint.activate([
addSubviews(mainButton, iconMask, favicon, headerLabelsContainer, closeButton, horizontalLine)
}

private func updateLayout(isAccessibilityCategory: Bool, isWebsiteIcon: Bool) {
removeConstraints(constraints)
favicon.removeConstraints(favicon.constraints)
closeButton.removeConstraints(closeButton.constraints)
iconMask.removeConstraints(iconMask.constraints)
viewConstraints.removeAll()
viewConstraints.append(contentsOf: [
favicon.leadingAnchor.constraint(
equalTo: self.leadingAnchor,
constant: UX.horizontalMargin
),
favicon.centerYAnchor.constraint(equalTo: self.centerYAnchor),

headerLabelsContainer.topAnchor.constraint(
equalTo: self.topAnchor,
Expand All @@ -96,26 +108,60 @@ public final class HeaderView: UIView, ThemeApplicable {
),

closeButton.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -UX.horizontalMargin),
closeButton.heightAnchor.constraint(greaterThanOrEqualToConstant: UX.closeButtonSize),
closeButton.widthAnchor.constraint(greaterThanOrEqualToConstant: UX.closeButtonSize),
closeButton.centerYAnchor.constraint(equalTo: centerYAnchor),

horizontalLine.leadingAnchor.constraint(equalTo: leadingAnchor),
horizontalLine.trailingAnchor.constraint(equalTo: trailingAnchor),
horizontalLine.bottomAnchor.constraint(equalTo: bottomAnchor),
horizontalLine.heightAnchor.constraint(equalToConstant: UX.separatorHeight),

iconMask.widthAnchor.constraint(equalToConstant: UX.maskFaviconImageSize),
iconMask.heightAnchor.constraint(equalToConstant: UX.maskFaviconImageSize),
iconMask.centerXAnchor.constraint(equalTo: favicon.centerXAnchor),
iconMask.centerYAnchor.constraint(equalTo: favicon.centerYAnchor)
iconMask.centerYAnchor.constraint(equalTo: favicon.centerYAnchor),

mainButton.leadingAnchor.constraint(equalTo: iconMask.leadingAnchor),
mainButton.trailingAnchor.constraint(equalTo: headerLabelsContainer.trailingAnchor),
mainButton.topAnchor.constraint(equalTo: headerLabelsContainer.topAnchor),
mainButton.bottomAnchor.constraint(equalTo: headerLabelsContainer.bottomAnchor)
])
let favIconSizes = isAccessibilityCategory ? UX.largeFaviconImageSize :
isWebsiteIcon ? UX.favIconImageSize: UX.smallFaviconImageSize
viewConstraints.append(favicon.heightAnchor.constraint(equalToConstant: favIconSizes))
viewConstraints.append(favicon.widthAnchor.constraint(equalToConstant: favIconSizes))

let closeButtonSizes = isAccessibilityCategory ? UX.largeFaviconImageSize : UX.closeButtonSize
viewConstraints.append(closeButton.heightAnchor.constraint(equalToConstant: closeButtonSizes))
viewConstraints.append(closeButton.widthAnchor.constraint(equalToConstant: closeButtonSizes))
closeButton.layer.cornerRadius = 0.5 * closeButtonSizes

let maskButtonSizes = isAccessibilityCategory ? UX.largeFaviconImageSize : UX.maskFaviconImageSize
viewConstraints.append(iconMask.heightAnchor.constraint(equalToConstant: maskButtonSizes))
viewConstraints.append(iconMask.widthAnchor.constraint(equalToConstant: maskButtonSizes))
iconMask.layer.cornerRadius = 0.5 * maskButtonSizes

if isAccessibilityCategory {
viewConstraints.append(favicon.topAnchor.constraint(equalTo: headerLabelsContainer.topAnchor))
viewConstraints.append(closeButton.topAnchor.constraint(equalTo: headerLabelsContainer.topAnchor))
} else {
viewConstraints.append(favicon.centerYAnchor.constraint(equalTo: centerYAnchor))
viewConstraints.append(closeButton.centerYAnchor.constraint(equalTo: centerYAnchor))
}
NSLayoutConstraint.activate(viewConstraints)
}

public func setupAccessibility(closeButtonA11yLabel: String, closeButtonA11yId: String) {
public func setupAccessibility(closeButtonA11yLabel: String,
closeButtonA11yId: String,
mainButtonA11yLabel: String? = nil,
mainButtonA11yId: String? = nil) {
let closeButtonViewModel = CloseButtonViewModel(a11yLabel: closeButtonA11yLabel,
a11yIdentifier: closeButtonA11yId)
closeButton.configure(viewModel: closeButtonViewModel)
if let mainButtonA11yLabel, let mainButtonA11yId {
titleLabel.isAccessibilityElement = false
subtitleLabel.isAccessibilityElement = false
mainButton.accessibilityIdentifier = mainButtonA11yId
mainButton.accessibilityLabel = mainButtonA11yLabel
} else {
mainButton.isAccessibilityElement = false
}
}

public func setupDetails(subtitle: String, title: String, icon: FaviconImageViewModel) {
Expand All @@ -132,34 +178,38 @@ public final class HeaderView: UIView, ThemeApplicable {
titleLabel.text = title
}

public func setIcon(isSmaller: Bool = false, theme: Theme? = nil) {
let sizes = isSmaller ? UX.smallFaviconImageSize : UX.faviconImageSize
faviconHeightConstraint = favicon.heightAnchor.constraint(equalToConstant: sizes)
faviconWidthConstraint = favicon.widthAnchor.constraint(equalToConstant: sizes)
faviconHeightConstraint?.isActive = true
faviconWidthConstraint?.isActive = true
if let theme {
iconMask.backgroundColor = theme.colors.layer2
iconMask.layer.cornerRadius = 0.5 * UX.maskFaviconImageSize
favicon.tintColor = theme.colors.iconSecondary
}
public func setIconTheme(with theme: Theme) {
iconMask.backgroundColor = theme.colors.layer2
favicon.tintColor = theme.colors.iconSecondary
}

func setTitle(with text: String) {
titleLabel.text = text
}

public func adjustLayout() {
let faviconDynamicSize = max(UIFontMetrics.default.scaledValue(for: UX.faviconImageSize), UX.faviconImageSize)
faviconHeightConstraint?.constant = faviconDynamicSize
faviconWidthConstraint?.constant = faviconDynamicSize
public func adjustLayout(isWebsiteIcon: Bool = false) {
updateLayout(isAccessibilityCategory: UIApplication.shared.preferredContentSizeCategory.isAccessibilityCategory,
isWebsiteIcon: isWebsiteIcon)
}

public func updateHeaderLineView(isHidden: Bool) {
if (isHidden && !horizontalLine.isHidden) || (!isHidden && horizontalLine.isHidden) {
UIView.animate(withDuration: 0.3) { [weak self] in
self?.horizontalLine.isHidden = isHidden
}
}
}

@objc
func closeButtonTapped() {
closeButtonCallback?()
}

@objc
func mainButtonTapped() {
mainButtonCallback?()
}

public func applyTheme(theme: Theme) {
let buttonImage = UIImage(named: StandardImageIdentifiers.Medium.cross)?
.withTintColor(theme.colors.iconSecondary)
Expand Down
Loading

0 comments on commit 120eb46

Please sign in to comment.