Commit 1d795f5f authored by Nohemi Fernandez's avatar Nohemi Fernandez Committed by Commit Bot

[iOS] Implement add account and more button press actions.

Add button press actions for two of the four button styles for the
UserSigninViewController. The sign-in operations will be added in a
follow-up patch.

See go/chrome-ios-signin-migration for more information.

Bug: 971989
Change-Id: Id669d2a788dd85849b13e1c27021fc7442e6a63d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2064945
Commit-Queue: Nohemi Fernandez <fernandex@chromium.org>
Reviewed-by: default avatarJérôme Lebel <jlebel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743517}
parent 57ef6fb6
...@@ -69,19 +69,6 @@ using signin_metrics::PromoAction; ...@@ -69,19 +69,6 @@ using signin_metrics::PromoAction;
[self.unifiedConsentCoordinator start]; [self.unifiedConsentCoordinator start];
self.addAccountSigninCoordinator = [SigninCoordinator
addAccountCoordinatorWithBaseViewController:self.viewController
browser:self.browser
accessPoint:self.accessPoint];
__weak UserSigninCoordinator* weakSelf = self;
self.addAccountSigninCoordinator.signinCompletion =
^(SigninCoordinatorResult signinResult, ChromeIdentity* identity) {
if (signinResult == SigninCoordinatorResultSuccess) {
weakSelf.defaultIdentity = identity;
}
};
// Display UnifiedConsentViewController within the host. // Display UnifiedConsentViewController within the host.
self.viewController.unifiedConsentViewController = self.viewController.unifiedConsentViewController =
self.unifiedConsentCoordinator.viewController; self.unifiedConsentCoordinator.viewController;
...@@ -113,7 +100,7 @@ using signin_metrics::PromoAction; ...@@ -113,7 +100,7 @@ using signin_metrics::PromoAction;
- (void)unifiedConsentCoordinatorDidTapOnAddAccount: - (void)unifiedConsentCoordinatorDidTapOnAddAccount:
(UnifiedConsentCoordinator*)coordinator { (UnifiedConsentCoordinator*)coordinator {
DCHECK_EQ(self.unifiedConsentCoordinator, coordinator); DCHECK_EQ(self.unifiedConsentCoordinator, coordinator);
[self.addAccountSigninCoordinator start]; [self userSigninViewControllerDidTapOnAddAccount];
} }
- (void)unifiedConsentCoordinatorNeedPrimaryButtonUpdate: - (void)unifiedConsentCoordinatorNeedPrimaryButtonUpdate:
...@@ -128,4 +115,26 @@ using signin_metrics::PromoAction; ...@@ -128,4 +115,26 @@ using signin_metrics::PromoAction;
return self.unifiedConsentCoordinator.selectedIdentity != nil; return self.unifiedConsentCoordinator.selectedIdentity != nil;
} }
- (void)userSigninViewControllerDidTapOnAddAccount {
self.addAccountSigninCoordinator = [SigninCoordinator
addAccountCoordinatorWithBaseViewController:self.viewController
browser:self.browser
accessPoint:self.accessPoint];
__weak UserSigninCoordinator* weakSelf = self;
self.addAccountSigninCoordinator.signinCompletion =
^(SigninCoordinatorResult signinResult, ChromeIdentity* identity) {
if (signinResult == SigninCoordinatorResultSuccess) {
weakSelf.unifiedConsentCoordinator.selectedIdentity = identity;
[weakSelf.addAccountSigninCoordinator stop];
weakSelf.addAccountSigninCoordinator = nil;
}
};
[self.addAccountSigninCoordinator start];
}
- (void)userSigninViewControllerDidScrollOnUnifiedConsent {
[self.unifiedConsentCoordinator scrollToBottom];
}
@end @end
...@@ -9,9 +9,17 @@ ...@@ -9,9 +9,17 @@
// Delegate that interacts with the user sign-in coordinator. // Delegate that interacts with the user sign-in coordinator.
@protocol UserSigninViewControllerDelegate @protocol UserSigninViewControllerDelegate
// Returns whether the user has selected an identity from the unified consent // Returns whether the user has selected an identity from the unified consent
// screen. // screen.
- (BOOL)unifiedConsentCoordinatorHasIdentity; - (BOOL)unifiedConsentCoordinatorHasIdentity;
// Performs add account operation.
- (void)userSigninViewControllerDidTapOnAddAccount;
// Performs scroll operation on unified consent screen.
- (void)userSigninViewControllerDidScrollOnUnifiedConsent;
@end @end
// View controller used to show sign-in UI. // View controller used to show sign-in UI.
......
...@@ -44,7 +44,14 @@ const AuthenticationViewConstants kRegularConstants = { ...@@ -44,7 +44,14 @@ const AuthenticationViewConstants kRegularConstants = {
32, // ButtonTopPadding 32, // ButtonTopPadding
32, // ButtonBottomPadding 32, // ButtonBottomPadding
}; };
}
// The style applied to a button type.
enum AuthenticationButtonType {
AuthenticationButtonTypeMore,
AuthenticationButtonTypeAddAccount,
AuthenticationButtonTypeConfirmation,
};
} // namespace
@interface UserSigninViewController () @interface UserSigninViewController ()
...@@ -80,16 +87,22 @@ const AuthenticationViewConstants kRegularConstants = { ...@@ -80,16 +87,22 @@ const AuthenticationViewConstants kRegularConstants = {
[self.confirmationButton setTitle:self.addAccountButtonTitle [self.confirmationButton setTitle:self.addAccountButtonTitle
forState:UIControlStateNormal]; forState:UIControlStateNormal];
[self setConfirmationStylingWithButton:self.confirmationButton]; [self setConfirmationStylingWithButton:self.confirmationButton];
self.confirmationButton.tag = AuthenticationButtonTypeAddAccount;
} else if (!self.hasUnifiedConsentScreenReachedBottom) { } else if (!self.hasUnifiedConsentScreenReachedBottom) {
// User has not scrolled to the bottom of the user consent screen. // User has not scrolled to the bottom of the user consent screen.
// Display 'more' button. // Display 'more' button.
[self updateButtonAsMoreButton:self.confirmationButton]; [self updateButtonAsMoreButton:self.confirmationButton];
self.confirmationButton.tag = AuthenticationButtonTypeMore;
} else { } else {
// By default display 'Yes I'm in' button. // By default display 'Yes I'm in' button.
[self.confirmationButton setTitle:self.confirmationButtonTitle [self.confirmationButton setTitle:self.confirmationButtonTitle
forState:UIControlStateNormal]; forState:UIControlStateNormal];
[self setConfirmationStylingWithButton:self.confirmationButton]; [self setConfirmationStylingWithButton:self.confirmationButton];
self.confirmationButton.tag = AuthenticationButtonTypeConfirmation;
} }
[self.confirmationButton addTarget:self
action:@selector(onConfirmationButtonPressed:)
forControlEvents:UIControlEventTouchUpInside];
} }
#pragma mark - UIViewController #pragma mark - UIViewController
...@@ -203,18 +216,16 @@ const AuthenticationViewConstants kRegularConstants = { ...@@ -203,18 +216,16 @@ const AuthenticationViewConstants kRegularConstants = {
[self.skipSigninButton setTitle:self.skipSigninButtonTitle [self.skipSigninButton setTitle:self.skipSigninButtonTitle
forState:UIControlStateNormal]; forState:UIControlStateNormal];
[self setSkipSigninStylingWithButton:self.skipSigninButton]; [self setSkipSigninStylingWithButton:self.skipSigninButton];
[self.skipSigninButton addTarget:self
action:@selector(onSkipSigninButtonPressed:)
forControlEvents:UIControlEventTouchUpInside];
} }
// Sets up button properties and adds it to view. // Sets up button properties and adds it to view.
- (void)addSubviewWithButton:(UIButton*)button { - (void)addSubviewWithButton:(UIButton*)button {
button.titleLabel.font = button.titleLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]; [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline];
[self.view addSubview:button]; [self.view addSubview:button];
[button addTarget:self
action:@selector(onButtonPressed:)
forControlEvents:UIControlEventTouchUpInside];
button.translatesAutoresizingMaskIntoConstraints = NO; button.translatesAutoresizingMaskIntoConstraints = NO;
} }
...@@ -245,9 +256,28 @@ const AuthenticationViewConstants kRegularConstants = { ...@@ -245,9 +256,28 @@ const AuthenticationViewConstants kRegularConstants = {
#pragma mark - Events #pragma mark - Events
- (void)onButtonPressed:(id)sender { - (void)onSkipSigninButtonPressed:(id)sender {
// TODO(crbug.com/971989): Populate action. // TODO(crbug.com/971989): Populate action.
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
- (void)onConfirmationButtonPressed:(id)sender {
DCHECK_EQ(self.confirmationButton, sender);
switch (self.confirmationButton.tag) {
case AuthenticationButtonTypeMore: {
[self.delegate userSigninViewControllerDidScrollOnUnifiedConsent];
break;
}
case AuthenticationButtonTypeAddAccount: {
[self.delegate userSigninViewControllerDidTapOnAddAccount];
break;
}
case AuthenticationButtonTypeConfirmation: {
// TODO(crbug.com/971989): Populate action.
NOTIMPLEMENTED();
break;
}
}
}
@end @end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment