123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513 |
- //
- // MinePageViewController.m
- // KulexiuForTeacher
- //
- // Created by Kyle on 2022/3/29.
- //
- #import "MinePageViewController.h"
- #import "MinePageHeadView.h"
- #import "JXCategoryView.h"
- #import "JXPagerListRefreshView.h"
- #import "MinePageVIPCourseView.h"
- #import "TeacherInfo.h"
- #import "UserInfoManager.h"
- #import "MinePageTopView.h"
- #import "BadgeIntroduceView.h"
- #import "MyStyleViewController.h"
- #import "JXCategoryIndicatorGradientLineView.h"
- #import "MinePageAccompanyCourseView.h"
- #import "MinePageVideoCourseView.h"
- #import "MinePageMusicView.h"
- #import "MinePageLiveCourseView.h"
- #import "MinePageGroupModel.h"
- #import "FansGroupAlertView.h"
- #import "KSGroupConversationController.h"
- #import "CreateFansGroupViewController.h"
- #import "MyStyleVideoListController.h"
- #import "MineGroupCourseBodyView.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;
- @property (nonatomic, strong) BadgeIntroduceView *intruduceAlert;
- @property (nonatomic, strong) NSMutableArray *fansGroupArray;
- @end
- @implementation MinePageViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.ks_prefersNavigationBarHidden = YES;
- _titles = @[@"VIP定制课",@"趣纠课",@"小组课",@"直播课",@"视频课",@"乐谱"];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startSearchEdit) name:@"MinePageStartSearch" object:nil];
- [self configUI];
- [self countUMEvent];
- }
- - (void)startSearchEdit {
- [self.pagerView setMainTableViewToMaxContentOffsetY];
- }
- - (void)countUMEvent {
- [USER_MANAGER sendUMEvent:@"klx_minePage"];
- }
- - (void)requestTeacherGroup {
- [KSNetworkingManager queryTeacherGroupRequest:KS_POST success:^(NSDictionary * _Nonnull dic) {
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- NSArray *sourceArray = [dic ks_arrayValueForKey:@"data"];
- NSMutableArray *groupArray = [NSMutableArray array];
- for (NSDictionary *parm in sourceArray) {
- MinePageGroupModel *model = [[MinePageGroupModel alloc] initWithDictionary:parm];
- [groupArray addObject:model];
- }
- self.fansGroupArray = [NSMutableArray arrayWithArray:groupArray];
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
-
- } faliure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (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;
-
- _categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0, topHeight, kScreenWidth, HEADER_HEIGHT)];
- _categoryView.backgroundColor = HexRGB(0xf8f9fc);
- self.categoryView.titles = self.titles;
- self.categoryView.delegate = self;
- self.categoryView.titleFont = [UIFont systemFontOfSize:16.0f];
- self.categoryView.titleSelectedFont = [UIFont systemFontOfSize:16.0f weight:UIFontWeightMedium];
- self.categoryView.titleSelectedColor = HexRGB(0x333333);
- self.categoryView.titleColor = HexRGB(0x666666);
- self.categoryView.titleColorGradientEnabled = YES;
- self.categoryView.cellSpacing = 16.0f;
-
- JXCategoryIndicatorGradientLineView *lineView = [[JXCategoryIndicatorGradientLineView alloc] init];
- lineView.indicatorColor = [UIColor clearColor];
- [lineView configStartColor:HexRGB(0x2DC7AA) startPoint:CGPointMake(0.02, 1) endColor:HexRGBAlpha(0x2DC7AA, 0) endPoint:CGPointMake(1, 1)];
- lineView.indicatorHeight = 6.0f;
- lineView.verticalMargin = 15;
- self.categoryView.indicators = @[lineView];
-
- _pagerView = [self preferredPagingView];
- self.pagerView.frame = CGRectMake(0, topHeight, KPortraitWidth, KPortraitHeight - 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 ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- self.teacherInfo = [[TeacherInfo alloc] initWithDictionary:[dic ks_dictionaryValueForKey:@"data"]];
- [self refreshHeadView];
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (void)refreshHeadView {
- [self.topView configSource:self.teacherInfo];
- // 刷新老师认证和音乐人认证状态
- [self refreshAuthStatus];
- [self.headView.bgView sd_setImageWithURL:[NSURL URLWithString:[self.teacherInfo.heardUrl getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:TEACHER_AVATAR]];
- [self.pagerView resizeTableHeaderViewHeightWithAnimatable:NO duration:0.3f curve:UIViewAnimationCurveEaseInOut];
- }
- - (void)refreshAuthStatus {
- for (NSInteger index = 0; index < self.listViewArray.count; index++) {
- id view = self.listViewArray[index];
- if ([view isKindOfClass:[MinePageLiveCourseView class]]) {
- MinePageLiveCourseView *courseView = (MinePageLiveCourseView *)view;
- courseView.liveFlag = [self.teacherInfo.liveFlag isEqualToString:@"1"] ? YES : NO;
- }
- }
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [self configStatusViewColorWhite:YES];
- self.navigationController.interactivePopGestureRecognizer.enabled = YES;
- [self requestTeachMessage];
- [self requestSubjectList];
- [self requestTeacherGroup];
- if (self.listViewArray.count > self.categoryView.selectedIndex) {
- id value = self.listViewArray[self.categoryView.selectedIndex];
- if ([value isKindOfClass:[KSJXBodyView class]]) {
- KSJXBodyView *listView = (KSJXBodyView *)value;
- [listView beginFirstRefresh];
- }
- else if ([value isKindOfClass:[kSJXCollectionView class]]) {
- kSJXCollectionView *listView = (kSJXCollectionView *)value;
- [listView beginFirstRefresh];
- }
- }
- [IQKeyboardManager sharedManager].enable = NO;
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- [self configStatusViewColorWhite:NO];
- [IQKeyboardManager sharedManager].enable = YES;
- }
- - (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 ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- NSArray *dataArray = [NSMutableArray array];
- dataArray = [dic ks_arrayValueForKey:@"data"];
- NSMutableArray *subjectArray = [NSMutableArray array];
- for (NSDictionary *parm in dataArray) {
- NSMutableDictionary *subjectSource = [NSMutableDictionary dictionary];
- [subjectSource setValue:[parm ks_stringValueForKey:@"id"] forKey:@"subjectId"];
- [subjectSource setValue:[parm ks_stringValueForKey:@"name"] forKey:@"subjectName"];
- [subjectArray addObject:subjectSource];
- }
- self.subjectList = [subjectArray mutableCopy];
- [self refreshSubjectMessage];
- }
- else{
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (void)refreshSubjectMessage {
- for (NSInteger index = 0; index < self.listViewArray.count; index++) {
- id view = self.listViewArray[index];
- if ([view isKindOfClass:[MinePageMusicView class]]) {
- MinePageMusicView *courseView = (MinePageMusicView *)view;
- courseView.subjectList = [self.subjectList mutableCopy];
- }
- }
- }
- #pragma mark - JXPagerViewDelegate
- - (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
- return self.topView;
- }
- - (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
- NSUInteger topHeight = 0.0f;
- if (!self.teacherInfo) {
- topHeight = 131 + 14 + 64;
- }
- else {
- topHeight = (NSUInteger)[self.topView getViewHeight:self.teacherInfo];
- }
-
- return topHeight;
- }
- - (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) { // VIP定制
- MinePageVIPCourseView *listView = [[MinePageVIPCourseView 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) { // 趣纠课
- MinePageAccompanyCourseView *listView = [[MinePageAccompanyCourseView 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 == 2) {
- MineGroupCourseBodyView *listView = [[MineGroupCourseBodyView 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 == 3) { // 直播
- MinePageLiveCourseView *listView = [[MinePageLiveCourseView 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;
- }
- else {
- listView.liveFlag = YES;
- }
- [listView beginFirstRefresh];
- return listView;
- }
- else if (index == 4) { // 视频课
- MinePageVideoCourseView *listView = [[MinePageVideoCourseView alloc] init];
- listView.naviController = self.navigationController;
- [self.listViewArray replaceObjectAtIndex:index withObject:listView];
- self.listViewArray[index] = listView;
- listView.selectIndex = index;
- [listView beginFirstRefresh];
- return listView;
- }
- else { // 乐谱
- MinePageMusicView *listView = [[MinePageMusicView alloc] init];
- listView.naviController = self.navigationController;
- [self.listViewArray replaceObjectAtIndex:index withObject:listView];
- self.listViewArray[index] = listView;
- listView.selectIndex = index;
- if (self.subjectList) {
- listView.subjectList = [self.subjectList mutableCopy];
- }
- [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]];
- }
- - (void)pagerView:(JXPagerView *)pagerView mainTableViewDidScroll:(UIScrollView *)scrollView {
-
- NSLog(@"sscroll content offset y %f", scrollView.contentOffset.y);
- CGFloat height = [self.topView getViewHeight:self.teacherInfo];
- CGFloat space = scrollView.contentOffset.y;
- if (space > 100) {
- CGFloat rate = (space - 100) / (height - 100);
- NSLog(@"rate ---------%f",rate);
- if (rate >= 1) {
- [self configStatusViewColorWhite:NO];
- self.headView.topView.backgroundColor = HexRGBAlpha(0xffffff, 1);
- [self.headView.backImage setImage:[UIImage imageNamed:@"back_black"]];
- [self.headView.editImage setImage:[UIImage imageNamed:@"minePage_nav_edit_black"]];
- self.headView.headTitle.hidden = NO;
- }
- else {
- [self configStatusViewColorWhite:YES];
- self.headView.topView.backgroundColor = [UIColor clearColor];
- [self.headView.backImage setImage:[UIImage imageNamed:@"back_white"]];
- [self.headView.editImage setImage:[UIImage imageNamed:@"minePage_nav_edit_white"]];
- self.headView.headTitle.hidden = YES;
- }
- }
- else {
- [self configStatusViewColorWhite:YES];
- self.headView.topView.backgroundColor = [UIColor clearColor];
- [self.headView.backImage setImage:[UIImage imageNamed:@"back_white"]];
- [self.headView.editImage setImage:[UIImage imageNamed:@"minePage_nav_edit_white"]];
- self.headView.headTitle.hidden = YES;
- }
- }
- #pragma mark --- lazying
- - (MinePageHeadView *)headView {
- if (!_headView) {
- _headView = [MinePageHeadView shareInstance];
- MJWeakSelf;
- [_headView backAction:^(BOOL isBack) {
- if (isBack) {
- [weakSelf backAction];
- }
- else {
- [weakSelf editAction];
- }
- }];
- }
- return _headView;
- }
- - (NSMutableArray *)listViewArray {
- if (!_listViewArray) {
- _listViewArray = [NSMutableArray arrayWithArray:@[@"",@"",@"",@"",@"",@""]];
- }
- return _listViewArray;
- }
- - (MinePageTopView *)topView {
- if (!_topView) {
- _topView = [MinePageTopView shareInstance];
- MJWeakSelf;
- [_topView badgeDetail:^(MINEPAGE_TOP topAction) {
- [weakSelf topAction:topAction];
- }];
- }
- return _topView;
- }
- - (void)topAction:(MINEPAGE_TOP)topAction {
- switch (topAction) {
- case MINEPAGE_TOP_STYLEVIDEO:
- {
- [self showStyleVideo];
- }
- break;
- case MINEPAGE_TOP_FANSGROUP:
- {
- [self showFansGroup];
- }
- break;
- case MINEPAGE_TOP_EDIT:
- {
- [self editAction];
- }
- break;
- default:
- break;
- }
- }
- - (void)showStyleVideo {
- MyStyleVideoListController *ctrl = [[MyStyleVideoListController alloc] init];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- - (void)showFansGroup {
- FansGroupAlertView *alert = [FansGroupAlertView sharedInstance];
- [alert configWithSource:self.fansGroupArray];
- [alert displayInView:self.view];
- MJWeakSelf;
- [alert groupChatConversation:^(BOOL isCreate, NSString * _Nullable imGroupId) {
- if (isCreate) {
- [weakSelf createGroup];
- }
- else {
- [weakSelf chatAction:imGroupId];
- }
- }];
- }
- - (void)createGroup {
- CreateFansGroupViewController *ctrl = [[CreateFansGroupViewController alloc] init];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- - (void)chatAction:(NSString *)imGroupId {
- if ([NSString isEmptyString:imGroupId]) {
- return;
- }
- TUIChatConversationModel *model = [[TUIChatConversationModel alloc] init];
- model.groupID = imGroupId;
- KSGroupConversationController *ctrl = [[KSGroupConversationController alloc] init];
- ctrl.conversation = model;
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- - (void)editAction {
- MyStyleViewController *style = [[MyStyleViewController alloc] init];
- [self.navigationController pushViewController:style animated:YES];
- }
- - (BadgeIntroduceView *)intruduceAlert {
- if (!_intruduceAlert) {
- _intruduceAlert = [BadgeIntroduceView shareInstance];
- _intruduceAlert.frame = CGRectMake(0, 0, KPortraitWidth, KPortraitHeight);
- }
- return _intruduceAlert;
- }
- - (void)showDescAlert {
- [self.intruduceAlert showAlertInView:[NSObject getKeyWindow]];
- }
- - (void)dealloc {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- /*
- #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
|