Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dynamic text on settings headers and footers #800

Merged
merged 1 commit into from
Dec 18, 2020
Merged
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
17 changes: 12 additions & 5 deletions DuckDuckGo/Base.lproj/Settings.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="w88-u3-TgK">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17506" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="w88-u3-TgK">
<device id="retina6_5" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17126"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17505"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="collection view cell content view" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand Down Expand Up @@ -1130,10 +1130,17 @@ After all, the internet shouldn’t feel so creepy, and getting the privacy you
<rect key="frame" x="0.0" y="0.0" width="414" height="72"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="These sites will not be enhanced by Privacy Protection." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zvh-2e-Wmz" userLabel="Info Label">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" usesAttributedText="YES" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zvh-2e-Wmz" userLabel="Info Label">
<rect key="frame" x="60" y="20" width="294" height="32"/>
<fontDescription key="fontDescription" name="ProximaNova-Regular" family="Proxima Nova" pointSize="14"/>
<color key="textColor" red="0.7434888482093811" green="0.76165848970413208" blue="0.79455751180648804" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<attributedString key="attributedText">
<fragment content="These sites will not be enhanced by Privacy Protection.">
<attributes>
<color key="NSColor" red="0.7434888482093811" green="0.76165848970413208" blue="0.79455751180648804" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<font key="NSFont" size="14" name="ProximaNova-Regular"/>
<paragraphStyle key="NSParagraphStyle" alignment="center" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0"/>
</attributes>
</fragment>
</attributedString>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="SWM-CB-n4U">
Expand Down
17 changes: 9 additions & 8 deletions DuckDuckGo/DoNotSellSettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,20 @@ class DoNotSellSettingsViewController: UITableViewController {
@IBOutlet weak var disclaimerTextView: UITextView!

private lazy var appSettings = AppDependencyProvider.shared.appSettings

let learnMoreStr = "Learn More"


override func viewDidLoad() {
super.viewDidLoad()

doNotSellToggle.isOn = appSettings.sendDoNotSell

let fontSize = SettingsViewController.fontSizeForHeaderView
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineHeightMultiple = 1.16
infoTextView.attributedText = NSAttributedString(string: UserText.doNotSellInfoText,
attributes: [
NSAttributedString.Key.kern: -0.08,
NSAttributedString.Key.paragraphStyle: paragraphStyle,
NSAttributedString.Key.font: UIFont.systemFont(ofSize: 13)
NSAttributedString.Key.font: UIFont.systemFont(ofSize: fontSize)
])

infoTextView.backgroundColor = .clear
Expand Down Expand Up @@ -93,28 +92,30 @@ extension DoNotSellSettingsViewController: Themable {
func applyAtributes(theme: Theme) {
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineHeightMultiple = 1.16
let fontSize = SettingsViewController.fontSizeForHeaderView
let tempStr = NSMutableAttributedString(string: UserText.doNotSellDisclaimerBold,
attributes: [
NSAttributedString.Key.kern: -0.08,
NSAttributedString.Key.paragraphStyle: paragraphStyle,
NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 13),
NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: fontSize),
NSAttributedString.Key.foregroundColor: theme.tableHeaderTextColor
])
tempStr.append(NSAttributedString(string: UserText.doNotSellDisclaimerSuffix,
attributes: [
NSAttributedString.Key.kern: -0.08,
NSAttributedString.Key.paragraphStyle: paragraphStyle,
NSAttributedString.Key.font: UIFont.systemFont(ofSize: 13),
NSAttributedString.Key.font: UIFont.systemFont(ofSize: fontSize),
NSAttributedString.Key.foregroundColor: theme.tableHeaderTextColor
]))
tempStr.append(NSAttributedString(string: UserText.doNotSellLearnMore,
attributes: [
NSAttributedString.Key.link: "ddgQuickLink://duckduckgo.com/global-privacy-control-learn-more"
NSAttributedString.Key.link: "ddgQuickLink://duckduckgo.com/global-privacy-control-learn-more",
NSAttributedString.Key.font: UIFont.systemFont(ofSize: fontSize)
]))
let linkAttributes: [NSAttributedString.Key: Any] = [
NSAttributedString.Key.kern: -0.08,
NSAttributedString.Key.paragraphStyle: paragraphStyle,
NSAttributedString.Key.font: UIFont.systemFont(ofSize: 13),
NSAttributedString.Key.font: UIFont.systemFont(ofSize: fontSize),
NSAttributedString.Key.foregroundColor: theme.searchBarTextColor,
NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue
]
Expand Down
34 changes: 34 additions & 0 deletions DuckDuckGo/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,37 @@ extension MFMailComposeViewController {
return MFMailComposeViewController()
}
}

extension SettingsViewController {
static var fontSizeForHeaderView: CGFloat {
let contentSize = UIApplication.shared.preferredContentSizeCategory
switch contentSize {
case .extraSmall:
return 12
case .small:
return 12
case .medium:
return 12
case .large:
return 13
case .extraLarge:
return 15
case .extraExtraLarge:
return 17
case .extraExtraExtraLarge:
return 19
case .accessibilityMedium:
return 23
case .accessibilityLarge:
return 27
case .accessibilityExtraLarge:
return 33
case .accessibilityExtraExtraLarge:
return 38
case .accessibilityExtraExtraExtraLarge:
return 44
default:
return 13
}
}
}
6 changes: 6 additions & 0 deletions DuckDuckGo/UnprotectedSitesViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ class UnprotectedSitesViewController: UITableViewController {
refreshToolbarItems(animated: false)

configureBackButton()

let fontSize = SettingsViewController.fontSizeForHeaderView
let text = NSAttributedString(string: infoText.text ?? "", attributes: [
NSAttributedString.Key.font: UIFont.systemFont(ofSize: fontSize)
])
infoText.attributedText = text
}

override func viewWillDisappear(_ animated: Bool) {
Expand Down