| OLD | NEW |
| (Empty) |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #import "ios/clean/chrome/browser/ui/ntp/new_tab_page_view_controller.h" | |
| 6 | |
| 7 #import "base/ios/crb_protocol_observers.h" | |
| 8 #include "components/strings/grit/components_strings.h" | |
| 9 #import "ios/chrome/browser/ui/ntp/new_tab_page_bar.h" | |
| 10 #import "ios/chrome/browser/ui/ntp/new_tab_page_bar_item.h" | |
| 11 #import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h" | |
| 12 #import "ios/chrome/browser/ui/ntp/new_tab_page_view.h" | |
| 13 #include "ios/chrome/grit/ios_strings.h" | |
| 14 #include "ui/base/l10n/l10n_util.h" | |
| 15 | |
| 16 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 17 #error "This file requires ARC support." | |
| 18 #endif | |
| 19 | |
| 20 @implementation NTPViewController | |
| 21 | |
| 22 #pragma mark - UIViewController | |
| 23 | |
| 24 - (void)viewDidLoad { | |
| 25 self.title = l10n_util::GetNSString(IDS_NEW_TAB_TITLE); | |
| 26 self.view.backgroundColor = [UIColor whiteColor]; | |
| 27 | |
| 28 UIScrollView* scrollView = [[UIScrollView alloc] initWithFrame:CGRectZero]; | |
| 29 [scrollView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | | |
| 30 UIViewAutoresizingFlexibleHeight)]; | |
| 31 scrollView.pagingEnabled = YES; | |
| 32 scrollView.showsHorizontalScrollIndicator = NO; | |
| 33 scrollView.showsVerticalScrollIndicator = NO; | |
| 34 scrollView.contentMode = UIViewContentModeScaleAspectFit; | |
| 35 scrollView.bounces = YES; | |
| 36 scrollView.scrollsToTop = NO; | |
| 37 | |
| 38 NewTabPageBar* tabBar = [[NewTabPageBar alloc] initWithFrame:CGRectZero]; | |
| 39 NewTabPageView* ntpView = [[NewTabPageView alloc] initWithFrame:CGRectZero | |
| 40 andScrollView:scrollView | |
| 41 andTabBar:tabBar]; | |
| 42 ntpView.translatesAutoresizingMaskIntoConstraints = NO; | |
| 43 [self.view addSubview:ntpView]; | |
| 44 | |
| 45 [NSLayoutConstraint activateConstraints:@[ | |
| 46 [ntpView.topAnchor constraintEqualToAnchor:self.view.topAnchor], | |
| 47 [ntpView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor], | |
| 48 [ntpView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor], | |
| 49 [ntpView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor], | |
| 50 ]]; | |
| 51 | |
| 52 // PLACEHOLDER: this logic should move out of the UIVC. | |
| 53 NSString* mostVisited = l10n_util::GetNSString(IDS_IOS_NEW_TAB_MOST_VISITED); | |
| 54 NSString* bookmarks = | |
| 55 l10n_util::GetNSString(IDS_IOS_NEW_TAB_BOOKMARKS_PAGE_TITLE_MOBILE); | |
| 56 NSString* openTabs = l10n_util::GetNSString(IDS_IOS_NEW_TAB_RECENT_TABS); | |
| 57 | |
| 58 NSMutableArray* tabBarItems = [NSMutableArray array]; | |
| 59 | |
| 60 NewTabPageBarItem* mostVisitedItem = [NewTabPageBarItem | |
| 61 newTabPageBarItemWithTitle:mostVisited | |
| 62 identifier:NewTabPage::kMostVisitedPanel | |
| 63 image:[UIImage imageNamed:@"ntp_mv_search"]]; | |
| 64 NewTabPageBarItem* bookmarksItem = [NewTabPageBarItem | |
| 65 newTabPageBarItemWithTitle:bookmarks | |
| 66 identifier:NewTabPage::kBookmarksPanel | |
| 67 image:[UIImage imageNamed:@"ntp_bookmarks"]]; | |
| 68 [tabBarItems addObject:bookmarksItem]; | |
| 69 [tabBarItems addObject:mostVisitedItem]; | |
| 70 | |
| 71 NewTabPageBarItem* openTabsItem = [NewTabPageBarItem | |
| 72 newTabPageBarItemWithTitle:openTabs | |
| 73 identifier:NewTabPage::kOpenTabsPanel | |
| 74 image:[UIImage imageNamed:@"ntp_opentabs"]]; | |
| 75 [tabBarItems addObject:openTabsItem]; | |
| 76 tabBar.items = tabBarItems; | |
| 77 } | |
| 78 | |
| 79 @end | |
| OLD | NEW |