Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public struct StandardImageIdentifiers {
public static let starOneHalfFill = "starOneHalfFillMedium"
public static let sun = "sunMedium"
public static let sunFill = "sunFillMedium"
public static let translate = "translateMedium"
public static let translateActive = "translateActiveMedium"
}

// Icon size 24x24
Expand Down
21 changes: 18 additions & 3 deletions BrowserKit/Sources/ToolbarKit/ToolbarButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ToolbarButton: UIButton, ThemeApplicable, UIGestureRecognizerDelegate {

private var isTextButton = false
private var hasCustomColor = false
private var hasHighlightedColor = false

override init(frame: CGRect) {
super.init(frame: frame)
Expand All @@ -59,6 +60,7 @@ class ToolbarButton: UIButton, ThemeApplicable, UIGestureRecognizerDelegate {
isSelected = element.isSelected
isTextButton = element.title != nil
hasCustomColor = element.hasCustomColor
hasHighlightedColor = element.hasHighlightedColor
self.notificationCenter = notificationCenter

let image = imageConfiguredForRTL(for: element)
Expand Down Expand Up @@ -208,9 +210,22 @@ class ToolbarButton: UIButton, ThemeApplicable, UIGestureRecognizerDelegate {
}

private func imageConfiguredForRTL(for element: ToolbarElement) -> UIImage? {
if let existingImage = configuration?.image { return existingImage }
// TODO: FXIOS-11973 For MVP purpose, should revisit
let inactiveImageName = StandardImageIdentifiers.Medium.translate
let activeImageName = StandardImageIdentifiers.Medium.translateActive
let isTranslateButton = element.iconName == inactiveImageName || element.iconName == activeImageName

if let existingImage = configuration?.image, !isTranslateButton {
return existingImage
}

guard let iconName = element.iconName else { return nil }
let image = UIImage(named: iconName)?.withRenderingMode(.alwaysTemplate)
var image = UIImage(named: iconName)?.withRenderingMode(.alwaysTemplate)

if element.iconName == StandardImageIdentifiers.Medium.translateActive {
image = UIImage(named: iconName)
}

return element.isFlippedForRTL ? image?.imageFlippedForRightToLeftLayoutDirection() : image
}

Expand Down Expand Up @@ -257,7 +272,7 @@ class ToolbarButton: UIButton, ThemeApplicable, UIGestureRecognizerDelegate {
public func applyTheme(theme: Theme) {
let colors = theme.colors
foregroundColorNormal = hasCustomColor ? colors.iconSecondary : colors.iconPrimary
foregroundColorHighlighted = colors.actionPrimary
foregroundColorHighlighted = hasHighlightedColor ? colors.actionPrimary : colors.iconPrimary
foregroundColorDisabled = colors.iconDisabled
backgroundColorNormal = .clear

Expand Down
5 changes: 5 additions & 0 deletions BrowserKit/Sources/ToolbarKit/ToolbarElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public struct ToolbarElement: Equatable {
/// Indicates if the element has a custom color
let hasCustomColor: Bool

/// Indicates if the element has a highlighted color when tapping on it
let hasHighlightedColor: Bool

/// Title to display in the large content viewer
let largeContentTitle: String?

Expand Down Expand Up @@ -74,6 +77,7 @@ public struct ToolbarElement: Equatable {
isFlippedForRTL: Bool = false,
isSelected: Bool = false,
hasCustomColor: Bool = false,
hasHighlightedColor: Bool = false,
largeContentTitle: String? = nil,
contextualHintType: String? = nil,
a11yLabel: String,
Expand All @@ -93,6 +97,7 @@ public struct ToolbarElement: Equatable {
self.isFlippedForRTL = isFlippedForRTL
self.isSelected = isSelected
self.hasCustomColor = hasCustomColor
self.hasHighlightedColor = hasHighlightedColor
self.largeContentTitle = largeContentTitle
self.contextualHintType = contextualHintType
self.onSelected = onSelected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct AccessibilityIdentifiers {
static let searchButton = "TabToolbar.searchButton"
static let stopButton = "TabToolbar.stopButton"
static let bookmarksButton = "TabToolbar.libraryButton"
static let translateButton = "TabToolbar.translateButton"
}

struct Browser {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "translateActive.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "translate-24.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2447,6 +2447,9 @@ class BrowserViewController: UIViewController,
lockIconImageName: lockIconImageName,
lockIconNeedsTheming: lockIconNeedsTheming,
safeListedURLImageName: safeListedURLImageName,
translationConfiguration: TranslationConfiguration(
hasTranslated: false
),
windowUUID: windowUUID,
actionType: ToolbarActionType.urlDidChange)
store.dispatchLegacy(action)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ final class AddressToolbarContainerModel: Equatable {
isFlippedForRTL: action.isFlippedForRTL,
isSelected: action.isSelected,
hasCustomColor: action.hasCustomColor,
hasHighlightedColor: action.hasHighlightedColor,
largeContentTitle: action.largeContentTitle,
contextualHintType: action.contextualHintType,
a11yLabel: action.a11yLabel,
Expand Down Expand Up @@ -313,6 +314,7 @@ final class AddressToolbarContainerModel: Equatable {

static func == (lhs: AddressToolbarContainerModel, rhs: AddressToolbarContainerModel) -> Bool {
lhs.navigationActions == rhs.navigationActions &&
lhs.leadingPageActions == rhs.leadingPageActions &&
lhs.trailingPageActions == rhs.trailingPageActions &&
lhs.browserActions == rhs.browserActions &&

Expand Down
Loading
Loading