Commit 7eacffe7 authored by François Doray's avatar François Doray Committed by Commit Bot

Revert "[iOS][Alert] Add alert controller to Showcase"

This reverts commit 2410dcb9.

Reason for revert: Bug 954134

Original change's description:
> [iOS][Alert] Add alert controller to Showcase
> 
> Bug: 951301, 951300
> Change-Id: If0af93103f0038ad35770cee09b94b455aeca92b
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1561109
> Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
> Reviewed-by: edchin <edchin@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#652122}

TBR=edchin@chromium.org,javierrobles@chromium.org

Bug: 954134
Change-Id: I4f4d441cf3fa9ea5651a0b0bc01ef41e9bd0f277
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 951301, 951300
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1573639Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Commit-Queue: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652127}
parent af26b85d
......@@ -22,7 +22,6 @@ ios_app_bundle("showcase") {
group("features") {
deps = [
"//ios/showcase/alert",
"//ios/showcase/bubble",
"//ios/showcase/content_suggestions",
"//ios/showcase/infobars",
......
# Copyright 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
source_set("alert") {
sources = [
"sc_alert_coordinator.h",
"sc_alert_coordinator.mm",
]
deps = [
"//ios/chrome/browser/ui/alert_view_controller",
"//ios/showcase/common",
]
libs = [ "UIKit.framework" ]
configs += [ "//build/config/compiler:enable_arc" ]
}
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_SHOWCASE_ALERT_SC_ALERT_COORDINATOR_H_
#define IOS_SHOWCASE_ALERT_SC_ALERT_COORDINATOR_H_
#import "ios/showcase/common/navigation_coordinator.h"
@interface SCAlertCoordinator : NSObject <NavigationCoordinator>
@end
#endif // IOS_SHOWCASE_ALERT_SC_ALERT_COORDINATOR_H_
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/showcase/alert/sc_alert_coordinator.h"
#import "ios/chrome/browser/ui/alert_view_controller/alert_view_controller.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface SCAlertCoordinator ()
@property(nonatomic, strong) UIViewController* containerViewController;
@end
@implementation SCAlertCoordinator
@synthesize baseViewController = _baseViewController;
- (void)start {
self.containerViewController = [[UIViewController alloc] init];
self.containerViewController.definesPresentationContext = YES;
self.containerViewController.title = @"Alert";
UIView* containerView = self.containerViewController.view;
containerView.backgroundColor = [UIColor whiteColor];
UIButton* alertButton = [UIButton buttonWithType:UIButtonTypeSystem];
[alertButton setTitle:@"alert()" forState:UIControlStateNormal];
[alertButton addTarget:self
action:@selector(showAlert)
forControlEvents:UIControlEventTouchUpInside];
UIButton* promptButton = [UIButton buttonWithType:UIButtonTypeSystem];
[promptButton setTitle:@"prompt()" forState:UIControlStateNormal];
[promptButton addTarget:self
action:@selector(showPrompt)
forControlEvents:UIControlEventTouchUpInside];
UIButton* confirmButton = [UIButton buttonWithType:UIButtonTypeSystem];
[confirmButton setTitle:@"confirm()" forState:UIControlStateNormal];
[confirmButton addTarget:self
action:@selector(showConfirm)
forControlEvents:UIControlEventTouchUpInside];
UIButton* authButton = [UIButton buttonWithType:UIButtonTypeSystem];
[authButton setTitle:@"HTTP Auth" forState:UIControlStateNormal];
[authButton addTarget:self
action:@selector(showHTTPAuth)
forControlEvents:UIControlEventTouchUpInside];
UIStackView* stack = [[UIStackView alloc] initWithArrangedSubviews:@[
alertButton, promptButton, confirmButton, authButton
]];
stack.axis = UILayoutConstraintAxisVertical;
stack.spacing = 30;
stack.translatesAutoresizingMaskIntoConstraints = NO;
[containerView addSubview:stack];
[NSLayoutConstraint activateConstraints:@[
[stack.centerXAnchor constraintEqualToAnchor:containerView.centerXAnchor],
[stack.centerYAnchor constraintEqualToAnchor:containerView.centerYAnchor],
]];
[self.baseViewController pushViewController:self.containerViewController
animated:YES];
}
- (void)showAlert {
AlertViewController* alert = [[AlertViewController alloc] init];
alert.title = @"chromium.org says";
alert.message = @"This is an alert message from a website.";
__weak __typeof(self) weakSelf = self;
AlertAction* action =
[AlertAction actionWithTitle:@"OK"
handler:^(AlertAction* action) {
[weakSelf.containerViewController
dismissViewControllerAnimated:YES
completion:nil];
}];
[alert addAction:action];
[self presentAlertViewController:alert];
}
- (void)showPrompt {
AlertViewController* alert = [[AlertViewController alloc] init];
alert.title = @"chromium.org says";
alert.message = @"This is a promp message from a website.";
[alert addTextFieldWithConfigurationHandler:^(UITextField* textField) {
textField.placeholder = @"placehorder";
}];
__weak __typeof(self) weakSelf = self;
AlertAction* OKAction =
[AlertAction actionWithTitle:@"OK"
handler:^(AlertAction* action) {
[weakSelf.containerViewController
dismissViewControllerAnimated:YES
completion:nil];
}];
[alert addAction:OKAction];
AlertAction* cancelAction =
[AlertAction actionWithTitle:@"Cancel"
handler:^(AlertAction* action) {
[weakSelf.containerViewController
dismissViewControllerAnimated:YES
completion:nil];
}];
[alert addAction:cancelAction];
[self presentAlertViewController:alert];
}
- (void)showConfirm {
AlertViewController* alert = [[AlertViewController alloc] init];
alert.title = @"chromium.org says";
alert.message = @"This is a confirm message from a website.";
__weak __typeof(self) weakSelf = self;
AlertAction* OKAction =
[AlertAction actionWithTitle:@"OK"
handler:^(AlertAction* action) {
[weakSelf.containerViewController
dismissViewControllerAnimated:YES
completion:nil];
}];
[alert addAction:OKAction];
AlertAction* cancelAction =
[AlertAction actionWithTitle:@"Cancel"
handler:^(AlertAction* action) {
[weakSelf.containerViewController
dismissViewControllerAnimated:YES
completion:nil];
}];
[alert addAction:cancelAction];
[self presentAlertViewController:alert];
}
- (void)showHTTPAuth {
AlertViewController* alert = [[AlertViewController alloc] init];
alert.title = @"Sign in";
alert.message =
@"https://www.chromium.org requires a username and a password.";
[alert addTextFieldWithConfigurationHandler:^(UITextField* textField) {
textField.placeholder = @"Username";
}];
[alert addTextFieldWithConfigurationHandler:^(UITextField* textField) {
textField.placeholder = @"Password";
textField.secureTextEntry = YES;
}];
__weak __typeof(self) weakSelf = self;
AlertAction* OKAction =
[AlertAction actionWithTitle:@"Sign In"
handler:^(AlertAction* action) {
[weakSelf.containerViewController
dismissViewControllerAnimated:YES
completion:nil];
}];
[alert addAction:OKAction];
AlertAction* cancelAction =
[AlertAction actionWithTitle:@"Cancel"
handler:^(AlertAction* action) {
[weakSelf.containerViewController
dismissViewControllerAnimated:YES
completion:nil];
}];
[alert addAction:cancelAction];
[self presentAlertViewController:alert];
}
- (void)presentAlertViewController:(AlertViewController*)alertViewController {
alertViewController.modalTransitionStyle =
UIModalTransitionStyleCrossDissolve;
alertViewController.modalPresentationStyle =
UIModalPresentationOverCurrentContext;
[self.containerViewController presentViewController:alertViewController
animated:true
completion:nil];
}
@end
......@@ -112,11 +112,6 @@
showcase::kClassForInstantiationKey : @"SCInfobarBannerCoordinator",
showcase::kUseCaseKey : @"Infobar Banner",
},
@{
showcase::kClassForDisplayKey : @"AlertController",
showcase::kClassForInstantiationKey : @"SCAlertCoordinator",
showcase::kUseCaseKey : @"Alert",
},
];
}
......
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