| 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/tab_grid/sc_tab_grid_coordinator.h" | 5 #import "ios/showcase/tab_grid/sc_tab_grid_coordinator.h" |
| 6 | 6 |
| 7 #import "base/format_macros.h" | 7 #import "base/format_macros.h" |
| 8 #import "ios/clean/chrome/browser/ui/commands/tab_commands.h" | 8 #import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h" |
| 9 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_data_source.h
" | 9 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_data_source.h
" |
| 10 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.h" | 10 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.h" |
| 11 #import "ios/showcase/common/protocol_alerter.h" | 11 #import "ios/showcase/common/protocol_alerter.h" |
| 12 | 12 |
| 13 #if !defined(__has_feature) || !__has_feature(objc_arc) | 13 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 14 #error "This file requires ARC support." | 14 #error "This file requires ARC support." |
| 15 #endif | 15 #endif |
| 16 | 16 |
| 17 @interface SCTabGridCoordinator ()<TabCollectionDataSource> | 17 @interface SCTabGridCoordinator ()<TabCollectionDataSource> |
| 18 @property(nonatomic, strong) TabGridViewController* viewController; | 18 @property(nonatomic, strong) TabGridViewController* viewController; |
| 19 @property(nonatomic, strong) ProtocolAlerter* alerter; | 19 @property(nonatomic, strong) ProtocolAlerter* alerter; |
| 20 @end | 20 @end |
| 21 | 21 |
| 22 @implementation SCTabGridCoordinator | 22 @implementation SCTabGridCoordinator |
| 23 @synthesize baseViewController = _baseViewController; | 23 @synthesize baseViewController = _baseViewController; |
| 24 @synthesize viewController = _viewController; | 24 @synthesize viewController = _viewController; |
| 25 @synthesize alerter = _alerter; | 25 @synthesize alerter = _alerter; |
| 26 | 26 |
| 27 - (void)start { | 27 - (void)start { |
| 28 self.alerter = | 28 self.alerter = [[ProtocolAlerter alloc] initWithProtocols:@[ |
| 29 [[ProtocolAlerter alloc] initWithProtocols:@[ @protocol(TabCommands) ]]; | 29 @protocol(SettingsCommands), @protocol(TabGridCommands) |
| 30 ]]; |
| 30 self.alerter.baseViewController = self.baseViewController; | 31 self.alerter.baseViewController = self.baseViewController; |
| 31 | 32 |
| 32 self.viewController = [[TabGridViewController alloc] init]; | 33 self.viewController = [[TabGridViewController alloc] init]; |
| 33 self.viewController.title = @"Tab Grid"; | 34 self.viewController.title = @"Tab Grid"; |
| 34 self.viewController.dataSource = self; | 35 self.viewController.dataSource = self; |
| 35 self.viewController.tabCommandHandler = | 36 self.viewController.dispatcher = |
| 36 static_cast<id<TabCommands>>(self.alerter); | 37 static_cast<id<SettingsCommands, TabGridCommands>>(self.alerter); |
| 37 | 38 |
| 38 [self.baseViewController setHidesBarsOnSwipe:YES]; | 39 [self.baseViewController setHidesBarsOnSwipe:YES]; |
| 39 [self.baseViewController pushViewController:self.viewController animated:YES]; | 40 [self.baseViewController pushViewController:self.viewController animated:YES]; |
| 40 } | 41 } |
| 41 | 42 |
| 42 #pragma mark - TabCollectionDataSource | 43 #pragma mark - TabCollectionDataSource |
| 43 | 44 |
| 44 - (int)numberOfTabs { | 45 - (int)numberOfTabs { |
| 45 return 3; | 46 return 3; |
| 46 } | 47 } |
| 47 | 48 |
| 48 - (NSString*)titleAtIndex:(int)index { | 49 - (NSString*)titleAtIndex:(int)index { |
| 49 return [NSString stringWithFormat:@"Tab %d", index]; | 50 return [NSString stringWithFormat:@"Tab %d", index]; |
| 50 } | 51 } |
| 51 | 52 |
| 52 - (int)indexOfActiveTab { | 53 - (int)indexOfActiveTab { |
| 53 return kTabCollectionDataSourceInvalidIndex; | 54 return kTabCollectionDataSourceInvalidIndex; |
| 54 } | 55 } |
| 55 | 56 |
| 56 @end | 57 @end |
| OLD | NEW |