YMPersonalPageViewController.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  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.otherPersonalPageButtonStackView];
  84. [self.otherPersonalPageButtonStackView addArrangedSubview:self.followBtn];
  85. [self.otherPersonalPageButtonStackView addArrangedSubview:self.editProfileBtn];
  86. [self.otherPersonalPageButtonStackView addArrangedSubview:self.callBtn];
  87. [self.otherPersonalPageButtonStackView addArrangedSubview:self.heartbeatOrAccostBtn];
  88. //[self.otherPersonalPageButtonStackView addArrangedSubview:self.privateChatBtn];
  89. [self.view setNeedsUpdateConstraints];
  90. [self.view updateConstraintsIfNeeded];
  91. }
  92. - (void)updateViewConstraints{
  93. [self.contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  94. make.top.equalTo(self.view);
  95. make.left.equalTo(self.view);
  96. make.right.equalTo(self.view);
  97. make.bottom.equalTo(self.view);
  98. }];
  99. [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  100. make.edges.equalTo(self.contentScrollView);
  101. make.width.equalTo(self.contentScrollView.mas_width);
  102. }];
  103. [self.albumView mas_makeConstraints:^(MASConstraintMaker *make) {
  104. make.top.equalTo(self.contentView);
  105. make.left.equalTo(self.contentView);
  106. make.right.equalTo(self.contentView);
  107. }];
  108. [self.aboutView mas_makeConstraints:^(MASConstraintMaker *make) {
  109. make.top.equalTo(self.albumView.mas_bottom).offset(adapt(10));
  110. make.left.equalTo(self.contentView);
  111. make.right.equalTo(self.contentView);
  112. }];
  113. [self.infoView mas_makeConstraints:^(MASConstraintMaker *make) {
  114. make.top.equalTo(self.aboutView.mas_bottom).offset(adapt(10));
  115. make.left.equalTo(self.contentView);
  116. make.right.equalTo(self.contentView);
  117. }];
  118. [self.socialContentStackView mas_makeConstraints:^(MASConstraintMaker *make) {
  119. make.top.equalTo(self.infoView.mas_bottom);
  120. make.left.equalTo(self.contentView);
  121. make.right.equalTo(self.contentView);
  122. make.bottom.equalTo(self.contentView).offset(adapt(-100));
  123. }];
  124. [self.dynamicView mas_makeConstraints:^(MASConstraintMaker *make) {
  125. make.left.equalTo(self.socialContentStackView);
  126. make.right.equalTo(self.socialContentStackView);
  127. }];
  128. [self.tagView mas_makeConstraints:^(MASConstraintMaker *make) {
  129. make.left.equalTo(self.socialContentStackView);
  130. make.right.equalTo(self.socialContentStackView);
  131. }];
  132. [self.giftWallView mas_makeConstraints:^(MASConstraintMaker *make) {
  133. make.left.equalTo(self.socialContentStackView);
  134. make.right.equalTo(self.socialContentStackView);
  135. }];
  136. [self.editProfileBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  137. make.width.mas_equalTo(adapt(180));
  138. make.height.mas_equalTo(adapt(60));
  139. }];
  140. [self.callBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  141. make.width.mas_equalTo(adapt(180));
  142. make.height.mas_equalTo(adapt(60));
  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.height.mas_equalTo(adapt(self.bottomButnHeight));
  149. make.bottom.equalTo(self.view).offset(Is_iPhoneX ? adapt(-32) : adapt(-12));
  150. }];
  151. [self.followBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  152. make.width.height.mas_equalTo(adapt(60));
  153. }];
  154. [self.heartbeatOrAccostBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  155. make.width.height.mas_equalTo(adapt(60));
  156. }];
  157. [self.privateChatBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  158. make.width.height.mas_equalTo(adapt(60));
  159. }];
  160. [super updateViewConstraints];
  161. }
  162. - (void)ym_bindViewModel{
  163. [self.albumView ym_bindViewModel:self.viewModel];
  164. [self.aboutView ym_bindViewModel:self.viewModel];
  165. [self.infoView ym_bindViewModel:self.viewModel];
  166. [self.dynamicView ym_bindViewModel:self.viewModel];
  167. [self.tagView ym_bindViewModel:self.viewModel];
  168. [self.giftWallView ym_bindViewModel:self.viewModel];
  169. [self.viewModel getPersonalPageData];
  170. RAC(self.dynamicView, hidden) = RACObserve(self.viewModel, isHideDynamic);
  171. RAC(self.tagView, hidden) = RACObserve(self.viewModel, isHideTag);
  172. RAC(self.giftWallView, hidden) = RACObserve(self.viewModel, isHideGiftWall);
  173. @weakify(self)
  174. [[[[RACObserve(self.viewModel, isOtherPersonalPage) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNumber *isOtherPersonalPage) {
  175. @strongify(self)
  176. self.bottomButnHeight = adapt(60);
  177. /// 是否他人主页
  178. if ([isOtherPersonalPage boolValue]) {
  179. self.otherPersonalPageButtonStackView.hidden = NO;
  180. self.followBtn.hidden = NO;
  181. self.callBtn.hidden = NO;
  182. self.editProfileBtn.hidden = YES;
  183. self.heartbeatOrAccostBtn.hidden = NO;
  184. if (([self.viewModel.userGender isEqualToString:@"女"] && !self.viewModel.isFemaleGender) || ([self.viewModel.userGender isEqualToString:@"男"] && self.viewModel.isFemaleGender) ) {
  185. // 异性,显示通话按钮
  186. self.callBtn.hidden = NO;
  187. } else {
  188. // 同性,不显示底部按钮
  189. self.bottomButnHeight = adapt(0);
  190. }
  191. } else {
  192. self.otherPersonalPageButtonStackView.hidden = NO;
  193. self.followBtn.hidden = YES;
  194. self.callBtn.hidden = YES;
  195. self.heartbeatOrAccostBtn.hidden = YES;
  196. self.editProfileBtn.hidden = NO;
  197. }
  198. [self.otherPersonalPageButtonStackView mas_updateConstraints:^(MASConstraintMaker *make) {
  199. make.height.mas_equalTo(adapt(self.bottomButnHeight));
  200. }];
  201. }];
  202. // [[[[RACObserve(self.viewModel, bottomHidden) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNumber *bottomHidden) {
  203. // @strongify(self)
  204. // if ([bottomHidden boolValue]) {
  205. // self.editProfileBtn.hidden = NO;
  206. // }else{
  207. // self.editProfileBtn.hidden = YES;
  208. // }
  209. // }];
  210. [[[[RACObserve(self.viewModel, heartbeatOrAccostButtonTitle) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString *heartbeatOrAccostButtonTitle) {
  211. @strongify(self)
  212. [self.heartbeatOrAccostBtn setTitle:heartbeatOrAccostButtonTitle forState:UIControlStateNormal];
  213. if([heartbeatOrAccostButtonTitle isEqualToString:@"私聊"]){
  214. [self.heartbeatOrAccostBtn ym_setGradientBackgroundWithColors:@[HexColorFromRGB(0xFD8887), HexColorFromRGB(0xFD8887)] locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  215. [self.heartbeatOrAccostBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
  216. [self.heartbeatOrAccostBtn setBackgroundColor:rgba(253, 104, 165, 1)];
  217. [self.heartbeatOrAccostBtn setImage:ImageByName(@"ym_personal_page_msg") forState:UIControlStateNormal];
  218. } else {
  219. [self.heartbeatOrAccostBtn ym_setGradientBackgroundWithColors:@[HexColorFromRGB(0xFFFFFF), HexColorFromRGB(0xFFFFFF)] locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  220. [self.heartbeatOrAccostBtn setTitleColor:rgba(253, 104, 165, 1) forState:UIControlStateNormal];
  221. [self.heartbeatOrAccostBtn setBackgroundColor:UIColor.whiteColor];
  222. [self.heartbeatOrAccostBtn setImage:ImageByName(@"ym_personal_page_dasan")forState:UIControlStateNormal];
  223. }
  224. }];
  225. [[[[RACObserve(self.viewModel, heartbeatOrAccostButtonImage) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString *heartbeatOrAccostButtonImage) {
  226. @strongify(self)
  227. self.heartbeatOrAccostBtn.imageEdgeInsets = UIEdgeInsetsMake(-self.heartbeatOrAccostBtn.titleLabel.intrinsicContentSize.height, 0, 0, -self.heartbeatOrAccostBtn.titleLabel.intrinsicContentSize.width);
  228. self.heartbeatOrAccostBtn.titleEdgeInsets = UIEdgeInsetsMake(0, -self.heartbeatOrAccostBtn.imageView.frame.size.width, -self.heartbeatOrAccostBtn.imageView.frame.size.height, 0);
  229. }];
  230. [[[[RACObserve(self.viewModel, isFollow) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNumber * isFollow) {
  231. @strongify(self)
  232. if (![isFollow boolValue]) {
  233. [self.followBtn setTitleColor:rgba(255, 141, 26, 1) forState:UIControlStateNormal];
  234. [self.followBtn setTitle:@"关注" forState:UIControlStateNormal];
  235. [self.followBtn setBackgroundColor:rgba(255, 255, 255, 1)];
  236. [self.followBtn setImage:ImageByName(@"ym_personal_page_followable") forState:UIControlStateNormal];
  237. }else{
  238. [self.followBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
  239. [self.followBtn setBackgroundColor:rgba(255, 141, 26, 1)];
  240. [self.followBtn setTitle:@"已关注" forState:UIControlStateNormal];
  241. [self.followBtn setImage:ImageByName(@"ym_personal_page_followed") forState:UIControlStateNormal];
  242. }
  243. self.followBtn.imageEdgeInsets = UIEdgeInsetsMake(-self.followBtn.titleLabel.intrinsicContentSize.height, 0, 0, -self.followBtn.titleLabel.intrinsicContentSize.width);
  244. self.followBtn.titleEdgeInsets = UIEdgeInsetsMake(0, -self.followBtn.imageView.frame.size.width, -self.followBtn.imageView.frame.size.height, 0);
  245. }];
  246. }
  247. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  248. CGFloat offsetY = scrollView.contentOffset.y;
  249. CGFloat navSBHeight = kYMStatusBarHeight + 44;
  250. CGFloat rate = offsetY / navSBHeight;
  251. CGFloat alpha = (rate <= 1) ? rate : 1;
  252. UIImage *img;
  253. if (offsetY > navSBHeight) {
  254. self.ym_navigationStyle = YMBaseNavigationStyleClearBgBlackBackArrow;
  255. img = ImageByName(@"ym_personal_page_more_icon_black");
  256. } else {
  257. self.ym_navigationStyle = YMBaseNavigationStyleClearBgWhiteBackArrow;
  258. img = ImageByName(@"ym_personal_page_more_icon_white");
  259. }
  260. [self.moreBtn setImage:img forState:(UIControlStateNormal)];
  261. self.ym_customNavView.backgroundColor = [UIColor.whiteColor colorWithAlphaComponent:alpha];
  262. }
  263. - (UIButton *)moreBtn {
  264. if (!_moreBtn) {
  265. _moreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  266. [_moreBtn setImage:ImageByName(@"ym_personal_page_more_icon_white") forState:UIControlStateNormal];
  267. WS(weakSelf)
  268. [[[_moreBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  269. [weakSelf.viewModel openMoreAlert];
  270. }];
  271. }
  272. return _moreBtn;
  273. }
  274. - (UIScrollView *)contentScrollView{
  275. if (!_contentScrollView) {
  276. _contentScrollView = [[UIScrollView alloc] init];
  277. _contentScrollView.delegate = self;
  278. _contentScrollView.bounces = NO;
  279. _contentScrollView.alwaysBounceVertical = YES;
  280. _contentScrollView.showsVerticalScrollIndicator = NO;
  281. _contentScrollView.showsHorizontalScrollIndicator = NO;
  282. _contentScrollView.backgroundColor = UIColor.clearColor;
  283. _contentScrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
  284. }
  285. return _contentScrollView;
  286. }
  287. - (UIView *)contentView{
  288. if (!_contentView) {
  289. _contentView = [[UIView alloc]init];
  290. }
  291. return _contentView;
  292. }
  293. - (YMPersonalPageAlbumView *)albumView{
  294. if (!_albumView) {
  295. _albumView = [[YMPersonalPageAlbumView alloc]init];
  296. }
  297. return _albumView;
  298. }
  299. - (YMPersonalPageAboutView *)aboutView {
  300. if (!_aboutView) {
  301. _aboutView = [[YMPersonalPageAboutView alloc] init];
  302. }
  303. return _aboutView;
  304. }
  305. - (YMPersonalPageInfoView *)infoView{
  306. if (!_infoView) {
  307. _infoView = [[YMPersonalPageInfoView alloc]init];
  308. }
  309. return _infoView;
  310. }
  311. - (UIStackView *)socialContentStackView{
  312. if(!_socialContentStackView){
  313. _socialContentStackView = [[UIStackView alloc]init];
  314. _socialContentStackView.translatesAutoresizingMaskIntoConstraints = NO;
  315. _socialContentStackView.axis = UILayoutConstraintAxisVertical;
  316. _socialContentStackView.alignment = UIStackViewAlignmentCenter;
  317. _socialContentStackView.spacing = adapt(10);
  318. }
  319. return _socialContentStackView;
  320. }
  321. - (YMPersonalPageDynamicView *)dynamicView{
  322. if (!_dynamicView) {
  323. _dynamicView = [[YMPersonalPageDynamicView alloc]init];
  324. _dynamicView.userInteractionEnabled = YES;
  325. WS(weakSelf)
  326. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
  327. [_dynamicView addGestureRecognizer:tap];
  328. [[[tap rac_gestureSignal] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  329. [weakSelf.viewModel gotoPersonalDynamic];
  330. }];
  331. }
  332. return _dynamicView;
  333. }
  334. - (YMPersonalPageTagView *)tagView{
  335. if (!_tagView) {
  336. _tagView = [[YMPersonalPageTagView alloc]init];
  337. }
  338. return _tagView;
  339. }
  340. - (YMPersonalPageGiftWallView *)giftWallView{
  341. if (!_giftWallView) {
  342. _giftWallView = [[YMPersonalPageGiftWallView alloc]init];
  343. }
  344. return _giftWallView;
  345. }
  346. - (UIButton *)editProfileBtn{
  347. if (!_editProfileBtn) {
  348. _editProfileBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  349. _editProfileBtn.titleLabel.font = LCFont(16);
  350. [_editProfileBtn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal];
  351. [_editProfileBtn setTitle:@"编辑资料" forState:UIControlStateNormal];
  352. [_editProfileBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  353. _editProfileBtn.layer.cornerRadius = adapt(60)/2;
  354. _editProfileBtn.layer.masksToBounds = YES;
  355. _editProfileBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
  356. [_editProfileBtn setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
  357. CGFloat margin = 5;
  358. _editProfileBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -margin, 0, margin);
  359. WS(weakSelf)
  360. [[[_editProfileBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  361. [weakSelf.viewModel gotoEditProfile];
  362. }];
  363. _editProfileBtn.hidden = YES;
  364. }
  365. return _editProfileBtn;
  366. }
  367. - (UIStackView *)otherPersonalPageButtonStackView{
  368. if(!_otherPersonalPageButtonStackView){
  369. _otherPersonalPageButtonStackView = [[UIStackView alloc]init];
  370. _otherPersonalPageButtonStackView.hidden = NO;
  371. _otherPersonalPageButtonStackView.backgroundColor = UIColor.clearColor;
  372. _otherPersonalPageButtonStackView.axis = UILayoutConstraintAxisHorizontal;
  373. _otherPersonalPageButtonStackView.alignment = UIStackViewAlignmentCenter;
  374. _otherPersonalPageButtonStackView.spacing = adapt(10);
  375. }
  376. return _otherPersonalPageButtonStackView;
  377. }
  378. - (UIButton *)heartbeatOrAccostBtn{
  379. if (!_heartbeatOrAccostBtn) {
  380. _heartbeatOrAccostBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  381. _heartbeatOrAccostBtn.hidden = YES;
  382. _heartbeatOrAccostBtn.titleLabel.font = LCFont(14);
  383. [_heartbeatOrAccostBtn setTitleColor:HexColorFromRGB(0x8167FF) forState:UIControlStateNormal];
  384. _heartbeatOrAccostBtn.layer.cornerRadius = adapt(60)/2;
  385. _heartbeatOrAccostBtn.layer.masksToBounds = YES;
  386. _heartbeatOrAccostBtn.layer.borderColor = HexColorFromRGB(0xEFEEEF).CGColor;
  387. _heartbeatOrAccostBtn.layer.borderWidth = 1;
  388. _heartbeatOrAccostBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
  389. [_heartbeatOrAccostBtn setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
  390. _heartbeatOrAccostBtn.imageEdgeInsets = UIEdgeInsetsMake(-_heartbeatOrAccostBtn.titleLabel.intrinsicContentSize.height, 0, 0, -_heartbeatOrAccostBtn.titleLabel.intrinsicContentSize.width);
  391. _heartbeatOrAccostBtn.titleEdgeInsets = UIEdgeInsetsMake(0, -_heartbeatOrAccostBtn.imageView.frame.size.width, -_heartbeatOrAccostBtn.imageView.frame.size.height, 0);
  392. WS(weakSelf)
  393. [[[_heartbeatOrAccostBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  394. [weakSelf.viewModel sendAccostRequest];
  395. }];
  396. }
  397. return _heartbeatOrAccostBtn;
  398. }
  399. - (UIButton *)followBtn{
  400. if (!_followBtn) {
  401. _followBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  402. _followBtn.titleLabel.font = LCFont(14);
  403. [_followBtn setTitle:@"关注" forState:UIControlStateNormal];
  404. [_followBtn setImage:ImageByName(@"ym_personal_page_add") forState:UIControlStateNormal];
  405. _followBtn.layer.cornerRadius = adapt(60) / 2;
  406. _followBtn.layer.masksToBounds = YES;
  407. _followBtn.layer.borderColor = HexColorFromRGB(0xEFEEEF).CGColor;
  408. _followBtn.layer.borderWidth = 1;
  409. _followBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
  410. [_followBtn setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
  411. _followBtn.imageEdgeInsets = UIEdgeInsetsMake(-_followBtn.titleLabel.intrinsicContentSize.height, 0, 0, -_followBtn.titleLabel.intrinsicContentSize.width);
  412. _followBtn.titleEdgeInsets = UIEdgeInsetsMake(0, -_followBtn.imageView.frame.size.width, -_followBtn.imageView.frame.size.height, 0);
  413. WS(weakSelf)
  414. [[[_followBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  415. [weakSelf.viewModel followUser];
  416. }];
  417. }
  418. return _followBtn;
  419. }
  420. - (UIButton *)callBtn{
  421. if (!_callBtn) {
  422. _callBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  423. [_callBtn setTitle:@" 视频聊天" forState:(UIControlStateNormal)];
  424. [_callBtn setImage:ImageByName(@"ym_personal_page_call_icon") forState:UIControlStateNormal];
  425. [_callBtn setTitleColor:HexColorFromRGB(0xFFFFFF) forState:(UIControlStateNormal)];
  426. //[_callBtn ym_setGradientBackgroundWithColors:@[HexColorFromRGBA(0xFF6E79, 1),HexColorFromRGBA(0xFF6E79, 1)] locations:kMainGradLocation startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0)];
  427. [_callBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  428. _callBtn.titleLabel.font = LCFont(14);
  429. _callBtn.layer.cornerRadius = adapt(60) / 2;
  430. _callBtn.layer.masksToBounds = YES;
  431. WS(weakSelf)
  432. [[[_callBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  433. [weakSelf.viewModel callVideo];
  434. }];
  435. }
  436. return _callBtn;
  437. }
  438. - (UIButton *)privateChatBtn{
  439. if (!_privateChatBtn) {
  440. _privateChatBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  441. [_privateChatBtn setBackgroundImage:ImageByName(@"ym_personal_page_siliao") forState:UIControlStateNormal];
  442. _privateChatBtn.layer.cornerRadius = adapt(60) / 2;
  443. _privateChatBtn.layer.masksToBounds = YES;
  444. WS(weakSelf)
  445. [[[_privateChatBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  446. [weakSelf.viewModel gotoPrivateChat];
  447. }];
  448. }
  449. return _privateChatBtn;
  450. }
  451. @end