Files
peko-ios/YuMi/Modules/YMMine/View/XPMomentUserDataViewController.m
eggmanQQQ dc7a2688cf temp save
2024-06-24 19:11:54 +08:00

91 lines
2.9 KiB
Objective-C

//
// XPMomentUserDataViewController.m
// YuMi
//
// Created by P on 2024/6/24.
//
#import "XPMomentUserDataViewController.h"
#import "XPMonentsLayoutConfig.h"
#import "XPMonentsEmptyTableViewCell.h"
#import "XPMonentsTableViewCell.h"
#import "MonentsInfoModel.h"
@interface XPMomentUserDataViewController () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic,strong) UITableView *tableView;
@end
@implementation XPMomentUserDataViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self.view addSubview:self.tableView];
}
#pragma mark - UITableViewDelegate And UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if(section == 0)return 1;
return self.datasource.count > 0 ? self.datasource.count : 1;;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (self.datasource.count > 0) {
MonentsInfoModel * momentInfo= [self.datasource xpSafeObjectAtIndex:indexPath.row];
[XPMonentsLayoutConfig getNewlayoutMonentsModelWithDynamic:momentInfo];
if(momentInfo.content.length == 0){
return momentInfo.rowHeight + 20;
}
return momentInfo.rowHeight;
}
return KScreenHeight - kNavigationHeight - 49 - kSafeAreaBottomHeight;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
return nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0.01;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
if(section == 0)return 0.01;
return self.datasource.count > 0 ? 30 : 0.01;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
if(section == 0)return nil;
return nil;//self.datasource.count > 0 ? self.headView : nil;
}
#pragma mark -
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.backgroundColor = [UIColor clearColor];
if (@available(iOS 11.0, *)) {
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
[_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])];
[_tableView registerClass:[XPMonentsTableViewCell class] forCellReuseIdentifier:@"XPMonentsDynamicTableViewCell"];
}
return _tableView;
}
- (NSMutableArray<MonentsInfoModel *> *)datasource {
if (!_datasource) {
_datasource = [NSMutableArray array];
}
return _datasource;
}
@end