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

Side by Side Diff: ios/chrome/browser/ui/reading_list/reading_list_collection_view_item.mm

Issue 2787763002: Add autolayout height constraint on ReadingListCell (Closed)
Patch Set: Created 3 years, 8 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/chrome/browser/ui/reading_list/reading_list_collection_view_item.h" 5 #import "ios/chrome/browser/ui/reading_list/reading_list_collection_view_item.h"
6 6
7 #include "base/strings/sys_string_conversions.h" 7 #include "base/strings/sys_string_conversions.h"
8 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" 8 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
9 #import "ios/chrome/browser/ui/favicon_view.h" 9 #import "ios/chrome/browser/ui/favicon_view.h"
10 #import "ios/chrome/browser/ui/reading_list/reading_list_collection_view_item_ac cessibility_delegate.h" 10 #import "ios/chrome/browser/ui/reading_list/reading_list_collection_view_item_ac cessibility_delegate.h"
11 #import "ios/chrome/browser/ui/uikit_ui_util.h" 11 #import "ios/chrome/browser/ui/uikit_ui_util.h"
12 #include "ios/chrome/grit/ios_strings.h" 12 #include "ios/chrome/grit/ios_strings.h"
13 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat erialPalettes.h" 13 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat erialPalettes.h"
14 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h" 14 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h"
15 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/base/l10n/time_format.h" 16 #include "ui/base/l10n/time_format.h"
17 #import "url/gurl.h" 17 #import "url/gurl.h"
18 18
19 #if !defined(__has_feature) || !__has_feature(objc_arc) 19 #if !defined(__has_feature) || !__has_feature(objc_arc)
20 #error "This file requires ARC support." 20 #error "This file requires ARC support."
21 #endif 21 #endif
22 22
23 namespace { 23 namespace {
24 NSString* kSuccessImageString = @"distillation_success"; 24 NSString* kSuccessImageString = @"distillation_success";
25 NSString* kFailureImageString = @"distillation_fail"; 25 NSString* kFailureImageString = @"distillation_fail";
26 26
27 // Height of the cell.
28 const CGFloat kCellHeight = 72;
29
27 // Distillation indicator constants. 30 // Distillation indicator constants.
28 const CGFloat kDistillationIndicatorSize = 18; 31 const CGFloat kDistillationIndicatorSize = 18;
29 32
30 // Margin for the elements displayed in the cell. 33 // Margin for the elements displayed in the cell.
31 const CGFloat kMargin = 16; 34 const CGFloat kMargin = 16;
32 35
33 // Transparency of the distillation size and date. 36 // Transparency of the distillation size and date.
34 const CGFloat kInfoTextTransparency = 0.38; 37 const CGFloat kInfoTextTransparency = 0.38;
35 } // namespace 38 } // namespace
36 39
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 323
321 // Sets the bottom of the text. Lower the priority so we can add the details 324 // Sets the bottom of the text. Lower the priority so we can add the details
322 // later. 325 // later.
323 NSLayoutConstraint* bottomTextConstraint = [_textGuide.bottomAnchor 326 NSLayoutConstraint* bottomTextConstraint = [_textGuide.bottomAnchor
324 constraintEqualToAnchor:_subtitleLabel.bottomAnchor]; 327 constraintEqualToAnchor:_subtitleLabel.bottomAnchor];
325 bottomTextConstraint.priority = UILayoutPriorityDefaultHigh; 328 bottomTextConstraint.priority = UILayoutPriorityDefaultHigh;
326 NSLayoutConstraint* topTextConstraint = 329 NSLayoutConstraint* topTextConstraint =
327 [_textGuide.topAnchor constraintEqualToAnchor:_titleLabel.topAnchor]; 330 [_textGuide.topAnchor constraintEqualToAnchor:_titleLabel.topAnchor];
328 331
329 [NSLayoutConstraint activateConstraints:@[ 332 [NSLayoutConstraint activateConstraints:@[
333 // Height for the cell.
334 [self.contentView.heightAnchor constraintEqualToConstant:kCellHeight],
335
336 // Text constraints.
330 topTextConstraint, 337 topTextConstraint,
331 bottomTextConstraint, 338 bottomTextConstraint,
339
332 // Favicons are always the same size. 340 // Favicons are always the same size.
333 [_faviconView.widthAnchor constraintEqualToConstant:faviconSize], 341 [_faviconView.widthAnchor constraintEqualToConstant:faviconSize],
334 [_faviconView.heightAnchor constraintEqualToConstant:faviconSize], 342 [_faviconView.heightAnchor constraintEqualToConstant:faviconSize],
343
335 // Center the content (favicon and text) vertically. 344 // Center the content (favicon and text) vertically.
336 [_faviconView.centerYAnchor 345 [_faviconView.centerYAnchor
337 constraintEqualToAnchor:self.contentView.centerYAnchor], 346 constraintEqualToAnchor:self.contentView.centerYAnchor],
338 [_textGuide.centerYAnchor 347 [_textGuide.centerYAnchor
339 constraintEqualToAnchor:self.contentView.centerYAnchor], 348 constraintEqualToAnchor:self.contentView.centerYAnchor],
340 349
341 // Place the download indicator in the bottom right corner of the favicon. 350 // Place the download indicator in the bottom right corner of the favicon.
342 [[_downloadIndicator centerXAnchor] 351 [[_downloadIndicator centerXAnchor]
343 constraintEqualToAnchor:_faviconView.trailingAnchor], 352 constraintEqualToAnchor:_faviconView.trailingAnchor],
344 [[_downloadIndicator centerYAnchor] 353 [[_downloadIndicator centerYAnchor]
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 self.subtitleLabel.text = nil; 451 self.subtitleLabel.text = nil;
443 self.distillationState = ReadingListEntry::WAITING; 452 self.distillationState = ReadingListEntry::WAITING;
444 self.distillationDate = 0; 453 self.distillationDate = 0;
445 self.distillationSize = 0; 454 self.distillationSize = 0;
446 [self setShowInfo:NO]; 455 [self setShowInfo:NO];
447 self.accessibilityCustomActions = nil; 456 self.accessibilityCustomActions = nil;
448 [super prepareForReuse]; 457 [super prepareForReuse];
449 } 458 }
450 459
451 @end 460 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698