YOUPAILZMusicWindow.m 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. //
  2. // YOUPAILZMusicWindow.m
  3. // YOUQU
  4. //
  5. // Created by CY on 2021/12/10.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZMusicWindow.h"
  9. #import "JXCategoryView.h"
  10. #import "YOUPAIJXCategoryTitleBackgroundView.h"
  11. #import "JXCategoryListContainerView.h"
  12. #import "YOUPAILZMyMusicVC.h"
  13. #import "YOUPAILZHotMusicVC.h"
  14. //#import "IQKeyboardManager.h"
  15. @interface YOUPAILZMusicWindow ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
  16. @property (nonatomic, weak) UIView *youpaipbgV;
  17. @property (nonatomic, weak) YOUPAIJXCategoryTitleBackgroundView *youpaipcategoryView;
  18. @end
  19. @implementation YOUPAILZMusicWindow
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. self.baseView.hidden = YES;
  23. [self youpaifinitUI];
  24. }
  25. - (void)youpaifinitUI{
  26. UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, KScreenWidth, 345.0f)];
  27. bgV.backgroundColor = LCBkgColor;
  28. [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:bgV size:CGSizeMake(20.0f, 20.0f)];
  29. [self.view addSubview:bgV];
  30. self.youpaipbgV = bgV;
  31. [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.left.right.bottom.offset(0.0f);
  33. make.height.offset(345.0f);
  34. }];
  35. UIView *navV = [[UIView alloc] init];
  36. [bgV addSubview:navV];
  37. [navV mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.left.top.right.offset(0.0f);
  39. make.height.offset(50.0f);
  40. }];
  41. [navV addLineWithColor:[[UIColor whiteColor] colorWithAlphaComponent:0.07f] lineRect:CGRectMake(0.0f, 49.5f, KScreenWidth, 0.5f)];
  42. UIButton *youpaipcloseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  43. [youpaipcloseBtn setImage:[UIImage imageNamed:@"vqu_images_navigation_back_black"] forState:UIControlStateNormal];
  44. [youpaipcloseBtn setImage:[UIImage imageNamed:@"vqu_images_navigation_back_black"] forState:UIControlStateHighlighted];
  45. [youpaipcloseBtn addTarget:self action:@selector(youpaifcloseBtnClick) forControlEvents:UIControlEventTouchUpInside];
  46. [navV addSubview:youpaipcloseBtn];
  47. [youpaipcloseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.left.offset(4.0f);
  49. make.centerY.equalTo(navV);
  50. make.size.mas_offset(CGSizeMake(44.0f, 44.0f));
  51. }];
  52. YOUPAIJXCategoryTitleBackgroundView *youpaipcategoryView = [[YOUPAIJXCategoryTitleBackgroundView alloc] init];
  53. youpaipcategoryView.backgroundColor = [UIColor clearColor];
  54. youpaipcategoryView.titles = self.titles;
  55. youpaipcategoryView.delegate = self;
  56. youpaipcategoryView.titleSelectedColor = HexColorFromRGB(0xF4003F);
  57. youpaipcategoryView.titleColor = HexColorFromRGB(0xffffff);
  58. youpaipcategoryView.titleColorGradientEnabled = YES;
  59. youpaipcategoryView.titleFont = LCFont(16.0f);
  60. youpaipcategoryView.titleSelectedFont = LCFont(16.0f);
  61. youpaipcategoryView.averageCellSpacingEnabled = YES;
  62. youpaipcategoryView.normalBackgroundColor = [UIColor clearColor];
  63. youpaipcategoryView.selectedBackgroundColor = [UIColor clearColor];
  64. youpaipcategoryView.cellWidthIncrement = 0;
  65. youpaipcategoryView.normalBorderColor = [UIColor clearColor];
  66. youpaipcategoryView.selectedBorderColor = [UIColor clearColor];
  67. youpaipcategoryView.borderLineWidth = 0;
  68. youpaipcategoryView.backgroundCornerRadius = 0.0f;
  69. [navV addSubview:youpaipcategoryView];
  70. self.youpaipcategoryView = youpaipcategoryView;
  71. [youpaipcategoryView mas_makeConstraints:^(MASConstraintMaker *make) {
  72. make.center.equalTo(navV);
  73. make.size.mas_offset(CGSizeMake(260.0f, 43.0f));
  74. }];
  75. JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
  76. lineView.verticalMargin = 4.0f;
  77. lineView.indicatorHeight = 2.5f;
  78. lineView.indicatorWidth = 8.0f;
  79. lineView.indicatorColor = HexColorFromRGB(0xF4003F);
  80. youpaipcategoryView.indicators = @[lineView];
  81. JXCategoryListContainerView *pagerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_CollectionView delegate:self];
  82. pagerView.listCellBackgroundColor = LCBkgColor;
  83. [bgV addSubview:pagerView];
  84. youpaipcategoryView.listContainer = pagerView;
  85. [pagerView mas_makeConstraints:^(MASConstraintMaker *make) {
  86. make.left.right.bottom.offset(0.0f);
  87. make.top.equalTo(navV.mas_bottom).offset(0.0f);
  88. }];
  89. }
  90. - (void)youpaifcloseBtnClick{
  91. [self dismissViewControllerAnimated:YES completion:^{}];
  92. }
  93. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
  94. [self.view endEditing:YES];
  95. UITouch *touch = [touches.allObjects lastObject];
  96. if (touch.view == self.view && self.isTouchDismiss) {
  97. [self dismissViewControllerAnimated:YES completion:nil];
  98. }
  99. }
  100. - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{
  101. return self.titles.count;
  102. }
  103. - (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
  104. if (index == 0) {
  105. YOUPAILZMyMusicVC *vc = [YOUPAILZMyMusicVC new];
  106. @weakify(self);
  107. [vc setGoHotMusicListBlock:^{
  108. @strongify(self);
  109. [self.youpaipcategoryView selectItemAtIndex:1];
  110. }];
  111. return vc;
  112. }else{
  113. YOUPAILZHotMusicVC *vc = [YOUPAILZHotMusicVC new];
  114. @weakify(self);
  115. [vc setKeyboardWillHideBlock:^{
  116. @strongify(self);
  117. [self.view layoutIfNeeded];
  118. [UIView animateWithDuration:0.25f animations:^{
  119. [self.youpaipbgV mas_updateConstraints:^(MASConstraintMaker *make) {
  120. make.bottom.offset(0.0f);
  121. }];
  122. [self.view layoutIfNeeded];
  123. }];
  124. }];
  125. [vc setKeyboardWillShowBlock:^(CGFloat keyboardHeight) {
  126. @strongify(self);
  127. [self.view layoutIfNeeded];
  128. [UIView animateWithDuration:0.25f animations:^{
  129. [self.youpaipbgV mas_updateConstraints:^(MASConstraintMaker *make) {
  130. make.bottom.offset(-keyboardHeight + (345.0f - 50.0f - 58.0f));
  131. }];
  132. [self.view layoutIfNeeded];
  133. }];
  134. }];
  135. return vc;
  136. }
  137. }
  138. - (NSArray <NSString *> *)titles{
  139. return @[@"我的音乐",@"热门音乐"];
  140. }
  141. @end