mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-06 15:08:50 +00:00
Summary: Relicensing IGListKit under MIT Reviewed By: calimarkus Differential Revision: D7764125 fbshipit-source-id: 6c773195ef3184202725fe7f08de754f979cb83f
64 lines
2.2 KiB
Objective-C
64 lines
2.2 KiB
Objective-C
/**
|
|
* Copyright (c) 2016-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
#import <IGListKit/IGListDiffable.h>
|
|
|
|
@class IGListAdapter;
|
|
@class IGListSectionController;
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
/**
|
|
Implement this protocol to provide data to an `IGListAdapter`.
|
|
*/
|
|
NS_SWIFT_NAME(ListAdapterDataSource)
|
|
@protocol IGListAdapterDataSource <NSObject>
|
|
|
|
/**
|
|
Asks the data source for the objects to display in the list.
|
|
|
|
@param listAdapter The list adapter requesting this information.
|
|
|
|
@return An array of objects for the list.
|
|
*/
|
|
- (NSArray<id <IGListDiffable>> *)objectsForListAdapter:(IGListAdapter *)listAdapter;
|
|
|
|
/**
|
|
Asks the data source for a section controller for the specified object in the list.
|
|
|
|
@param listAdapter The list adapter requesting this information.
|
|
@param object An object in the list.
|
|
|
|
@return A new section controller instance that can be displayed in the list.
|
|
|
|
@note New section controllers should be initialized here for objects when asked. You may pass any other data to
|
|
the section controller at this time.
|
|
|
|
Section controllers are initialized for all objects whenever the `IGListAdapter` is created, updated, or reloaded.
|
|
Section controllers are reused when objects are moved or updated. Maintaining the `-[IGListDiffable diffIdentifier]`
|
|
guarantees this.
|
|
*/
|
|
- (IGListSectionController *)listAdapter:(IGListAdapter *)listAdapter sectionControllerForObject:(id)object;
|
|
|
|
/**
|
|
Asks the data source for a view to use as the collection view background when the list is empty.
|
|
|
|
@param listAdapter The list adapter requesting this information.
|
|
|
|
@return A view to use as the collection view background, or `nil` if you don't want a background view.
|
|
|
|
@note This method is called every time the list adapter is updated. You are free to return new views every time,
|
|
but for performance reasons you may want to retain the view and return it here. The infra is only responsible for
|
|
adding the background view and maintaining its visibility.
|
|
*/
|
|
- (nullable UIView *)emptyViewForListAdapter:(IGListAdapter *)listAdapter;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|