OLD | NEW |
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 #ifndef IOS_CHROME_BROWSER_UI_COLLECTION_VIEW_COLLECTION_VIEW_MODEL_H_ | 5 #ifndef IOS_CHROME_BROWSER_UI_COLLECTION_VIEW_COLLECTION_VIEW_MODEL_H_ |
6 #define IOS_CHROME_BROWSER_UI_COLLECTION_VIEW_COLLECTION_VIEW_MODEL_H_ | 6 #define IOS_CHROME_BROWSER_UI_COLLECTION_VIEW_COLLECTION_VIEW_MODEL_H_ |
7 | 7 |
8 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
9 | 9 |
10 @class CollectionViewItem; | 10 @class CollectionViewItem; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // |index|. | 78 // |index|. |
79 - (void)removeItemWithType:(NSInteger)itemType | 79 - (void)removeItemWithType:(NSInteger)itemType |
80 fromSectionWithIdentifier:(NSInteger)sectionIdentifier | 80 fromSectionWithIdentifier:(NSInteger)sectionIdentifier |
81 atIndex:(NSUInteger)index; | 81 atIndex:(NSUInteger)index; |
82 | 82 |
83 // Removes the section for |sectionIdentifier|. If there are still items left in | 83 // Removes the section for |sectionIdentifier|. If there are still items left in |
84 // the section, they are removed. | 84 // the section, they are removed. |
85 - (void)removeSectionWithIdentifier:(NSInteger)sectionIdentifier; | 85 - (void)removeSectionWithIdentifier:(NSInteger)sectionIdentifier; |
86 | 86 |
87 // Sets the header item for the section with the given |sectionIdentifier|. | 87 // Sets the header item for the section with the given |sectionIdentifier|. |
88 - (void)setHeader:(ObjectType)header | 88 - (void)setHeader:(CollectionViewItem*)header |
89 forSectionWithIdentifier:(NSInteger)sectionIdentifier; | 89 forSectionWithIdentifier:(NSInteger)sectionIdentifier; |
90 | 90 |
91 // Sets the footer item for the section with the given |sectionIdentifier|. | 91 // Sets the footer item for the section with the given |sectionIdentifier|. |
92 - (void)setFooter:(ObjectType)footer | 92 - (void)setFooter:(CollectionViewItem*)footer |
93 forSectionWithIdentifier:(NSInteger)sectionIdentifier; | 93 forSectionWithIdentifier:(NSInteger)sectionIdentifier; |
94 | 94 |
95 #pragma mark Query model coordinates from index paths | 95 #pragma mark Query model coordinates from index paths |
96 | 96 |
97 // Returns the section identifier for the given section. | 97 // Returns the section identifier for the given section. |
98 - (NSInteger)sectionIdentifierForSection:(NSInteger)section; | 98 - (NSInteger)sectionIdentifierForSection:(NSInteger)section; |
99 | 99 |
100 // Returns the item type for the given index path. | 100 // Returns the item type for the given index path. |
101 - (NSInteger)itemTypeForIndexPath:(NSIndexPath*)indexPath; | 101 - (NSInteger)itemTypeForIndexPath:(NSIndexPath*)indexPath; |
102 | 102 |
103 // Returns the index in item type for the given index path. | 103 // Returns the index in item type for the given index path. |
104 // It corresponds to the index of the item at index path, among all the items if | 104 // It corresponds to the index of the item at index path, among all the items if |
105 // the same type in the given section. | 105 // the same type in the given section. |
106 // For example, let [A, B, B, B] a section, where A and B are item identifiers. | 106 // For example, let [A, B, B, B] a section, where A and B are item identifiers. |
107 // -indexInItemTypeForIndexPath:{0, 0} would return 0. | 107 // -indexInItemTypeForIndexPath:{0, 0} would return 0. |
108 // -indexInItemTypeForIndexPath:{0, 1} would return 0. | 108 // -indexInItemTypeForIndexPath:{0, 1} would return 0. |
109 // -indexInItemTypeForIndexPath:{0, 3} would return 2. | 109 // -indexInItemTypeForIndexPath:{0, 3} would return 2. |
110 - (NSUInteger)indexInItemTypeForIndexPath:(NSIndexPath*)indexPath; | 110 - (NSUInteger)indexInItemTypeForIndexPath:(NSIndexPath*)indexPath; |
111 | 111 |
112 #pragma mark Query items from index paths | 112 #pragma mark Query items from index paths |
113 | 113 |
114 // Returns whether there is an item at the given index path. | 114 // Returns whether there is an item at the given index path. |
115 - (BOOL)hasItemAtIndexPath:(NSIndexPath*)indexPath; | 115 - (BOOL)hasItemAtIndexPath:(NSIndexPath*)indexPath; |
116 | 116 |
117 // Returns the item at the given index path. | 117 // Returns the item at the given index path. |
118 - (ObjectType)itemAtIndexPath:(NSIndexPath*)indexPath; | 118 - (ObjectType)itemAtIndexPath:(NSIndexPath*)indexPath; |
119 | 119 |
120 // Returns the header for the given |section|. | 120 // Returns the header for the given |section|. |
121 - (ObjectType)headerForSection:(NSInteger)section; | 121 - (CollectionViewItem*)headerForSection:(NSInteger)section; |
122 | 122 |
123 // Returns the footer for the given |section|. | 123 // Returns the footer for the given |section|. |
124 - (ObjectType)footerForSection:(NSInteger)section; | 124 - (CollectionViewItem*)footerForSection:(NSInteger)section; |
125 | 125 |
126 // Returns an array of items in the section with the given identifier. | 126 // Returns an array of items in the section with the given identifier. |
127 - (NSArray<ObjectType>*)itemsInSectionWithIdentifier: | 127 - (NSArray<ObjectType>*)itemsInSectionWithIdentifier: |
128 (NSInteger)sectionIdentifier; | 128 (NSInteger)sectionIdentifier; |
129 | 129 |
130 // Returns the header for the section with the given |sectionIdentifier|. | 130 // Returns the header for the section with the given |sectionIdentifier|. |
131 - (ObjectType)headerForSectionWithIdentifier:(NSInteger)sectionIdentifier; | 131 - (CollectionViewItem*)headerForSectionWithIdentifier: |
| 132 (NSInteger)sectionIdentifier; |
132 | 133 |
133 // Returns the footer for the section with the given |sectionIdentifier|. | 134 // Returns the footer for the section with the given |sectionIdentifier|. |
134 - (ObjectType)footerForSectionWithIdentifier:(NSInteger)sectionIdentifier; | 135 - (CollectionViewItem*)footerForSectionWithIdentifier: |
| 136 (NSInteger)sectionIdentifier; |
135 | 137 |
136 #pragma mark Query index paths from model coordinates | 138 #pragma mark Query index paths from model coordinates |
137 | 139 |
138 // Returns whether there is a section at the given section identifier. | 140 // Returns whether there is a section at the given section identifier. |
139 - (BOOL)hasSectionForSectionIdentifier:(NSInteger)sectionIdentifier; | 141 - (BOOL)hasSectionForSectionIdentifier:(NSInteger)sectionIdentifier; |
140 | 142 |
141 // Returns the index path's section for the given section identifier. | 143 // Returns the index path's section for the given section identifier. |
142 - (NSInteger)sectionForSectionIdentifier:(NSInteger)sectionIdentifier; | 144 - (NSInteger)sectionForSectionIdentifier:(NSInteger)sectionIdentifier; |
143 | 145 |
144 // Returns whether there is an item of type |itemType| at the given | 146 // Returns whether there is an item of type |itemType| at the given |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 180 |
179 // Returns the number of collection view sections. | 181 // Returns the number of collection view sections. |
180 - (NSInteger)numberOfSections; | 182 - (NSInteger)numberOfSections; |
181 | 183 |
182 // Returns the number of collection view items in the given section. | 184 // Returns the number of collection view items in the given section. |
183 - (NSInteger)numberOfItemsInSection:(NSInteger)section; | 185 - (NSInteger)numberOfItemsInSection:(NSInteger)section; |
184 | 186 |
185 @end | 187 @end |
186 | 188 |
187 #endif // IOS_CHROME_BROWSER_UI_COLLECTION_VIEW_COLLECTION_VIEW_MODEL_H_ | 189 #endif // IOS_CHROME_BROWSER_UI_COLLECTION_VIEW_COLLECTION_VIEW_MODEL_H_ |
OLD | NEW |