YMPersonalPageViewController.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. //
  2. // YMPersonalPageViewController.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/17.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMPersonalPageViewController.h"
  9. #import "YMPersonalPageViewModel.h"
  10. #import "YMPersonalPageAlbumView.h"
  11. #import "YMPersonalPageInfoView.h"
  12. #import "YMPersonalPageDynamicView.h"
  13. #import "YMPersonalPageTagView.h"
  14. #import "YMPersonalPageGiftWallView.h"
  15. #import "YMPersonalPageAboutView.h"
  16. @interface YMPersonalPageViewController ()<UIScrollViewDelegate>
  17. /// 个人主页VM
  18. @property (nonatomic, strong) YMPersonalPageViewModel *viewModel;
  19. /// 更多按钮
  20. @property (nonatomic, strong) UIButton *moreBtn;
  21. /// 容器滚动视图
  22. @property (nonatomic, strong) UIScrollView *contentScrollView;
  23. /// 容器视图
  24. @property (nonatomic, strong) UIView *contentView;
  25. /// 相册视图
  26. @property (nonatomic, strong) YMPersonalPageAlbumView *albumView;
  27. /// 账号信息等视图
  28. @property (nonatomic, strong) YMPersonalPageAboutView *aboutView;
  29. /// 信息视图
  30. @property (nonatomic, strong) YMPersonalPageInfoView *infoView;
  31. /// 社交内容堆叠视图
  32. @property (nonatomic, strong) UIStackView *socialContentStackView;
  33. /// 动态视图
  34. @property (nonatomic, strong) YMPersonalPageDynamicView *dynamicView;
  35. /// 标签视图
  36. @property (nonatomic, strong) YMPersonalPageTagView *tagView;
  37. /// 礼物墙视图
  38. @property (nonatomic, strong) YMPersonalPageGiftWallView *giftWallView;
  39. /// 编辑资料按钮
  40. @property (nonatomic, strong) UIButton *editProfileBtn;
  41. /// 按钮堆叠视图
  42. @property (nonatomic, strong) UIStackView *otherPersonalPageButtonStackView;
  43. /// 心动或搭讪按钮
  44. @property (nonatomic, strong) UIButton *heartbeatOrAccostBtn;
  45. /// 通话按钮
  46. @property (nonatomic, strong) UIButton *callBtn;
  47. /// 私聊按钮
  48. @property (nonatomic, strong) UIButton *privateChatBtn;
  49. ///关注按钮
  50. //@property (nonatomic, strong) UIButton *followBtn;
  51. @property (nonatomic, assign) CGFloat bottomButnHeight;
  52. @end
  53. @implementation YMPersonalPageViewController
  54. @dynamic viewModel;
  55. - (void)viewDidLoad {
  56. [super viewDidLoad];
  57. self.ym_navigationStyle = YMBaseNavigationStyleClearBgWhiteBackArrow;
  58. [UMengRecordTool umengEventCountWithId:EnterPersonalCenter];
  59. self.bottomButnHeight = 0;
  60. }
  61. - (void)viewDidDisappear:(BOOL)animated{
  62. [super viewDidDisappear:animated];
  63. [[YMAudioPlayer sharedInstance] stop];
  64. }
  65. - (void)viewWillAppear:(BOOL)animated{
  66. [super viewWillAppear:animated];
  67. [self.viewModel getPersonalPageData];
  68. }
  69. - (void)ym_setupViews{
  70. [self setTitle:@"个人详情"];
  71. [self setRightBarButtonWithCustomView:self.moreBtn];
  72. [self.view addSubview:self.contentScrollView];
  73. [self.view sendSubviewToBack:self.contentScrollView];
  74. [self.contentScrollView addSubview:self.contentView];
  75. [self.contentView addSubview:self.albumView];
  76. [self.contentView addSubview:self.aboutView];
  77. WS(weakSelf)
  78. [self.contentView addSubview:self.infoView];
  79. [self.contentView addSubview:self.socialContentStackView];
  80. [self.socialContentStackView addArrangedSubview:self.dynamicView];
  81. [self.socialContentStackView addArrangedSubview:self.tagView];
  82. [self.socialContentStackView addArrangedSubview:self.giftWallView];
  83. [self.view addSubview:self.editProfileBtn];
  84. [self.view addSubview:self.callBtn];
  85. [self.view addSubview:self.otherPersonalPageButtonStackView];
  86. //[self.otherPersonalPageButtonStackView addArrangedSubview:self.followBtn];
  87. [self.otherPersonalPageButtonStackView addArrangedSubview:self.heartbeatOrAccostBtn];
  88. [self.view setNeedsUpdateConstraints];
  89. [self.view updateConstraintsIfNeeded];
  90. }
  91. - (void)updateViewConstraints{
  92. [self.contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  93. make.top.equalTo(self.view);
  94. make.left.equalTo(self.view);
  95. make.right.equalTo(self.view);
  96. }];
  97. [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  98. make.edges.equalTo(self.contentScrollView);
  99. make.width.equalTo(self.contentScrollView.mas_width);
  100. }];
  101. [self.albumView mas_makeConstraints:^(MASConstraintMaker *make) {
  102. make.top.equalTo(self.contentView);
  103. make.left.equalTo(self.contentView);
  104. make.right.equalTo(self.contentView);
  105. }];
  106. [self.aboutView mas_makeConstraints:^(MASConstraintMaker *make) {
  107. make.top.equalTo(self.albumView.mas_bottom).offset(adapt(10));
  108. make.left.equalTo(self.contentView);
  109. make.right.equalTo(self.contentView);
  110. }];
  111. [self.infoView mas_makeConstraints:^(MASConstraintMaker *make) {
  112. make.top.equalTo(self.aboutView.mas_bottom).offset(adapt(10));
  113. make.left.equalTo(self.contentView);
  114. make.right.equalTo(self.contentView);
  115. }];
  116. [self.socialContentStackView mas_makeConstraints:^(MASConstraintMaker *make) {
  117. make.top.equalTo(self.infoView.mas_bottom);
  118. make.left.equalTo(self.contentView);
  119. make.right.equalTo(self.contentView);
  120. make.bottom.equalTo(self.contentView);
  121. }];
  122. [self.dynamicView mas_makeConstraints:^(MASConstraintMaker *make) {
  123. make.left.equalTo(self.socialContentStackView);
  124. make.right.equalTo(self.socialContentStackView);
  125. }];
  126. [self.tagView mas_makeConstraints:^(MASConstraintMaker *make) {
  127. make.left.equalTo(self.socialContentStackView);
  128. make.right.equalTo(self.socialContentStackView);
  129. }];
  130. [self.giftWallView mas_makeConstraints:^(MASConstraintMaker *make) {
  131. make.left.equalTo(self.socialContentStackView);
  132. make.right.equalTo(self.socialContentStackView);
  133. }];
  134. [self.editProfileBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  135. make.top.equalTo(self.contentScrollView.mas_bottom).offset(adapt(10));
  136. make.left.equalTo(self.view).offset(adapt(12));
  137. make.right.equalTo(self.view).offset(adapt(-12));
  138. make.bottom.equalTo(self.view).offset(Is_iPhoneX ? adapt(-32) : adapt(-12));
  139. make.height.mas_equalTo(self.bottomButnHeight);
  140. }];
  141. [self.callBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  142. make.edges.equalTo(self.editProfileBtn);
  143. }];
  144. [self.otherPersonalPageButtonStackView mas_makeConstraints:^(MASConstraintMaker *make) {
  145. make.top.equalTo(self.contentScrollView.mas_bottom).offset(adapt(10));
  146. make.left.equalTo(self.view).offset(adapt(12));
  147. make.right.equalTo(self.view).offset(adapt(-12));
  148. make.bottom.equalTo(self.view).offset(Is_iPhoneX ? adapt(-32) : adapt(-12));
  149. }];
  150. // [self.followBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  151. // make.width.mas_equalTo((kScreenWidth - adapt(24))/2 - adapt(5));
  152. // make.height.mas_equalTo(adapt(45));
  153. // }];
  154. [self.heartbeatOrAccostBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  155. make.width.mas_equalTo((kScreenWidth - adapt(24))/2 - adapt(5));
  156. make.height.mas_equalTo(adapt(45));
  157. }];
  158. //
  159. // [self.privateChatBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  160. // make.width.height.mas_equalTo(adapt(45));
  161. // }];
  162. //
  163. [super updateViewConstraints];
  164. }
  165. - (void)ym_bindViewModel{
  166. [self.albumView ym_bindViewModel:self.viewModel];
  167. [self.aboutView ym_bindViewModel:self.viewModel];
  168. [self.infoView ym_bindViewModel:self.viewModel];
  169. [self.dynamicView ym_bindViewModel:self.viewModel];
  170. [self.tagView ym_bindViewModel:self.viewModel];
  171. [self.giftWallView ym_bindViewModel:self.viewModel];
  172. [self.viewModel getPersonalPageData];
  173. RAC(self.dynamicView, hidden) = RACObserve(self.viewModel, isHideDynamic);
  174. RAC(self.tagView, hidden) = RACObserve(self.viewModel, isHideTag);
  175. RAC(self.giftWallView, hidden) = RACObserve(self.viewModel, isHideGiftWall);
  176. @weakify(self)
  177. [[[[RACObserve(self.viewModel, isOtherPersonalPage) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNumber *isOtherPersonalPage) {
  178. @strongify(self)
  179. /// 是否他人主页
  180. if ([isOtherPersonalPage boolValue]) {
  181. self.editProfileBtn.hidden = YES;
  182. if (([self.viewModel.userGender isEqualToString:@"女"] && !self.viewModel.isFemaleGender) || ([self.viewModel.userGender isEqualToString:@"男"] && self.viewModel.isFemaleGender) ) {
  183. // 异性,显示通话按钮
  184. self.callBtn.hidden = NO;
  185. self.bottomButnHeight = adapt(45);
  186. } else {
  187. // 同性,不显示底部按钮
  188. self.callBtn.hidden = YES;
  189. self.bottomButnHeight = adapt(0.1);
  190. }
  191. } else {
  192. self.editProfileBtn.hidden = NO;
  193. self.callBtn.hidden = YES;
  194. self.bottomButnHeight = adapt(45);
  195. }
  196. [self.editProfileBtn mas_updateConstraints:^(MASConstraintMaker *make) {
  197. make.height.mas_equalTo(self.bottomButnHeight);
  198. }];
  199. }];
  200. [[[[RACObserve(self.viewModel, bottomHidden) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNumber *bottomHidden) {
  201. @strongify(self)
  202. if ([bottomHidden boolValue]) {
  203. self.editProfileBtn.hidden = NO;
  204. }else{
  205. self.editProfileBtn.hidden = YES;
  206. }
  207. }];
  208. [[[[RACObserve(self.viewModel, heartbeatOrAccostButtonTitle) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString *heartbeatOrAccostButtonTitle) {
  209. @strongify(self)
  210. [self.heartbeatOrAccostBtn setTitle:heartbeatOrAccostButtonTitle forState:UIControlStateNormal];
  211. if([heartbeatOrAccostButtonTitle isEqualToString:@"私聊"]){
  212. [self.heartbeatOrAccostBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  213. [self.heartbeatOrAccostBtn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal];
  214. }else{
  215. [self.heartbeatOrAccostBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  216. [self.heartbeatOrAccostBtn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal];
  217. }
  218. }];
  219. [[[[RACObserve(self.viewModel, heartbeatOrAccostButtonImage) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString *heartbeatOrAccostButtonImage) {
  220. @strongify(self)
  221. [self.heartbeatOrAccostBtn setImage:ImageByName(heartbeatOrAccostButtonImage) forState:UIControlStateNormal];
  222. }];
  223. [[[[RACObserve(self.viewModel, isFollow) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNumber * isFollow) {
  224. @strongify(self)
  225. // if (![isFollow boolValue]) {
  226. // [self.followBtn setTitle:@"关注" forState:UIControlStateNormal];
  227. // [self.followBtn setImage:ImageByName(@"ym_personal_page_add") forState:UIControlStateNormal];
  228. // }else{
  229. // [self.followBtn setTitle:@"已关注" forState:UIControlStateNormal];
  230. // [self.followBtn setImage:ImageByName(@"ym_personal_page_added") forState:UIControlStateNormal];
  231. // }
  232. }];
  233. }
  234. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  235. CGFloat offsetY = scrollView.contentOffset.y;
  236. CGFloat navSBHeight = kYMStatusBarHeight + 44;
  237. CGFloat rate = offsetY / navSBHeight;
  238. CGFloat alpha = (rate <= 1) ? rate : 1;
  239. UIImage *img;
  240. if (offsetY > navSBHeight) {
  241. self.ym_navigationStyle = YMBaseNavigationStyleClearBgBlackBackArrow;
  242. img = ImageByName(@"ym_personal_page_more_icon_black");
  243. } else {
  244. self.ym_navigationStyle = YMBaseNavigationStyleClearBgWhiteBackArrow;
  245. img = ImageByName(@"ym_personal_page_more_icon_white");
  246. }
  247. [self.moreBtn setImage:img forState:(UIControlStateNormal)];
  248. self.ym_customNavView.backgroundColor = [UIColor.whiteColor colorWithAlphaComponent:alpha];
  249. }
  250. - (UIButton *)moreBtn {
  251. if (!_moreBtn) {
  252. _moreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  253. [_moreBtn setImage:ImageByName(@"ym_personal_page_more_icon_white") forState:UIControlStateNormal];
  254. WS(weakSelf)
  255. [[[_moreBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  256. [weakSelf.viewModel openMoreAlert];
  257. }];
  258. }
  259. return _moreBtn;
  260. }
  261. - (UIScrollView *)contentScrollView{
  262. if (!_contentScrollView) {
  263. _contentScrollView = [[UIScrollView alloc] init];
  264. _contentScrollView.delegate = self;
  265. _contentScrollView.bounces = NO;
  266. _contentScrollView.alwaysBounceVertical = YES;
  267. _contentScrollView.showsVerticalScrollIndicator = NO;
  268. _contentScrollView.showsHorizontalScrollIndicator = NO;
  269. _contentScrollView.backgroundColor = UIColor.clearColor;
  270. _contentScrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
  271. }
  272. return _contentScrollView;
  273. }
  274. - (UIView *)contentView{
  275. if (!_contentView) {
  276. _contentView = [[UIView alloc]init];
  277. }
  278. return _contentView;
  279. }
  280. - (YMPersonalPageAlbumView *)albumView{
  281. if (!_albumView) {
  282. _albumView = [[YMPersonalPageAlbumView alloc]init];
  283. }
  284. return _albumView;
  285. }
  286. - (YMPersonalPageAboutView *)aboutView {
  287. if (!_aboutView) {
  288. _aboutView = [[YMPersonalPageAboutView alloc] init];
  289. }
  290. return _aboutView;
  291. }
  292. - (YMPersonalPageInfoView *)infoView{
  293. if (!_infoView) {
  294. _infoView = [[YMPersonalPageInfoView alloc]init];
  295. }
  296. return _infoView;
  297. }
  298. - (UIStackView *)socialContentStackView{
  299. if(!_socialContentStackView){
  300. _socialContentStackView = [[UIStackView alloc]init];
  301. _socialContentStackView.translatesAutoresizingMaskIntoConstraints = NO;
  302. _socialContentStackView.axis = UILayoutConstraintAxisVertical;
  303. _socialContentStackView.alignment = UIStackViewAlignmentCenter;
  304. _socialContentStackView.spacing = adapt(10);
  305. }
  306. return _socialContentStackView;
  307. }
  308. - (YMPersonalPageDynamicView *)dynamicView{
  309. if (!_dynamicView) {
  310. _dynamicView = [[YMPersonalPageDynamicView alloc]init];
  311. _dynamicView.userInteractionEnabled = YES;
  312. WS(weakSelf)
  313. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
  314. [_dynamicView addGestureRecognizer:tap];
  315. [[[tap rac_gestureSignal] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  316. [weakSelf.viewModel gotoPersonalDynamic];
  317. }];
  318. }
  319. return _dynamicView;
  320. }
  321. - (YMPersonalPageTagView *)tagView{
  322. if (!_tagView) {
  323. _tagView = [[YMPersonalPageTagView alloc]init];
  324. }
  325. return _tagView;
  326. }
  327. - (YMPersonalPageGiftWallView *)giftWallView{
  328. if (!_giftWallView) {
  329. _giftWallView = [[YMPersonalPageGiftWallView alloc]init];
  330. }
  331. return _giftWallView;
  332. }
  333. - (UIButton *)editProfileBtn{
  334. if (!_editProfileBtn) {
  335. _editProfileBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  336. _editProfileBtn.titleLabel.font = LCFont(16);
  337. [_editProfileBtn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal];
  338. [_editProfileBtn setTitle:@"编辑资料" forState:UIControlStateNormal];
  339. [_editProfileBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  340. _editProfileBtn.layer.cornerRadius = adapt(25)/2;
  341. _editProfileBtn.layer.masksToBounds = YES;
  342. _editProfileBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
  343. [_editProfileBtn setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
  344. CGFloat margin = 5;
  345. _editProfileBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -margin, 0, margin);
  346. WS(weakSelf)
  347. [[[_editProfileBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  348. [weakSelf.viewModel gotoEditProfile];
  349. }];
  350. _editProfileBtn.hidden = YES;
  351. }
  352. return _editProfileBtn;
  353. }
  354. - (UIStackView *)otherPersonalPageButtonStackView{
  355. if(!_otherPersonalPageButtonStackView){
  356. _otherPersonalPageButtonStackView = [[UIStackView alloc]init];
  357. _otherPersonalPageButtonStackView.hidden = YES;
  358. // _otherPersonalPageButtonStackView.translatesAutoresizingMaskIntoConstraints = NO;
  359. _otherPersonalPageButtonStackView.axis = UILayoutConstraintAxisHorizontal;
  360. _otherPersonalPageButtonStackView.alignment = UIStackViewAlignmentCenter;
  361. _otherPersonalPageButtonStackView.spacing = adapt(10);
  362. }
  363. return _otherPersonalPageButtonStackView;
  364. }
  365. - (UIButton *)heartbeatOrAccostBtn{
  366. if (!_heartbeatOrAccostBtn) {
  367. _heartbeatOrAccostBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  368. _heartbeatOrAccostBtn.hidden = YES;
  369. _heartbeatOrAccostBtn.titleLabel.font = LCFont(16);
  370. _heartbeatOrAccostBtn.layer.cornerRadius = adapt(25)/2;
  371. _heartbeatOrAccostBtn.layer.masksToBounds = YES;
  372. _heartbeatOrAccostBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
  373. [_heartbeatOrAccostBtn setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
  374. CGFloat margin = 5;
  375. _heartbeatOrAccostBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -margin, 0, margin);
  376. WS(weakSelf)
  377. [[[_heartbeatOrAccostBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  378. [weakSelf.viewModel sendAccostRequest];
  379. }];
  380. }
  381. return _heartbeatOrAccostBtn;
  382. }
  383. //- (UIButton *)followBtn{
  384. // if (!_followBtn) {
  385. // _followBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  386. // _followBtn.titleLabel.font = LCFont(16);
  387. // [_followBtn setTitleColor:HexColorFromRGB(0xFFFFFF) forState:UIControlStateNormal];
  388. // [_followBtn setTitle:@"关注" forState:UIControlStateNormal];
  389. // [_followBtn setImage:ImageByName(@"ym_personal_page_add") forState:UIControlStateNormal];
  390. // [_followBtn setBackgroundColor:HexColorFromRGB(0x000000)];
  391. // _followBtn.layer.cornerRadius = adapt(12);
  392. // _followBtn.layer.masksToBounds = YES;
  393. // _followBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
  394. // [_followBtn setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
  395. // CGFloat margin = 5;
  396. // _followBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -margin, 0, margin);
  397. // WS(weakSelf)
  398. // [[[_followBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  399. // [weakSelf.viewModel followUser];
  400. // }];
  401. // }
  402. // return _followBtn;
  403. //}
  404. - (UIButton *)callBtn{
  405. if (!_callBtn) {
  406. _callBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  407. [_callBtn setTitle:@" 通话" forState:(UIControlStateNormal)];
  408. [_callBtn setImage:ImageByName(@"ym_personal_page_call_icon") forState:UIControlStateNormal];
  409. [_callBtn setTitleColor:HexColorFromRGB(0xFFFFFF) forState:(UIControlStateNormal)];
  410. [_callBtn ym_setGradientBackgroundWithColors:@[HexColorFromRGBA(0xFF6E79, 1),HexColorFromRGBA(0xFF6E79, 1)] locations:kMainGradLocation startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0)];
  411. _callBtn.titleLabel.font = LCFont(16);
  412. _callBtn.layer.cornerRadius = adapt(45)/2;
  413. _callBtn.layer.masksToBounds = YES;
  414. WS(weakSelf)
  415. [[[_callBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  416. [weakSelf.viewModel callVideo];
  417. }];
  418. }
  419. return _callBtn;
  420. }
  421. - (UIButton *)privateChatBtn{
  422. if (!_privateChatBtn) {
  423. _privateChatBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  424. [_privateChatBtn setBackgroundImage:ImageByName(@"ym_personal_page_private_chat_icon") forState:UIControlStateNormal];
  425. WS(weakSelf)
  426. [[[_privateChatBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  427. [weakSelf.viewModel gotoPrivateChat];
  428. }];
  429. }
  430. return _privateChatBtn;
  431. }
  432. @end