This commit is contained in:
2025-11-06 14:59:00 +08:00
parent 15fc9621cd
commit a1db745b6c
9 changed files with 517 additions and 24 deletions

View File

@@ -6,6 +6,18 @@
//
#import "HomeHotVC.h"
//
#import "KBTopThreeView.h"
#import "HomeHotCell.h"
#import <HWPanModal/HWPanModal.h>
@interface HomeHotVC () <UITableViewDataSource, UITableViewDelegate>
//
@property (nonatomic, strong) KBTopThreeView *topThreeView;
@property (nonatomic, strong) NSArray<NSDictionary *> *dataSource; //
@end
@interface HomeHotVC ()
@@ -15,17 +27,77 @@
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor whiteColor];
//
self.dataSource = @[
@{@"rank":@4, @"title":@"Ambiguous", @"sub":@"Be Neither Too Close Nor Too Distant, Want To ...", @"joined":@NO},
@{@"rank":@5, @"title":@"Ambiguous", @"sub":@"Be Neither Too Close Nor Too Distant, Want To ...", @"joined":@YES},
@{@"rank":@6, @"title":@"Ambiguous", @"sub":@"Be Neither Too Close Nor Too Distant, Want To ...", @"joined":@NO},
@{@"rank":@7, @"title":@"Ambiguous", @"sub":@"Be Neither Too Close Nor Too Distant, Want To ...", @"joined":@NO}
];
// UI
[self.view addSubview:self.tableView];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view);
}];
// tableHeaderViewtableHeaderView
CGFloat headerH = 280.0;
self.topThreeView = [[KBTopThreeView alloc] initWithFrame:CGRectMake(0, 0, KB_SCREEN_WIDTH, headerH)];
//
[self.topThreeView configWithItems:@[
@{@"title":@"High EQ", @"rank":@1},
@{@"title":@"Flirt Girls", @"rank":@2},
@{@"title":@"Humorous", @"rank":@3}
]];
self.tableView.tableHeaderView = self.topThreeView;
}
/*
#pragma mark - Navigation
#pragma mark - UITableViewDataSource
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataSource.count;
}
*/
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
HomeHotCell *cell = [tableView dequeueReusableCellWithIdentifier:HomeHotCell.reuseId forIndexPath:indexPath];
NSDictionary *item = self.dataSource[indexPath.row];
// cell
[cell configWithRank:[item[@"rank"] integerValue]
title:item[@"title"]
subtitle:item[@"sub"]
joined:[item[@"joined"] boolValue]];
return cell;
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 84.0;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
#pragma mark - Lazy
- (BaseTableView *)tableView {
if (!_tableView) {
// 使 BaseTableView
_tableView = [[BaseTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableView.dataSource = self;
_tableView.delegate = self;
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone; // 线
_tableView.showsVerticalScrollIndicator = NO;
_tableView.contentInset = UIEdgeInsetsMake(8, 0, KB_SafeAreaBottom(), 0);
[_tableView registerClass:HomeHotCell.class forCellReuseIdentifier:HomeHotCell.reuseId];
}
return _tableView;
}
@end