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