Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Unified Diff: ios/showcase/tab_grid/sc_tab_grid_coordinator.mm

Issue 2592593003: Upstream ios/showcase source code. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/showcase/tab_grid/sc_tab_grid_coordinator.h ('k') | ios/showcase/tab_grid/sc_tab_grid_egtest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/showcase/tab_grid/sc_tab_grid_coordinator.mm
diff --git a/ios/showcase/tab_grid/sc_tab_grid_coordinator.mm b/ios/showcase/tab_grid/sc_tab_grid_coordinator.mm
new file mode 100644
index 0000000000000000000000000000000000000000..59cb68b70e91869ab1007d57c8d4066e07272905
--- /dev/null
+++ b/ios/showcase/tab_grid/sc_tab_grid_coordinator.mm
@@ -0,0 +1,81 @@
+// Copyright 2016 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/tab_grid/sc_tab_grid_coordinator.h"
+
+#import "base/format_macros.h"
+#import "ios/chrome/browser/ui/tab_grid/tab_grid_view_controller.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+@interface SCTabGridCoordinator ()<TabGridDataSource, TabGridActionDelegate>
+@property(nonatomic, strong) TabGridViewController* viewController;
+@end
+
+@implementation SCTabGridCoordinator
+@synthesize baseViewController = _baseViewController;
+@synthesize viewController = _viewController;
+
+- (void)start {
+ self.viewController = [[TabGridViewController alloc] init];
+ self.viewController.title = @"Tab Grid";
+ self.viewController.dataSource = self;
+ self.viewController.actionDelegate = self;
+ [self.baseViewController setHidesBarsOnSwipe:YES];
+ [self.baseViewController pushViewController:self.viewController animated:YES];
+}
+
+#pragma mark - TabGridDataSource
+
+- (NSUInteger)numberOfTabsInTabGrid {
+ return 3;
+}
+
+- (NSString*)titleAtIndex:(NSInteger)index {
+ return [NSString stringWithFormat:@"Tab %" PRIdNS, index];
+}
+
+#pragma mark - TabGridActionDelegate
+
+- (void)showTabAtIndexPath:(NSIndexPath*)indexPath {
+ [self
+ showAlertWithTitle:NSStringFromProtocol(@protocol(TabGridActionDelegate))
+ message:[NSString
+ stringWithFormat:@"showTabAtIndexPath:%" PRIdNS,
+ indexPath.item]];
+}
+
+- (void)showTabGrid {
+ [self
+ showAlertWithTitle:NSStringFromProtocol(@protocol(TabGridActionDelegate))
+ message:NSStringFromSelector(_cmd)];
+}
+
+- (void)showSettings {
+ [self
+ showAlertWithTitle:NSStringFromProtocol(@protocol(TabGridActionDelegate))
+ message:NSStringFromSelector(_cmd)];
+}
+
+#pragma mark - Private
+
+// Helper to show simple alert.
+- (void)showAlertWithTitle:(NSString*)title message:(NSString*)message {
+ UIAlertController* alertController =
+ [UIAlertController alertControllerWithTitle:title
+ message:message
+ preferredStyle:UIAlertControllerStyleAlert];
+ UIAlertAction* action =
+ [UIAlertAction actionWithTitle:@"Done"
+ style:UIAlertActionStyleCancel
+ handler:nil];
+ [alertController addAction:action];
+ [self.baseViewController presentViewController:alertController
+ animated:YES
+ completion:nil];
+}
+
+@end
« no previous file with comments | « ios/showcase/tab_grid/sc_tab_grid_coordinator.h ('k') | ios/showcase/tab_grid/sc_tab_grid_egtest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698