123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- //
- // XYMakingFriendsSkillViewController.m
- // Starbuds
- //
- // Created by 翟玉磊 on 2020/12/7.
- // Copyright © 2020 翟玉磊. All rights reserved.
- //
- #import "XYMakingFriendsSkillViewController.h"
- #import <JXCategoryView/JXCategoryView.h>
- #import "XYCertificationSkillModel.h"
- #import "XYMarkingFriendsSkillListViewController.h"
- @interface XYMakingFriendsSkillViewController ()<JXCategoryViewDelegate, JXCategoryListContainerViewDelegate>
- @property (nonatomic, strong) JXCategoryTitleView *categoryTitleView;
- @property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
- @property (nonatomic, strong) NSMutableArray *skills;
- @end
- @implementation XYMakingFriendsSkillViewController
- - (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.view.backgroundColor = Color_Clear;
-
- [self setupUI];
- }
- - (void)setupUI {
-
- NSInteger i = 0;
- NSInteger defaultSelectedIndex = 0;
- NSMutableArray *titles = [NSMutableArray array];
- for (XYCertificationSkillModel *model in ApplicationDelegate.appConfigModel.skills) {
- if (model.voiceMatchEnable == 1) {
- // 语音速配跳过
- continue;
- }
- [titles addObject:model.skillName];
- [self.skills addObject:model];
- if ([model.skillId isEqualToString:self.currentSkillId]) {
- defaultSelectedIndex = i;
- }
- i++;
- }
-
- // 分类标题view
- self.categoryTitleView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, SCREEN_WIDTH, 48.0f)];
- self.categoryTitleView.titles = titles;
- self.categoryTitleView.delegate = self;
- self.categoryTitleView.titleFont = Font(12);
- self.categoryTitleView.titleColor = Color_Nakaguro;
- self.categoryTitleView.titleSelectedColor = Color_TextRed;
- self.categoryTitleView.averageCellSpacingEnabled = YES;
- self.categoryTitleView.contentEdgeInsetLeft = 16.0f;
- self.categoryTitleView.contentEdgeInsetRight = 16.0f;
- self.categoryTitleView.cellSpacing = 16;
- self.categoryTitleView.defaultSelectedIndex = defaultSelectedIndex;
- [self.view addSubview:self.categoryTitleView];
-
- JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
- lineView.indicatorWidth = 4.0f;
- lineView.indicatorHeight = 2.0f;
- lineView.indicatorColor = Color_TextRed;
- lineView.verticalMargin = 10.0f;
- self.categoryTitleView.indicators = @[lineView];
-
- // 列表容器
- self.listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
- self.listContainerView.frame = CGRectMake(0, self.categoryTitleView.f_top, SCREEN_WIDTH, SCREEN_HEIGHT - (STATUS_HEIGHT + 48.0f + 68.0f + TABBAR_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<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
-
- XYCertificationSkillModel *skillModel = self.skills[index];
-
- if ([skillModel.skillName isEqualToString:kLocalizedString(@"人工闹钟")]) {
- // 交友Tab,[人工闹钟]页的曝光量
- // [StatisticsManager event:@"match_wake_show"];
- }else if ([skillModel.skillName isEqualToString:kLocalizedString(@"小睡眠")]) {
- // 交友Tab,[小睡眠]页的曝光量
- // [StatisticsManager event:@"match_sleep_show"];
- }else if ([skillModel.skillName isEqualToString:kLocalizedString(@"音乐")]) {
- // 交友Tab,[音乐]页的曝光量
- // [StatisticsManager event:@"match_music_show"];
- }else if ([skillModel.skillName isEqualToString:kLocalizedString(@"和平精英")]) {
- // 交友Tab,[和平精英]页的曝光量
- // [StatisticsManager event:@"match_chicken_show"];
- }else if ([skillModel.skillName isEqualToString:kLocalizedString(@"情感树洞")]) {
- // 交友Tab,[情感树洞]页的曝光量
- // [StatisticsManager event:@"match_emotion__show"];
- }else if ([skillModel.skillName isEqualToString:kLocalizedString(@"王者荣耀")]) {
- // 交友Tab,[王者荣耀]页的曝光量
- // [StatisticsManager event:@"match_king_show"];
- }else if ([skillModel.skillName isEqualToString:kLocalizedString(@"英雄联盟")]) {
- // 交友Tab,[英雄联盟]
- // [StatisticsManager event:@"match_lo_show"];
- }
-
- XYMarkingFriendsSkillListViewController *controller = [[XYMarkingFriendsSkillListViewController alloc] init];
- controller.skillId = [skillModel.skillId copy];
- return controller;
- }
- - (NSMutableArray *)skills {
- if (!_skills) {
- _skills = [NSMutableArray array];
- }
- return _skills;
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|