Commit e50fc4d7 authored by sczs's avatar sczs Committed by Commit Bot

[ios] Adds SaveCard Infobar Modal to showcase.

The modal will be presented from an Infobar banner (which might change in
subsequent CL's).

Adds a forward GURL declaration on InfobarSaveCardModalDelegate

Bug: 1029067
Change-Id: I6d4f69aa69ced0b93b46b36809b229cdf6b6fd05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2028743Reviewed-by: default avatarChris Lu <thegreenfrog@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737433}
parent d5a87784
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#import "ios/chrome/browser/ui/infobars/modals/infobar_modal_delegate.h" #import "ios/chrome/browser/ui/infobars/modals/infobar_modal_delegate.h"
class GURL;
// Delegate to handle Save Card Infobar Modal actions. // Delegate to handle Save Card Infobar Modal actions.
@protocol InfobarSaveCardModalDelegate <InfobarModalDelegate> @protocol InfobarSaveCardModalDelegate <InfobarModalDelegate>
......
...@@ -128,6 +128,12 @@ ...@@ -128,6 +128,12 @@
showcase::kClassForInstantiationKey : @"SCBadgeCoordinator", showcase::kClassForInstantiationKey : @"SCBadgeCoordinator",
showcase::kUseCaseKey : @"Badge View", showcase::kUseCaseKey : @"Badge View",
}, },
@{
showcase::kClassForDisplayKey : @"SaveCardModalViewController",
showcase::
kClassForInstantiationKey : @"SCInfobarModalSaveCardCoordinator",
showcase::kUseCaseKey : @"Save Card Modal",
},
]; ];
} }
......
...@@ -10,16 +10,20 @@ source_set("infobars") { ...@@ -10,16 +10,20 @@ source_set("infobars") {
"sc_infobar_banner_no_modal_coordinator.mm", "sc_infobar_banner_no_modal_coordinator.mm",
"sc_infobar_container_view_controller.h", "sc_infobar_container_view_controller.h",
"sc_infobar_container_view_controller.mm", "sc_infobar_container_view_controller.mm",
"sc_infobar_modal_save_card_coordinator.h",
"sc_infobar_modal_save_card_coordinator.mm",
] ]
deps = [ deps = [
":constants", ":constants",
"//base", "//base",
"//ios/chrome/browser/infobars:public", "//ios/chrome/browser/infobars:public",
"//ios/chrome/browser/ui/autofill:autofill_message",
"//ios/chrome/browser/ui/infobars/banners", "//ios/chrome/browser/ui/infobars/banners",
"//ios/chrome/browser/ui/infobars/coordinators", "//ios/chrome/browser/ui/infobars/coordinators",
"//ios/chrome/browser/ui/infobars/modals", "//ios/chrome/browser/ui/infobars/modals",
"//ios/chrome/browser/ui/infobars/presentation", "//ios/chrome/browser/ui/infobars/presentation",
"//ios/showcase/common", "//ios/showcase/common",
"//url",
] ]
libs = [ "UIKit.framework" ] libs = [ "UIKit.framework" ]
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#pragma mark InfobarModalPositioner #pragma mark InfobarModalPositioner
- (CGFloat)modalHeightForWidth:(CGFloat)width { - (CGFloat)modalHeightForWidth:(CGFloat)width {
return 200; return 350;
} }
@end @end
// Copyright 2020 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_INFOBARS_SC_INFOBAR_MODAL_SAVE_CARD_COORDINATOR_H_
#define IOS_SHOWCASE_INFOBARS_SC_INFOBAR_MODAL_SAVE_CARD_COORDINATOR_H_
#import "ios/showcase/common/navigation_coordinator.h"
@interface SCInfobarModalSaveCardCoordinator : NSObject <NavigationCoordinator>
@end
#endif // IOS_SHOWCASE_INFOBARS_SC_INFOBAR_MODAL_SAVE_CARD_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/infobars/sc_infobar_modal_save_card_coordinator.h"
#import "ios/chrome/browser/ui/autofill/save_card_message_with_links.h"
#import "ios/chrome/browser/ui/infobars/banners/infobar_banner_delegate.h"
#import "ios/chrome/browser/ui/infobars/banners/infobar_banner_view_controller.h"
#import "ios/chrome/browser/ui/infobars/modals/infobar_save_card_modal_delegate.h"
#import "ios/chrome/browser/ui/infobars/modals/infobar_save_card_table_view_controller.h"
#import "ios/chrome/browser/ui/infobars/presentation/infobar_modal_transition_driver.h"
#import "ios/showcase/infobars/sc_infobar_constants.h"
#import "ios/showcase/infobars/sc_infobar_container_view_controller.h"
#include "url/gurl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
class GURL;
@interface SCInfobarModalSaveCardCoordinator () <InfobarBannerDelegate,
InfobarSaveCardModalDelegate>
@property(nonatomic, strong) InfobarBannerViewController* bannerViewController;
@property(nonatomic, strong) ContainerViewController* containerViewController;
@property(nonatomic, strong)
InfobarModalTransitionDriver* modalTransitionDriver;
@property(nonatomic, strong)
InfobarSaveCardTableViewController* modalViewController;
@end
@implementation SCInfobarModalSaveCardCoordinator
@synthesize baseViewController = _baseViewController;
- (void)start {
self.containerViewController = [[ContainerViewController alloc] init];
UIView* containerView = self.containerViewController.view;
containerView.backgroundColor = [UIColor whiteColor];
self.containerViewController.title = @"Save Card Infobar";
self.bannerViewController = [[InfobarBannerViewController alloc]
initWithDelegate:self
presentsModal:YES
type:InfobarType::kInfobarTypeConfirm];
self.bannerViewController.titleText = kInfobarBannerTitleLabel;
self.bannerViewController.subtitleText = kInfobarBannerSubtitleLabel;
self.bannerViewController.buttonText = kInfobarBannerButtonLabel;
self.containerViewController.bannerViewController = self.bannerViewController;
[self.baseViewController pushViewController:self.containerViewController
animated:YES];
}
#pragma mark InfobarSaveCardModalDelegate
- (void)dismissInfobarModal:(id)infobarModal {
[self.baseViewController dismissViewControllerAnimated:YES completion:nil];
}
- (void)modalInfobarButtonWasAccepted:(id)infobarModal {
[self dismissInfobarModal:infobarModal];
}
- (void)modalInfobarWasDismissed:(id)infobarModal {
}
- (void)saveCardWithCardholderName:(NSString*)cardholderName
expirationMonth:(NSString*)month
expirationYear:(NSString*)year {
}
- (void)dismissModalAndOpenURL:(const GURL&)linkURL {
}
#pragma mark InfobarBannerDelegate
- (void)bannerInfobarButtonWasPressed:(UIButton*)sender {
[self dismissInfobarBannerForUserInteraction:NO];
}
- (void)dismissInfobarBannerForUserInteraction:(BOOL)userInitiated {
[self.baseViewController dismissViewControllerAnimated:YES completion:nil];
}
- (void)presentInfobarModalFromBanner {
self.modalTransitionDriver = [[InfobarModalTransitionDriver alloc]
initWithTransitionMode:InfobarModalTransitionBanner];
self.modalTransitionDriver.modalPositioner = self.containerViewController;
self.modalViewController =
[[InfobarSaveCardTableViewController alloc] initWithModalDelegate:self];
self.modalViewController.title = @"Title";
self.modalViewController.cardIssuerIcon =
[UIImage imageNamed:@"infobar_save_card_icon"];
self.modalViewController.cardNumber = @"•••• 1234";
SaveCardMessageWithLinks* message = [[SaveCardMessageWithLinks alloc] init];
message.messageText = @"Terms of Service";
std::vector<GURL> linkURLs;
linkURLs.push_back(GURL("http://www.google.com"));
message.linkURLs = linkURLs;
message.linkRanges = [[NSArray alloc]
initWithObjects:[NSValue valueWithRange:NSMakeRange(0, 5)], nil];
self.modalViewController.legalMessages =
[NSMutableArray arrayWithObject:message];
self.modalViewController.supportsEditing = YES;
UINavigationController* navController = [[UINavigationController alloc]
initWithRootViewController:self.modalViewController];
navController.transitioningDelegate = self.modalTransitionDriver;
navController.modalPresentationStyle = UIModalPresentationCustom;
[self.bannerViewController presentViewController:navController
animated:YES
completion:nil];
}
- (void)infobarBannerWasDismissed {
self.bannerViewController = nil;
}
@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