CommonListCell.m 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. //
  2. // CommonListCell.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2020/4/28.
  6. // Copyright © 2020 tederen. All rights reserved.
  7. //
  8. #import "CommonListCell.h"
  9. @implementation CommonListCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. // Initialization code
  13. }
  14. + (CGFloat)configCell0Height{
  15. return 72;
  16. }
  17. + (CommonListCell *)configCell0:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
  18. static NSString *cellIdentifer = @"CommonListCell0";
  19. CommonListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
  20. if (cell == nil) {
  21. cell = [[[NSBundle mainBundle] loadNibNamed:@"CommonListCell" owner:nil options:nil] objectAtIndex:0];
  22. }
  23. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  24. return cell;
  25. }
  26. + (CommonListCell *)configCell1:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
  27. static NSString *cellIdentifer = @"CommonListCell1";
  28. CommonListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
  29. if (cell == nil) {
  30. cell = [[[NSBundle mainBundle] loadNibNamed:@"CommonListCell" owner:nil options:nil] objectAtIndex:1];
  31. }
  32. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  33. return cell;
  34. }
  35. - (void)setCell1Data:(MyFavoriteSubModel *)model
  36. {
  37. switch (model.CollectionType) {
  38. // 文章
  39. case CollectModel_Aritle:{
  40. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"文章")];
  41. }break;
  42. // 话题 || 小组
  43. case CollectModel_Toipc:
  44. {
  45. self.iconV.image = IMG(@"话题");
  46. }break;
  47. case CollectModel_NewTopic:
  48. {
  49. self.iconV.image = IMG(@"话题");
  50. }break;
  51. case CollectModel_Group:{
  52. self.iconV.image = IMG(@"笔记小组");
  53. }break;
  54. // 收藏
  55. case CollectModel_Collect:{
  56. self.iconV.image = IMG(@"收藏");
  57. }break;
  58. // 笔记
  59. case CollectModel_NoteBook: {
  60. self.iconV.image = IMG(@"noteBook_icon");
  61. }break;
  62. case CollectModel_CollectFile:{
  63. self.iconV.image = IMG(@"find_1");
  64. }break;
  65. case CollectModel_NoteFile: {
  66. self.iconV.image = IMG(@"find_1");
  67. }break;
  68. // 通知 || 站内信
  69. case CollectModel_Notice:
  70. {
  71. self.iconV.image = IMG(@"通知图标");
  72. }break;
  73. case CollectModel_InterMail:{
  74. self.iconV.image = IMG(@"站内信");
  75. }break;
  76. // 会议
  77. case CollectModel_meetMian:{
  78. self.iconV.image = IMG(@"会议");
  79. }break;
  80. case CollectModel_meetDetail:{
  81. self.iconV.image = IMG(@"会议");
  82. }break;
  83. case CollectModel_file:{
  84. NSString * imageStr = [ZYCTool getFileNameImage:model.Data.FileName];
  85. if (imageStr.length == 0) {
  86. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.MinFile]];
  87. }else{
  88. self.iconV.image = IMG(imageStr);
  89. }
  90. }break;
  91. case CollectModel_work:
  92. {
  93. self.iconV.image = IMG(@"审批");
  94. }
  95. break;
  96. case CollectModel_financeCount:
  97. {
  98. self.iconV.image = IMG(@"报表");
  99. }
  100. break;
  101. case CollectModel_affairsCount:
  102. {
  103. self.iconV.image = IMG(@"报表");
  104. }
  105. break;
  106. case CollectModel_publishCount:
  107. {
  108. self.iconV.image = IMG(@"报表");
  109. }
  110. break;
  111. default:{
  112. NSString * imageStr = [ZYCTool getFileNameImage:model.Data.FileName];
  113. if (imageStr.length == 0) {
  114. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.MinFile]];
  115. }else{
  116. self.iconV.image = IMG(imageStr);
  117. }
  118. }break;
  119. }
  120. self.isTopV.hidden = !model.IsTop;
  121. [self.titleL mas_remakeConstraints:^(MASConstraintMaker *make) {
  122. make.left.mas_equalTo(self.iconV.mas_right).offset(15);
  123. make.top.mas_offset(15);
  124. make.height.mas_greaterThanOrEqualTo(20);
  125. make.width.mas_lessThanOrEqualTo(SCREEN_WIDTH - (model.IsTop ? 125 : 85));
  126. }];
  127. self.titleL.text = model.Data.Title;
  128. self.nameL.text = [model.Data.Author length] > 0 ? model.Data.Author : @" ";
  129. self.desL.text = [model.FolderName length] > 0 ? model.FolderName : @" ";
  130. }
  131. - (void)setCellData:(MyFavoriteSubModel *)model withText:(NSString *)text
  132. {
  133. switch (model.CollectionType) {
  134. // 文章
  135. case CollectModel_Aritle:{
  136. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"文章")];
  137. }break;
  138. // 话题 || 小组
  139. case CollectModel_Toipc:
  140. {
  141. self.iconV.image = IMG(@"话题");
  142. }break;
  143. case CollectModel_NewTopic:
  144. {
  145. self.iconV.image = IMG(@"话题");
  146. }break;
  147. case CollectModel_Group:{
  148. self.iconV.image = IMG(@"笔记小组");
  149. }break;
  150. // 收藏
  151. case CollectModel_Collect:{
  152. self.iconV.image = IMG(@"收藏");
  153. }break;
  154. // 笔记
  155. case CollectModel_NoteBook: {
  156. self.iconV.image = IMG(@"noteBook_icon");
  157. }break;
  158. case CollectModel_CollectFile:{
  159. self.iconV.image = IMG(@"find_1");
  160. }break;
  161. case CollectModel_NoteFile: {
  162. self.iconV.image = IMG(@"find_1");
  163. }break;
  164. // 通知 || 站内信
  165. case CollectModel_Notice:
  166. {
  167. self.iconV.image = IMG(@"通知图标");
  168. }break;
  169. case CollectModel_InterMail:{
  170. self.iconV.image = IMG(@"站内信");
  171. }break;
  172. // 会议
  173. case CollectModel_meetMian:{
  174. self.iconV.image = IMG(@"会议");
  175. }break;
  176. case CollectModel_meetDetail:{
  177. self.iconV.image = IMG(@"会议");
  178. }break;
  179. case CollectModel_file:{
  180. NSString * imageStr = [ZYCTool getFileNameImage:model.Data.FileName];
  181. if (imageStr.length == 0) {
  182. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.MinFile]];
  183. }else{
  184. self.iconV.image = IMG(imageStr);
  185. }
  186. }break;
  187. case CollectModel_work:
  188. {
  189. self.iconV.image = IMG(@"审批");
  190. }
  191. break;
  192. case CollectModel_financeCount:
  193. {
  194. self.iconV.image = IMG(@"报表");
  195. }
  196. break;
  197. case CollectModel_affairsCount:
  198. {
  199. self.iconV.image = IMG(@"报表");
  200. }
  201. break;
  202. case CollectModel_publishCount:
  203. {
  204. self.iconV.image = IMG(@"报表");
  205. }
  206. break;
  207. default:{
  208. NSString * imageStr = [ZYCTool getFileNameImage:model.Data.FileName];
  209. if (imageStr.length == 0) {
  210. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.MinFile]];
  211. }else{
  212. self.iconV.image = IMG(imageStr);
  213. }
  214. }break;
  215. }
  216. self.isTopV.hidden = !model.IsTop;
  217. [self.titleL mas_remakeConstraints:^(MASConstraintMaker *make) {
  218. make.left.mas_equalTo(self.iconV.mas_right).offset(15);
  219. make.top.mas_offset(15);
  220. make.height.mas_greaterThanOrEqualTo(20);
  221. make.width.mas_lessThanOrEqualTo(SCREEN_WIDTH - (model.IsTop ? 125 : 85));
  222. }];
  223. self.titleL.attributedText = [ZYCTool checkOfString:model.Data.Title withSearchText:text withColor:UIColorHex(0xFF5252)];
  224. self.nameL.attributedText = [model.Data.Author length] > 0 ? [ZYCTool checkOfString:model.Data.Author withSearchText:text withColor:UIColorHex(0xFF5252)] : [[NSAttributedString alloc] initWithString:@" "];
  225. self.desL.attributedText = [model.FolderName length] > 0 ? [ZYCTool checkOfString:model.FolderName withSearchText:text withColor:UIColorHex(0xFF5252)] : [[NSAttributedString alloc] initWithString:@" "];
  226. }
  227. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  228. [super setSelected:selected animated:animated];
  229. // Configure the view for the selected state
  230. }
  231. @end