2017-03-31 04:32:56 +02:00
|
|
|
//
|
2019-02-25 18:58:15 +01:00
|
|
|
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
2017-03-31 04:32:56 +02:00
|
|
|
//
|
|
|
|
|
2020-11-11 06:30:54 +01:00
|
|
|
#import <SignalUtilitiesKit/OWSViewController.h>
|
2017-03-31 04:32:56 +02:00
|
|
|
|
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;
|
|
|
|
|
2017-03-31 04:32:56 +02:00
|
|
|
@class OWSTableItem;
|
|
|
|
@class OWSTableSection;
|
|
|
|
|
|
|
|
@interface OWSTableContents : NSObject
|
|
|
|
|
|
|
|
@property (nonatomic) NSString *title;
|
2017-10-14 19:20:46 +02:00
|
|
|
@property (nonatomic, nullable) NSInteger (^sectionForSectionIndexTitleBlock)(NSString *title, NSInteger index);
|
|
|
|
@property (nonatomic, nullable) NSArray<NSString *> * (^sectionIndexTitlesForTableViewBlock)(void);
|
2017-03-31 04:32:56 +02:00
|
|
|
|
2017-10-14 19:20:46 +02:00
|
|
|
@property (nonatomic, readonly) NSArray<OWSTableSection *> *sections;
|
2017-03-31 04:32:56 +02:00
|
|
|
- (void)addSection:(OWSTableSection *)section;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
@interface OWSTableSection : NSObject
|
|
|
|
|
2017-04-10 21:58:34 +02:00
|
|
|
@property (nonatomic, nullable) NSString *headerTitle;
|
|
|
|
@property (nonatomic, nullable) NSString *footerTitle;
|
2017-03-31 04:32:56 +02:00
|
|
|
|
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;
|
|
|
|
|
2017-04-10 21:58:34 +02:00
|
|
|
+ (OWSTableSection *)sectionWithTitle:(nullable NSString *)title items:(NSArray<OWSTableItem *> *)items;
|
2017-03-31 04:32:56 +02:00
|
|
|
|
|
|
|
- (void)addItem:(OWSTableItem *)item;
|
|
|
|
|
2017-04-25 18:56:37 +02:00
|
|
|
- (NSUInteger)itemCount;
|
|
|
|
|
2017-03-31 04:32:56 +02:00
|
|
|
@end
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
2017-11-08 20:04:51 +01:00
|
|
|
typedef void (^OWSTableActionBlock)(void);
|
2018-01-05 20:42:50 +01:00
|
|
|
typedef void (^OWSTableSubPageBlock)(UIViewController *viewController);
|
2017-11-08 20:04:51 +01:00
|
|
|
typedef UITableViewCell *_Nonnull (^OWSTableCustomCellBlock)(void);
|
2019-02-25 18:58:15 +01:00
|
|
|
typedef BOOL (^OWSTableSwitchBlock)(void);
|
2017-03-31 04:32:56 +02:00
|
|
|
|
|
|
|
@interface OWSTableItem : NSObject
|
|
|
|
|
2018-01-05 20:42:50 +01:00
|
|
|
@property (nonatomic, weak) UIViewController *tableViewController;
|
|
|
|
|
2018-07-13 00:01:43 +02:00
|
|
|
+ (UITableViewCell *)newCell;
|
2018-07-13 00:38:55 +02:00
|
|
|
+ (void)configureCell:(UITableViewCell *)cell;
|
2018-07-13 00:01:43 +02:00
|
|
|
|
2018-09-20 18:52:43 +02:00
|
|
|
+ (OWSTableItem *)itemWithTitle:(NSString *)title
|
|
|
|
actionBlock:(nullable OWSTableActionBlock)actionBlock NS_SWIFT_NAME(init(title:actionBlock:));
|
2017-04-03 16:29:11 +02:00
|
|
|
|
|
|
|
+ (OWSTableItem *)itemWithCustomCell:(UITableViewCell *)customCell
|
|
|
|
customRowHeight:(CGFloat)customRowHeight
|
2017-04-05 15:09:09 +02:00
|
|
|
actionBlock:(nullable OWSTableActionBlock)actionBlock;
|
2017-04-03 16:29:11 +02:00
|
|
|
|
|
|
|
+ (OWSTableItem *)itemWithCustomCellBlock:(OWSTableCustomCellBlock)customCellBlock
|
|
|
|
customRowHeight:(CGFloat)customRowHeight
|
2017-04-05 15:09:09 +02:00
|
|
|
actionBlock:(nullable OWSTableActionBlock)actionBlock;
|
2017-04-03 16:29:11 +02:00
|
|
|
|
|
|
|
+ (OWSTableItem *)itemWithCustomCellBlock:(OWSTableCustomCellBlock)customCellBlock
|
2017-04-05 15:09:09 +02:00
|
|
|
actionBlock:(nullable OWSTableActionBlock)actionBlock;
|
2017-04-03 16:29:11 +02:00
|
|
|
|
2017-05-10 23:27:53 +02:00
|
|
|
+ (OWSTableItem *)disclosureItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock;
|
|
|
|
|
2019-03-14 15:26:38 +01:00
|
|
|
+ (OWSTableItem *)disclosureItemWithText:(NSString *)text
|
|
|
|
accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier
|
|
|
|
actionBlock:(nullable OWSTableActionBlock)actionBlock;
|
|
|
|
|
|
|
|
+ (OWSTableItem *)disclosureItemWithText:(NSString *)text
|
|
|
|
detailText:(NSString *)detailText
|
|
|
|
actionBlock:(nullable OWSTableActionBlock)actionBlock;
|
|
|
|
|
2018-02-28 15:58:54 +01:00
|
|
|
+ (OWSTableItem *)disclosureItemWithText:(NSString *)text
|
|
|
|
detailText:(NSString *)detailText
|
2019-03-14 15:26:38 +01:00
|
|
|
accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier
|
2018-02-28 15:58:54 +01:00
|
|
|
actionBlock:(nullable OWSTableActionBlock)actionBlock;
|
|
|
|
|
2017-06-20 16:53:30 +02:00
|
|
|
+ (OWSTableItem *)disclosureItemWithText:(NSString *)text
|
|
|
|
customRowHeight:(CGFloat)customRowHeight
|
|
|
|
actionBlock:(nullable OWSTableActionBlock)actionBlock;
|
|
|
|
|
2019-03-22 18:05:35 +01:00
|
|
|
+ (OWSTableItem *)disclosureItemWithText:(NSString *)text
|
|
|
|
accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier
|
|
|
|
customRowHeight:(CGFloat)customRowHeight
|
|
|
|
actionBlock:(nullable OWSTableActionBlock)actionBlock;
|
|
|
|
|
2018-02-21 04:13:01 +01:00
|
|
|
+ (OWSTableItem *)checkmarkItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock;
|
|
|
|
|
2019-03-19 21:17:10 +01:00
|
|
|
+ (OWSTableItem *)checkmarkItemWithText:(NSString *)text
|
|
|
|
accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier
|
|
|
|
actionBlock:(nullable OWSTableActionBlock)actionBlock;
|
|
|
|
|
2018-02-21 04:13:01 +01:00
|
|
|
+ (OWSTableItem *)itemWithText:(NSString *)text
|
|
|
|
actionBlock:(nullable OWSTableActionBlock)actionBlock
|
|
|
|
accessoryType:(UITableViewCellAccessoryType)accessoryType;
|
|
|
|
|
2018-01-05 20:42:50 +01:00
|
|
|
+ (OWSTableItem *)subPageItemWithText:(NSString *)text actionBlock:(nullable OWSTableSubPageBlock)actionBlock;
|
|
|
|
|
|
|
|
+ (OWSTableItem *)subPageItemWithText:(NSString *)text
|
|
|
|
customRowHeight:(CGFloat)customRowHeight
|
|
|
|
actionBlock:(nullable OWSTableSubPageBlock)actionBlock;
|
|
|
|
|
2017-05-11 15:30:19 +02:00
|
|
|
+ (OWSTableItem *)actionItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock;
|
2019-03-19 21:17:10 +01:00
|
|
|
|
|
|
|
+ (OWSTableItem *)actionItemWithText:(NSString *)text
|
|
|
|
accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier
|
|
|
|
actionBlock:(nullable OWSTableActionBlock)actionBlock;
|
2017-05-11 15:30:19 +02:00
|
|
|
|
2017-07-11 22:00:32 +02:00
|
|
|
+ (OWSTableItem *)softCenterLabelItemWithText:(NSString *)text;
|
|
|
|
|
|
|
|
+ (OWSTableItem *)softCenterLabelItemWithText:(NSString *)text customRowHeight:(CGFloat)customRowHeight;
|
|
|
|
|
2017-06-15 19:43:18 +02:00
|
|
|
+ (OWSTableItem *)labelItemWithText:(NSString *)text;
|
|
|
|
|
2017-06-22 18:58:59 +02:00
|
|
|
+ (OWSTableItem *)labelItemWithText:(NSString *)text accessoryText:(NSString *)accessoryText;
|
|
|
|
|
2018-11-27 17:15:09 +01:00
|
|
|
+ (OWSTableItem *)longDisclosureItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock;
|
|
|
|
|
2019-02-25 18:58:15 +01:00
|
|
|
+ (OWSTableItem *)switchItemWithText:(NSString *)text
|
|
|
|
isOnBlock:(OWSTableSwitchBlock)isOnBlock
|
|
|
|
target:(id)target
|
|
|
|
selector:(SEL)selector;
|
2017-07-14 16:55:49 +02:00
|
|
|
|
|
|
|
+ (OWSTableItem *)switchItemWithText:(NSString *)text
|
2019-02-25 18:58:15 +01:00
|
|
|
isOnBlock:(OWSTableSwitchBlock)isOnBlock
|
|
|
|
isEnabledBlock:(OWSTableSwitchBlock)isEnabledBlock
|
2017-07-14 16:55:49 +02:00
|
|
|
target:(id)target
|
|
|
|
selector:(SEL)selector;
|
|
|
|
|
2019-03-14 15:26:38 +01:00
|
|
|
+ (OWSTableItem *)switchItemWithText:(NSString *)text
|
|
|
|
accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier
|
|
|
|
isOnBlock:(OWSTableSwitchBlock)isOnBlock
|
|
|
|
isEnabledBlock:(OWSTableSwitchBlock)isEnabledBlock
|
|
|
|
target:(id)target
|
|
|
|
selector:(SEL)selector;
|
|
|
|
|
2017-04-06 21:30:21 +02:00
|
|
|
- (nullable UITableViewCell *)customCell;
|
2017-04-03 16:29:11 +02:00
|
|
|
- (NSNumber *)customRowHeight;
|
2017-03-31 04:32:56 +02:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
2017-04-25 18:56:37 +02:00
|
|
|
@protocol OWSTableViewControllerDelegate <NSObject>
|
|
|
|
|
2017-11-20 22:50:18 +01:00
|
|
|
- (void)tableViewWillBeginDragging;
|
2017-04-25 18:56:37 +02:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
2017-07-25 19:23:23 +02:00
|
|
|
@interface OWSTableViewController : OWSViewController
|
2017-03-31 04:32:56 +02:00
|
|
|
|
2017-04-25 18:56:37 +02:00
|
|
|
@property (nonatomic, weak) id<OWSTableViewControllerDelegate> delegate;
|
|
|
|
|
2017-03-31 04:32:56 +02:00
|
|
|
@property (nonatomic) OWSTableContents *contents;
|
2017-04-17 21:13:15 +02:00
|
|
|
@property (nonatomic, readonly) UITableView *tableView;
|
2017-03-31 04:32:56 +02:00
|
|
|
|
2017-05-04 19:51:39 +02:00
|
|
|
@property (nonatomic) UITableViewStyle tableViewStyle;
|
|
|
|
|
2018-11-14 16:14:39 +01:00
|
|
|
- (instancetype)init NS_DESIGNATED_INITIALIZER;
|
|
|
|
|
2017-03-31 04:32:56 +02:00
|
|
|
#pragma mark - Presentation
|
|
|
|
|
|
|
|
- (void)presentFromViewController:(UIViewController *)fromViewController;
|
|
|
|
|
2018-11-15 16:25:48 +01:00
|
|
|
- (void)applyTheme;
|
|
|
|
|
2017-03-31 04:32:56 +02:00
|
|
|
@end
|
2017-04-03 23:12:29 +02:00
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|