session-ios/Signal/src/ViewControllers/OWSTableViewController.h

122 lines
3.6 KiB
C
Raw Normal View History

//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <UIKit/UIKit.h>
2017-04-03 23:12:29 +02:00
NS_ASSUME_NONNULL_BEGIN
2017-04-17 21:13:15 +02:00
extern const CGFloat kOWSTable_DefaultCellHeight;
@class OWSTableItem;
@class OWSTableSection;
@interface OWSTableContents : NSObject
@property (nonatomic) NSString *title;
- (void)addSection:(OWSTableSection *)section;
@end
#pragma mark -
@interface OWSTableSection : NSObject
@property (nonatomic, nullable) NSString *headerTitle;
@property (nonatomic, nullable) NSString *footerTitle;
2017-04-17 21:13:15 +02:00
@property (nonatomic, nullable) UIView *customHeaderView;
@property (nonatomic, nullable) UIView *customFooterView;
@property (nonatomic, nullable) NSNumber *customHeaderHeight;
@property (nonatomic, nullable) NSNumber *customFooterHeight;
+ (OWSTableSection *)sectionWithTitle:(nullable NSString *)title items:(NSArray<OWSTableItem *> *)items;
- (void)addItem:(OWSTableItem *)item;
- (NSUInteger)itemCount;
@end
#pragma mark -
typedef NS_ENUM(NSInteger, OWSTableItemType) {
OWSTableItemTypeDefault,
OWSTableItemTypeAction,
};
typedef void (^OWSTableActionBlock)();
2017-04-06 21:30:21 +02:00
typedef UITableViewCell *_Nonnull (^OWSTableCustomCellBlock)();
@interface OWSTableItem : NSObject
2017-04-05 15:09:09 +02:00
+ (OWSTableItem *)itemWithTitle:(NSString *)title actionBlock:(nullable OWSTableActionBlock)actionBlock;
+ (OWSTableItem *)itemWithCustomCell:(UITableViewCell *)customCell
customRowHeight:(CGFloat)customRowHeight
2017-04-05 15:09:09 +02:00
actionBlock:(nullable OWSTableActionBlock)actionBlock;
+ (OWSTableItem *)itemWithCustomCellBlock:(OWSTableCustomCellBlock)customCellBlock
customRowHeight:(CGFloat)customRowHeight
2017-04-05 15:09:09 +02:00
actionBlock:(nullable OWSTableActionBlock)actionBlock;
+ (OWSTableItem *)itemWithCustomCellBlock:(OWSTableCustomCellBlock)customCellBlock
2017-04-05 15:09:09 +02:00
actionBlock:(nullable OWSTableActionBlock)actionBlock;
+ (OWSTableItem *)disclosureItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock;
+ (OWSTableItem *)disclosureItemWithText:(NSString *)text
customRowHeight:(CGFloat)customRowHeight
actionBlock:(nullable OWSTableActionBlock)actionBlock;
+ (OWSTableItem *)actionItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock;
+ (OWSTableItem *)softCenterLabelItemWithText:(NSString *)text;
+ (OWSTableItem *)softCenterLabelItemWithText:(NSString *)text customRowHeight:(CGFloat)customRowHeight;
+ (OWSTableItem *)labelItemWithText:(NSString *)text;
+ (OWSTableItem *)labelItemWithText:(NSString *)text accessoryText:(NSString *)accessoryText;
+ (OWSTableItem *)switchItemWithText:(NSString *)text isOn:(BOOL)isOn target:(id)target selector:(SEL)selector;
+ (OWSTableItem *)switchItemWithText:(NSString *)text
isOn:(BOOL)isOn
isEnabled:(BOOL)isEnabled
target:(id)target
selector:(SEL)selector;
2017-04-06 21:30:21 +02:00
- (nullable UITableViewCell *)customCell;
- (NSNumber *)customRowHeight;
@end
#pragma mark -
@protocol OWSTableViewControllerDelegate <NSObject>
- (void)tableViewDidScroll;
@end
#pragma mark -
2017-04-17 21:13:15 +02:00
@interface OWSTableViewController : UIViewController
@property (nonatomic, weak) id<OWSTableViewControllerDelegate> delegate;
@property (nonatomic) OWSTableContents *contents;
2017-04-17 21:13:15 +02:00
@property (nonatomic, readonly) UITableView *tableView;
2017-05-04 19:51:39 +02:00
@property (nonatomic) UITableViewStyle tableViewStyle;
#pragma mark - Presentation
- (void)presentFromViewController:(UIViewController *)fromViewController;
@end
2017-04-03 23:12:29 +02:00
NS_ASSUME_NONNULL_END