/YBL365/Class/Category/CategoryList/ViewController/YBLCategoryListViewController.m

https://github.com/Josin22/Yuncai · Objective C · 95 lines · 51 code · 27 blank · 17 comment · 0 complexity · 3ec48fcdbeda299b38cceceb497a5a72 MD5 · raw file

  1. //
  2. // YBLCategoryListViewController.m
  3. // YBL365
  4. //
  5. // Created by 乔同新 on 16/12/22.
  6. // Copyright © 2016年 乔同新. All rights reserved.
  7. //
  8. #import "YBLCategoryListViewController.h"
  9. #import "YBLSearchNavView.h"
  10. #import "YBLCategoryListService.h"
  11. #import "YBLGoodSearchView.h"
  12. @interface YBLCategoryListViewController ()
  13. @property (nonatomic, strong) YBLSearchNavView *searchView;
  14. @property (nonatomic, strong) UIButton *productButton;
  15. @property (nonatomic, strong) YBLCategoryListService *listService;
  16. @property (nonatomic, strong) NSMutableArray *dataArray;
  17. @end
  18. @implementation YBLCategoryListViewController
  19. - (void)viewDidLoad {
  20. [super viewDidLoad];
  21. [self createNavigationBar];
  22. [self starUIService];
  23. }
  24. //- (NSMutableArray *)dataArray {
  25. // if (!_dataArray) {
  26. // _dataArray = [NSMutableArray array];
  27. // NSArray *array = [YBLShopCarModel shareInstance].tempGoods;
  28. // for (int i = 0; i < 0; i++) {
  29. // [_dataArray addObject:array[arc4random()%9]];
  30. // }
  31. // }
  32. // return _dataArray;
  33. //}
  34. - (void)starUIService {
  35. self.listService = [[YBLCategoryListService alloc] init];
  36. self.listService.categoryListVC = self;
  37. [self.listService updateWithGoodArray:self.dataArray];
  38. }
  39. - (void)createNavigationBar {
  40. YBLSearchNavView *searchView = [[YBLSearchNavView alloc] initWithFrame:CGRectMake(0, 0, YBLWindowWidth, 30)];
  41. self.searchView = searchView;
  42. self.navigationItem.titleView = searchView;
  43. WEAK
  44. searchView.searchBlock = ^(){
  45. STRONG
  46. [YBLGoodSearchView showGoodSearchViewWithRightItemViewType:rightItemViewTypeNone
  47. SearchHandle:^{
  48. STRONG
  49. }
  50. cancleHandle:^{
  51. }
  52. animationEndHandle:^{
  53. }];
  54. };
  55. self.productButton = [UIButton buttonWithType:UIButtonTypeCustom];
  56. [self.productButton setImage:[UIImage imageNamed:@"product_list_top_list"] forState:UIControlStateNormal];
  57. [self.productButton setImage:[UIImage imageNamed:@"product_list_top_grid"] forState:UIControlStateSelected];
  58. self.productButton.frame = CGRectMake(0, 0, 44, 44);
  59. UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemFixedSpace target:nil action:nil];
  60. negativeSpacer.width = -15;
  61. self.navigationItem.rightBarButtonItems = @[negativeSpacer,[[UIBarButtonItem alloc] initWithCustomView:self.productButton]];
  62. __weak typeof (self)weakSelf = self;
  63. [[self.productButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
  64. weakSelf.productButton.selected = !weakSelf.productButton.selected;
  65. weakSelf.listService.isList = weakSelf.productButton.selected;
  66. }];
  67. }
  68. @end