Update font sizes in onboarding views.

pull/2/head
Matthew Chen 6 years ago
parent 6bc46fad66
commit 8cfe768e86

@ -488,9 +488,9 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
[onboardingController [onboardingController
updateWithPhoneNumber:[[OnboardingPhoneNumber alloc] initWithE164:@"+13213214321" userInput:@"3213214321"]]; updateWithPhoneNumber:[[OnboardingPhoneNumber alloc] initWithE164:@"+13213214321" userInput:@"3213214321"]];
// UIViewController *view = [onboardingController initialViewController]; UIViewController *view = [onboardingController initialViewController];
UIViewController *view = // UIViewController *view =
[[OnboardingPhoneNumberViewController alloc] initWithOnboardingController:onboardingController]; // [[OnboardingPermissionsViewController alloc] initWithOnboardingController:onboardingController];
OWSNavigationController *navigationController = OWSNavigationController *navigationController =
[[OWSNavigationController alloc] initWithRootViewController:view]; [[OWSNavigationController alloc] initWithRootViewController:view];
[self presentViewController:navigationController animated:YES completion:nil]; [self presentViewController:navigationController animated:YES completion:nil];

@ -31,7 +31,7 @@ public class OnboardingBaseViewController: OWSViewController {
let titleLabel = UILabel() let titleLabel = UILabel()
titleLabel.text = text titleLabel.text = text
titleLabel.textColor = Theme.primaryColor titleLabel.textColor = Theme.primaryColor
titleLabel.font = UIFont.ows_dynamicTypeTitle1.ows_mediumWeight() titleLabel.font = UIFont.ows_dynamicTypeTitle1Clamped.ows_mediumWeight()
titleLabel.numberOfLines = 0 titleLabel.numberOfLines = 0
titleLabel.lineBreakMode = .byWordWrapping titleLabel.lineBreakMode = .byWordWrapping
titleLabel.textAlignment = .center titleLabel.textAlignment = .center
@ -41,7 +41,7 @@ public class OnboardingBaseViewController: OWSViewController {
func explanationLabel(explanationText: String) -> UILabel { func explanationLabel(explanationText: String) -> UILabel {
let explanationLabel = UILabel() let explanationLabel = UILabel()
explanationLabel.textColor = Theme.secondaryColor explanationLabel.textColor = Theme.secondaryColor
explanationLabel.font = UIFont.ows_dynamicTypeCaption1 explanationLabel.font = UIFont.ows_dynamicTypeSubheadlineClamped
explanationLabel.text = explanationText explanationLabel.text = explanationText
explanationLabel.numberOfLines = 0 explanationLabel.numberOfLines = 0
explanationLabel.textAlignment = .center explanationLabel.textAlignment = .center
@ -51,9 +51,11 @@ public class OnboardingBaseViewController: OWSViewController {
func button(title: String, selector: Selector) -> OWSFlatButton { func button(title: String, selector: Selector) -> OWSFlatButton {
// TODO: Make sure this all fits if dynamic font sizes are maxed out. // TODO: Make sure this all fits if dynamic font sizes are maxed out.
let buttonHeight: CGFloat = 48 let font = UIFont.ows_dynamicTypeBodyClamped.ows_mediumWeight()
// Button height should be 48pt if the font is 17pt.
let buttonHeight = font.pointSize * 48 / 17
let button = OWSFlatButton.button(title: title, let button = OWSFlatButton.button(title: title,
font: OWSFlatButton.fontForHeight(buttonHeight), font: font,
titleColor: .white, titleColor: .white,
backgroundColor: .ows_materialBlue, backgroundColor: .ows_materialBlue,
target: self, target: self,
@ -64,9 +66,11 @@ public class OnboardingBaseViewController: OWSViewController {
func linkButton(title: String, selector: Selector) -> OWSFlatButton { func linkButton(title: String, selector: Selector) -> OWSFlatButton {
// TODO: Make sure this all fits if dynamic font sizes are maxed out. // TODO: Make sure this all fits if dynamic font sizes are maxed out.
let buttonHeight: CGFloat = 48 let font = UIFont.ows_dynamicTypeBodyClamped.ows_mediumWeight()
// Button height should be 48pt if the font is 17pt.
let buttonHeight = font.pointSize * 48 / 17
let button = OWSFlatButton.button(title: title, let button = OWSFlatButton.button(title: title,
font: OWSFlatButton.fontForHeight(buttonHeight), font: font,
titleColor: .ows_materialBlue, titleColor: .ows_materialBlue,
backgroundColor: .white, backgroundColor: .white,
target: self, target: self,

@ -23,7 +23,6 @@ public class OnboardingPermissionsViewController: OnboardingBaseViewController {
let explanationLabel = self.explanationLabel(explanationText: NSLocalizedString("ONBOARDING_PERMISSIONS_EXPLANATION", let explanationLabel = self.explanationLabel(explanationText: NSLocalizedString("ONBOARDING_PERMISSIONS_EXPLANATION",
comment: "Explanation in the 'onboarding permissions' view.")) comment: "Explanation in the 'onboarding permissions' view."))
explanationLabel.setCompressionResistanceVerticalLow()
// TODO: Make sure this all fits if dynamic font sizes are maxed out. // TODO: Make sure this all fits if dynamic font sizes are maxed out.
let giveAccessButton = self.button(title: NSLocalizedString("ONBOARDING_PERMISSIONS_ENABLE_PERMISSIONS_BUTTON", let giveAccessButton = self.button(title: NSLocalizedString("ONBOARDING_PERMISSIONS_ENABLE_PERMISSIONS_BUTTON",

@ -36,7 +36,7 @@ public class OnboardingPhoneNumberViewController: OnboardingBaseViewController {
let rowHeight: CGFloat = 40 let rowHeight: CGFloat = 40
countryNameLabel.textColor = Theme.primaryColor countryNameLabel.textColor = Theme.primaryColor
countryNameLabel.font = UIFont.ows_dynamicTypeBody countryNameLabel.font = UIFont.ows_dynamicTypeBodyClamped
countryNameLabel.setContentHuggingHorizontalLow() countryNameLabel.setContentHuggingHorizontalLow()
countryNameLabel.setCompressionResistanceHorizontalLow() countryNameLabel.setCompressionResistanceHorizontalLow()
@ -61,7 +61,7 @@ public class OnboardingPhoneNumberViewController: OnboardingBaseViewController {
addBottomStroke(countryRow) addBottomStroke(countryRow)
callingCodeLabel.textColor = Theme.primaryColor callingCodeLabel.textColor = Theme.primaryColor
callingCodeLabel.font = UIFont.ows_dynamicTypeBody callingCodeLabel.font = UIFont.ows_dynamicTypeBodyClamped
callingCodeLabel.setContentHuggingHorizontalHigh() callingCodeLabel.setContentHuggingHorizontalHigh()
callingCodeLabel.setCompressionResistanceHorizontalHigh() callingCodeLabel.setCompressionResistanceHorizontalHigh()
callingCodeLabel.isUserInteractionEnabled = true callingCodeLabel.isUserInteractionEnabled = true
@ -73,7 +73,7 @@ public class OnboardingPhoneNumberViewController: OnboardingBaseViewController {
phoneNumberTextField.delegate = self phoneNumberTextField.delegate = self
phoneNumberTextField.keyboardType = .numberPad phoneNumberTextField.keyboardType = .numberPad
phoneNumberTextField.textColor = Theme.primaryColor phoneNumberTextField.textColor = Theme.primaryColor
phoneNumberTextField.font = UIFont.ows_dynamicTypeBody phoneNumberTextField.font = UIFont.ows_dynamicTypeBodyClamped
phoneNumberTextField.setContentHuggingHorizontalLow() phoneNumberTextField.setContentHuggingHorizontalLow()
phoneNumberTextField.setCompressionResistanceHorizontalLow() phoneNumberTextField.setCompressionResistanceHorizontalLow()

@ -30,7 +30,7 @@ public class OnboardingSplashViewController: OnboardingBaseViewController {
explanationLabel.text = NSLocalizedString("ONBOARDING_SPLASH_TERM_AND_PRIVACY_POLICY", explanationLabel.text = NSLocalizedString("ONBOARDING_SPLASH_TERM_AND_PRIVACY_POLICY",
comment: "Link to the 'terms and privacy policy' in the 'onboarding splash' view.") comment: "Link to the 'terms and privacy policy' in the 'onboarding splash' view.")
explanationLabel.textColor = .ows_materialBlue explanationLabel.textColor = .ows_materialBlue
explanationLabel.font = UIFont.ows_dynamicTypeCaption1 explanationLabel.font = UIFont.ows_dynamicTypeSubheadlineClamped
explanationLabel.numberOfLines = 0 explanationLabel.numberOfLines = 0
explanationLabel.textAlignment = .center explanationLabel.textAlignment = .center
explanationLabel.lineBreakMode = .byWordWrapping explanationLabel.lineBreakMode = .byWordWrapping

@ -1512,7 +1512,7 @@
"ONBOARDING_CAPTCHA_TITLE" = "We need to verify that you're human"; "ONBOARDING_CAPTCHA_TITLE" = "We need to verify that you're human";
/* Explanation in the 'onboarding permissions' view. */ /* Explanation in the 'onboarding permissions' view. */
"ONBOARDING_PERMISSIONS_EXPLANATION" = "Allowing Signal to send you notifications and access your contacts makes it easier to communicate with your friends. Your contact information is always transmitted securely."; "ONBOARDING_PERMISSIONS_EXPLANATION" = "Your contact information is always transmitted securely.";
/* Label for the 'give access' button in the 'onboarding permissions' view. */ /* Label for the 'give access' button in the 'onboarding permissions' view. */
"ONBOARDING_PERMISSIONS_ENABLE_PERMISSIONS_BUTTON" = "Enable Permissions"; "ONBOARDING_PERMISSIONS_ENABLE_PERMISSIONS_BUTTON" = "Enable Permissions";

@ -1,5 +1,5 @@
// //
// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // Copyright (c) 2019 Open Whisper Systems. All rights reserved.
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@ -36,6 +36,18 @@ NS_ASSUME_NONNULL_BEGIN
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeCaption1Font; @property (class, readonly, nonatomic) UIFont *ows_dynamicTypeCaption1Font;
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeCaption2Font; @property (class, readonly, nonatomic) UIFont *ows_dynamicTypeCaption2Font;
#pragma mark - Dynamic Type Clamped
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeTitle1ClampedFont;
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeTitle2ClampedFont;
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeTitle3ClampedFont;
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeHeadlineClampedFont;
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeBodyClampedFont;
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeSubheadlineClampedFont;
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeFootnoteClampedFont;
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeCaption1ClampedFont;
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeCaption2ClampedFont;
#pragma mark - Styles #pragma mark - Styles
- (UIFont *)ows_italic; - (UIFont *)ows_italic;

@ -1,5 +1,5 @@
// //
// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // Copyright (c) 2019 Open Whisper Systems. All rights reserved.
// //
#import "UIFont+OWS.h" #import "UIFont+OWS.h"
@ -97,6 +97,84 @@ NS_ASSUME_NONNULL_BEGIN
return [UIFont preferredFontForTextStyle:UIFontTextStyleCaption2]; return [UIFont preferredFontForTextStyle:UIFontTextStyleCaption2];
} }
#pragma mark - Dynamic Type Clamped
+ (UIFont *)preferredFontForTextStyleClamped:(UIFontTextStyle)fontTextStyle
{
static NSDictionary<UIFontTextStyle, NSNumber *> *maxPointSizeMap = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
maxPointSizeMap = @{
UIFontTextStyleTitle1 : @(34.0),
UIFontTextStyleTitle2 : @(28.0),
UIFontTextStyleTitle3 : @(26.0),
UIFontTextStyleHeadline : @(23.0),
UIFontTextStyleBody : @(23.0),
UIFontTextStyleSubheadline : @(21.0),
UIFontTextStyleFootnote : @(19.0),
UIFontTextStyleCaption1 : @(18.0),
UIFontTextStyleCaption2 : @(17.0),
};
});
UIFont *font = [UIFont preferredFontForTextStyle:fontTextStyle];
NSNumber *_Nullable maxPointSize = maxPointSizeMap[fontTextStyle];
if (maxPointSize) {
if (maxPointSize.floatValue < font.pointSize) {
return [font fontWithSize:maxPointSize.floatValue];
}
} else {
OWSFailDebug(@"Missing max point size for style: %@", fontTextStyle);
}
return font;
}
+ (UIFont *)ows_dynamicTypeTitle1ClampedFont
{
return [UIFont preferredFontForTextStyleClamped:UIFontTextStyleTitle1];
}
+ (UIFont *)ows_dynamicTypeTitle2ClampedFont
{
return [UIFont preferredFontForTextStyleClamped:UIFontTextStyleTitle2];
}
+ (UIFont *)ows_dynamicTypeTitle3ClampedFont
{
return [UIFont preferredFontForTextStyleClamped:UIFontTextStyleTitle3];
}
+ (UIFont *)ows_dynamicTypeHeadlineClampedFont
{
return [UIFont preferredFontForTextStyleClamped:UIFontTextStyleHeadline];
}
+ (UIFont *)ows_dynamicTypeBodyClampedFont
{
return [UIFont preferredFontForTextStyleClamped:UIFontTextStyleBody];
}
+ (UIFont *)ows_dynamicTypeSubheadlineClampedFont
{
return [UIFont preferredFontForTextStyleClamped:UIFontTextStyleSubheadline];
}
+ (UIFont *)ows_dynamicTypeFootnoteClampedFont
{
return [UIFont preferredFontForTextStyleClamped:UIFontTextStyleFootnote];
}
+ (UIFont *)ows_dynamicTypeCaption1ClampedFont
{
return [UIFont preferredFontForTextStyleClamped:UIFontTextStyleCaption1];
}
+ (UIFont *)ows_dynamicTypeCaption2ClampedFont
{
return [UIFont preferredFontForTextStyleClamped:UIFontTextStyleCaption2];
}
#pragma mark - Styles #pragma mark - Styles
- (UIFont *)ows_italic - (UIFont *)ows_italic

Loading…
Cancel
Save