省钱达人

DRCommissionMainViewController.m 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. //
  2. // DRCommissionMainViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/18.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRCommissionMainViewController.h"
  9. #import "MLMSegmentHead.h"
  10. #import "MLMSegmentManager.h"
  11. #import "DROrderTableView.h"
  12. #import "DRChildCommissionController.h"
  13. #import "DRCommissionHeaderView.h"
  14. #import "DRChildCommissionController.h"
  15. @interface DRCommissionMainViewController ()
  16. <
  17. UITableViewDelegate,
  18. UITableViewDataSource
  19. >
  20. @property (nonatomic, strong) DROrderTableView *tableView;
  21. @property (nonatomic, strong) DRCommissionHeaderView *headerView;
  22. @property (nonatomic, strong) MLMSegmentHead *titleView;
  23. @property (nonatomic, strong) MLMSegmentScroll *segScroll;
  24. @property (nonatomic, strong) NSMutableArray *vcList;
  25. @property (nonatomic, assign) BOOL canScroll;
  26. @end
  27. @implementation DRCommissionMainViewController
  28. - (void)viewDidLoad {
  29. [super viewDidLoad];
  30. [self configNavigationBar];
  31. // [self configTableView];
  32. [self creatHeaderViewAndFooterView];
  33. }
  34. -(void)viewWillAppear:(BOOL)animated{
  35. [super viewWillAppear:animated];
  36. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  37. }
  38. - (void)configTableView {
  39. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeScrollStatus) name:@"leaveTop" object:nil];
  40. self.canScroll = YES;
  41. self.headerView = [[DRCommissionHeaderView alloc] initWithFrame:CGRectMake(0, 0,SCREEN_WIDTH , 135)];
  42. self.tableView.tableHeaderView = self.headerView;
  43. [self.view addSubview:self.tableView];
  44. }
  45. - (void)configNavigationBar {
  46. [self.navigationBar setNavTitle:@"订单明细"];
  47. self.navigationBar.backgroundColor = [UIColor changeColor];
  48. self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor];
  49. UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  50. [leftBtn setImage:[UIImage imageNamed:@"back_white"] forState:UIControlStateNormal];
  51. [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  52. [self.navigationBar setCustomLeftButtons:@[leftBtn]];
  53. }
  54. - (void)backAction {
  55. [self.navigationController popViewControllerAnimated:YES];
  56. }
  57. - (void)creatHeaderViewAndFooterView {
  58. self.view.backgroundColor = [UIColor whiteColor];
  59. NSArray *titleArr = @[@"全部",@"已付款",@"已结算",@"已失效"];
  60. for (int i = 0; i < titleArr.count; i++) {
  61. DRChildCommissionController *child = [[DRChildCommissionController alloc] init];
  62. switch (i) {
  63. case 0:
  64. {
  65. child.type=4;
  66. }
  67. break;
  68. case 1:
  69. {
  70. child.type=1;
  71. }
  72. break;
  73. case 2:
  74. {
  75. child.type=2;
  76. }
  77. break;
  78. case 3:
  79. {
  80. child.type=0;
  81. }
  82. break;
  83. default:
  84. break;
  85. }
  86. [self.vcList addObject:child];
  87. }
  88. self.segScroll = [[MLMSegmentScroll alloc] initWithFrame:CGRectMake(0, NavBarHeight+40, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-40) vcOrViews:self.vcList];
  89. self.segScroll.bounces = NO;
  90. self.titleView = [[MLMSegmentHead alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, 40) titles:titleArr headStyle:SegmentHeadStyleDefault layoutStyle:MLMSegmentLayoutDefault];
  91. self.titleView.headColor = [UIColor whiteColor];
  92. self.titleView.bottomLineHeight = 1;
  93. self.titleView.bottomLineColor = [UIColor yhGrayColor];
  94. self.titleView.fontScale = 1;
  95. self.titleView.fontSize = 14;
  96. self.titleView.equalSize = YES;
  97. self.titleView.showIndex = 0;
  98. self.titleView.selectColor = [UIColor YHColorWithHex:0xff442a];
  99. self.titleView.deSelectColor = [UIColor YHColorWithHex:0x666666];
  100. [MLMSegmentManager associateHead:self.titleView withScroll:self.segScroll completion:^{
  101. [self.view addSubview:self.titleView];
  102. [self.view addSubview:self.segScroll];
  103. }];
  104. }
  105. #pragma mark ----- nofi -----
  106. - (void)changeScrollStatus {
  107. self.canScroll = YES;
  108. for (DRChildCommissionController *childVc in self.vcList) {
  109. childVc.childCanScroll = NO;
  110. }
  111. }
  112. #pragma mark --------------------- UITableView delegate -------
  113. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  114. return 1;
  115. }
  116. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  117. return 1;
  118. }
  119. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  120. return 0.1;
  121. }
  122. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  123. return 40;
  124. }
  125. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  126. return SCREEN_HEIGHT-NavBarHeight-40;
  127. }
  128. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  129. UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellID"];
  130. return cell;
  131. }
  132. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  133. return self.titleView;
  134. }
  135. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
  136. return self.segScroll;
  137. }
  138. #pragma mark ----- scroll delegete ----
  139. //
  140. //- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  141. // CGFloat bottomCellOffset = [_tableView rectForSection:0].origin.y;
  142. // if (scrollView.contentOffset.y >= bottomCellOffset) {
  143. // scrollView.contentOffset = CGPointMake(0, bottomCellOffset);
  144. // if (self.canScroll) {
  145. // self.canScroll = NO;
  146. // [self setChildViewControllerCanScroll:YES];
  147. // }
  148. // }else{
  149. // if (!self.canScroll) {//子视图没到顶部
  150. // scrollView.contentOffset = CGPointMake(0, bottomCellOffset);
  151. // }
  152. // }
  153. //}
  154. - (void)setChildViewControllerCanScroll:(BOOL)childCanScroll {
  155. for (DRChildCommissionController *childVc in self.vcList) {
  156. childVc.childCanScroll = childCanScroll;
  157. if (!childCanScroll) {
  158. childVc.tableView.contentOffset = CGPointZero;
  159. }
  160. }
  161. }
  162. #pragma mark ----------------
  163. - (DROrderTableView *)tableView {
  164. if (!_tableView) {
  165. _tableView = [[DROrderTableView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight) style:UITableViewStylePlain];
  166. _tableView.estimatedSectionHeaderHeight = 0;
  167. _tableView.estimatedSectionFooterHeight = 0;
  168. _tableView.sectionFooterHeight = 0;
  169. _tableView.sectionHeaderHeight = 0;
  170. _tableView.delegate = self;
  171. _tableView.dataSource = self;
  172. _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  173. _tableView.backgroundColor = [UIColor yhGrayColor];
  174. _tableView.bounces = YES;
  175. _tableView.showsVerticalScrollIndicator = NO;
  176. [_tableView setSeparatorColor:[UIColor YHColorWithHex:0xdddddd]];
  177. }
  178. return _tableView;
  179. }
  180. - (NSMutableArray *)vcList {
  181. if (!_vcList) {
  182. _vcList = [NSMutableArray array];
  183. }
  184. return _vcList;
  185. }
  186. - (void)didReceiveMemoryWarning {
  187. [super didReceiveMemoryWarning];
  188. // Dispose of any resources that can be recreated.
  189. }
  190. /*
  191. #pragma mark - Navigation
  192. // In a storyboard-based application, you will often want to do a little preparation before navigation
  193. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  194. // Get the new view controller using [segue destinationViewController].
  195. // Pass the selected object to the new view controller.
  196. }
  197. */
  198. @end