Commit 4c2bd534 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Additional CollectionView cleanup

This CL cleans a bit more the collection view.

Bug: 894800
Change-Id: I3211f9afa8af578323bec1a2a13ca8842d91c42c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1991449
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#730095}
parent 0d25815e
......@@ -6,8 +6,6 @@ source_set("cells") {
sources = [
"MDCCollectionViewCell+Chrome.h",
"MDCCollectionViewCell+Chrome.mm",
"activity_indicator_cell.h",
"activity_indicator_cell.mm",
"collection_view_account_item.h",
"collection_view_account_item.mm",
"collection_view_cell_constants.h",
......@@ -56,7 +54,6 @@ source_set("unit_tests") {
testonly = true
sources = [
"MDCCollectionViewCell+Chrome_unittest.mm",
"activity_indicator_cell_unittest.mm",
"collection_view_account_item_unittest.mm",
"collection_view_footer_item_unittest.mm",
"collection_view_item_unittest.mm",
......
// 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.
#ifndef IOS_CHROME_BROWSER_UI_COLLECTION_VIEW_CELLS_ACTIVITY_INDICATOR_CELL_H_
#define IOS_CHROME_BROWSER_UI_COLLECTION_VIEW_CELLS_ACTIVITY_INDICATOR_CELL_H_
#import "ios/third_party/material_components_ios/src/components/CollectionCells/src/MaterialCollectionCells.h"
extern const CGFloat kIndicatorSize;
@class MDCActivityIndicator;
// MDCCollectionViewCell that displays an activity indicator.
@interface ActivityIndicatorCell : MDCCollectionViewCell
@property(nonatomic, strong) MDCActivityIndicator* activityIndicator;
@end
#endif // IOS_CHROME_BROWSER_UI_COLLECTION_VIEW_CELLS_ACTIVITY_INDICATOR_CELL_H_
// 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/chrome/browser/ui/collection_view/cells/activity_indicator_cell.h"
#import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrome.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h"
#import "ios/chrome/browser/ui/material_components/activity_indicator.h"
#import "ios/third_party/material_components_ios/src/components/ActivityIndicator/src/MaterialActivityIndicator.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
const CGFloat kIndicatorSize = 32;
@implementation ActivityIndicatorCell
@synthesize activityIndicator = _activityIndicator;
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
_activityIndicator = [[MDCActivityIndicator alloc]
initWithFrame:CGRectMake(0, 0, kIndicatorSize, kIndicatorSize)];
_activityIndicator.cycleColors = ActivityIndicatorBrandedCycleColors();
[self.contentView addSubview:_activityIndicator];
_activityIndicator.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
[_activityIndicator.topAnchor
constraintEqualToAnchor:self.contentView.topAnchor],
[_activityIndicator.bottomAnchor
constraintEqualToAnchor:self.contentView.bottomAnchor],
[_activityIndicator.leadingAnchor
constraintEqualToAnchor:self.contentView.leadingAnchor],
[_activityIndicator.trailingAnchor
constraintEqualToAnchor:self.contentView.trailingAnchor],
]];
[_activityIndicator startAnimating];
}
return self;
}
@end
// 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/chrome/browser/ui/collection_view/cells/activity_indicator_cell.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h"
#import "ios/third_party/material_components_ios/src/components/ActivityIndicator/src/MaterialActivityIndicator.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
using ActivityIndicatorItemTest = PlatformTest;
// Tests that when an ActivityIndicatorCell is configured, it has a
// MDCActivityIndicator that is animating.
TEST_F(ActivityIndicatorItemTest, CellDisplaysActivityIndicator) {
CollectionViewItem* item = [[CollectionViewItem alloc] initWithType:0];
item.cellClass = [ActivityIndicatorCell class];
ActivityIndicatorCell* cell =
[[ActivityIndicatorCell alloc] initWithFrame:CGRectZero];
[item configureCell:cell];
MDCActivityIndicator* activity_indicator = cell.activityIndicator;
EXPECT_TRUE([activity_indicator isDescendantOfView:cell]);
EXPECT_TRUE(activity_indicator.isAnimating);
}
}
......@@ -7,31 +7,13 @@
#import <CoreGraphics/CoreGraphics.h>
// The amount of padding at the top and bottom of UIKit-style cells.
const CGFloat kUIKitVerticalPadding = 16;
// The font size to use for main text in UIKit-style cells.
const CGFloat kUIKitMainFontSize = 17;
// The font size to use for detail text that is on the trailing edge
// of the top line.
const CGFloat kUIKitDetailFontSize = 17;
// The font size to use for detail text that is on its own line.
const CGFloat kUIKitMultilineDetailFontSize = 12;
// The font size and color to use for footer text in UIKit-style cells.
const CGFloat kUIKitFooterFontSize = 13;
// The tint color to use for switches in UIKit-style cells.
const int kUIKitSwitchTintColor = 0x1A73E8;
// The font size and color to use for headers in UIKit-style cells.
const int kUIKitHeaderTextColor = 0x000000;
const CGFloat kUIKitHeaderTextAlpha = 0.5;
const CGFloat kUIKitHeaderFontSize = 13;
// The color to use for separators between UIKit-style cells.
const int kUIKitSeparatorColor = 0xC8C7CC;
#endif // IOS_CHROME_BROWSER_UI_COLLECTION_VIEW_CELLS_COLLECTION_VIEW_CELL_CONSTANTS_H_
......@@ -115,7 +115,8 @@ TEST_F(BlockPopupsTableViewControllerTest, TestOneAllowedItem) {
EXPECT_EQ(2, NumberOfSections());
EXPECT_EQ(1, NumberOfItemsInSection(1));
CheckSectionHeaderWithId(IDS_IOS_POPUPS_ALLOWED, 1);
CheckTextCellText(base::SysUTF8ToNSString(kAllowedPattern), 1, 0);
CheckTextCellTextAndDetailText(base::SysUTF8ToNSString(kAllowedPattern), nil,
1, 0);
EXPECT_TRUE([controller() navigationItem].rightBarButtonItem);
}
......
......@@ -107,8 +107,8 @@ TEST_F(PrivacyTableViewControllerTest, TestModel) {
// Sections[1].
EXPECT_EQ(1, NumberOfItemsInSection(1));
CheckTextCellText(l10n_util::GetNSString(IDS_IOS_CLEAR_BROWSING_DATA_TITLE),
1, 0);
CheckTextCellTextAndDetailText(
l10n_util::GetNSString(IDS_IOS_CLEAR_BROWSING_DATA_TITLE), nil, 1, 0);
}
} // namespace
......@@ -11,9 +11,7 @@
@protocol BrowserCommands;
@protocol BrowsingDataCommands;
// TODO(crbug.com/894800): This protocol is added to have a common interface
// between the SettingsRootViewControllers for table views and collections.
// Remove it once it is completed.
// Protocol allowing the dispatcher to be passed to the settings ViewController.
@protocol SettingsRootViewControlling
// The dispatcher used by this ViewController.
......
......@@ -115,9 +115,6 @@ void ChromeTableViewControllerTest::CheckSectionFooterWithId(
CheckSectionFooter(l10n_util::GetNSString(expected_text_id), section);
}
// TODO(crbug.com/894800): There are some unittests that are using
// CheckTextCellText to check Item with both "text" and "detailText". Change all
// of them to CheckTextCellTextAndDetailText when the migration is finished.
void ChromeTableViewControllerTest::CheckTextCellText(NSString* expected_text,
int section,
int item) {
......
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