123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351 |
- //
- // MinePageViewController.m
- // KulexiuForTeacher
- //
- // Created by Kyle on 2022/3/29.
- //
- #import "MinePageViewController.h"
- #import "MinePageHeadView.h"
- #import "JXCategoryView.h"
- #import "JXPagerListRefreshView.h"
- #import "MinePageMienBodyView.h"
- #import "MinePageCourseView.h"
- #import "MinePageVideoView.h"
- #import "TeacherInfo.h"
- #import "UserInfoManager.h"
- #import "MinePageTopView.h"
- #define HEADER_HEIGHT (50)
- @interface MinePageViewController ()<JXPagerViewDelegate, JXPagerMainTableViewGestureDelegate,JXCategoryViewDelegate>
- @property (nonatomic, strong) MinePageHeadView *headView;
- @property (nonatomic, assign) NSInteger selectedIndex;
- @property (nonatomic, strong) NSMutableArray *listViewArray;
- @property (nonatomic, strong) TeacherInfo *teacherInfo;
- @property (nonatomic, strong) MinePageTopView *topView;
- @property (nonatomic, strong) NSMutableArray *subjectList;
- @end
- @implementation MinePageViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.ks_prefersNavigationBarHidden = YES;
- _titles = @[@"个人风采",@"陪练课",@"直播课",@"视频课",@"乐谱"];
- [self configUI];
- }
- - (void)configUI {
-
- [self.scrollView removeFromSuperview];
- [self.view addSubview:self.headView];
- CGFloat headHeight = [self.headView getViewHeight];
- self.headView.frame = CGRectMake(0, 0, kScreenWidth, headHeight);
-
- CGFloat topHeight = kNaviBarHeight + 30;
-
- _categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0, topHeight, kScreenWidth, HEADER_HEIGHT)];
- _categoryView.backgroundColor = [UIColor clearColor];
- self.categoryView.titles = self.titles;
- self.categoryView.delegate = self;
- self.categoryView.titleFont = [UIFont systemFontOfSize:16.0f];
- self.categoryView.titleSelectedFont = [UIFont systemFontOfSize:18.0f weight:UIFontWeightMedium];
- self.categoryView.titleSelectedColor = HexRGB(0x333333);
- self.categoryView.titleColor = HexRGB(0x666666);
- self.categoryView.titleColorGradientEnabled = YES;
-
- JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
- lineView.indicatorColor = THEMECOLOR;
- lineView.indicatorWidth = 16;
- lineView.indicatorHeight = 4.0f;
- self.categoryView.indicators = @[lineView];
-
- _pagerView = [self preferredPagingView];
- self.pagerView.frame = CGRectMake(0, topHeight, kScreenWidth, kScreenHeight - iPhoneXSafeBottomMargin - topHeight);
- self.pagerView.mainTableView.gestureDelegate = self;
- self.pagerView.backgroundColor = [UIColor clearColor];
- self.pagerView.mainTableView.backgroundColor = [UIColor clearColor];
- self.pagerView.listContainerView.backgroundColor = [UIColor clearColor];
- self.pagerView.listContainerView.listCellBackgroundColor = [UIColor clearColor];
- [self.view addSubview:self.pagerView];
- self.categoryView.listContainer = (id<JXCategoryViewListContainer>)self.pagerView.listContainerView;
- }
- - (void)requestTeachMessage {
- [KSNetworkingManager queryTeacherInfoRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- self.teacherInfo = [[TeacherInfo alloc] initWithDictionary:[dic dictionaryValueForKey:@"data"]];
- NSString *rongToken = UserDefault(RongTokenKey);
- if ([NSString isEmptyString:rongToken]) {
- [USER_MANAGER queryUserInfoConnectRongCloud:YES];
- }
- [self refreshHeadView];
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (void)refreshHeadView {
- [self.topView configSource:self.teacherInfo];
- // 刷新老师认证和音乐人认证状态
- [self refreshAuthStatus];
- }
- - (void)refreshAuthStatus {
- for (NSInteger index = 0; index < self.listViewArray.count; index++) {
- id view = self.listViewArray[index];
- if ([view isKindOfClass:[MinePageCourseView class]]) {
- MinePageCourseView *courseView = (MinePageCourseView *)view;
- courseView.liveFlag = [self.teacherInfo.liveFlag isEqualToString:@"1"] ? YES : NO;
- courseView.teaherStatus = self.teacherInfo.entryStatus;
- courseView.musicianStatus = self.teacherInfo.musicianAuthStatus;
- }
- else if ([view isKindOfClass:[MinePageVideoView class]]) {
- MinePageVideoView *videoCourseView = (MinePageVideoView *)view;
- videoCourseView.teaherStatus = self.teacherInfo.entryStatus;
- }
- }
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- self.navigationController.interactivePopGestureRecognizer.enabled = YES;
- [self requestTeachMessage];
- [self requestSubjectList];
- if (self.listViewArray.count > self.categoryView.selectedIndex) {
- id value = self.listViewArray[self.categoryView.selectedIndex];
- if ([value isKindOfClass:[MinePageCourseView class]]) {
- MinePageCourseView *listView = (MinePageCourseView *)value;
- [listView beginFirstRefresh];
- }
- else if ([value isKindOfClass:[MinePageMienBodyView class]]) {
- MinePageMienBodyView *listView = (MinePageMienBodyView *)value;
- [listView beginFirstRefresh];
- }
- else if ([value isKindOfClass:[kSJXCollectionView class]]) {
- MinePageVideoView *listView = (MinePageVideoView *)value;
- [listView beginFirstRefresh];
- }
- }
- }
- - (void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
- self.navigationController.interactivePopGestureRecognizer.enabled = (self.categoryView.selectedIndex == 0);
- }
- - (JXPagerView *)preferredPagingView {
- return [[JXPagerListRefreshView alloc] initWithDelegate:self];
- }
- - (void)requestSubjectList {
- [KSNetworkingManager querySubjectItemRequest:KS_POST success:^(NSDictionary * _Nonnull dic) {
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSArray *dataArray = [NSMutableArray array];
- dataArray = [dic arrayValueForKey:@"data"];
- NSMutableArray *subjectArray = [NSMutableArray array];
- for (NSDictionary *parm in dataArray) {
- NSMutableDictionary *subjectSource = [NSMutableDictionary dictionary];
- [subjectSource setValue:[parm stringValueForKey:@"id"] forKey:@"subjectId"];
- [subjectSource setValue:[parm stringValueForKey:@"name"] forKey:@"subjectName"];
- [subjectArray addObject:subjectSource];
- }
- self.subjectList = [subjectArray mutableCopy];
- [self refreshSubjectMessage];
- }
- else{
- [self MBPShow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (void)refreshSubjectMessage {
- for (NSInteger index = 0; index < self.listViewArray.count; index++) {
- id view = self.listViewArray[index];
- if ([view isKindOfClass:[MinePageCourseView class]]) {
- MinePageCourseView *courseView = (MinePageCourseView *)view;
- courseView.subjectList = [self.subjectList mutableCopy];
- }
- }
- }
- #pragma mark - JXPagerViewDelegate
- - (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
- return self.topView;
- }
- - (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
- return [self.topView getViewHeight];
- }
- - (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
- return HEADER_HEIGHT;
- }
- - (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
- return self.categoryView;
- }
- - (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView {
- //和categoryView的item数量一致
- return self.titles.count;
- }
- - (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
- if (index == 0) { // 个人风采
- MinePageMienBodyView *listView = [[MinePageMienBodyView alloc] init];
- listView.naviController = self.navigationController;
- [self.listViewArray replaceObjectAtIndex:index withObject:listView];
- self.listViewArray[index] = listView;
- listView.selectIndex = index;
- [listView beginFirstRefresh];
- return listView;
- }
- else if (index == 1) { // 陪练课
- MinePageCourseView *listView = [[MinePageCourseView alloc] init];
- listView.naviController = self.navigationController;
- [self.listViewArray replaceObjectAtIndex:index withObject:listView];
- self.listViewArray[index] = listView;
- listView.selectIndex = index;
- if (self.teacherInfo) {
- listView.teaherStatus = self.teacherInfo.entryStatus;
- }
- else {
- listView.teaherStatus = @"PASS";
- }
- [listView beginFirstRefresh];
- return listView;
- }
- else if (index == 2) { // 直播
- MinePageCourseView *listView = [[MinePageCourseView alloc] init];
- listView.naviController = self.navigationController;
- [self.listViewArray replaceObjectAtIndex:index withObject:listView];
- self.listViewArray[index] = listView;
- listView.selectIndex = index;
- if (self.teacherInfo) {
- listView.liveFlag = [self.teacherInfo.liveFlag isEqualToString:@"1"] ? YES : NO;
- listView.teaherStatus = self.teacherInfo.entryStatus;
- }
- else {
- listView.liveFlag = YES;
- listView.teaherStatus = @"PASS";
- }
- [listView beginFirstRefresh];
- return listView;
- }
- else if (index == 4) { // 乐谱
- MinePageCourseView *listView = [[MinePageCourseView alloc] init];
- listView.naviController = self.navigationController;
- [self.listViewArray replaceObjectAtIndex:index withObject:listView];
- self.listViewArray[index] = listView;
- listView.selectIndex = index;
- if (self.teacherInfo) {
- listView.musicianStatus = self.teacherInfo.musicianAuthStatus;
- }
- else {
- listView.musicianStatus = @"PASS";
- }
- if (self.subjectList) {
- listView.subjectList = [self.subjectList mutableCopy];
- }
- [listView beginFirstRefresh];
- return listView;
- }
- else { // 视频课
- MinePageVideoView *listView = [[MinePageVideoView alloc] init];
- listView.naviController = self.navigationController;
- [self.listViewArray replaceObjectAtIndex:index withObject:listView];
- self.listViewArray[index] = listView;
- listView.selectIndex = index;
- if (self.teacherInfo) {
- listView.teaherStatus = self.teacherInfo.entryStatus;
- }
- else {
- listView.teaherStatus = @"PASS";
- }
- [listView beginFirstRefresh];
- return listView;
- }
- }
- #pragma mark - JXCategoryViewDelegate
- - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
- self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0);
- if (self.listViewArray.count > index) {
- id value = self.listViewArray[index];
- if ([value isKindOfClass:[KSJXBodyView class]]) {
- KSJXBodyView *listView = (KSJXBodyView *)value;
- [listView beginFirstRefresh];
- }
- else if ([value isKindOfClass:[kSJXCollectionView class]]) {
- kSJXCollectionView *listView = (kSJXCollectionView *)value;
- [listView beginFirstRefresh];
- }
- }
- }
- #pragma mark - JXPagerMainTableViewGestureDelegate
- - (BOOL)mainTableViewGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
- //禁止categoryView左右滑动的时候,上下和左右都可以滚动
- if (otherGestureRecognizer == self.categoryView.collectionView.panGestureRecognizer) {
- return NO;
- }
- return [gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]];
- }
- #pragma mark --- lazying
- - (MinePageHeadView *)headView {
- if (!_headView) {
- _headView = [MinePageHeadView shareInstance];
- MJWeakSelf;
- [_headView backAction:^{
- [weakSelf backAction];
- }];
- }
- return _headView;
- }
- - (NSMutableArray *)listViewArray {
- if (!_listViewArray) {
- _listViewArray = [NSMutableArray arrayWithArray:@[@"",@"",@"",@"",@""]];
- }
- return _listViewArray;
- }
- - (MinePageTopView *)topView {
- if (!_topView) {
- _topView = [MinePageTopView shareInstance];
- }
- return _topView;
- }
- /*
- #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
|