OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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 #ifndef IOS_CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_COLLECTION_CELLS_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_COLLECTION_CELLS_H_ |
| 7 |
| 8 #import <UIKit/UIKit.h> |
| 9 |
| 10 namespace bookmark_cell { |
| 11 // The types get cached, which means that their values must not change. |
| 12 typedef enum { |
| 13 ButtonNone = 0, // No button. |
| 14 ButtonMenu, // 3-vertical-dots button. |
| 15 } ButtonType; |
| 16 |
| 17 } // bookmark_cell |
| 18 |
| 19 // Views that expect to display an image associated with a bookmark must |
| 20 // implement this protocol. |
| 21 // Since the image fetching API is asynchronous and uncancellable, views must |
| 22 // store some metadata associated with the image to ensure irrelevant callbacks |
| 23 // are discarded. |
| 24 @protocol BookmarkImageableView |
| 25 @property(nonatomic, assign) BOOL shouldAnimateImageChanges; |
| 26 // Sets the image on the view, animating the change if |
| 27 // shouldAnimateImageChanges is YES. Hides the overlay placeholder text. |
| 28 - (void)setImage:(UIImage*)image; |
| 29 // Sets the placeholder text that is displayed over the image view. Hides the |
| 30 // image. |
| 31 - (void)setPlaceholderText:(NSString*)text |
| 32 textColor:(UIColor*)textColor |
| 33 backgroundColor:(UIColor*)backgroundColor; |
| 34 @end |
| 35 |
| 36 #pragma mark - Base Classes For Both Device Types |
| 37 |
| 38 // Abstract base class for cells in the bookmark collection view. |
| 39 // Most controllers that use this cell have an "edit" mode that allows users to |
| 40 // select multiple bookmarks. When a cell is selected, a translucent overlay |
| 41 // is layered on top to change the look of the view. |
| 42 // Subclasses should insert new views below the "highlightCover" property. |
| 43 // There is also an image and an optional menu button. |
| 44 @interface BookmarkCell : UICollectionViewCell<BookmarkImageableView> |
| 45 |
| 46 @property(nonatomic, retain, readonly) UILabel* titleLabel; |
| 47 |
| 48 + (NSString*)reuseIdentifier; |
| 49 |
| 50 // Sets the target/selector for the top-right corner button. |
| 51 // |action| must take exactly 2 arguments. |
| 52 // The first object passed to |action| will be of type BookmarkItemCell. |
| 53 // The second will be the view that was tapped on to trigger the action. |
| 54 - (void)setButtonTarget:(id)target action:(SEL)action; |
| 55 |
| 56 // Changes the appearance of the button. |
| 57 - (void)showButtonOfType:(bookmark_cell::ButtonType)buttonType |
| 58 animated:(BOOL)animated; |
| 59 |
| 60 // The cell has been selected by the user in editing mode. |
| 61 - (void)setSelectedForEditing:(BOOL)selected animated:(BOOL)animated; |
| 62 |
| 63 // Sets the title. |
| 64 - (void)updateWithTitle:(NSString*)title; |
| 65 |
| 66 @end |
| 67 |
| 68 #pragma mark - Specialized Cells |
| 69 |
| 70 // Specialized cell for bookmark urls. |
| 71 // It is intended to show the title, domain, and parent folder of the bookmark. |
| 72 @interface BookmarkItemCell : BookmarkCell |
| 73 // Returns the icon size that is preferred for this cell. Icons are square, and |
| 74 // the returned value is the side of the square in points. |
| 75 + (CGFloat)preferredImageSize; |
| 76 @end |
| 77 |
| 78 // Specialized cell for bookmark folders. Uses a default folder image. |
| 79 @interface BookmarkFolderCell : BookmarkCell |
| 80 @end |
| 81 |
| 82 #pragma mark - Header Views |
| 83 |
| 84 // Standard header view for a section. |
| 85 @interface BookmarkHeaderView : UICollectionReusableView |
| 86 + (NSString*)reuseIdentifier; |
| 87 + (CGFloat)handsetHeight; |
| 88 - (void)setTitle:(NSString*)title; |
| 89 @end |
| 90 |
| 91 // Blank white header with thin separator line in the bottom. |
| 92 @interface BookmarkHeaderSeparatorView : UICollectionReusableView |
| 93 + (NSString*)reuseIdentifier; |
| 94 + (CGFloat)preferredHeight; |
| 95 @end |
| 96 |
| 97 #endif // IOS_CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_COLLECTION_CELLS_H_ |
OLD | NEW |