diff --git a/Signal/src/ViewControllers/HomeView/HomeViewController.m b/Signal/src/ViewControllers/HomeView/HomeViewController.m index 6d525276b..640a097a3 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewController.m @@ -488,8 +488,9 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations [onboardingController updateWithPhoneNumber:[[OnboardingPhoneNumber alloc] initWithE164:@"+13213214321" userInput:@"3213214321"]]; - UIViewController *view = [onboardingController initialViewController]; - // [[OnboardingCaptchaViewController 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 5ba07714a..84c2455a9 100644 --- a/Signal/src/ViewControllers/Registration/OnboardingBaseViewController.swift +++ b/Signal/src/ViewControllers/Registration/OnboardingBaseViewController.swift @@ -38,22 +38,14 @@ public class OnboardingBaseViewController: OWSViewController { return titleLabel } - func explanationLabel(explanationText: String, linkText: String, selector: Selector) -> UILabel { - let explanationText = NSAttributedString(string: explanationText) - .rtlSafeAppend(NSAttributedString(string: " ")) - .rtlSafeAppend(linkText, - attributes: [ - NSAttributedStringKey.foregroundColor: UIColor.ows_materialBlue - ]) + func explanationLabel(explanationText: String) -> UILabel { let explanationLabel = UILabel() explanationLabel.textColor = Theme.secondaryColor explanationLabel.font = UIFont.ows_dynamicTypeCaption1 - explanationLabel.attributedText = explanationText + explanationLabel.text = explanationText explanationLabel.numberOfLines = 0 explanationLabel.textAlignment = .center explanationLabel.lineBreakMode = .byWordWrapping - explanationLabel.isUserInteractionEnabled = true - explanationLabel.addGestureRecognizer(UITapGestureRecognizer(target: self, action: selector)) return explanationLabel } @@ -70,6 +62,19 @@ public class OnboardingBaseViewController: OWSViewController { return button } + 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 button = OWSFlatButton.button(title: title, + font: OWSFlatButton.fontForHeight(buttonHeight), + titleColor: .ows_materialBlue, + backgroundColor: .white, + target: self, + selector: selector) + button.autoSetDimension(.height, toSize: buttonHeight) + return button + } + // MARK: - View Lifecycle public override func viewWillAppear(_ animated: Bool) { diff --git a/Signal/src/ViewControllers/Registration/OnboardingPermissionsViewController.swift b/Signal/src/ViewControllers/Registration/OnboardingPermissionsViewController.swift index 434495541..9d39883eb 100644 --- a/Signal/src/ViewControllers/Registration/OnboardingPermissionsViewController.swift +++ b/Signal/src/ViewControllers/Registration/OnboardingPermissionsViewController.swift @@ -12,10 +12,7 @@ public class OnboardingPermissionsViewController: OnboardingBaseViewController { super.loadView() view.backgroundColor = Theme.backgroundColor - view.layoutMargins = UIEdgeInsets(top: 32, left: 32, bottom: 32, right: 32) - - // TODO: -// navigationItem.title = NSLocalizedString("SETTINGS_BACKUP", comment: "Label for the backup view in app settings.") + view.layoutMargins = .zero navigationItem.rightBarButtonItem = UIBarButtonItem(title: NSLocalizedString("NAVIGATION_ITEM_SKIP_BUTTON", comment: "A button to skip a view."), style: .plain, @@ -23,46 +20,42 @@ public class OnboardingPermissionsViewController: OnboardingBaseViewController { action: #selector(skipWasPressed)) let titleLabel = self.titleLabel(text: NSLocalizedString("ONBOARDING_PERMISSIONS_TITLE", comment: "Title of the 'onboarding permissions' view.")) - view.addSubview(titleLabel) - titleLabel.autoPinEdges(toSuperviewMarginsExcludingEdge: .bottom) - // TODO: Finalize copy. let explanationLabel = self.explanationLabel(explanationText: NSLocalizedString("ONBOARDING_PERMISSIONS_EXPLANATION", - comment: "Explanation in the 'onboarding permissions' view."), - linkText: NSLocalizedString("ONBOARDING_PERMISSIONS_LEARN_MORE_LINK", - comment: "Link to the 'learn more' in the 'onboarding permissions' view."), - selector: #selector(explanationLabelTapped)) + comment: "Explanation in the 'onboarding permissions' view.")) // TODO: Make sure this all fits if dynamic font sizes are maxed out. - let giveAccessButton = self.button(title: NSLocalizedString("ONBOARDING_PERMISSIONS_GIVE_ACCESS_BUTTON", + let giveAccessButton = self.button(title: NSLocalizedString("ONBOARDING_PERMISSIONS_ENABLE_PERMISSIONS_BUTTON", comment: "Label for the 'give access' button in the 'onboarding permissions' view."), selector: #selector(giveAccessPressed)) - let notNowButton = self.button(title: NSLocalizedString("ONBOARDING_PERMISSIONS_NOT_NOW_BUTTON", - comment: "Label for the 'not now' button in the 'onboarding permissions' view."), + let notNowButton = self.linkButton(title: NSLocalizedString("ONBOARDING_PERMISSIONS_NOT_NOW_BUTTON", + comment: "Label for the 'not now' button in the 'onboarding permissions' view."), selector: #selector(notNowPressed)) - let buttonStack = UIStackView(arrangedSubviews: [ - giveAccessButton, - notNowButton - ]) - buttonStack.axis = .vertical - buttonStack.alignment = .fill - buttonStack.spacing = 12 - + let topSpacer = UIView.vStretchingSpacer() + let bottomSpacer = UIView.vStretchingSpacer() let stackView = UIStackView(arrangedSubviews: [ + titleLabel, + UIView.spacer(withHeight: 20), explanationLabel, - buttonStack + topSpacer, + giveAccessButton, + UIView.spacer(withHeight: 12), + notNowButton, + bottomSpacer ]) stackView.axis = .vertical stackView.alignment = .fill - stackView.spacing = 40 + stackView.layoutMargins = UIEdgeInsets(top: 32, left: 32, bottom: 32, right: 32) + stackView.isLayoutMarginsRelativeArrangement = true view.addSubview(stackView) - stackView.autoPinWidthToSuperviewMargins() - stackView.autoPinEdge(.top, to: .bottom, of: titleLabel, withOffset: 20, relation: .greaterThanOrEqual) - NSLayoutConstraint.autoSetPriority(.defaultHigh) { - stackView.autoVCenterInSuperview() - } + stackView.autoPinWidthToSuperview() + stackView.autoPin(toTopLayoutGuideOf: self, withInset: 0) + stackView.autoPin(toBottomLayoutGuideOf: self, withInset: 0) + + // Ensure whitespace is balanced, so inputs are vertically centered. + topSpacer.autoMatch(.height, to: .height, of: bottomSpacer) } // MARK: Request Access @@ -105,13 +98,6 @@ public class OnboardingPermissionsViewController: OnboardingBaseViewController { onboardingController.onboardingPermissionsWasSkipped(viewController: self) } - @objc func explanationLabelTapped(sender: UIGestureRecognizer) { - guard sender.state == .recognized else { - return - } - // TODO: - } - @objc func giveAccessPressed() { Logger.info("") diff --git a/Signal/src/ViewControllers/Registration/OnboardingSplashViewController.swift b/Signal/src/ViewControllers/Registration/OnboardingSplashViewController.swift index 0e7825748..384a8084b 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_dynamicTypeBody + explanationLabel.font = UIFont.ows_dynamicTypeCaption1 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 18754b04b..070a8b3f5 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -1512,10 +1512,10 @@ "ONBOARDING_CAPTCHA_TITLE" = "We need to verify that you're human"; /* Explanation in the 'onboarding permissions' view. */ -"ONBOARDING_PERMISSIONS_EXPLANATION" = "ONBOARDING_PERMISSIONS_EXPLANATION"; +"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."; /* Label for the 'give access' button in the 'onboarding permissions' view. */ -"ONBOARDING_PERMISSIONS_GIVE_ACCESS_BUTTON" = "Give Access"; +"ONBOARDING_PERMISSIONS_ENABLE_PERMISSIONS_BUTTON" = "Enable Permissions"; /* Link to the 'learn more' in the 'onboarding permissions' view. */ "ONBOARDING_PERMISSIONS_LEARN_MORE_LINK" = "Learn More"; @@ -1524,7 +1524,7 @@ "ONBOARDING_PERMISSIONS_NOT_NOW_BUTTON" = "Not Now"; /* Title of the 'onboarding permissions' view. */ -"ONBOARDING_PERMISSIONS_TITLE" = "We need access to your contacts and notifications"; +"ONBOARDING_PERMISSIONS_TITLE" = "Signal can let you know when you get a message (and who it is from)"; /* Title of the 'onboarding phone number' view. */ "ONBOARDING_PHONE_NUMBER_TITLE" = "Enter your phone number to get started";