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

Commit

Permalink
Closes #1494 Just-in time information – Tracking Protection (#1611)
Browse files Browse the repository at this point in the history
  • Loading branch information
NSBaguette authored and sblatz committed Dec 20, 2018
1 parent 3b57d11 commit a647f90
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Blockzilla/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ class BrowserViewController: UIViewController {
private func buildTrackingProtectionMenu(info: TPPageStats?) -> PhotonActionSheet {
var actions = [[PhotonActionSheetItem]]()
if info != nil {
let titleItem = PhotonActionSheetItem(title: UIConstants.strings.trackingProtectionLabel, iconString: "tracking_protection", isEnabled: true, accessory: .Switch)
let titleItem = PhotonActionSheetItem(title: UIConstants.strings.trackingProtectionLabel, text: UIConstants.strings.trackingProtectionLabelDescription, textStyle: .subtitle, iconString: "tracking_protection", isEnabled: true, accessory: .Switch)
actions.append([titleItem])
} else {
let titleItem = PhotonActionSheetItem(title: UIConstants.strings.trackingProtectionLabel, iconString: "tracking_protection_off", isEnabled: false, accessory: .Switch)
Expand Down
14 changes: 13 additions & 1 deletion Blockzilla/PhotonActionSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@ public struct PhotonActionSheetItem {
case right
}

public enum TextStyle {
case normal
case subtitle
}

public fileprivate(set) var title: String
public fileprivate(set) var text: String?
public fileprivate(set) var textStyle: TextStyle
public fileprivate(set) var iconString: String?
public fileprivate(set) var iconURL: URL?
public fileprivate(set) var iconAlignment: IconAlignment
Expand All @@ -52,14 +58,15 @@ public struct PhotonActionSheetItem {
public fileprivate(set) var bold: Bool = false
public fileprivate(set) var handler: ((PhotonActionSheetItem) -> Void)?

init(title: String, text: String? = nil, iconString: String? = nil, iconAlignment: IconAlignment = .left, isEnabled: Bool = false, accessory: PhotonActionSheetCellAccessoryType = .None, accessoryText: String? = nil, bold: Bool? = false, handler: ((PhotonActionSheetItem) -> Void)? = nil) {
init(title: String, text: String? = nil, textStyle: TextStyle = .normal, iconString: String? = nil, iconAlignment: IconAlignment = .left, isEnabled: Bool = false, accessory: PhotonActionSheetCellAccessoryType = .None, accessoryText: String? = nil, bold: Bool? = false, handler: ((PhotonActionSheetItem) -> Void)? = nil) {
self.title = title
self.iconString = iconString
self.iconAlignment = iconAlignment
self.isEnabled = isEnabled
self.accessory = accessory
self.handler = handler
self.text = text
self.textStyle = textStyle
self.accessoryText = accessoryText
self.bold = bold ?? false
}
Expand Down Expand Up @@ -565,6 +572,11 @@ private class PhotonActionSheetCell: UITableViewCell {
statusIcon.removeFromSuperview()
}

if action.textStyle == .subtitle {
subtitleLabel.textColor = UIConstants.colors.actionMenuItemSubtitleLabel
subtitleLabel.font = UIConstants.fonts.actionMenuItemSubtitle
}

switch action.accessory {
case .Text:
disclosureLabel.font = action.bold ? UIConstants.fonts.actionMenuItemBold : UIConstants.fonts.actionMenuItem
Expand Down
3 changes: 3 additions & 0 deletions Blockzilla/UIConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct UIConstants {
static let whatsNew = UIConstants.Photon.Teal50
static let settingsNavBar = UIConstants.Photon.Ink80.withAlphaComponent(0.9)
static let settingsNavBorder = UIConstants.Photon.Grey10.withAlphaComponent(0.5)
static let actionMenuItemSubtitleLabel = UIConstants.Photon.Grey10.withAlphaComponent(0.6)

static let inputPlaceholder = UIColor(rgb: 0xb2b2b2)

Expand Down Expand Up @@ -170,6 +171,7 @@ struct UIConstants {
static let actionMenuItem = UIFont.systemFont(ofSize: 16)
static let actionMenuTitle = UIFont.systemFont(ofSize: 12)
static let actionMenuItemBold = UIFont.systemFont(ofSize: 16, weight: UIFont.Weight.bold)
static let actionMenuItemSubtitle = UIFont.systemFont(ofSize: 12)
}

struct layout {
Expand Down Expand Up @@ -354,6 +356,7 @@ struct UIConstants {
static let linkYouCopied = NSLocalizedString("contextMenu.clipboardLink", value: "Link you copied: %@", comment: "Text for the context menu when a user has a link on their clipboard.") // deprecated
static let copiedLink = NSLocalizedString("contextMenu.linkCopied", value: "Link you copied: ", comment: "Text for the context menu when a user has a link on their clipboard.")
static let trackingProtectionLabel = NSLocalizedString("trackingProtection.label", value: "Tracking Protection", comment: "Title for the tracking settings page to change what trackers are blocked.")
static let trackingProtectionLabelDescription = NSLocalizedString("trackingProtection.labelDescription", value: "Turning this off may fix some site problems", comment: "Description/subtitle for the tracking protection label.")
static let trackingProtectionToggleLabel = NSLocalizedString("trackingProtection.toggleLabel", value: "Tracking Protection", comment: "Text for the toggle that temporarily disables tracking protection.") // deprecated
static let trackingProtectionToggleDescription = NSLocalizedString("trackingProtection.toggleDescription1", value: "Disable until you close %@ or tap ERASE.", comment: "Description for the tracking protection toggle. Placeholder is either Firefox Focus or Firefox Klar")
static let trackingProtectionDisabledLabel = NSLocalizedString("trackingProtection.disabledLabel", value: "Tracking Protection off", comment: "text showing the tracking protection is disabled.")
Expand Down

0 comments on commit a647f90

Please sign in to comment.