Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/showcase/suggestions/sc_suggestions_coordinator.h" | 5 #import "ios/showcase/suggestions/sc_suggestions_coordinator.h" |
| 6 | 6 |
| 7 #import "ios/chrome/browser/ui/suggestions/suggestions_commands.h" | 7 #import "ios/chrome/browser/ui/suggestions/suggestions_commands.h" |
| 8 #import "ios/chrome/browser/ui/suggestions/suggestions_view_controller.h" | 8 #import "ios/chrome/browser/ui/suggestions/suggestions_view_controller.h" |
| 9 #import "ios/showcase/common/protocol_alerter.h" | |
| 9 | 10 |
| 10 #if !defined(__has_feature) || !__has_feature(objc_arc) | 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 11 #error "This file requires ARC support." | 12 #error "This file requires ARC support." |
| 12 #endif | 13 #endif |
| 13 | 14 |
| 14 @interface SCSuggestionsCoordinator ()<SuggestionsCommands> | 15 @interface SCSuggestionsCoordinator ()<SuggestionsCommands> |
| 15 | 16 |
| 16 @property(nonatomic, strong) | 17 @property(nonatomic, strong) |
| 17 SuggestionsViewController* suggestionViewController; | 18 SuggestionsViewController* suggestionViewController; |
| 19 @property(nonatomic, strong) ProtocolAlerter* alerter; | |
| 18 | 20 |
| 19 @end | 21 @end |
| 20 | 22 |
| 21 @implementation SCSuggestionsCoordinator | 23 @implementation SCSuggestionsCoordinator |
| 22 | 24 |
| 23 @synthesize baseViewController; | 25 @synthesize baseViewController; |
| 24 @synthesize suggestionViewController = _suggestionViewController; | 26 @synthesize suggestionViewController = _suggestionViewController; |
| 27 @synthesize alerter = _alerter; | |
| 25 | 28 |
| 26 #pragma mark - Coordinator | 29 #pragma mark - Coordinator |
| 27 | 30 |
| 28 - (void)start { | 31 - (void)start { |
| 32 self.alerter = [[ProtocolAlerter alloc] | |
| 33 initWithProtocols:@[ @protocol(SuggestionsCommands) ]]; | |
| 34 self.alerter.baseViewController = self.baseViewController; | |
| 35 | |
| 29 _suggestionViewController = [[SuggestionsViewController alloc] | 36 _suggestionViewController = [[SuggestionsViewController alloc] |
| 30 initWithStyle:CollectionViewControllerStyleDefault]; | 37 initWithStyle:CollectionViewControllerStyleDefault]; |
| 31 | 38 |
| 32 _suggestionViewController.suggestionCommandHandler = self; | 39 _suggestionViewController.suggestionCommandHandler = self; |
|
marq (ping after 24h)
2017/01/16 18:04:43
Just make protocolAlerter the suggestionCommandHan
gambard
2017/01/17 13:28:11
I want to respond to some command (like "addEmptyI
| |
| 33 | 40 |
| 34 [self.baseViewController pushViewController:_suggestionViewController | 41 [self.baseViewController pushViewController:_suggestionViewController |
| 35 animated:YES]; | 42 animated:YES]; |
| 36 } | 43 } |
| 37 | 44 |
| 38 #pragma mark - SuggestionsCommands | 45 #pragma mark - SuggestionsCommands |
| 39 | 46 |
| 40 - (void)addEmptyItem { | 47 - (void)addEmptyItem { |
| 41 [self.suggestionViewController addTextItem:@"Button clicked" | 48 [self.suggestionViewController addTextItem:@"Button clicked" |
| 42 subtitle:@"Item Added!" | 49 subtitle:@"Item Added!" |
| 43 toSection:5]; | 50 toSection:5]; |
| 44 } | 51 } |
| 45 | 52 |
| 53 - (void)openReadingList { | |
| 54 [static_cast<id<SuggestionsCommands>>(self.alerter) openReadingList]; | |
| 55 } | |
| 56 | |
| 57 - (void)openFirstPageOfReadingList { | |
| 58 [static_cast<id<SuggestionsCommands>>(self.alerter) | |
| 59 openFirstPageOfReadingList]; | |
| 60 } | |
| 61 | |
| 46 @end | 62 @end |
| OLD | NEW |