XYMakingFriendsSkillViewController.m 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. //
  2. // XYMakingFriendsSkillViewController.m
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2020/12/7.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. //
  8. #import "XYMakingFriendsSkillViewController.h"
  9. #import <JXCategoryView/JXCategoryView.h>
  10. #import "XYCertificationSkillModel.h"
  11. #import "XYMarkingFriendsSkillListViewController.h"
  12. @interface XYMakingFriendsSkillViewController ()<JXCategoryViewDelegate, JXCategoryListContainerViewDelegate>
  13. @property (nonatomic, strong) JXCategoryTitleView *categoryTitleView;
  14. @property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
  15. @property (nonatomic, strong) NSMutableArray *skills;
  16. @end
  17. @implementation XYMakingFriendsSkillViewController
  18. - (instancetype)init
  19. {
  20. self = [super init];
  21. if (self) {
  22. self.prefersNavigationBarHidden = YES;
  23. }
  24. return self;
  25. }
  26. - (void)viewDidLoad {
  27. [super viewDidLoad];
  28. // Do any additional setup after loading the view.
  29. self.view.backgroundColor = Color_Clear;
  30. [self setupUI];
  31. }
  32. - (void)setupUI {
  33. NSInteger i = 0;
  34. NSInteger defaultSelectedIndex = 0;
  35. NSMutableArray *titles = [NSMutableArray array];
  36. for (XYCertificationSkillModel *model in ApplicationDelegate.appConfigModel.skills) {
  37. if (model.voiceMatchEnable == 1) {
  38. // 语音速配跳过
  39. continue;
  40. }
  41. [titles addObject:model.skillName];
  42. [self.skills addObject:model];
  43. if ([model.skillId isEqualToString:self.currentSkillId]) {
  44. defaultSelectedIndex = i;
  45. }
  46. i++;
  47. }
  48. // 分类标题view
  49. self.categoryTitleView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, SCREEN_WIDTH, 48.0f)];
  50. self.categoryTitleView.titles = titles;
  51. self.categoryTitleView.delegate = self;
  52. self.categoryTitleView.titleFont = Font(12);
  53. self.categoryTitleView.titleColor = Color_Nakaguro;
  54. self.categoryTitleView.titleSelectedColor = Color_TextRed;
  55. self.categoryTitleView.averageCellSpacingEnabled = YES;
  56. self.categoryTitleView.contentEdgeInsetLeft = 16.0f;
  57. self.categoryTitleView.contentEdgeInsetRight = 16.0f;
  58. self.categoryTitleView.cellSpacing = 16;
  59. self.categoryTitleView.defaultSelectedIndex = defaultSelectedIndex;
  60. [self.view addSubview:self.categoryTitleView];
  61. JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
  62. lineView.indicatorWidth = 4.0f;
  63. lineView.indicatorHeight = 2.0f;
  64. lineView.indicatorColor = Color_TextRed;
  65. lineView.verticalMargin = 10.0f;
  66. self.categoryTitleView.indicators = @[lineView];
  67. // 列表容器
  68. self.listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
  69. self.listContainerView.frame = CGRectMake(0, self.categoryTitleView.f_top, SCREEN_WIDTH, SCREEN_HEIGHT - (STATUS_HEIGHT + 48.0f + 68.0f + TABBAR_HEIGHT));
  70. [self.view addSubview:self.listContainerView];
  71. self.categoryTitleView.listContainer = self.listContainerView;
  72. }
  73. #pragma mark — JXCategoryViewDelegate
  74. /**
  75. 点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,不关心具体是点击还是滚动选中的。
  76. @param categoryView categoryView对象
  77. @param index 选中的index
  78. */
  79. - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
  80. }
  81. #pragma mark — JXCategoryListContainerViewDelegate
  82. /**
  83. 返回list的数量
  84. @param listContainerView 列表的容器视图
  85. @return list的数量
  86. */
  87. - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
  88. return self.categoryTitleView.titles.count;
  89. }
  90. /**
  91. 根据index返回一个对应列表实例,需要是遵从`JXCategoryListContentViewDelegate`协议的对象。
  92. 你可以代理方法调用的时候初始化对应列表,达到懒加载的效果。这也是默认推荐的初始化列表方法。你也可以提前创建好列表,等该代理方法回调的时候再返回也可以,达到预加载的效果。
  93. 如果列表是用自定义UIView封装的,就让自定义UIView遵从`JXCategoryListContentViewDelegate`协议,该方法返回自定义UIView即可。
  94. 如果列表是用自定义UIViewController封装的,就让自定义UIViewController遵从`JXCategoryListContentViewDelegate`协议,该方法返回自定义UIViewController即可。
  95. @param listContainerView 列表的容器视图
  96. @param index 目标下标
  97. @return 遵从JXCategoryListContentViewDelegate协议的list实例
  98. */
  99. - (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
  100. XYCertificationSkillModel *skillModel = self.skills[index];
  101. if ([skillModel.skillName isEqualToString:kLocalizedString(@"人工闹钟")]) {
  102. // 交友Tab,[人工闹钟]页的曝光量
  103. // [StatisticsManager event:@"match_wake_show"];
  104. }else if ([skillModel.skillName isEqualToString:kLocalizedString(@"小睡眠")]) {
  105. // 交友Tab,[小睡眠]页的曝光量
  106. // [StatisticsManager event:@"match_sleep_show"];
  107. }else if ([skillModel.skillName isEqualToString:kLocalizedString(@"音乐")]) {
  108. // 交友Tab,[音乐]页的曝光量
  109. // [StatisticsManager event:@"match_music_show"];
  110. }else if ([skillModel.skillName isEqualToString:kLocalizedString(@"和平精英")]) {
  111. // 交友Tab,[和平精英]页的曝光量
  112. // [StatisticsManager event:@"match_chicken_show"];
  113. }else if ([skillModel.skillName isEqualToString:kLocalizedString(@"情感树洞")]) {
  114. // 交友Tab,[情感树洞]页的曝光量
  115. // [StatisticsManager event:@"match_emotion__show"];
  116. }else if ([skillModel.skillName isEqualToString:kLocalizedString(@"王者荣耀")]) {
  117. // 交友Tab,[王者荣耀]页的曝光量
  118. // [StatisticsManager event:@"match_king_show"];
  119. }else if ([skillModel.skillName isEqualToString:kLocalizedString(@"英雄联盟")]) {
  120. // 交友Tab,[英雄联盟]
  121. // [StatisticsManager event:@"match_lo_show"];
  122. }
  123. XYMarkingFriendsSkillListViewController *controller = [[XYMarkingFriendsSkillListViewController alloc] init];
  124. controller.skillId = [skillModel.skillId copy];
  125. return controller;
  126. }
  127. - (NSMutableArray *)skills {
  128. if (!_skills) {
  129. _skills = [NSMutableArray array];
  130. }
  131. return _skills;
  132. }
  133. /*
  134. #pragma mark - Navigation
  135. // In a storyboard-based application, you will often want to do a little preparation before navigation
  136. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  137. // Get the new view controller using [segue destinationViewController].
  138. // Pass the selected object to the new view controller.
  139. }
  140. */
  141. @end