// // XYSkillReceiveOrderViewController.m // Starbuds // // Created by 翟玉磊 on 2020/11/4. // Copyright © 2020 翟玉磊. All rights reserved. // #import "XYSkillReceiveOrderViewController.h" #import #import "XYSkillOrderListViewController.h" #import "JXCategoryTitleBackgroundView.h" @interface XYSkillReceiveOrderViewController () @property (nonatomic, strong) JXCategoryTitleBackgroundView *categoryTitleView; @property (nonatomic, strong) JXCategoryListContainerView *listContainerView; @end @implementation XYSkillReceiveOrderViewController - (instancetype)init { self = [super init]; if (self) { self.prefersNavigationBarHidden = YES; } return self; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self setupUI]; } - (void)setupUI { self.categoryTitleView = [[JXCategoryTitleBackgroundView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, SCREEN_WIDTH, 48.0f)]; self.categoryTitleView.titles = @[kLocalizedString(@"全部"), kLocalizedString(@"待接单"), kLocalizedString(@"待服务"), kLocalizedString(@"服务中"), kLocalizedString(@"已完成"), kLocalizedString(@"已拒绝")]; self.categoryTitleView.delegate = self; self.categoryTitleView.titleFont = Font(14); self.categoryTitleView.titleSelectedFont = Font_B(14); self.categoryTitleView.titleColor = Color_TextGray; self.categoryTitleView.titleSelectedColor = Color_TextRed; self.categoryTitleView.averageCellSpacingEnabled = YES; self.categoryTitleView.cellWidthIncrement = 20; self.categoryTitleView.contentEdgeInsetLeft = 20.0f; self.categoryTitleView.contentEdgeInsetRight = 20.0f; self.categoryTitleView.cellSpacing = 12; self.categoryTitleView.normalBackgroundColor = [UIColor clearColor]; self.categoryTitleView.normalBorderColor = [UIColor colorWithHexString:@"#B8BCC5" alpha:1]; self.categoryTitleView.selectedBackgroundColor = [UIColor clearColor]; self.categoryTitleView.selectedBorderColor = [UIColor colorWithHexString:@"#FF4D5C" alpha:1]; self.categoryTitleView.borderLineWidth = 1; self.categoryTitleView.backgroundCornerRadius = 14; self.categoryTitleView.backgroundWidth = JXCategoryViewAutomaticDimension; self.categoryTitleView.backgroundHeight = 28; self.categoryTitleView.backgroundColor = Color_White; [self.view addSubview:self.categoryTitleView]; // 列表容器 self.listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self]; self.listContainerView.frame = CGRectMake(0, self.categoryTitleView.f_top, SCREEN_WIDTH, SCREEN_HEIGHT - self.categoryTitleView.f_top - NAVGATION_HEIGHT); [self.view addSubview:self.listContainerView]; self.categoryTitleView.listContainer = self.listContainerView; } #pragma mark — JXCategoryViewDelegate /** 点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,不关心具体是点击还是滚动选中的。 @param categoryView categoryView对象 @param index 选中的index */ - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index { } #pragma mark — JXCategoryListContainerViewDelegate /** 返回list的数量 @param listContainerView 列表的容器视图 @return list的数量 */ - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView { return self.categoryTitleView.titles.count; } /** 根据index返回一个对应列表实例,需要是遵从`JXCategoryListContentViewDelegate`协议的对象。 你可以代理方法调用的时候初始化对应列表,达到懒加载的效果。这也是默认推荐的初始化列表方法。你也可以提前创建好列表,等该代理方法回调的时候再返回也可以,达到预加载的效果。 如果列表是用自定义UIView封装的,就让自定义UIView遵从`JXCategoryListContentViewDelegate`协议,该方法返回自定义UIView即可。 如果列表是用自定义UIViewController封装的,就让自定义UIViewController遵从`JXCategoryListContentViewDelegate`协议,该方法返回自定义UIViewController即可。 @param listContainerView 列表的容器视图 @param index 目标下标 @return 遵从JXCategoryListContentViewDelegate协议的list实例 */ - (id)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index { XYSkillOrderListViewController *controller = XYSkillOrderListViewController.new; controller.orderType = 1; switch (index) { case 1: controller.orderStatus = XYPeiPeiOrderStatusWaitReceive; break; case 2: controller.orderStatus = XYPeiPeiOrderStatusWaitService; break; case 3: controller.orderStatus = XYPeiPeiOrderStatusInService; break; case 4: controller.orderStatus = XYPeiPeiOrderStatusComplete; break; case 5: controller.orderStatus = XYPeiPeiOrderStatusReject; break; default: controller.orderStatus = -1; break; } return controller; } #pragma mark — JXCategoryListContentViewDelegate /** 如果列表是VC,就返回VC.view 如果列表是View,就返回View自己 @return 返回列表视图 */ - (UIView *)listView { return self.view; } @end