Commit 2fef7a52 authored by Stepan Khapugin's avatar Stepan Khapugin Committed by Commit Bot

[iOS] Share constants between NTP and Shortcuts.

Creates a shared file with NTP tile-related constants.

Bug: None
Test: None
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: I315b5c6fee67356c70b315771980d7654381dcf6
Reviewed-on: https://chromium-review.googlesource.com/c/1288789
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601588}
parent ab7c15df
...@@ -59,6 +59,7 @@ source_set("cells_ui") { ...@@ -59,6 +59,7 @@ source_set("cells_ui") {
"//ios/chrome/browser/ui/content_suggestions/identifier", "//ios/chrome/browser/ui/content_suggestions/identifier",
"//ios/chrome/browser/ui/material_components", "//ios/chrome/browser/ui/material_components",
"//ios/chrome/browser/ui/ntp_tile_views", "//ios/chrome/browser/ui/ntp_tile_views",
"//ios/chrome/browser/ui/ntp_tile_views:constants",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ios/chrome/common", "//ios/chrome/common",
"//ios/chrome/common/favicon", "//ios/chrome/common/favicon",
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_most_visited_constants.h" #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_most_visited_constants.h"
#import "ios/chrome/browser/ui/ntp_tile_views/ntp_shortcut_tile_view.h" #import "ios/chrome/browser/ui/ntp_tile_views/ntp_shortcut_tile_view.h"
#import "ios/chrome/browser/ui/ntp_tile_views/ntp_tile_constants.h"
#include "ios/chrome/browser/ui/ui_util.h" #include "ios/chrome/browser/ui/ui_util.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h" #import "ios/chrome/browser/ui/uikit_ui_util.h"
#import "ios/chrome/common/favicon/favicon_view.h" #import "ios/chrome/common/favicon/favicon_view.h"
...@@ -55,7 +56,7 @@ ...@@ -55,7 +56,7 @@
} }
+ (CGSize)defaultSize { + (CGSize)defaultSize {
return kCellSize; return kMostVisitedCellSize;
} }
- (CGSize)intrinsicContentSize { - (CGSize)intrinsicContentSize {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#import "ios/chrome/browser/ui/ntp_tile_views/ntp_most_visited_tile_view.h" #import "ios/chrome/browser/ui/ntp_tile_views/ntp_most_visited_tile_view.h"
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_most_visited_constants.h" #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_most_visited_constants.h"
#import "ios/chrome/browser/ui/ntp_tile_views/ntp_tile_constants.h"
#include "ios/chrome/browser/ui/ui_util.h" #include "ios/chrome/browser/ui/ui_util.h"
#import "ios/chrome/common/favicon/favicon_view.h" #import "ios/chrome/common/favicon/favicon_view.h"
#import "ios/chrome/common/material_timing.h" #import "ios/chrome/common/material_timing.h"
...@@ -59,7 +60,7 @@ ...@@ -59,7 +60,7 @@
} }
+ (CGSize)defaultSize { + (CGSize)defaultSize {
return kCellSize; return kMostVisitedCellSize;
} }
- (CGSize)intrinsicContentSize { - (CGSize)intrinsicContentSize {
......
...@@ -19,9 +19,6 @@ extern const NSInteger kLabelNumLines; ...@@ -19,9 +19,6 @@ extern const NSInteger kLabelNumLines;
// Space between the icon and the title label. // Space between the icon and the title label.
extern const CGFloat kSpaceIconTitle; extern const CGFloat kSpaceIconTitle;
// Size of a Most Visited cell.
extern const CGSize kCellSize;
// The alpha value for text. // The alpha value for text.
extern const CGFloat kTitleAlpha; extern const CGFloat kTitleAlpha;
......
...@@ -12,5 +12,4 @@ const CGFloat kIconSize = 56; ...@@ -12,5 +12,4 @@ const CGFloat kIconSize = 56;
const CGFloat kLabelTextColor = 0.314; const CGFloat kLabelTextColor = 0.314;
const NSInteger kLabelNumLines = 2; const NSInteger kLabelNumLines = 2;
const CGFloat kSpaceIconTitle = 10; const CGFloat kSpaceIconTitle = 10;
const CGSize kCellSize = {73, 100};
const CGFloat kTitleAlpha = 0.54; const CGFloat kTitleAlpha = 0.54;
...@@ -411,7 +411,6 @@ GREYElementInteraction* CellWithMatcher(id<GREYMatcher> matcher) { ...@@ -411,7 +411,6 @@ GREYElementInteraction* CellWithMatcher(id<GREYMatcher> matcher) {
@"Test did not switch to incognito"); @"Test did not switch to incognito");
} }
// Tests the "Remove" action of the Most Visited context menu, and the "Undo"
// action. // action.
- (void)testMostVisitedRemoveUndo { - (void)testMostVisitedRemoveUndo {
[self setupMostVisitedTileLongPress]; [self setupMostVisitedTileLongPress];
......
...@@ -23,3 +23,11 @@ source_set("ntp_tile_views") { ...@@ -23,3 +23,11 @@ source_set("ntp_tile_views") {
"//ios/chrome/common/ui_util", "//ios/chrome/common/ui_util",
] ]
} }
source_set("constants") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"ntp_tile_constants.h",
"ntp_tile_constants.mm",
]
}
// Copyright 2018 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.
#ifndef IOS_CHROME_BROWSER_UI_NTP_TILE_VIEWS_NTP_TILE_CONSTANTS_H_
#define IOS_CHROME_BROWSER_UI_NTP_TILE_VIEWS_NTP_TILE_CONSTANTS_H_
#import <UIKit/UIKit.h>
// Size of a Most Visited cell, for example on NTP.
extern const CGSize kMostVisitedCellSize;
#endif // IOS_CHROME_BROWSER_UI_NTP_TILE_VIEWS_NTP_TILE_CONSTANTS_H_
// Copyright 2018 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/chrome/browser/ui/ntp_tile_views/ntp_tile_constants.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
const CGSize kMostVisitedCellSize = {/*width=*/73, /*height=*/100};
...@@ -18,6 +18,7 @@ source_set("shortcuts") { ...@@ -18,6 +18,7 @@ source_set("shortcuts") {
"//ios/chrome/browser/reading_list", "//ios/chrome/browser/reading_list",
"//ios/chrome/browser/ui/coordinators:chrome_coordinators", "//ios/chrome/browser/ui/coordinators:chrome_coordinators",
"//ios/chrome/browser/ui/ntp_tile_views", "//ios/chrome/browser/ui/ntp_tile_views",
"//ios/chrome/browser/ui/ntp_tile_views:constants",
"//ios/chrome/common/favicon", "//ios/chrome/common/favicon",
"//ios/chrome/common/ui_util", "//ios/chrome/common/ui_util",
] ]
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/logging.h" #include "base/logging.h"
#import "ios/chrome/browser/ui/ntp_tile_views/ntp_most_visited_tile_view.h" #import "ios/chrome/browser/ui/ntp_tile_views/ntp_most_visited_tile_view.h"
#import "ios/chrome/browser/ui/ntp_tile_views/ntp_tile_constants.h"
#import "ios/chrome/common/favicon/favicon_view.h" #import "ios/chrome/common/favicon/favicon_view.h"
#import "ios/chrome/common/ui_util/constraints_ui_util.h" #import "ios/chrome/common/ui_util/constraints_ui_util.h"
...@@ -18,7 +19,6 @@ const NSInteger kNumberOfItemsPerRow = 4; ...@@ -18,7 +19,6 @@ const NSInteger kNumberOfItemsPerRow = 4;
const CGFloat kLineSpacing = 30; const CGFloat kLineSpacing = 30;
const CGFloat kItemSpacing = 10; const CGFloat kItemSpacing = 10;
const CGFloat kTopInset = 10; const CGFloat kTopInset = 10;
const CGSize kItemSize = {73, 100};
} // namespace } // namespace
#pragma mark - ShortcutCell #pragma mark - ShortcutCell
...@@ -78,10 +78,10 @@ const CGSize kItemSize = {73, 100}; ...@@ -78,10 +78,10 @@ const CGSize kItemSize = {73, 100};
[super viewWillAppear:animated]; [super viewWillAppear:animated];
// Calculate insets to center the items in the view. // Calculate insets to center the items in the view.
CGFloat widthInsets = CGFloat widthInsets = (self.view.bounds.size.width -
(self.view.bounds.size.width - kItemSize.width * kNumberOfItemsPerRow - kMostVisitedCellSize.width * kNumberOfItemsPerRow -
kItemSpacing * (kNumberOfItemsPerRow - 1)) / kItemSpacing * (kNumberOfItemsPerRow - 1)) /
2; 2;
self.layout.sectionInset = self.layout.sectionInset =
UIEdgeInsetsMake(kTopInset, widthInsets, 0, widthInsets); UIEdgeInsetsMake(kTopInset, widthInsets, 0, widthInsets);
} }
...@@ -111,7 +111,7 @@ const CGSize kItemSize = {73, 100}; ...@@ -111,7 +111,7 @@ const CGSize kItemSize = {73, 100};
_layout = [[UICollectionViewFlowLayout alloc] init]; _layout = [[UICollectionViewFlowLayout alloc] init];
_layout.minimumLineSpacing = kLineSpacing; _layout.minimumLineSpacing = kLineSpacing;
_layout.itemSize = kItemSize; _layout.itemSize = kMostVisitedCellSize;
return _layout; return _layout;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment