|
@@ -11,6 +11,13 @@
|
|
|
#import "FLEXSubtitleTableViewCell.h"
|
|
#import "FLEXSubtitleTableViewCell.h"
|
|
|
#import "FLEXMultilineTableViewCell.h"
|
|
#import "FLEXMultilineTableViewCell.h"
|
|
|
|
|
|
|
|
|
|
+FLEXTableViewCellReuseIdentifier const kFLEXDefaultCell = @"kFLEXDefaultCell";
|
|
|
|
|
+FLEXTableViewCellReuseIdentifier const kFLEXDetailCell = @"kFLEXDetailCell";
|
|
|
|
|
+FLEXTableViewCellReuseIdentifier const kFLEXMultilineCell = @"kFLEXMultilineCell";
|
|
|
|
|
+FLEXTableViewCellReuseIdentifier const kFLEXMultilineDetailCell = @"kFLEXMultilineDetailCell";
|
|
|
|
|
+
|
|
|
|
|
+#pragma mark Private
|
|
|
|
|
+
|
|
|
@interface UITableView (Private)
|
|
@interface UITableView (Private)
|
|
|
- (CGFloat)_heightForHeaderInSection:(NSInteger)section;
|
|
- (CGFloat)_heightForHeaderInSection:(NSInteger)section;
|
|
|
- (NSString *)_titleForHeaderInSection:(NSInteger)section;
|
|
- (NSString *)_titleForHeaderInSection:(NSInteger)section;
|
|
@@ -44,40 +51,44 @@
|
|
|
return height;
|
|
return height;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style
|
|
|
|
|
-{
|
|
|
|
|
|
|
+#pragma mark - Initialization
|
|
|
|
|
+
|
|
|
|
|
++ (id)groupedTableView {
|
|
|
|
|
+#if FLEX_AT_LEAST_IOS13_SDK
|
|
|
|
|
+ if (@available(iOS 13.0, *)) {
|
|
|
|
|
+ return [[self alloc] initWithFrame:CGRectZero style:UITableViewStyleInsetGrouped];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return [[self alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
|
|
|
|
|
+ }
|
|
|
|
|
+#else
|
|
|
|
|
+ return [[self alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
|
|
|
|
|
+#endif
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
++ (id)plainTableView {
|
|
|
|
|
+ return [[self alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style {
|
|
|
self = [super initWithFrame:frame style:style];
|
|
self = [super initWithFrame:frame style:style];
|
|
|
if (self) {
|
|
if (self) {
|
|
|
[self registerCells:@{
|
|
[self registerCells:@{
|
|
|
- self.defaultReuseIdentifier : [FLEXTableViewCell class],
|
|
|
|
|
- self.subtitleReuseIdentifier : [FLEXSubtitleTableViewCell class],
|
|
|
|
|
- self.multilineReuseIdentifier : [FLEXMultilineTableViewCell class],
|
|
|
|
|
|
|
+ kFLEXDefaultCell : [FLEXTableViewCell class],
|
|
|
|
|
+ kFLEXDetailCell : [FLEXSubtitleTableViewCell class],
|
|
|
|
|
+ kFLEXMultilineCell : [FLEXMultilineTableViewCell class],
|
|
|
|
|
+ kFLEXMultilineDetailCell : [FLEXMultilineDetailTableViewCell class]
|
|
|
}];
|
|
}];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
return self;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-- (void)registerCells:(NSDictionary<NSString*,Class> *)registrationMapping
|
|
|
|
|
-{
|
|
|
|
|
|
|
+#pragma mark - Public
|
|
|
|
|
+
|
|
|
|
|
+- (void)registerCells:(NSDictionary<NSString*, Class> *)registrationMapping {
|
|
|
[registrationMapping enumerateKeysAndObjectsUsingBlock:^(NSString *identifier, Class cellClass, BOOL *stop) {
|
|
[registrationMapping enumerateKeysAndObjectsUsingBlock:^(NSString *identifier, Class cellClass, BOOL *stop) {
|
|
|
[self registerClass:cellClass forCellReuseIdentifier:identifier];
|
|
[self registerClass:cellClass forCellReuseIdentifier:identifier];
|
|
|
}];
|
|
}];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-- (NSString *)defaultReuseIdentifier
|
|
|
|
|
-{
|
|
|
|
|
- return @"kFLEXTableViewCellIdentifier";
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-- (NSString *)subtitleReuseIdentifier
|
|
|
|
|
-{
|
|
|
|
|
- return @"kFLEXSubtitleTableViewCellIdentifier";
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-- (NSString *)multilineReuseIdentifier
|
|
|
|
|
-{
|
|
|
|
|
- return kFLEXMultilineTableViewCellIdentifier;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
@end
|
|
@end
|