diff --git a/Signal/src/ViewControllers/HomeView/HomeViewController.m b/Signal/src/ViewControllers/HomeView/HomeViewController.m index f77de2219..2cc3f8337 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewController.m @@ -488,9 +488,9 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations [onboardingController updateWithPhoneNumber:[[OnboardingPhoneNumber alloc] initWithE164:@"+13213214321" userInput:@"3213214321"]]; - // UIViewController *view = [onboardingController initialViewController]; - UIViewController *view = - [[OnboardingPhoneNumberViewController alloc] initWithOnboardingController:onboardingController]; + UIViewController *view = [onboardingController initialViewController]; + // UIViewController *view = + // [[OnboardingPermissionsViewController alloc] initWithOnboardingController:onboardingController]; OWSNavigationController *navigationController = [[OWSNavigationController alloc] initWithRootViewController:view]; [self presentViewController:navigationController animated:YES completion:nil]; diff --git a/Signal/src/ViewControllers/Registration/OnboardingBaseViewController.swift b/Signal/src/ViewControllers/Registration/OnboardingBaseViewController.swift index 84c2455a9..bd76bdb98 100644 --- a/Signal/src/ViewControllers/Registration/OnboardingBaseViewController.swift +++ b/Signal/src/ViewControllers/Registration/OnboardingBaseViewController.swift @@ -31,7 +31,7 @@ public class OnboardingBaseViewController: OWSViewController { let titleLabel = UILabel() titleLabel.text = text titleLabel.textColor = Theme.primaryColor - titleLabel.font = UIFont.ows_dynamicTypeTitle1.ows_mediumWeight() + titleLabel.font = UIFont.ows_dynamicTypeTitle1Clamped.ows_mediumWeight() titleLabel.numberOfLines = 0 titleLabel.lineBreakMode = .byWordWrapping titleLabel.textAlignment = .center @@ -41,7 +41,7 @@ public class OnboardingBaseViewController: OWSViewController { func explanationLabel(explanationText: String) -> UILabel { let explanationLabel = UILabel() explanationLabel.textColor = Theme.secondaryColor - explanationLabel.font = UIFont.ows_dynamicTypeCaption1 + explanationLabel.font = UIFont.ows_dynamicTypeSubheadlineClamped explanationLabel.text = explanationText explanationLabel.numberOfLines = 0 explanationLabel.textAlignment = .center @@ -51,9 +51,11 @@ public class OnboardingBaseViewController: OWSViewController { func button(title: String, selector: Selector) -> OWSFlatButton { // 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, - font: OWSFlatButton.fontForHeight(buttonHeight), + font: font, titleColor: .white, backgroundColor: .ows_materialBlue, target: self, @@ -64,9 +66,11 @@ public class OnboardingBaseViewController: OWSViewController { func linkButton(title: String, selector: Selector) -> OWSFlatButton { // 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, - font: OWSFlatButton.fontForHeight(buttonHeight), + font: font, titleColor: .ows_materialBlue, backgroundColor: .white, target: self, diff --git a/Signal/src/ViewControllers/Registration/OnboardingPermissionsViewController.swift b/Signal/src/ViewControllers/Registration/OnboardingPermissionsViewController.swift index 5a9e9cc59..9d39883eb 100644 --- a/Signal/src/ViewControllers/Registration/OnboardingPermissionsViewController.swift +++ b/Signal/src/ViewControllers/Registration/OnboardingPermissionsViewController.swift @@ -23,7 +23,6 @@ public class OnboardingPermissionsViewController: OnboardingBaseViewController { let explanationLabel = self.explanationLabel(explanationText: NSLocalizedString("ONBOARDING_PERMISSIONS_EXPLANATION", comment: "Explanation in the 'onboarding permissions' view.")) - explanationLabel.setCompressionResistanceVerticalLow() // TODO: Make sure this all fits if dynamic font sizes are maxed out. let giveAccessButton = self.button(title: NSLocalizedString("ONBOARDING_PERMISSIONS_ENABLE_PERMISSIONS_BUTTON", diff --git a/Signal/src/ViewControllers/Registration/OnboardingPhoneNumberViewController.swift b/Signal/src/ViewControllers/Registration/OnboardingPhoneNumberViewController.swift index de2a8c4ad..51e517767 100644 --- a/Signal/src/ViewControllers/Registration/OnboardingPhoneNumberViewController.swift +++ b/Signal/src/ViewControllers/Registration/OnboardingPhoneNumberViewController.swift @@ -36,7 +36,7 @@ public class OnboardingPhoneNumberViewController: OnboardingBaseViewController { let rowHeight: CGFloat = 40 countryNameLabel.textColor = Theme.primaryColor - countryNameLabel.font = UIFont.ows_dynamicTypeBody + countryNameLabel.font = UIFont.ows_dynamicTypeBodyClamped countryNameLabel.setContentHuggingHorizontalLow() countryNameLabel.setCompressionResistanceHorizontalLow() @@ -61,7 +61,7 @@ public class OnboardingPhoneNumberViewController: OnboardingBaseViewController { addBottomStroke(countryRow) callingCodeLabel.textColor = Theme.primaryColor - callingCodeLabel.font = UIFont.ows_dynamicTypeBody + callingCodeLabel.font = UIFont.ows_dynamicTypeBodyClamped callingCodeLabel.setContentHuggingHorizontalHigh() callingCodeLabel.setCompressionResistanceHorizontalHigh() callingCodeLabel.isUserInteractionEnabled = true @@ -73,7 +73,7 @@ public class OnboardingPhoneNumberViewController: OnboardingBaseViewController { phoneNumberTextField.delegate = self phoneNumberTextField.keyboardType = .numberPad phoneNumberTextField.textColor = Theme.primaryColor - phoneNumberTextField.font = UIFont.ows_dynamicTypeBody + phoneNumberTextField.font = UIFont.ows_dynamicTypeBodyClamped phoneNumberTextField.setContentHuggingHorizontalLow() phoneNumberTextField.setCompressionResistanceHorizontalLow() diff --git a/Signal/src/ViewControllers/Registration/OnboardingSplashViewController.swift b/Signal/src/ViewControllers/Registration/OnboardingSplashViewController.swift index 384a8084b..195e6dfa2 100644 --- a/Signal/src/ViewControllers/Registration/OnboardingSplashViewController.swift +++ b/Signal/src/ViewControllers/Registration/OnboardingSplashViewController.swift @@ -30,7 +30,7 @@ public class OnboardingSplashViewController: OnboardingBaseViewController { explanationLabel.text = NSLocalizedString("ONBOARDING_SPLASH_TERM_AND_PRIVACY_POLICY", comment: "Link to the 'terms and privacy policy' in the 'onboarding splash' view.") explanationLabel.textColor = .ows_materialBlue - explanationLabel.font = UIFont.ows_dynamicTypeCaption1 + explanationLabel.font = UIFont.ows_dynamicTypeSubheadlineClamped explanationLabel.numberOfLines = 0 explanationLabel.textAlignment = .center explanationLabel.lineBreakMode = .byWordWrapping diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 070a8b3f5..65fa69982 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -1512,7 +1512,7 @@ "ONBOARDING_CAPTCHA_TITLE" = "We need to verify that you're human"; /* 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. */ "ONBOARDING_PERMISSIONS_ENABLE_PERMISSIONS_BUTTON" = "Enable Permissions"; diff --git a/SignalMessaging/categories/UIFont+OWS.h b/SignalMessaging/categories/UIFont+OWS.h index e719dddcb..b0bcda463 100644 --- a/SignalMessaging/categories/UIFont+OWS.h +++ b/SignalMessaging/categories/UIFont+OWS.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import @@ -36,6 +36,18 @@ NS_ASSUME_NONNULL_BEGIN @property (class, readonly, nonatomic) UIFont *ows_dynamicTypeCaption1Font; @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 - (UIFont *)ows_italic; diff --git a/SignalMessaging/categories/UIFont+OWS.m b/SignalMessaging/categories/UIFont+OWS.m index 2cd08f628..6c237aec0 100644 --- a/SignalMessaging/categories/UIFont+OWS.m +++ b/SignalMessaging/categories/UIFont+OWS.m @@ -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" @@ -97,6 +97,84 @@ NS_ASSUME_NONNULL_BEGIN return [UIFont preferredFontForTextStyle:UIFontTextStyleCaption2]; } +#pragma mark - Dynamic Type Clamped + ++ (UIFont *)preferredFontForTextStyleClamped:(UIFontTextStyle)fontTextStyle +{ + static NSDictionary *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 - (UIFont *)ows_italic