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

Unified Diff: ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrome.h

Issue 2588713002: Upstream Chrome on iOS source code [4/11]. (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
Index: ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrome.h
diff --git a/ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrome.h b/ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrome.h
new file mode 100644
index 0000000000000000000000000000000000000000..a06fc18d6522e71a6b53f7f2268a728f7387c955
--- /dev/null
+++ b/ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrome.h
@@ -0,0 +1,46 @@
+// 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_MDCCOLLECTIONVIEWCELL_CHROME_H_
+#define IOS_CHROME_BROWSER_UI_COLLECTION_VIEW_CELLS_MDCCOLLECTIONVIEWCELL_CHROME_H_
+
+#import <CoreGraphics/CoreGraphics.h>
+
+#import "ios/third_party/material_components_ios/src/components/CollectionCells/src/MaterialCollectionCells.h"
+
+@class CollectionViewItem;
+
+// Augments MDCCollectionViewCell for use in conjunction with
+// CollectionViewItem.
+@interface MDCCollectionViewCell (Chrome)
+
+// Returns the height this class of cell would need to be to fit within
+// |targetWidth|, configured by |item|. The returned height is calculated by
+// Auto Layout so that the contents of the cell could fit within the
+// |targetWidth|.
+// If the cell contains multi-line labels, make sure to update the
+// |preferredMaxLayoutWidth| in -layoutSubviews like so:
+//
+// @implementation MyCell
+//
+// - (void)layoutSubView {
+// [super layoutSubviews];
+//
+// // Adjust the text label preferredMaxLayoutWidth when the parent's width
+// // changes, for instance on screen rotation.
+// CGFloat parentWidth = CGRectGetWidth(self.contentView.bounds);
+// _textLabel.preferredMaxLayoutWidth = parentWidth - 2 * kHorizontalPadding;
+//
+// // Re-layout with the new preferred width to allow the label to adjust its
+// // height.
+// [super layoutSubviews];
+// }
+//
+// @end
++ (CGFloat)cr_preferredHeightForWidth:(CGFloat)targetWidth
+ forItem:(CollectionViewItem*)item;
+
+@end
+
+#endif // IOS_CHROME_BROWSER_UI_COLLECTION_VIEW_CELLS_MDCCOLLECTIONVIEWCELL_CHROME_H_

Powered by Google App Engine
This is Rietveld 408576698