|
@@ -38,6 +38,9 @@
|
|
|
#import "HomeAlbumModel.h"
|
|
|
#import "HomeHotAlbumCell.h"
|
|
|
|
|
|
+#import "HomeQualityMusic.h"
|
|
|
+#import "HomeQualityMusicCollectionCell.h"
|
|
|
+
|
|
|
#import "HomeHotMusicView.h"
|
|
|
#import "HomeHotMusicCollectionCell.h"
|
|
|
#import "KSPremissionAlert.h"
|
|
@@ -64,6 +67,7 @@
|
|
|
#import "TeacherStyleModel.h"
|
|
|
#import "HomeTeacherLiveModel.h"
|
|
|
|
|
|
+
|
|
|
#define BUTTONWIDTH (65)
|
|
|
#define BUTTONHEIGHT (80)
|
|
|
|
|
@@ -108,6 +112,12 @@
|
|
|
@property (nonatomic, strong) UICollectionView *albumCollectionView; // 专辑容器
|
|
|
@property (nonatomic, assign) CGFloat albumViewHeight; // album 高度
|
|
|
|
|
|
+// 精品曲谱
|
|
|
+@property (nonatomic, strong) HomeQualityMusic *qualityMusicView;
|
|
|
+@property (nonatomic, strong) UICollectionView *qualityMusicCollectionView; // 精品曲谱容器
|
|
|
+@property (nonatomic, strong) NSMutableArray *qualityMusicArray; // 精品曲谱数据
|
|
|
+@property (nonatomic, assign) CGFloat qualityMusicViewHeight; // 精品music高度
|
|
|
+
|
|
|
// 热门曲谱
|
|
|
@property (nonatomic, strong) HomeHotMusicView *hotMusicView;
|
|
|
@property (nonatomic, strong) UICollectionView *musicCollectionView; // 曲谱容器
|
|
@@ -235,12 +245,21 @@
|
|
|
make.height.mas_equalTo(self.albumViewHeight);
|
|
|
}];
|
|
|
|
|
|
+ // 精品曲谱
|
|
|
+ [self.headView addSubview:self.qualityMusicView];
|
|
|
+ self.qualityMusicViewHeight = [HomeQualityMusic getViewHeight];
|
|
|
+ [self.qualityMusicView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.right.mas_equalTo(self.headView);
|
|
|
+ make.top.mas_equalTo(self.albumView.mas_bottom);
|
|
|
+ make.height.mas_equalTo(self.self.qualityMusicViewHeight);
|
|
|
+ }];
|
|
|
+
|
|
|
// 热门曲目
|
|
|
[self.headView addSubview:self.hotMusicView];
|
|
|
self.musicViewHeight = [HomeHotMusicView getViewHeight];
|
|
|
[self.hotMusicView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.left.right.mas_equalTo(self.headView);
|
|
|
- make.top.mas_equalTo(self.albumView.mas_bottom);
|
|
|
+ make.top.mas_equalTo(self.qualityMusicView.mas_bottom);
|
|
|
make.height.mas_equalTo(self.musicViewHeight);
|
|
|
}];
|
|
|
|
|
@@ -288,7 +307,7 @@
|
|
|
|
|
|
- (void)refreshHeadHeight {
|
|
|
CGFloat bottomSpace = 20.0f;
|
|
|
- self.headViewHeight = self.bannerViewHeight + self.buttonViewHeight + self.noticeViewHeight + self.courseViewHeight + self.albumViewHeight + self.musicViewHeight + self.talentViewHeight + self.liveViewHeight + self.videoViewHeight + bottomSpace;
|
|
|
+ self.headViewHeight = self.bannerViewHeight + self.buttonViewHeight + self.noticeViewHeight + self.courseViewHeight + self.albumViewHeight + self.qualityMusicViewHeight + self.musicViewHeight + self.talentViewHeight + self.liveViewHeight + self.videoViewHeight + bottomSpace;
|
|
|
[self.pagerView reloadData];
|
|
|
}
|
|
|
|
|
@@ -315,7 +334,7 @@
|
|
|
self.categoryView.indicators = @[lineView];
|
|
|
|
|
|
_pagerView = [self preferredPagingView];
|
|
|
- self.pagerView.frame = CGRectMake(0, kNaviBarHeight, kScreenWidth, kScreenHeight - kNaviBarHeight - kTabBarHeight);
|
|
|
+ self.pagerView.frame = CGRectMake(0, kNaviBarHeight, KPortraitWidth, KPortraitHeight - kNaviBarHeight - kTabBarHeight);
|
|
|
self.pagerView.mainTableView.gestureDelegate = self;
|
|
|
[self.view addSubview:self.pagerView];
|
|
|
self.pagerView.backgroundColor = [UIColor clearColor];
|
|
@@ -556,10 +575,31 @@
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
+- (void)requestQualityMusic {
|
|
|
+ [KSNetworkingManager homeQualityMusicListRequest:KS_POST version:[USER_MANAGER getCurrentVersion] success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ dispatch_group_leave(self.requestGroup);
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
+ NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
|
|
|
+ NSMutableArray *musicArray = [NSMutableArray array];
|
|
|
+ for (NSDictionary *parm in sourceArray) {
|
|
|
+ HomeHotMusicModel *model = [[HomeHotMusicModel alloc] initWithDictionary:parm];
|
|
|
+ [musicArray addObject:model];
|
|
|
+ }
|
|
|
+ self.qualityMusicArray = [NSMutableArray arrayWithArray:musicArray];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self MBPShow:MESSAGEKEY];
|
|
|
+ }
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+ dispatch_group_leave(self.requestGroup);
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
- (void)requestHotMusic {
|
|
|
dispatch_group_enter(self.requestGroup);
|
|
|
[KSNetworkingManager homeMusicListRequest:KS_POST version:[USER_MANAGER getCurrentVersion] success:^(NSDictionary * _Nonnull dic) {
|
|
|
- dispatch_group_leave(self.requestGroup);
|
|
|
+
|
|
|
if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
|
|
|
NSMutableArray *musicArray = [NSMutableArray array];
|
|
@@ -572,8 +612,9 @@
|
|
|
else {
|
|
|
[self MBPShow:MESSAGEKEY];
|
|
|
}
|
|
|
+ [self requestQualityMusic];
|
|
|
} faliure:^(NSError * _Nonnull error) {
|
|
|
- dispatch_group_leave(self.requestGroup);
|
|
|
+ [self requestQualityMusic];
|
|
|
}];
|
|
|
}
|
|
|
|
|
@@ -691,6 +732,9 @@
|
|
|
[self refreshCourseView:self.recentCourseModel];
|
|
|
|
|
|
[self refreshAlbumView];
|
|
|
+
|
|
|
+ [self refreshQualityView];
|
|
|
+
|
|
|
[self refreshMusicView];
|
|
|
// 达人
|
|
|
[self refreshTalentView];
|
|
@@ -946,6 +990,21 @@
|
|
|
[self.albumCollectionView reloadData];
|
|
|
}
|
|
|
|
|
|
+- (void)refreshQualityView {
|
|
|
+ if (self.qualityMusicArray.count) {
|
|
|
+ self.qualityMusicViewHeight = [HomeQualityMusic getViewHeight];
|
|
|
+ self.qualityMusicView.hidden = NO;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ self.qualityMusicViewHeight = CGFLOAT_MIN;
|
|
|
+ self.qualityMusicView.hidden = YES;
|
|
|
+ }
|
|
|
+ [self.qualityMusicView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.height.mas_equalTo(self.qualityMusicViewHeight);
|
|
|
+ }];
|
|
|
+ [self.qualityMusicCollectionView reloadData];
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
- (void)refreshMusicView {
|
|
|
|
|
@@ -1129,6 +1188,11 @@
|
|
|
if (collectionView == self.albumCollectionView) { // 专辑
|
|
|
return self.albumArray.count;
|
|
|
}
|
|
|
+ else if (collectionView == self.qualityMusicCollectionView) {
|
|
|
+ NSInteger lastRowCount = (self.qualityMusicArray.count % 3) > 0 ? 1 : 0;
|
|
|
+ NSInteger count = self.qualityMusicArray.count / 3 + lastRowCount;
|
|
|
+ return count;
|
|
|
+ }
|
|
|
else if (collectionView == self.musicCollectionView) { // 乐谱
|
|
|
NSInteger lastRowCount = (self.musicArray.count % 3) > 0 ? 1 : 0;
|
|
|
NSInteger count = self.musicArray.count / 3 + lastRowCount;
|
|
@@ -1153,6 +1217,19 @@
|
|
|
[cell configWithAlbumModel:model];
|
|
|
return cell;
|
|
|
}
|
|
|
+ else if (collectionView == self.qualityMusicCollectionView) {
|
|
|
+ NSMutableArray *songArray = [NSMutableArray array];
|
|
|
+ NSInteger length = indexPath.item * 3 + 3 > self.qualityMusicArray.count ? self.qualityMusicArray.count - indexPath.item * 3: 3;
|
|
|
+ NSRange range = NSMakeRange(indexPath.item * 3, length);
|
|
|
+
|
|
|
+ songArray = [NSMutableArray arrayWithArray:[self.qualityMusicArray subarrayWithRange:range]];
|
|
|
+ HomeQualityMusicCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeQualityMusicCollectionCell" forIndexPath:indexPath];
|
|
|
+ MJWeakSelf;
|
|
|
+ [cell configWithSourceArray:songArray callback:^(NSString * _Nonnull songId) {
|
|
|
+ [weakSelf displaySongDetail:songId];
|
|
|
+ }];
|
|
|
+ return cell;
|
|
|
+ }
|
|
|
else if (collectionView == self.musicCollectionView) {
|
|
|
NSMutableArray *songArray = [NSMutableArray array];
|
|
|
NSInteger length = indexPath.item * 3 + 3 > self.musicArray.count ? self.musicArray.count - indexPath.item * 3: 3;
|
|
@@ -1288,6 +1365,9 @@
|
|
|
if (collectionView == self.albumCollectionView) {
|
|
|
return CGSizeMake(100, 134);
|
|
|
}
|
|
|
+ else if (collectionView == self.qualityMusicCollectionView) {
|
|
|
+ return CGSizeMake(KPortraitWidth * 0.83, 240);
|
|
|
+ }
|
|
|
else if (collectionView == self.musicCollectionView) {
|
|
|
return CGSizeMake(KPortraitWidth * 0.83, 240);
|
|
|
}
|
|
@@ -1612,6 +1692,47 @@
|
|
|
[self.navigationController pushViewController:ctrl animated:YES];
|
|
|
}
|
|
|
|
|
|
+#pragma mark ---- 精品曲目
|
|
|
+- (HomeQualityMusic *)qualityMusicView {
|
|
|
+ if (!_qualityMusicView) {
|
|
|
+ _qualityMusicView = [HomeQualityMusic shareInstance];
|
|
|
+ MJWeakSelf;
|
|
|
+ [_qualityMusicView homeMusicMore:^{
|
|
|
+ [weakSelf moreHotMusic];
|
|
|
+ }];
|
|
|
+ [_qualityMusicView.musicContentView addSubview:self.qualityMusicCollectionView];
|
|
|
+ [self.qualityMusicCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.right.bottom.top.mas_equalTo(_qualityMusicView.musicContentView);
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ return _qualityMusicView;
|
|
|
+}
|
|
|
+
|
|
|
+- (UICollectionView *)qualityMusicCollectionView {
|
|
|
+ if (!_qualityMusicCollectionView) {
|
|
|
+ UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
|
|
+ layout.sectionInset = UIEdgeInsetsMake(12, 14, 12, 14);
|
|
|
+ layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
|
|
+ _qualityMusicCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
|
|
+ _qualityMusicCollectionView.backgroundColor = [UIColor clearColor];
|
|
|
+ _qualityMusicCollectionView.delegate = self;
|
|
|
+ _qualityMusicCollectionView.dataSource = self;
|
|
|
+ _qualityMusicCollectionView.showsVerticalScrollIndicator = NO;
|
|
|
+ _qualityMusicCollectionView.showsHorizontalScrollIndicator = NO;
|
|
|
+ if (@available(iOS 11.0, *)) {
|
|
|
+ _qualityMusicCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
|
|
+ } else {
|
|
|
+ // Fallback on earlier versions
|
|
|
+ if (@available(iOS 13.0, *)) {
|
|
|
+ _qualityMusicCollectionView.automaticallyAdjustsScrollIndicatorInsets = NO;
|
|
|
+ } else {
|
|
|
+ // Fallback on earlier versions
|
|
|
+ }
|
|
|
+ }
|
|
|
+ [_qualityMusicCollectionView registerNib:[UINib nibWithNibName:@"HomeQualityMusicCollectionCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"HomeQualityMusicCollectionCell"];
|
|
|
+ }
|
|
|
+ return _qualityMusicCollectionView;
|
|
|
+}
|
|
|
|
|
|
#pragma mark ---- 热门曲目
|
|
|
- (HomeHotMusicView *)hotMusicView {
|