123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- //
- // MyMusicViewController.m
- // KulexiuForTeacher
- //
- // Created by Kyle on 2022/3/28.
- //
- #import "MyMusicViewController.h"
- #import "KSBaseWKWebViewController.h"
- #import "JXCategoryView.h"
- #import "JXPagerListRefreshView.h"
- #import "MyMusicBodyView.h"
- #import "TeacherInfo.h"
- #import "UserInfoManager.h"
- #define HEADER_HEIGHT (64)
- @interface MyMusicViewController ()<JXPagerViewDelegate, JXPagerMainTableViewGestureDelegate,JXCategoryViewDelegate>
- @property (nonatomic, assign) NSInteger selectedIndex;
- @property (nonatomic, strong) NSMutableArray *listViewArray;
- @property (nonatomic, strong) TeacherInfo *teacherInfo;
- @end
- @implementation MyMusicViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- [self allocTitle:@"我的曲谱"];
- _titles = @[@"已上架",@"审核中",@"审核失败"];
- [self configUI];
- }
- - (void)configUI {
- [self rightButton:[UIImage imageNamed:@"nav_share_image"]];
- [self.scrollView removeFromSuperview];
- self.view.backgroundColor = HexRGB(0xf6f8f9);
-
- _categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, HEADER_HEIGHT)];
- self.categoryView.titles = self.titles;
- self.categoryView.delegate = self;
- self.categoryView.titleFont = [UIFont systemFontOfSize:17.0f];
- self.categoryView.titleSelectedFont = [UIFont systemFontOfSize:17.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;
- self.categoryView.indicators = @[lineView];
-
- _pagerView = [self preferredPagingView];
- self.pagerView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight - kNaviBarHeight - iPhoneXSafeBottomMargin);
- self.pagerView.backgroundColor = [UIColor clearColor];
- self.pagerView.mainTableView.backgroundColor = [UIColor clearColor];
- self.pagerView.listContainerView.backgroundColor = [UIColor clearColor];
- self.pagerView.mainTableView.gestureDelegate = self;
- self.categoryView.listContainer = (id<JXCategoryViewListContainer>)self.pagerView.listContainerView;
- self.pagerView.listContainerView.listCellBackgroundColor = [UIColor clearColor];
- [self.view addSubview:self.pagerView];
- self.categoryView.listContainer = (id<JXCategoryViewListContainer>)self.pagerView.listContainerView;
- }
- - (void)rightBtnClick { // 获取分享数据
-
-
- [self showhud];
- [KSNetworkingManager queryMusicShareMessageRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
- [self removehub];
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- // if (<#condition#>) {
- // <#statements#>
- // }
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- [self removehub];
- }];
- }
- - (void)displayShareView {
-
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- self.navigationController.interactivePopGestureRecognizer.enabled = YES;
- [self requestTeachMessage];
- if (self.listViewArray.count > self.categoryView.selectedIndex) {
- id value = self.listViewArray[self.categoryView.selectedIndex];
- if ([value isKindOfClass:[MyMusicBodyView class]]) {
- MyMusicBodyView *listView = (MyMusicBodyView *)value;
- [listView beginFirstRefresh];
- }
- }
- }
- - (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 refreshAuthStatus];
- }
- - (void)refreshAuthStatus {
- for (NSInteger index = 0; index < self.listViewArray.count; index++) {
- id view = self.listViewArray[index];
- if ([view isKindOfClass:[MyMusicBodyView class]]) {
- MyMusicBodyView *listView = (MyMusicBodyView *)view;
- listView.musicianStatus = self.teacherInfo.musicianAuthStatus;
- }
- }
- }
- - (void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
- self.navigationController.interactivePopGestureRecognizer.enabled = (self.categoryView.selectedIndex == 0);
- }
- - (JXPagerView *)preferredPagingView {
- return [[JXPagerListRefreshView alloc] initWithDelegate:self];
- }
- #pragma mark - JXPagerViewDelegate
- - (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
- return [UIView new];
- }
- - (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
- return CGFLOAT_MIN;
- }
- - (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 {
- MyMusicBodyView *listView = [[MyMusicBodyView alloc] init];
- listView.naviController = self.navigationController;
- [self.listViewArray replaceObjectAtIndex:index withObject:listView];
- self.listViewArray[index] = listView;
- if (index == 0) {
- listView.selectIndex = 0;
- }else if (index == 1) {
- listView.selectIndex = 1;
- }
- else {
- listView.selectIndex = 2;
- }
- if (self.teacherInfo) {
- listView.musicianStatus = self.teacherInfo.musicianAuthStatus;
- }
- else {
- listView.musicianStatus = @"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];
- }
- }
- }
- #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]];
- }
- - (NSMutableArray *)listViewArray {
- if (!_listViewArray) {
- _listViewArray = [NSMutableArray arrayWithArray:@[@"",@"",@""]];
- }
- return _listViewArray;
- }
- /*
- #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
|