Chromium Code Reviews| Index: ios/showcase/payments/sc_payments_picker_coordinator.mm |
| diff --git a/ios/showcase/payments/sc_payments_picker_coordinator.mm b/ios/showcase/payments/sc_payments_picker_coordinator.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cfdc35f98b188d80c2312b60969a2449cb74bc41 |
| --- /dev/null |
| +++ b/ios/showcase/payments/sc_payments_picker_coordinator.mm |
| @@ -0,0 +1,59 @@ |
| +// Copyright 2017 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/payments/sc_payments_picker_coordinator.h" |
| + |
| +#import "ios/chrome/browser/payments/payment_request_picker_row.h" |
| +#import "ios/chrome/browser/payments/payment_request_picker_view_controller.h" |
| + |
| +#if !defined(__has_feature) || !__has_feature(objc_arc) |
| +#error "This file requires ARC support." |
| +#endif |
| + |
| +@interface SCPaymentsPickerCoordinator ()< |
| + PaymentRequestPickerViewControllerDelegate> |
| + |
| +@property(nonatomic, strong) |
| + PaymentRequestPickerViewController* pickerViewController; |
| + |
| +@end |
| + |
| +@implementation SCPaymentsPickerCoordinator |
| + |
| +@synthesize baseViewController = _baseViewController; |
| +@synthesize pickerViewController = _pickerViewController; |
| + |
| +- (void)start { |
| + NSArray<PickerRow*>* rows = [self rows]; |
| + _pickerViewController = [[PaymentRequestPickerViewController alloc] |
| + initWithRows:rows |
| + selected:rows[rows.count - 1]]; |
| + [_pickerViewController setTitle:@"Select a country"]; |
| + [_pickerViewController setDelegate:self]; |
| + [self.baseViewController pushViewController:_pickerViewController |
| + animated:YES]; |
| +} |
| + |
| +#pragma mark - PaymentRequestPickerViewControllerDelegate |
| + |
| +- (void)paymentRequestPickerViewController: |
| + (PaymentRequestPickerViewController*)controller |
| + didSelectRow:(PickerRow*)row { |
|
lpromero
2017/03/29 11:38:15
You can use the ProtocolAlerter to trigger an aler
Moe
2017/03/29 17:04:09
Done.
|
| +} |
| + |
| +#pragma mark - Helper methods |
| + |
| +- (NSArray<PickerRow*>*)rows { |
| + return @[ |
| + [[PickerRow alloc] initWithLabel:@"Chile" value:@"CHL"], |
| + [[PickerRow alloc] initWithLabel:@"Canada" value:@"CAN"], |
| + [[PickerRow alloc] initWithLabel:@"Belgium" value:@"BEL"], |
| + [[PickerRow alloc] initWithLabel:@"España" value:@"ESP"], |
| + [[PickerRow alloc] initWithLabel:@"México" value:@"MEX"], |
| + [[PickerRow alloc] initWithLabel:@"Brazil" value:@"BRA"], |
| + [[PickerRow alloc] initWithLabel:@"China" value:@"CHN"] |
| + ]; |
| +} |
| + |
| +@end |