Skip to content

Commit

Permalink
Bug 1394362 - Allow font scaling in Onboarding slides. (#3112) r=garvan
Browse files Browse the repository at this point in the history
  • Loading branch information
farhanpatel committed Aug 31, 2017
1 parent acf8db2 commit fdee601
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Client/Frontend/Intro/IntroViewController.swift
Expand Up @@ -8,6 +8,8 @@ import SnapKit
struct IntroViewControllerUX {
static let Width = 375
static let Height = 667
static let SyncButtonTopPadding = 5
static let MinimumFontScale: CGFloat = 0.5

static let CardSlides = ["tour-Welcome", "tour-Search", "tour-Private", "tour-Mail", "tour-Sync"]
static let NumberOfCards = CardSlides.count
Expand Down Expand Up @@ -153,6 +155,9 @@ class IntroViewController: UIViewController, UIScrollViewDelegate {
let textLabel = UILabel()
textLabel.numberOfLines = 0
textLabel.attributedText = attributedStringForLabel(text)
textLabel.adjustsFontSizeToFitWidth = true
textLabel.minimumScaleFactor = IntroViewControllerUX.MinimumFontScale
textLabel.lineBreakMode = .byTruncatingTail
textLabels.append(textLabel)
introView.addSubview(textLabel)
textLabel.snp.makeConstraints({ (make) -> Void in
Expand Down Expand Up @@ -189,6 +194,13 @@ class IntroViewController: UIViewController, UIScrollViewDelegate {
make.bottom.equalTo(syncCardView)
}

// We need a reference to the sync pages textlabel so we can adjust the constraints
if let index = introViews.index(of: syncCardView), index < textLabels.count {
let syncTextLabel = textLabels[index]
syncTextLabel.snp.makeConstraints { make in
make.bottom.equalTo(signInButton.snp.top).offset(-IntroViewControllerUX.SyncButtonTopPadding)
}
}
// Add all the cards to the view, make them invisible with zero alpha
for introView in introViews {
introView.alpha = 0
Expand Down

0 comments on commit fdee601

Please sign in to comment.