YMPersonalPageInfoView.m 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. //
  2. // YMPersonalPageInfoView.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/17.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMPersonalPageInfoView.h"
  9. #import "YMPersonalPageViewModel.h"
  10. #import "YMPersonalPageInfoCell.h"
  11. #import "CHTCollectionViewWaterfallLayout.h"
  12. @interface YMPersonalPageInfoView ()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout,CHTCollectionViewDelegateWaterfallLayout>
  13. /// 个人主页VM
  14. @property (nonatomic, strong) YMPersonalPageViewModel *viewModel;
  15. /// 用户昵称标签
  16. @property (nonatomic, strong) UILabel *userNicknameLb;
  17. /// 用户在线状态视图
  18. @property (nonatomic, strong) UIView *userOnlineStatusView;
  19. /// 用户在线状态点
  20. @property (nonatomic, strong) UIView *userOnlineStatusPoint;
  21. /// 用户在线状态标签
  22. @property (nonatomic, strong) UILabel *userOnlineStatusLb;
  23. /// 状态堆叠视图
  24. @property (nonatomic, strong) UIStackView *statusStackView;
  25. /// 用户性别和年龄视图
  26. @property (nonatomic, strong) UIView *userGenderAndAgeView;
  27. /// 用户性别图标
  28. @property (nonatomic, strong) UIImageView *userGenderAndAgeIcon;
  29. /// 用户年龄标签
  30. @property (nonatomic, strong) UILabel *userGenderAndAgeLb;
  31. /// 用户真人认证图标
  32. @property (nonatomic, strong) UIImageView *userRealPersonCertIcon;
  33. /// 用户VIP图标
  34. @property (nonatomic, strong) UIImageView *userVIPIcon;
  35. /// 关注按钮
  36. @property (nonatomic, strong) UIButton *followBtn;
  37. /// 用户视频费用金额按钮
  38. @property (nonatomic, strong) UIButton *userVideoFeesAmountBtn;
  39. /// 用户简介视图背景
  40. @property (nonatomic, strong) UIView *userIntroBgv;
  41. /// 用户简介视图
  42. @property (nonatomic, strong) UIImageView *userIntroView;
  43. /// 用户简介标签
  44. @property (nonatomic, strong) UILabel *userIntroLb;
  45. /// 用户简介图标
  46. @property (nonatomic, strong) UIImageView *userIntroIcon;
  47. /// 个人主页信息标签
  48. @property (nonatomic, strong) UILabel *personalPageInfoLb;
  49. /// 信息排版
  50. @property (nonatomic, strong) CHTCollectionViewWaterfallLayout *infoLayout;
  51. /// 信息容器列表
  52. @property (nonatomic, strong) UICollectionView *infoCollectionView;
  53. @end
  54. @implementation YMPersonalPageInfoView
  55. - (void)ym_setupViews{
  56. // [self addSubview:self.userNicknameLb];
  57. //
  58. // [self addSubview:self.userOnlineStatusView];
  59. // [self.userOnlineStatusView addSubview:self.userOnlineStatusPoint];
  60. // [self.userOnlineStatusView addSubview:self.userOnlineStatusLb];
  61. //
  62. // [self addSubview:self.statusStackView];
  63. //
  64. // [self.statusStackView addArrangedSubview:self.userGenderAndAgeView];
  65. // [self.userGenderAndAgeView addSubview:self.userGenderAndAgeIcon];
  66. // [self.userGenderAndAgeView addSubview:self.userGenderAndAgeLb];
  67. //
  68. // [self.statusStackView addArrangedSubview:self.userRealPersonCertIcon];
  69. // [self.statusStackView addArrangedSubview:self.userVIPIcon];
  70. //
  71. // [self addSubview:self.userVideoFeesAmountBtn];
  72. // [self addSubview:self.followBtn];
  73. [self addSubview:self.userIntroBgv];
  74. [self addSubview:self.userIntroView];
  75. [self.userIntroBgv addSubview:self.userIntroLb];
  76. // [self addSubview:self.userIntroIcon];
  77. [self addSubview:self.personalPageInfoLb];
  78. [self addSubview:self.infoCollectionView];
  79. [self setNeedsUpdateConstraints];
  80. [self updateConstraintsIfNeeded];
  81. }
  82. - (void)updateConstraints{
  83. // [self.userNicknameLb mas_makeConstraints:^(MASConstraintMaker *make) {
  84. // make.top.equalTo(self).offset(adapt(20));
  85. // make.left.equalTo(self).offset(adapt(20));
  86. // }];
  87. // [self.userOnlineStatusView mas_makeConstraints:^(MASConstraintMaker *make) {
  88. // make.centerY.equalTo(self.userNicknameLb.mas_centerY);
  89. // make.left.equalTo(self.userNicknameLb.mas_right).offset(adapt(10));
  90. // make.height.mas_equalTo(adapt(18));
  91. // }];
  92. //
  93. // [self.userOnlineStatusPoint mas_makeConstraints:^(MASConstraintMaker *make) {
  94. // make.centerY.equalTo(self.userOnlineStatusView.mas_centerY);
  95. // make.left.equalTo(self.userOnlineStatusView).offset(adapt(10));
  96. // make.width.height.mas_equalTo(adapt(6));
  97. // }];
  98. //
  99. // [self.userOnlineStatusLb mas_makeConstraints:^(MASConstraintMaker *make) {
  100. // make.centerY.equalTo(self.userOnlineStatusView.mas_centerY);
  101. // make.left.equalTo(self.userOnlineStatusPoint.mas_right).offset(adapt(5));
  102. // make.right.equalTo(self.userOnlineStatusView).offset(adapt(-10));
  103. // }];
  104. //
  105. // [self.statusStackView mas_makeConstraints:^(MASConstraintMaker *make) {
  106. // make.top.equalTo(self.userNicknameLb.mas_bottom).offset(adapt(10));
  107. // make.left.equalTo(self).offset(adapt(20));
  108. // }];
  109. // [self.userGenderAndAgeView mas_makeConstraints:^(MASConstraintMaker *make) {
  110. // make.height.mas_equalTo(adapt(15));
  111. // }];
  112. // [self.userGenderAndAgeIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  113. // make.top.equalTo(self.userGenderAndAgeView);
  114. // make.left.equalTo(self.userGenderAndAgeView).offset(adapt(7));
  115. // make.bottom.equalTo(self.userGenderAndAgeView);
  116. // make.width.height.mas_equalTo(adapt(15));
  117. // }];
  118. //
  119. // [self.userGenderAndAgeLb mas_makeConstraints:^(MASConstraintMaker *make) {
  120. // make.centerY.equalTo(self.userGenderAndAgeView.mas_centerY);
  121. // make.left.equalTo(self.userGenderAndAgeIcon.mas_right).offset(adapt(3));
  122. // make.right.equalTo(self.userGenderAndAgeView).offset(adapt(-7));
  123. // }];
  124. //
  125. // [self.userRealPersonCertIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  126. // make.width.mas_equalTo(adapt(66));
  127. // make.height.mas_equalTo(adapt(15));
  128. // }];
  129. //
  130. // [self.userVIPIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  131. // make.width.mas_equalTo(adapt(40));
  132. // make.height.mas_equalTo(adapt(15));
  133. // }];
  134. //
  135. // [self.followBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  136. // make.centerY.equalTo(self.userNicknameLb.mas_centerY);
  137. // make.right.equalTo(self).offset(adapt(-20));
  138. // make.width.mas_equalTo(adapt(80));
  139. // make.height.mas_equalTo(adapt(30));
  140. // }];
  141. //
  142. // [self.userVideoFeesAmountBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  143. // make.top.equalTo(self.statusStackView.mas_bottom).offset(adapt(10));
  144. // make.left.equalTo(self).offset(adapt(20));
  145. // }];
  146. [self.userIntroBgv mas_makeConstraints:^(MASConstraintMaker *make) {
  147. make.top.equalTo(self).offset(adapt(5));
  148. make.centerX.equalTo(self);
  149. make.width.mas_equalTo(adapt(332));
  150. make.height.mas_equalTo(adapt(50));
  151. }];
  152. [self.userIntroView mas_makeConstraints:^(MASConstraintMaker *make) {
  153. make.bottom.equalTo(self.userIntroBgv.mas_top).offset(adapt(6));
  154. make.left.equalTo(self.userIntroBgv.mas_left).offset(adapt(0));
  155. make.height.mas_equalTo(adapt(14));
  156. }];
  157. [self.userIntroLb mas_makeConstraints:^(MASConstraintMaker *make) {
  158. make.top.equalTo(self.userIntroBgv).offset(adapt(15));
  159. make.left.equalTo(self.userIntroBgv).offset(adapt(20));
  160. make.right.equalTo(self.userIntroBgv).offset(adapt(-15));
  161. make.bottom.equalTo(self.userIntroBgv).offset(adapt(-15));
  162. }];
  163. // [self.userIntroIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  164. // make.top.equalTo(self.userIntroView.mas_top).offset(adapt(-7));
  165. // make.right.equalTo(self.userIntroView).offset(adapt(-5));
  166. // make.width.height.mas_equalTo(adapt(20));
  167. // }];
  168. [self.personalPageInfoLb mas_makeConstraints:^(MASConstraintMaker *make) {
  169. make.top.equalTo(self).offset(adapt(5));
  170. make.left.equalTo(self).offset(adapt(20));
  171. }];
  172. [self.infoCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  173. make.top.equalTo(self.personalPageInfoLb.mas_bottom).offset(adapt(10));
  174. make.left.equalTo(self).offset(adapt(20));
  175. make.right.equalTo(self).offset(adapt(-20));
  176. make.bottom.equalTo(self).offset(adapt(-10));
  177. }];
  178. [super updateConstraints];
  179. }
  180. - (void)ym_bindViewModel:(YMPersonalPageViewModel *)viewModel{
  181. if (!viewModel) {
  182. return;
  183. }
  184. _viewModel = viewModel;
  185. @weakify(self)
  186. [[self.viewModel.refreshUISubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id result) {
  187. @strongify(self)
  188. [self.infoCollectionView reloadData];
  189. [self.infoCollectionView layoutIfNeeded];
  190. //刷新高度
  191. CGFloat infoCollectionViewHeight = self.infoCollectionView.collectionViewLayout.collectionViewContentSize.height;
  192. [self.infoCollectionView mas_updateConstraints:^(MASConstraintMaker *make) {
  193. make.height.mas_equalTo(infoCollectionViewHeight);
  194. }];
  195. }];
  196. // RAC(self.userNicknameLb, text) = RACObserve(self.viewModel, userNickname);
  197. // RAC(self.userNicknameLb, textColor) = RACObserve(self.viewModel, userNicknameColor);
  198. //
  199. // [[[[RACObserve(self.viewModel, userOnlineStatusColor) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(UIColor * userOnlineStatusColor) {
  200. // @strongify(self)
  201. // self.userOnlineStatusView.layer.borderColor = userOnlineStatusColor.CGColor;
  202. // self.userOnlineStatusPoint.backgroundColor = userOnlineStatusColor;
  203. // self.userOnlineStatusLb.textColor = userOnlineStatusColor;
  204. // }];
  205. //
  206. // [[[[RACObserve(self.viewModel, userOnlineStatusText) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString * userOnlineStatusText) {
  207. // @strongify(self)
  208. // self.userOnlineStatusLb.text = userOnlineStatusText;
  209. // }];
  210. //
  211. // RAC(self.userGenderAndAgeIcon, image) = RACObserve(self.viewModel, userGenderAndAgeIcon);
  212. //
  213. // RAC(self.userGenderAndAgeLb, text) = RACObserve(self.viewModel, userGenderAndAgeText);
  214. //
  215. // [[[[RACObserve(self.viewModel, userGender) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString * userGender) {
  216. // @strongify(self)
  217. // if ([userGender isEqualToString:@"女"]) {
  218. // [self.userGenderAndAgeView ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  219. // } else {
  220. // [self.userGenderAndAgeView ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  221. //
  222. // }
  223. // }];
  224. //
  225. // [[[[RACObserve(self.viewModel, isRealPersonCert) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNumber * isRealPersonCert) {
  226. // @strongify(self)
  227. // if ([isRealPersonCert boolValue]) {
  228. // self.userRealPersonCertIcon.hidden = NO;
  229. // } else {
  230. // self.userRealPersonCertIcon.hidden = YES;
  231. // }
  232. // }];
  233. // [[[[RACObserve(self.viewModel, isVIP) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNumber * isVIP) {
  234. // @strongify(self)
  235. // if ([isVIP boolValue]) {
  236. // self.userVIPIcon.hidden = NO;
  237. // } else {
  238. // self.userVIPIcon.hidden = YES;
  239. // }
  240. // }];
  241. // [[[[RACObserve(self.viewModel, userVideoFeesAmount) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString * userVideoFeesAmount) {
  242. // @strongify(self)
  243. // [self.userVideoFeesAmountBtn setTitle:userVideoFeesAmount?:@"****钻石/分钟" forState:UIControlStateNormal];
  244. // }];
  245. // [[[[RACObserve(self.viewModel, isHideUserFeesAmount) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNumber * isHideUserFeesAmount) {
  246. // @strongify(self)
  247. // if ([isHideUserFeesAmount boolValue]) {
  248. // self.userVideoFeesAmountBtn.hidden = YES;
  249. // [self.userVideoFeesAmountBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  250. //
  251. // }];
  252. //
  253. // [self.userIntroView mas_remakeConstraints:^(MASConstraintMaker *make) {
  254. // make.top.equalTo(self.statusStackView.mas_bottom).offset(adapt(20));
  255. // make.left.equalTo(self).offset(adapt(20));
  256. // make.right.equalTo(self).offset(adapt(-20));
  257. // }];
  258. // } else {
  259. // self.userVideoFeesAmountBtn.hidden = NO;
  260. // [self.userVideoFeesAmountBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  261. // make.top.equalTo(self.statusStackView.mas_bottom).offset(adapt(10));
  262. // make.left.equalTo(self).offset(adapt(20));
  263. // }];
  264. //
  265. // [self.userIntroView mas_remakeConstraints:^(MASConstraintMaker *make) {
  266. // make.top.equalTo(self.userVideoFeesAmountBtn.mas_bottom).offset(adapt(20));
  267. // make.left.equalTo(self).offset(adapt(20));
  268. // make.right.equalTo(self).offset(adapt(-20));
  269. // }];
  270. // }
  271. // }];
  272. RAC(self.userIntroLb, text) = RACObserve(self.viewModel, userIntro);
  273. [[[[RACObserve(self.viewModel, isFollow) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNumber * isFollow) {
  274. @strongify(self)
  275. if (![isFollow boolValue]) {
  276. [self.followBtn setTitle:@"关注" forState:UIControlStateNormal];
  277. [self.followBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  278. }else{
  279. [self.followBtn setTitle:@"已关注" forState:UIControlStateNormal];
  280. [self.followBtn ym_setGradientBackgroundWithColors:@[HexColorFromRGB(0xCCCCCC),HexColorFromRGB(0xCCCCCC)] locations:kMainGradLocation startPoint:CGPointMake(1, 1) endPoint:CGPointMake(1, 1)];
  281. }
  282. }];
  283. [[[[RACObserve(self.viewModel, isOtherPersonalPage) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNumber *isOtherPersonalPage) {
  284. @strongify(self)
  285. if ([isOtherPersonalPage boolValue]) {
  286. self.followBtn.hidden = NO;
  287. } else {
  288. self.followBtn.hidden = YES;
  289. }
  290. }];
  291. }
  292. #pragma mark - UICollectionViewDataSource
  293. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  294. return 1;
  295. }
  296. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  297. return self.viewModel.infoDataArray.count;
  298. }
  299. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  300. YMPersonalPageInfoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([YMPersonalPageInfoCell class]) forIndexPath:indexPath];
  301. [cell ym_bindViewModel:self.viewModel.infoDataArray[indexPath.item]];
  302. return cell;
  303. }
  304. - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
  305. UICollectionReusableView *reusableView = nil;
  306. reusableView.backgroundColor = [UIColor clearColor];
  307. return reusableView;
  308. }
  309. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
  310. return CGSizeZero;
  311. }
  312. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section{
  313. return CGSizeZero;
  314. }
  315. #pragma mark - UICollectionViewDelegate
  316. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  317. if (!self.viewModel.infoDataArray[indexPath.item].isHideCopy) {
  318. UIPasteboard *pab = [UIPasteboard generalPasteboard];
  319. pab.string = self.viewModel.infoDataArray[indexPath.item].infoContent?:@"";
  320. if (pab == nil) {
  321. [ZCHUDHelper showTitle:@"复制失败"];
  322. }else{
  323. [ZCHUDHelper showTitle:@"已复制到剪切板"];
  324. }
  325. }
  326. }
  327. #pragma mark - CHTCollectionViewDelegateWaterfallLayout
  328. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  329. return CGSizeMake(adapt(220), adapt(30));
  330. // CGFloat realW = UIScreen.mainScreen.bounds.size.width - adapt(20 * 2) - adapt(10 * 2);
  331. // CGFloat width = (realW / 3) - 1;
  332. // return CGSizeMake(width, adapt(30));
  333. }
  334. - (UILabel *)userNicknameLb{
  335. if (!_userNicknameLb) {
  336. _userNicknameLb = [[UILabel alloc]init];
  337. _userNicknameLb.font = LCBoldFont(20);
  338. _userNicknameLb.textColor = HexColorFromRGB(0x000000);
  339. _userNicknameLb.textAlignment = NSTextAlignmentLeft;
  340. _userNicknameLb.text = @"******";
  341. }
  342. return _userNicknameLb;
  343. }
  344. - (UIView *)userOnlineStatusView{
  345. if (!_userOnlineStatusView) {
  346. _userOnlineStatusView = [[UIView alloc]init];
  347. _userOnlineStatusView.layer.borderWidth = 1;
  348. _userOnlineStatusView.layer.borderColor = HexColorFromRGB(0xD8BFD8).CGColor;
  349. _userOnlineStatusView.layer.cornerRadius = adapt(18)/2;
  350. _userOnlineStatusView.layer.masksToBounds = YES;
  351. }
  352. return _userOnlineStatusView;
  353. }
  354. - (UIView *)userOnlineStatusPoint{
  355. if (!_userOnlineStatusPoint) {
  356. _userOnlineStatusPoint = [[UIView alloc]init];
  357. _userOnlineStatusPoint.backgroundColor = HexColorFromRGB(0xD8BFD8);
  358. _userOnlineStatusPoint.layer.cornerRadius = adapt(6)/2;
  359. _userOnlineStatusPoint.layer.masksToBounds = YES;
  360. }
  361. return _userOnlineStatusPoint;
  362. }
  363. - (UILabel *)userOnlineStatusLb{
  364. if (!_userOnlineStatusLb) {
  365. _userOnlineStatusLb = [[UILabel alloc]init];
  366. _userOnlineStatusLb.font = LCFont(10);
  367. _userOnlineStatusLb.textColor = HexColorFromRGB(0xD8BFD8);
  368. _userOnlineStatusLb.textAlignment = NSTextAlignmentCenter;
  369. _userOnlineStatusLb.text = @"离线";
  370. }
  371. return _userOnlineStatusLb;
  372. }
  373. - (UIStackView *)statusStackView{
  374. if (!_statusStackView) {
  375. _statusStackView = [[UIStackView alloc]init];
  376. /**
  377. UILayoutConstraintAxisVertical 纵向
  378. UILayoutConstraintAxisHorizontal 横向
  379. */
  380. _statusStackView.axis = UILayoutConstraintAxisHorizontal;
  381. /**
  382. UIsectionStackViewAlignmentFill 将sectionStackView充满
  383. 比如label,不管文字多少,将大小按照设置的非主轴方向充满
  384. ex: Vertical 就是水平铺满
  385. UIsectionStackViewAlignmentLeading 在Vertical方向上生效,表示左对齐
  386. 比如label,文字自适应,如果小于非主轴方向的宽度,将不充满
  387. UIsectionStackViewAlignmentTop 在Horizontal方向上生效,表示左对齐
  388. 比如label,文字自适应,如果小于非主轴方向的高度,将不充满
  389. 本质UIsectionStackViewAlignmentTop = UIsectionStackViewAlignmentLeading
  390. UIsectionStackViewAlignmentTrailing 在Vertical方向上生效,表示右对齐
  391. 比如label,文字自适应,如果小于非主轴方向的宽度,将不充满
  392. UIsectionStackViewAlignmentBottom 在Horizontal方向上生效,表示右对齐
  393. 比如label,文字自适应,如果小于非主轴方向的高度,将不充满
  394. 本质UIsectionStackViewAlignmentBottom = UIsectionStackViewAlignmentTrailing
  395. UIsectionStackViewAlignmentLastBaseline 仅限于Horizontal
  396. 按照最高的一个视图的bottom对齐,最高的视图top对齐
  397. UIsectionStackViewAlignmentCenter 中心对齐
  398. 不充满,沿主轴方向中心对齐
  399. */
  400. _statusStackView.alignment = UIStackViewAlignmentCenter;
  401. _statusStackView.spacing = adapt(10);
  402. }
  403. return _statusStackView;
  404. }
  405. - (UIView *)userGenderAndAgeView{
  406. if (!_userGenderAndAgeView) {
  407. _userGenderAndAgeView = [[UIView alloc]init];
  408. _userGenderAndAgeView.layer.cornerRadius = adapt(15)/2;
  409. }
  410. return _userGenderAndAgeView;
  411. }
  412. - (UIImageView *)userGenderAndAgeIcon{
  413. if (!_userGenderAndAgeIcon) {
  414. _userGenderAndAgeIcon = [[UIImageView alloc]init];
  415. _userGenderAndAgeIcon.image = ImageByName(@"ym_personal_page_female_icon");
  416. }
  417. return _userGenderAndAgeIcon;
  418. }
  419. - (UILabel *)userGenderAndAgeLb{
  420. if (!_userGenderAndAgeLb) {
  421. _userGenderAndAgeLb = [[UILabel alloc]init];
  422. _userGenderAndAgeLb.font = LCFont(11);
  423. _userGenderAndAgeLb.textColor = HexColorFromRGB(0xFFFFFF);
  424. _userGenderAndAgeLb.textAlignment = NSTextAlignmentCenter;
  425. _userGenderAndAgeLb.text = @"***";
  426. }
  427. return _userGenderAndAgeLb;
  428. }
  429. - (UIImageView *)userRealPersonCertIcon{
  430. if (!_userRealPersonCertIcon) {
  431. _userRealPersonCertIcon = [[UIImageView alloc]init];
  432. _userRealPersonCertIcon.image = ImageByName(@"ym_personal_page_real_person_cert_icon");
  433. }
  434. return _userRealPersonCertIcon;
  435. }
  436. - (UIImageView *)userVIPIcon{
  437. if (!_userVIPIcon) {
  438. _userVIPIcon = [[UIImageView alloc]init];
  439. _userVIPIcon.image = ImageByName(@"ym_mine_vip_icon");
  440. }
  441. return _userVIPIcon;
  442. }
  443. - (UIButton *)followBtn{
  444. if (!_followBtn) {
  445. _followBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  446. _followBtn.titleLabel.font = LCFont(14);
  447. [_followBtn setTitleColor:HexColorFromRGB(0xFFFFFF) forState:UIControlStateNormal];
  448. [_followBtn setTitle:@"关注" forState:UIControlStateNormal];
  449. [_followBtn setImage:ImageByName(@"ym_personal_page_follow_icon") forState:UIControlStateNormal];
  450. [_followBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  451. _followBtn.layer.cornerRadius = adapt(10);
  452. _followBtn.layer.masksToBounds = YES;
  453. _followBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
  454. [_followBtn setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
  455. CGFloat margin = 3;
  456. _followBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -margin, 0, margin);
  457. WS(weakSelf)
  458. [[[_followBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  459. [weakSelf.viewModel followUser];
  460. }];
  461. }
  462. return _followBtn;
  463. }
  464. - (UIButton *)userVideoFeesAmountBtn{
  465. if (!_userVideoFeesAmountBtn) {
  466. _userVideoFeesAmountBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  467. _userVideoFeesAmountBtn.titleLabel.font = LCBoldFont(11);
  468. [_userVideoFeesAmountBtn setTitleColor:HexColorFromRGB(0xB26AFD) forState:UIControlStateNormal];
  469. [_userVideoFeesAmountBtn setTitle:@"****钻石/分钟" forState:UIControlStateNormal];
  470. [_userVideoFeesAmountBtn setImage:ImageByName(@"ym_home_page_diamond_icon") forState:UIControlStateNormal];
  471. _userVideoFeesAmountBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  472. [_userVideoFeesAmountBtn setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
  473. CGFloat margin = 3;
  474. _userVideoFeesAmountBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -margin, 0, margin);
  475. }
  476. return _userVideoFeesAmountBtn;
  477. }
  478. - (UIView *)userIntroBgv {
  479. if (!_userIntroBgv) {
  480. _userIntroBgv = [[UIView alloc] init];
  481. _userIntroBgv.hidden = YES;
  482. _userIntroBgv.backgroundColor = HexColorFromRGB(0xF8F7F8);
  483. [_userIntroBgv addRectCorner:(UIRectCornerTopRight | UIRectCornerBottomLeft | UIRectCornerBottomRight) radius:25];
  484. }
  485. return _userIntroBgv;
  486. }
  487. - (UIImageView *)userIntroView {
  488. if (!_userIntroView) {
  489. _userIntroView = [[UIImageView alloc] init];
  490. _userIntroView.hidden = YES;
  491. [_userIntroView setImage:[UIImage imageNamed:@"ym_personal_qm_bg"]];
  492. _userIntroView.contentMode = UIViewContentModeScaleAspectFit;
  493. // _userIntroView.backgroundColor = HexColorFromRGB(0xF6F6F6);
  494. // _userIntroView.layer.cornerRadius = adapt(10);
  495. // _userIntroView.layer.masksToBounds = YES;
  496. }
  497. return _userIntroView;
  498. }
  499. - (UILabel *)userIntroLb{
  500. if (!_userIntroLb) {
  501. _userIntroLb = [[UILabel alloc]init];
  502. _userIntroLb.hidden = YES;
  503. _userIntroLb.font = LCFont(15);
  504. _userIntroLb.textColor = HexColorFromRGBA(0x000000,0.55);
  505. _userIntroLb.textAlignment = NSTextAlignmentLeft;
  506. _userIntroLb.text = @"这个人很懒,什么都没有留下...";
  507. }
  508. return _userIntroLb;
  509. }
  510. - (UIImageView *)userIntroIcon{
  511. if (!_userIntroIcon) {
  512. _userIntroIcon = [[UIImageView alloc]init];
  513. _userIntroIcon.hidden = YES;
  514. _userIntroIcon.image = ImageByName(@"ym_personal_page_intro_icon");
  515. }
  516. return _userIntroIcon;
  517. }
  518. - (UILabel *)personalPageInfoLb{
  519. if (!_personalPageInfoLb) {
  520. _personalPageInfoLb = [[UILabel alloc]init];
  521. _personalPageInfoLb.font = LCBoldFont(17);
  522. _personalPageInfoLb.textColor = HexColorFromRGB(0x000000);
  523. _personalPageInfoLb.textAlignment = NSTextAlignmentLeft;
  524. _personalPageInfoLb.text = @"TA的信息";
  525. }
  526. return _personalPageInfoLb;
  527. }
  528. - (CHTCollectionViewWaterfallLayout *)infoLayout{
  529. if (!_infoLayout) {
  530. _infoLayout = [[CHTCollectionViewWaterfallLayout alloc] init];
  531. _infoLayout.columnCount = 2;
  532. _infoLayout.sectionInset = UIEdgeInsetsZero;
  533. }
  534. return _infoLayout;
  535. }
  536. - (UICollectionView *)infoCollectionView{
  537. if (!_infoCollectionView) {
  538. _infoCollectionView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:self.infoLayout];
  539. _infoCollectionView.delegate = self;
  540. _infoCollectionView.dataSource = self;
  541. _infoCollectionView.showsVerticalScrollIndicator = NO;
  542. _infoCollectionView.showsHorizontalScrollIndicator = NO;
  543. _infoCollectionView.backgroundColor = UIColor.whiteColor;
  544. [_infoCollectionView registerClass:[YMPersonalPageInfoCell class] forCellWithReuseIdentifier:NSStringFromClass([YMPersonalPageInfoCell class])];
  545. }
  546. return _infoCollectionView;
  547. }
  548. @end