XYSkillReceiveOrderViewController.m 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //
  2. // XYSkillReceiveOrderViewController.m
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2020/11/4.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. //
  8. #import "XYSkillReceiveOrderViewController.h"
  9. #import <JXCategoryView/JXCategoryView.h>
  10. #import "XYSkillOrderListViewController.h"
  11. #import "JXCategoryTitleBackgroundView.h"
  12. @interface XYSkillReceiveOrderViewController ()<JXCategoryViewDelegate, JXCategoryListContainerViewDelegate>
  13. @property (nonatomic, strong) JXCategoryTitleBackgroundView *categoryTitleView;
  14. @property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
  15. @end
  16. @implementation XYSkillReceiveOrderViewController
  17. - (instancetype)init
  18. {
  19. self = [super init];
  20. if (self) {
  21. self.prefersNavigationBarHidden = YES;
  22. }
  23. return self;
  24. }
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. // Do any additional setup after loading the view.
  28. [self setupUI];
  29. }
  30. - (void)setupUI {
  31. self.categoryTitleView = [[JXCategoryTitleBackgroundView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, SCREEN_WIDTH, 48.0f)];
  32. self.categoryTitleView.titles = @[kLocalizedString(@"全部"), kLocalizedString(@"待接单"), kLocalizedString(@"待服务"), kLocalizedString(@"服务中"), kLocalizedString(@"已完成"), kLocalizedString(@"已拒绝")];
  33. self.categoryTitleView.delegate = self;
  34. self.categoryTitleView.titleFont = Font(14);
  35. self.categoryTitleView.titleSelectedFont = Font_B(14);
  36. self.categoryTitleView.titleColor = Color_TextGray;
  37. self.categoryTitleView.titleSelectedColor = Color_TextRed;
  38. self.categoryTitleView.averageCellSpacingEnabled = YES;
  39. self.categoryTitleView.cellWidthIncrement = 20;
  40. self.categoryTitleView.contentEdgeInsetLeft = 20.0f;
  41. self.categoryTitleView.contentEdgeInsetRight = 20.0f;
  42. self.categoryTitleView.cellSpacing = 12;
  43. self.categoryTitleView.normalBackgroundColor = [UIColor clearColor];
  44. self.categoryTitleView.normalBorderColor = [UIColor colorWithHexString:@"#B8BCC5" alpha:1];
  45. self.categoryTitleView.selectedBackgroundColor = [UIColor clearColor];
  46. self.categoryTitleView.selectedBorderColor = [UIColor colorWithHexString:@"#FF4D5C" alpha:1];
  47. self.categoryTitleView.borderLineWidth = 1;
  48. self.categoryTitleView.backgroundCornerRadius = 14;
  49. self.categoryTitleView.backgroundWidth = JXCategoryViewAutomaticDimension;
  50. self.categoryTitleView.backgroundHeight = 28;
  51. self.categoryTitleView.backgroundColor = Color_White;
  52. [self.view addSubview:self.categoryTitleView];
  53. // 列表容器
  54. self.listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
  55. self.listContainerView.frame = CGRectMake(0, self.categoryTitleView.f_top, SCREEN_WIDTH, SCREEN_HEIGHT - self.categoryTitleView.f_top - NAVGATION_HEIGHT);
  56. [self.view addSubview:self.listContainerView];
  57. self.categoryTitleView.listContainer = self.listContainerView;
  58. }
  59. #pragma mark — JXCategoryViewDelegate
  60. /**
  61. 点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,不关心具体是点击还是滚动选中的。
  62. @param categoryView categoryView对象
  63. @param index 选中的index
  64. */
  65. - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
  66. }
  67. #pragma mark — JXCategoryListContainerViewDelegate
  68. /**
  69. 返回list的数量
  70. @param listContainerView 列表的容器视图
  71. @return list的数量
  72. */
  73. - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
  74. return self.categoryTitleView.titles.count;
  75. }
  76. /**
  77. 根据index返回一个对应列表实例,需要是遵从`JXCategoryListContentViewDelegate`协议的对象。
  78. 你可以代理方法调用的时候初始化对应列表,达到懒加载的效果。这也是默认推荐的初始化列表方法。你也可以提前创建好列表,等该代理方法回调的时候再返回也可以,达到预加载的效果。
  79. 如果列表是用自定义UIView封装的,就让自定义UIView遵从`JXCategoryListContentViewDelegate`协议,该方法返回自定义UIView即可。
  80. 如果列表是用自定义UIViewController封装的,就让自定义UIViewController遵从`JXCategoryListContentViewDelegate`协议,该方法返回自定义UIViewController即可。
  81. @param listContainerView 列表的容器视图
  82. @param index 目标下标
  83. @return 遵从JXCategoryListContentViewDelegate协议的list实例
  84. */
  85. - (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
  86. XYSkillOrderListViewController *controller = XYSkillOrderListViewController.new;
  87. controller.orderType = 1;
  88. switch (index) {
  89. case 1:
  90. controller.orderStatus = XYPeiPeiOrderStatusWaitReceive;
  91. break;
  92. case 2:
  93. controller.orderStatus = XYPeiPeiOrderStatusWaitService;
  94. break;
  95. case 3:
  96. controller.orderStatus = XYPeiPeiOrderStatusInService;
  97. break;
  98. case 4:
  99. controller.orderStatus = XYPeiPeiOrderStatusComplete;
  100. break;
  101. case 5:
  102. controller.orderStatus = XYPeiPeiOrderStatusReject;
  103. break;
  104. default:
  105. controller.orderStatus = -1;
  106. break;
  107. }
  108. return controller;
  109. }
  110. #pragma mark — JXCategoryListContentViewDelegate
  111. /**
  112. 如果列表是VC,就返回VC.view
  113. 如果列表是View,就返回View自己
  114. @return 返回列表视图
  115. */
  116. - (UIView *)listView {
  117. return self.view;
  118. }
  119. @end