NoticeNewGroupMenuVC.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. //
  2. // NoticeNewGroupMenuVC.m
  3. // smartRhino
  4. //
  5. // Created by armin on 2019/11/5.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "NoticeNewGroupMenuVC.h"
  9. #import "GHRefreshCollectionView.h"
  10. #import "NoticeNewGroupMenuCell.h"
  11. #import "ZLCollectionViewFlowLayout.h"
  12. @interface NoticeNewGroupMenuVC ()<UICollectionViewDelegate,UICollectionViewDataSource,ZLCollectionViewFlowLayoutDelegate>
  13. @property (strong,nonatomic) IBOutlet UIView *menuBgView;
  14. @property (strong,nonatomic) IBOutlet UIView *wenziBgView;
  15. @property (strong,nonatomic) GHRefreshCollectionView *menuCollectionView;
  16. @property (nonatomic,strong) ZLCollectionViewFlowLayout *flowLayout;
  17. @property (strong,nonatomic) NSMutableArray *menuDataSource;
  18. @end
  19. @implementation NoticeNewGroupMenuVC
  20. +(NoticeNewGroupMenuVC *)initNoticeNewGroupMenuVC{
  21. NoticeNewGroupMenuVC *controller = [StoryboardManager.shared.chatMsgNotice instantiateViewControllerWithIdentifier:@"NoticeNewGroupMenuVC"];
  22. return controller;
  23. }
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. self.fd_prefersNavigationBarHidden = YES;
  27. self.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3f];
  28. self.menuCollectionView = [[GHRefreshCollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:self.flowLayout];
  29. [self.menuBgView addSubview:self.menuCollectionView];
  30. WS(weakSelf);
  31. [self.menuCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.left.equalTo(weakSelf.menuBgView).offset(30);
  33. make.right.equalTo(weakSelf.menuBgView).offset(-30);
  34. make.bottom.top.equalTo(@(0));
  35. }];
  36. [self.menuCollectionView registerNib:[UINib nibWithNibName:@"NoticeNewGroupMenuCell" bundle:nil] forCellWithReuseIdentifier:@"NoticeNewGroupMenuCell"];
  37. self.menuCollectionView.backgroundColor = RGB(244, 244, 246);
  38. self.menuCollectionView.showsVerticalScrollIndicator = NO;
  39. self.menuCollectionView.showsHorizontalScrollIndicator = NO;
  40. self.menuCollectionView.alwaysBounceVertical = YES;
  41. [self.menuCollectionView setDataSource:self];
  42. [self.menuCollectionView setDelegate:self];
  43. [self.menuCollectionView reloadData];
  44. }
  45. -(void)changShow:(NoticeNewGroupMenuPageType )pageType{
  46. self.pageType = pageType;
  47. if(self.pageType == NoticeNewGroupMenuPageType_Menu){
  48. self.menuBgView.hidden = NO;
  49. self.wenziBgView.hidden = YES;
  50. [self.menuDataSource removeAllObjects];
  51. for (int i=0; i<4; i++) {
  52. NoticeNewGroupMenuModel *model = [[NoticeNewGroupMenuModel alloc] init];
  53. switch (i) {
  54. case 0:{
  55. model.menuImgName = @"chatmsg_notice_photo_icon";
  56. model.menuTitle = @"图片";
  57. }break;
  58. case 1:{
  59. model.menuImgName = @"chatmsg_notice_xiangji_icon";
  60. model.menuTitle = @"拍摄";
  61. }break;
  62. case 2:{
  63. model.menuImgName = @"chatmsg_notice_biji_icon";
  64. model.menuTitle = @"我的笔记";
  65. }break;
  66. case 3:{
  67. model.menuImgName = @"chatmsg_notice_sc_icon";
  68. model.menuTitle = @"我的收藏";
  69. }break;
  70. default:
  71. break;
  72. }
  73. [self.menuDataSource addObject:model];
  74. }
  75. [self.menuCollectionView reloadData];
  76. }else{
  77. self.menuBgView.hidden = YES;
  78. self.wenziBgView.hidden = NO;
  79. [self addWenziContent];
  80. }
  81. }
  82. /**********************************************************************/
  83. #pragma mark -ZLLayoutType的代理
  84. /**********************************************************************/
  85. - (ZLLayoutType)collectionView:(GHRefreshCollectionView *)collectionView layout:(ZLCollectionViewFlowLayout *)collectionViewLayout typeOfLayout:(NSInteger)section {
  86. return ClosedLayout;
  87. }
  88. /**********************************************************************/
  89. #pragma mark -如果是ClosedLayout样式的section,必须实现该代理,指定列数
  90. /**********************************************************************/
  91. - (NSInteger)collectionView:(UICollectionView *)collectionView layout:(ZLCollectionViewFlowLayout*)collectionViewLayout columnCountOfSection:(NSInteger)section {
  92. return 4;
  93. }
  94. /**********************************************************************/
  95. #pragma mark -如果是百分比布局必须实现该代理,设置每个item的百分比,如果没实现默认比例为1
  96. /**********************************************************************/
  97. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(ZLCollectionViewFlowLayout*)collectionViewLayout percentOfRow:(NSIndexPath*)indexPath {
  98. return 1;
  99. }
  100. #pragma mark UICollectionView
  101. - (NSInteger)numberOfSectionsInCollectionView:(GHRefreshCollectionView *)collectionView{
  102. if(collectionView == self.menuCollectionView){
  103. return 1;
  104. }
  105. return 0;
  106. }
  107. /**********************************************************************/
  108. #pragma mark -UICollectionViewDataSource
  109. /**********************************************************************/
  110. - (NSInteger)collectionView:(GHRefreshCollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  111. return self.menuDataSource.count;
  112. }
  113. - (UICollectionViewCell *)collectionView:(GHRefreshCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  114. {
  115. NoticeNewGroupMenuModel *bean = [self.menuDataSource objectAtIndex:indexPath.item];
  116. NoticeNewGroupMenuCell *cell = [ collectionView dequeueReusableCellWithReuseIdentifier:@"NoticeNewGroupMenuCell" forIndexPath:indexPath];
  117. cell.cell0ImgView.image = [UIImage imageNamed:bean.menuImgName];
  118. cell.cell0TitleLabel.text = bean.menuTitle;
  119. cell.backgroundColor = RGB(244, 244, 246);
  120. cell.contentView.backgroundColor = RGB(244, 244, 246);
  121. return cell;
  122. }
  123. /****************************************************/
  124. #pragma mark --UICollectionViewDelegateFlowLayout
  125. /****************************************************/
  126. - (CGSize)collectionView:(GHRefreshCollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
  127. {
  128. CGFloat width = SCREEN_WIDTH / 4;
  129. CGFloat height = 112;
  130. return CGSizeMake(width, height);
  131. }
  132. -(UIEdgeInsets)collectionView:(GHRefreshCollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
  133. {
  134. return UIEdgeInsetsMake(0,0,0,0);
  135. }
  136. - (void)collectionView:(GHRefreshCollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  137. [collectionView deselectItemAtIndexPath:indexPath animated:YES];
  138. NoticeNewGroupMenuModel *bean = [self.menuDataSource objectAtIndex:indexPath.item];
  139. NSLog(@"%@",bean.menuTitle);
  140. if(self.isAutomaticHidePage){
  141. self.view.hidden = !self.view.hidden;
  142. }
  143. if(self.delegate && [self.delegate respondsToSelector:@selector(userDidSelectMenuWithIndex:title:)]){
  144. [self.delegate userDidSelectMenuWithIndex:indexPath.item title:bean.menuTitle];
  145. }
  146. }
  147. -(NSMutableArray *)menuDataSource{
  148. if(!_menuDataSource){
  149. _menuDataSource = [[NSMutableArray alloc] init];
  150. }
  151. return _menuDataSource;
  152. }
  153. -(void)addWenziContent{
  154. [self.wenziBgView removeAllSubviews];
  155. UILabel *ziHao = [[UILabel alloc] init];
  156. [self.wenziBgView addSubview:ziHao];
  157. ziHao.text = @"字号";
  158. ziHao.textColor = RGB(10, 10, 10);
  159. ziHao.font = [UIFont systemFontOfSize:12];
  160. ziHao.frame = CGRectMake(15, self.wenziBgView.height - 110, 30, 30);
  161. [ziHao sizeToFit];
  162. UILabel *ziHaoRight = [[UILabel alloc] init];
  163. [self.wenziBgView addSubview:ziHaoRight];
  164. ziHaoRight.text = @"较小";
  165. ziHaoRight.textColor = RGB(10, 10, 10);
  166. ziHaoRight.font = [UIFont systemFontOfSize:12];
  167. ziHaoRight.frame = CGRectMake(SCREEN_WIDTH - 70, self.wenziBgView.height - 110, 30, 30);
  168. [ziHaoRight sizeToFit];
  169. NSMutableArray *allYuanViewArr = [[NSMutableArray alloc] init];
  170. CGFloat yuanWidth = 16;
  171. CGFloat startX = 60;
  172. CGFloat endX = SCREEN_WIDTH - 80;
  173. CGFloat txLineWidth = (endX - startX - 4*yuanWidth) / 3;
  174. CGFloat startY = ziHao.y;
  175. for(int i=0;i<4;i++){
  176. UIView *yuanContentView = [[UIView alloc] init];
  177. [self.wenziBgView addSubview:yuanContentView];
  178. yuanContentView.frame = CGRectMake(startX+i*txLineWidth + i*yuanWidth, startY, yuanWidth, yuanWidth);
  179. yuanContentView.backgroundColor = [UIColor whiteColor];
  180. [yuanContentView setRadius:yuanWidth/2.0 borderColor:RGB(162, 162, 162) borderWidth:.5];
  181. if(i < 3){
  182. UIView *yuanMianLineContentView = [[UIView alloc] init];
  183. [self.wenziBgView addSubview:yuanMianLineContentView];
  184. yuanMianLineContentView.frame = CGRectMake(yuanContentView.x + yuanContentView.width - 1, startY + yuanWidth/4, txLineWidth + 2, yuanWidth - yuanWidth/2);
  185. yuanMianLineContentView.backgroundColor = [UIColor whiteColor];
  186. [yuanMianLineContentView setRadius:0 borderColor:RGB(162, 162, 162) borderWidth:.5];
  187. }
  188. [allYuanViewArr addObject:yuanContentView];
  189. UILabel *TLabel = [[UILabel alloc] init];
  190. [self.wenziBgView addSubview:TLabel];
  191. TLabel.text = @"T";
  192. TLabel.textColor = RGB(10, 10, 10);
  193. TLabel.font = [UIFont systemFontOfSize:12 + i*2];
  194. TLabel.frame = CGRectMake(yuanContentView.x + 2, self.wenziBgView.height - 145, 30, 30);
  195. [TLabel sizeToFit];
  196. if(i == 0){
  197. UIView *heiView = [[UIView alloc] init];
  198. [yuanContentView addSubview:heiView];
  199. heiView.backgroundColor = [UIColor blackColor];
  200. heiView.frame = CGRectMake(yuanContentView.width/4, yuanContentView.width/4, yuanContentView.width/2, yuanContentView.width/2);
  201. [heiView setRadius:yuanContentView.width/4 corners:UIRectCornerAllCorners];
  202. }
  203. }
  204. for (UIView *yuanView in allYuanViewArr) {
  205. [self.wenziBgView bringSubviewToFront:yuanView];
  206. }
  207. UILabel *ziColor = [[UILabel alloc] init];
  208. [self.wenziBgView addSubview:ziColor];
  209. ziColor.text = @"字色";
  210. ziColor.textColor = RGB(10, 10, 10);
  211. ziColor.font = [UIFont systemFontOfSize:12];
  212. ziColor.frame = CGRectMake(15, self.wenziBgView.height - 50, 30, 30);
  213. [ziColor sizeToFit];
  214. [self.wenziBgView sizeToFit];
  215. UIScrollView *scrollView = [[UIScrollView alloc] init];
  216. [self.wenziBgView addSubview:scrollView];
  217. scrollView.frame = CGRectMake(50, ziColor.y - 10, SCREEN_WIDTH - 50, 40);
  218. [scrollView sizeToFit];
  219. CGFloat jg = 12;
  220. CGFloat x = 0;
  221. CGFloat y = 0;
  222. CGFloat wh = 30;
  223. for(int i=0;i<7;i++){
  224. UIView *colorBgView = [[UIView alloc] init];
  225. [scrollView addSubview:colorBgView];
  226. colorBgView.frame = CGRectMake(x + i*jg, y, wh, wh);
  227. [colorBgView setRadius:2 corners:UIRectCornerAllCorners];
  228. x += wh;
  229. switch (i) {
  230. case 0:{
  231. colorBgView.backgroundColor = RGB(74, 74, 74);
  232. }break;
  233. case 1:{
  234. colorBgView.backgroundColor = RGB(155, 155, 155);
  235. }break;
  236. case 2:{
  237. colorBgView.backgroundColor = RGB(204, 204, 204);
  238. }break;
  239. case 3:{
  240. colorBgView.backgroundColor = RGB(229, 111, 111);
  241. }break;
  242. case 4:{
  243. colorBgView.backgroundColor = RGB(100, 156, 224);
  244. }break;
  245. case 5:{
  246. colorBgView.backgroundColor = RGB(237, 178, 79);
  247. }break;
  248. case 6:{
  249. colorBgView.backgroundColor = RGB(132, 73, 221);
  250. }break;
  251. default:{
  252. colorBgView.backgroundColor = RGB(132, 73, 221);
  253. }break;
  254. }
  255. if(colorBgView.x + wh <= SCREEN_WIDTH - 50){
  256. scrollView.contentSize = CGSizeMake(SCREEN_WIDTH - 49 , 40);
  257. }else{
  258. scrollView.contentSize = CGSizeMake(colorBgView.x + wh, 40);
  259. }
  260. }
  261. scrollView.showsHorizontalScrollIndicator = NO;//不显示水平拖地的条
  262. scrollView.showsVerticalScrollIndicator=NO;//不显示垂直拖动的条
  263. self.automaticallyAdjustsScrollViewInsets = NO;
  264. self.edgesForExtendedLayout = UIRectEdgeNone;
  265. }
  266. - (ZLCollectionViewFlowLayout *)flowLayout{
  267. if(_flowLayout == nil){
  268. _flowLayout = [[ZLCollectionViewFlowLayout alloc] init];
  269. _flowLayout.delegate = self;
  270. }
  271. return _flowLayout;
  272. }
  273. @end