Update permissions view.

pull/2/head
Matthew Chen 6 years ago
parent 78ea3e565f
commit 8bdbe24bd0

@ -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];

@ -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) {

@ -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("")

@ -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

@ -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";

Loading…
Cancel
Save