| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- //
- // RAHomeViewController+HomeTableDelegate.m
- // Apex And Drivers
- //
- // Created by Jack on 2018/6/1.
- // Copyright © 2018年 USAI. All rights reserved.
- //
- #import "RAHomeViewController+HomeTableDelegate.h"
- #import "RAHomeOrderModel.h"
- #import "RABadgeNumberView.h"
- @implementation RAHomeViewController (HomeTableDelegate)
- #pragma mark - TableView Delegate
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- return 140.0f;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
-
- // UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(tableView.bounds), 44.0f)];
- // header.backgroundColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:0.8];
- // UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 11, CGRectGetWidth(tableView.bounds) - 100, 22)];
- // [header addSubview:label];
- //
- // label.text = [self titleForSection:section];
- //
- // UIButton *expandBtn = [UIButton buttonWithType:UIButtonTypeSystem];
- // expandBtn.frame = CGRectMake(CGRectGetWidth(tableView.bounds) - 90, 11, 80, 22);
- // [expandBtn setTitle:@"More" forState:UIControlStateNormal];
- //
- //
- // expandBtn.tag = section;
- // [expandBtn addTarget:self action:@selector(sectionExpandSwithBtnClick:) forControlEvents:UIControlEventTouchUpInside];
- // [header addSubview:expandBtn];
- //
- // expandBtn.hidden = ![self hasMoreOrderForSection:section];
- //
-
- UIView *header = [[[NSBundle mainBundle] loadNibNamed:@"HomeHeader" owner:nil options:nil] objectAtIndex:0];
- header.backgroundColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:0.8];
-
- UILabel *titleLabel = (UILabel *)[header viewWithTag:5000];
- RABadgeNumberView *badgeNumberView = (RABadgeNumberView *)[header viewWithTag:5001];
- UIButton *moreBtn = (UIButton *)[header viewWithTag:5002];
-
- titleLabel.text = [self titleForSection:section];
-
- badgeNumberView.badgeNumber = [self backendCountForSection:section];
-
- moreBtn.tag = 6000 + section;
- [moreBtn addTarget:self action:@selector(sectionExpandSwithBtnClick:) forControlEvents:UIControlEventTouchUpInside];
- moreBtn.hidden = ![self hasMoreOrderForSection:section];
-
- return header;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
- return 44.f;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
-
- RAHomeOrderModel *order = [self orderModelForIndexPath:indexPath];
- if (order.backendFlag) {
- order.backendFlag = !order.backendFlag;
- }
- self.currentOrderID = order.orderID;
- [self pushDetailViewControllerForModel:order];
- }
- #pragma mark - Action
- - (void)sectionExpandSwithBtnClick:(UIButton *)sender {
- [self showMoreOrderForSection:sender.tag - 6000];
- }
- @end
|