XYLiveRoomChatInputView.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. //
  2. // XYLiveRoomChatInputView.m
  3. // Starbuds
  4. //
  5. // Created by pajia on 2020/1/7.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. //
  8. #import "XYLiveRoomChatInputView.h"
  9. #import "UITextView+KCPlaceHolder.h"
  10. #import "uiview_ViewControllerMethods.h"
  11. #import "UIViewController+KCTopViewController.h"
  12. #import "XYLiveRoomMessageInfo.h"
  13. #import "XYHeadlineRoomManage.h"
  14. @interface XYLiveRoomChatInputView ()<UITextViewDelegate>
  15. @property (nonatomic, strong) UIView *shadowView;
  16. @property (nonatomic, strong) UIView *textInputShadowView;
  17. //@property (nonatomic, strong) UITextView *textView;
  18. @property (nonatomic, strong) UIButton *sendBtn;
  19. @property (nonatomic, strong) UIButton *giftBtn;
  20. @property (nonatomic, strong) NSTimer *timer;
  21. //@property (nonatomic, strong) UIButton *emojiBtn;
  22. @property (nonatomic, strong) UIButton *headLineBtn;
  23. //@property (nonatomic, strong) UIButton *balanceBtn;
  24. @end
  25. @implementation XYLiveRoomChatInputView
  26. - (void)setup{
  27. [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
  28. [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
  29. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardWillShowNotification object:nil];
  30. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidhidden:) name:UIKeyboardWillHideNotification object:nil];
  31. self.userInteractionEnabled = YES;
  32. self.hidden = YES;
  33. self.hiddenView.hidden = YES;
  34. [self hiddenView];
  35. [self shadowView];
  36. [self textView];
  37. [self sendBtn];
  38. if ([XYLiveManger shareInstance].liveRoomType == HeadLineRoom ||
  39. [XYLiveManger shareInstance].liveRoomType == QuickMatchingRoom) {
  40. [self.shadowView addShadowPathWith:[UIColor colorWithHexString:@"#000000" alpha:0.1] shadowOpacity:3 shadowRadius:12 shadowSide:ShadowPathTop shadowPathWidth:8];
  41. self.shadowView.backgroundColor = [UIColor whiteColor];
  42. self.textInputShadowView.backgroundColor = [UIColor colorWithHexString:@"#F7F8FA" alpha:1];
  43. [self showBottomItem];
  44. if (self.headLineActivity){
  45. self.headLineBtn.hidden = NO;
  46. self.balanceBtn.hidden = NO;
  47. [self headLineBtnAction];
  48. [self.textInputShadowView mas_remakeConstraints:^(MASConstraintMaker *make) {
  49. make.left.equalTo(self.headLineBtn.mas_right).offset(8);
  50. make.right.equalTo(self.shadowView.mas_right).offset(-66);
  51. make.centerY.equalTo(self.shadowView.mas_centerY).offset(0);
  52. make.height.offset(40);
  53. }];
  54. [self.textView mas_remakeConstraints:^(MASConstraintMaker *make) {
  55. make.left.equalTo(self.textInputShadowView.mas_left).offset(10);
  56. make.right.equalTo(self.textInputShadowView.mas_right).offset(-40);
  57. make.centerY.equalTo(self.textInputShadowView.mas_centerY).offset(0);
  58. make.height.offset(40);
  59. }];
  60. [self.textInputShadowView addSubview:self.emojiBtn];
  61. [self.emojiBtn mas_remakeConstraints:^(MASConstraintMaker *make) {;
  62. make.right.equalTo(self.textInputShadowView.mas_right).offset(-10);
  63. make.centerY.equalTo(self.textInputShadowView.mas_centerY).offset(0);
  64. make.width.offset(20);
  65. make.height.offset(20);
  66. }];
  67. [self.sendBtn setTitle:@"" forState:UIControlStateNormal];
  68. [self.sendBtn setImage:[UIImage imageNamed:@"xy-headlineroom-iputsendnor"] forState:UIControlStateNormal];
  69. [self.sendBtn setImage:[UIImage imageNamed:@"xy-headlineroom-inputsendsel"] forState:UIControlStateSelected];
  70. self.sendBtn.adjustsImageWhenHighlighted = NO;
  71. }
  72. }else{
  73. self.shadowView.backgroundColor = [UIColor colorWithHexString:@"#F7F8FA" alpha:1];
  74. self.textInputShadowView.backgroundColor = [UIColor whiteColor];
  75. }
  76. }
  77. - (void)showBottomItem{
  78. self.hidden = NO;
  79. self.hiddenView.hidden = YES;
  80. self.emojiBtn.selected = NO;
  81. [self.textView resignFirstResponder];
  82. if ([XYLiveManger shareInstance].liveRoomType == QuickMatchingRoom) {
  83. self.giftBtn.hidden = NO;
  84. self.sendBtn.hidden = YES;
  85. }
  86. }
  87. - (void)showTopItem{
  88. self.hidden = NO;
  89. self.hiddenView.hidden = NO;
  90. self.emojiBtn.selected = YES;
  91. [self.textView becomeFirstResponder];
  92. if ([XYLiveManger shareInstance].liveRoomType == QuickMatchingRoom) {
  93. self.giftBtn.hidden = YES;
  94. self.sendBtn.hidden = NO;
  95. }
  96. }
  97. //输入数量
  98. - (void)show{
  99. if ([XYLiveManger shareInstance].liveRoomType == HeadLineRoom ||
  100. [XYLiveManger shareInstance].liveRoomType == QuickMatchingRoom) {
  101. [self showTopItem];
  102. }else{//语音房间时
  103. self.hidden = NO;
  104. self.hiddenView.hidden = NO;
  105. [self.textView becomeFirstResponder];
  106. if (!self.inputGiftNum) {
  107. BOOL limtUser = [[XYChatRoomManager sharedInstance].chatRoomController.infoManager isLimitUser];
  108. if (limtUser) {
  109. self.textView.kc_maxWordInput = [NSNumber numberWithInt:50];
  110. }else{
  111. self.textView.kc_maxWordInput = [NSNumber numberWithInt:30];
  112. }
  113. }
  114. }
  115. }
  116. - (void)hide{
  117. if ([XYLiveManger shareInstance].liveRoomType == HeadLineRoom ||
  118. [XYLiveManger shareInstance].liveRoomType == QuickMatchingRoom) {
  119. if (!self.hiddenView.hidden) { [self.textView resignFirstResponder]; }
  120. [self showBottomItem];
  121. }else{
  122. [self.textView resignFirstResponder];
  123. self.hidden = YES;
  124. self.hiddenView.hidden = YES;
  125. }
  126. [self timerAction];
  127. }
  128. - (void)hiddenViewTapAction{
  129. [self hide];
  130. }
  131. - (void)clear{
  132. [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
  133. [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
  134. [_timer invalidate];
  135. _timer = nil;
  136. [_hiddenView removeFromSuperview];
  137. _hiddenView = nil;
  138. }
  139. - (void)textViewDidChange:(UITextView *)textView{
  140. if (textView.text.length) {
  141. self.sendBtn.selected = YES;
  142. }else{
  143. self.sendBtn.selected = NO;
  144. }
  145. }
  146. - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
  147. if ([text isEqualToString:@"\n"]){
  148. [self sendBtnAction:nil];
  149. return NO;
  150. }
  151. return YES;
  152. }
  153. - (void)setAiteName:(NSString *)aiteName{
  154. _aiteName = aiteName;
  155. _textView.text = [NSString stringWithFormat:@"@%@ ", aiteName];
  156. }
  157. - (void)giftBtnAction{
  158. self.XYLiveMessageManagerBlock(nil);
  159. }
  160. - (void)sendBtnAction:(UIButton *)sender{
  161. if (self.inputGiftNum) {
  162. if (self.XYLiveMessageManagerBlock && self.textView.text.length) {
  163. NSDictionary *dataDict = @{@"giftNum":self.textView.text};
  164. self.XYLiveMessageManagerBlock(dataDict);
  165. self.textView.text = @"";
  166. self.sendBtn.selected = NO;
  167. _aiteName = nil;
  168. [self hiddenViewTapAction];
  169. }
  170. }else{
  171. if (!self.textView.text.length) {
  172. [SVProgressHUD showInfoWithStatus:@"消息不能为空"];
  173. return;
  174. }
  175. if (_timer) {
  176. [SVProgressHUD showInfoWithStatus:@"发送频率每秒一条"];
  177. return;
  178. }
  179. _timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerAction) userInfo:nil repeats:NO];
  180. [[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSRunLoopCommonModes];
  181. NSMutableDictionary *dataDict = [[NSMutableDictionary alloc] init];
  182. [dataDict setObject:[XYUserInfoManager nowUser].userId forKey:@"senderId"];
  183. [dataDict setObject:self.targetId forKey:@"targetId"];
  184. //senderProfile
  185. NSMutableDictionary *senderProfileDict = [[NSMutableDictionary alloc] init];
  186. [dataDict setObject:senderProfileDict forKey:@"senderProfile"];
  187. [senderProfileDict setObject:[XYUserInfoManager nowUser].userId forKey:@"userId"];
  188. [senderProfileDict setObject:[XYUserInfoManager nowUser].userAvatar forKey:@"userAvatar"];
  189. [senderProfileDict setObject:[XYUserInfoManager nowUser].userName forKey:@"userName"];
  190. [senderProfileDict setObject:[XYUserInfoManager nowUser].headWearAnimationId forKey:@"headWearAnimationId"];
  191. NSString *bubbleId = [XYUserInfoManager nowUser].bubbleId;
  192. if (StringIsNotEmpty(bubbleId)) {
  193. [senderProfileDict setObject:[XYUserInfoManager nowUser].bubbleId forKey:@"bubbleId"];
  194. }
  195. if ([XYUserInfoManager nowUser].isOfficial == 1) { [senderProfileDict setObject:@"99" forKey:@"userRole"]; }
  196. //
  197. if ([XYChatRoomManager sharedInstance].chatRoomController.infoManager.profile) {
  198. NSMutableDictionary *senderProfile = [NSMutableDictionary dictionaryWithDictionary:[XYChatRoomManager sharedInstance].chatRoomController.infoManager.profile];
  199. NSString *bubbleId = [XYUserInfoManager nowUser].bubbleId;
  200. if (StringIsNotEmpty(bubbleId)) {
  201. [senderProfile setObject:[XYUserInfoManager nowUser].bubbleId forKey:@"bubbleId"];
  202. }
  203. NSString *medalId = [XYUserInfoManager nowUser].medal.medalId;
  204. if (StringIsNotEmpty(medalId)) {
  205. [senderProfile setObject:[XYUserInfoManager nowUser].medal.medalId forKey:@"medalId"];
  206. }
  207. [dataDict setObject:senderProfile forKey:@"senderProfile"];
  208. }
  209. //msg
  210. NSMutableDictionary *msgDict = [[NSMutableDictionary alloc] init];
  211. [dataDict setObject:msgDict forKey:@"msg"];
  212. if([XYLiveManger shareInstance].liveRoomType == HeadLineRoom){
  213. [msgDict setObject:HEADLINE_MSG_TEXT forKey:@"type"];
  214. [dataDict setObject:HEADLINE_MSG_TEXT forKey:@"type"];
  215. }else if([XYLiveManger shareInstance].liveRoomType == QuickMatchingRoom){
  216. [msgDict setObject:LIVEROOM_MSG_TEXT forKey:@"type"];
  217. [dataDict setObject:LIVEROOM_MSG_TEXT forKey:@"type"];
  218. }else{
  219. [msgDict setObject:LIVEROOM_MSG_TEXT forKey:@"type"];
  220. [dataDict setObject:LIVEROOM_MSG_TEXT forKey:@"type"];
  221. }
  222. if ([XYChatRoomManager sharedInstance].chatRoomController.infoManager.roomInfoModel.roomType == XYVoiceRoomTypeVoiceLive) {
  223. // 是否个播房间 1是个播房间
  224. [msgDict setObject:@(1) forKey:@"bType"];
  225. // 个播房场次id
  226. NSString *sessionID = [XYChatRoomManager sharedInstance].chatRoomController.infoManager.singleRtcHisId;
  227. if (StringIsNotEmpty(sessionID)) {
  228. [msgDict setObject:sessionID forKey:@"sessionID"];
  229. }
  230. }
  231. [msgDict setObject:[[SystemTimeObject getSystemTime] stringValue] forKey:@"timestamp"];
  232. //NSString *text = [self.textView.text stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"@%@ ", self.aiteName] withString:@""];
  233. //text = [text stringByReplacingOccurrencesOfString:self.aiteName withString:@""];
  234. [msgDict setObject:self.textView.text forKey:@"text"];
  235. if (self.aiteName) {
  236. [msgDict setObject:self.aiteUserId forKey:@"mentionUserId"];
  237. [dataDict setObject:@{@"userId":self.aiteUserId, @"userName":self.aiteName} forKey:@"mentionProfile"];
  238. }
  239. if (self.XYLiveMessageManagerBlock && self.textView.text.length) {
  240. self.XYLiveMessageManagerBlock(dataDict);
  241. self.textView.text = @"";
  242. self.sendBtn.selected = NO;
  243. _aiteName = nil;
  244. }
  245. }
  246. }
  247. - (void)keyboardDidShow:(NSNotification *)notification{
  248. if (self.hiddenView.hidden == YES) {return;}
  249. NSValue* aValue = [[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey];
  250. CGRect keyboardRect = [aValue CGRectValue];
  251. CGRect keyboardFrame = [self.viewController.view convertRect:keyboardRect fromView:[[UIApplication sharedApplication] keyWindow]];
  252. CGFloat keyboardHeight = keyboardFrame.size.height;
  253. if (self.XYLiveRoomChatInputViewStatusBlock) {
  254. self.XYLiveRoomChatInputViewStatusBlock(YES, keyboardHeight);
  255. }
  256. }
  257. - (void)keyboardDidhidden:(NSNotification *)notification{
  258. if (self.hiddenView.hidden == YES) {return; }
  259. [self hide];
  260. if (self.XYLiveRoomChatInputViewStatusBlock) {
  261. self.XYLiveRoomChatInputViewStatusBlock(NO, 0);
  262. }
  263. }
  264. - (void)timerAction{
  265. [_timer invalidate];
  266. _timer = nil;
  267. }
  268. - (void)emojiBtnAction{
  269. if (self.XYLiveRoomChatInputViewEmojiBntBlock) {
  270. if (self.emojiBtn.isSelected) {
  271. self.XYLiveRoomChatInputViewEmojiBntBlock(2);
  272. if ([XYLiveManger shareInstance].liveRoomType == QuickMatchingRoom) {
  273. [self quickMatchRoomHide];
  274. }
  275. }else{
  276. self.emojiBtn.selected = YES;
  277. self.XYLiveRoomChatInputViewEmojiBntBlock(1);
  278. self.giftBtn.hidden = YES;
  279. self.sendBtn.hidden = NO;
  280. }
  281. }
  282. //self.emojiBtn.selected = !self.emojiBtn.selected;
  283. }
  284. - (void)quickMatchRoomHide{
  285. if ([XYLiveManger shareInstance].liveRoomType == QuickMatchingRoom) {
  286. self.giftBtn.hidden = NO;
  287. self.sendBtn.hidden = YES;
  288. }
  289. }
  290. - (void)headLineBtnAction{
  291. if (self.headLineBtn.isSelected) {
  292. self.headLineBtn.selected = NO;
  293. self.balanceBtn.selected = NO;
  294. kViewBorderRadius(self.headLineBtn, 10, 1, [UIColor colorWithHexString:@"#CCCCCC" alpha:1]);
  295. }else{
  296. self.headLineBtn.selected = YES;
  297. self.balanceBtn.selected = YES;
  298. kViewBorderRadius(self.headLineBtn, 10, 1, [UIColor colorWithHexString:@"#FF198C" alpha:1]);
  299. }
  300. }
  301. #pragma mark - lazy
  302. - (UIView *)shadowView{
  303. if (_shadowView == nil) {
  304. _shadowView = [[UIView alloc] init];
  305. [self addSubview:_shadowView];
  306. [_shadowView mas_makeConstraints:^(MASConstraintMaker *make) {;
  307. make.left.equalTo(self.mas_left).offset(0);
  308. make.bottom.equalTo(self.mas_bottom).offset(0);
  309. make.width.offset(kScreenWidth);
  310. make.height.offset(56);
  311. }];
  312. [_shadowView layoutIfNeeded];
  313. _shadowView.userInteractionEnabled = YES;
  314. }
  315. return _shadowView;
  316. }
  317. - (UIView *)hiddenView{
  318. if (_hiddenView == nil) {
  319. _hiddenView = [[UIView alloc] init];
  320. _hiddenView.backgroundColor = [UIColor clearColor];
  321. [self.showView addSubview:_hiddenView];
  322. [self.showView bringSubviewToFront:self];
  323. [_hiddenView mas_makeConstraints:^(MASConstraintMaker *make) {;
  324. make.left.equalTo(self.showView.mas_left).offset(0);
  325. make.top.equalTo(self.showView.mas_top).offset(0);
  326. make.width.offset(kScreenWidth);
  327. make.height.offset(kScreenHeight);
  328. }];
  329. [_hiddenView layoutIfNeeded];
  330. _hiddenView.hidden = YES;
  331. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hiddenViewTapAction)];
  332. _hiddenView.userInteractionEnabled = YES;
  333. [_hiddenView addGestureRecognizer:tap];
  334. }
  335. return _hiddenView;
  336. }
  337. - (UITextView *)textView{
  338. if (_textView == nil) {
  339. _textInputShadowView = [[UIView alloc] init];
  340. [self.shadowView addSubview:_textInputShadowView];
  341. [_textInputShadowView mas_makeConstraints:^(MASConstraintMaker *make) {
  342. // if ([XYLiveManger shareInstance].liveRoomType == HeadLineRoom ||
  343. // [XYLiveManger shareInstance].liveRoomType == QuickMatchingRoom) {
  344. // make.left.equalTo(self.emojiBtn.mas_right).offset(10);
  345. // }else{
  346. // make.left.equalTo(self.shadowView.mas_left).offset(20);
  347. // }
  348. make.left.equalTo(self.shadowView.mas_left).offset(20);
  349. make.right.equalTo(self.shadowView.mas_right).offset(-56);
  350. make.centerY.equalTo(self.shadowView.mas_centerY).offset(0);
  351. make.height.offset(40);
  352. }];
  353. _textView = [[UITextView alloc] init];
  354. _textView.backgroundColor = [UIColor clearColor];
  355. _textView.kc_placeHolderColor = UIColorFromRGB(0x909399);
  356. _textView.kc_placeHolderFont = [UIFont fontWithName:kPFSCFont size:16];
  357. _textView.delegate = self ;
  358. _textView.textColor = UIColorFromRGB(0x303133);
  359. _textView.font = RegularFont(16);
  360. if (self.inputGiftNum) {
  361. _textView.kc_placeHolder = @"";
  362. _textView.keyboardType = UIKeyboardTypeNumberPad;
  363. _textView.textAlignment = NSTextAlignmentCenter;
  364. _textView.kc_maxWordInput = [NSNumber numberWithInt:5];
  365. }else{
  366. _textView.kc_placeHolder = kLocalizedString(@"说点什么吧~");
  367. _textView.kc_maxWordInput = [NSNumber numberWithInt:50];
  368. _textView.returnKeyType = UIReturnKeySend;
  369. }
  370. if (self.headLineActivity) {
  371. _textView.kc_maxWordInput = [NSNumber numberWithInt:30];
  372. }
  373. [_textInputShadowView addSubview:_textView];
  374. [_textView mas_makeConstraints:^(MASConstraintMaker *make) {
  375. make.left.equalTo(_textInputShadowView.mas_left).offset(10);
  376. make.right.equalTo(_textInputShadowView.mas_right).offset(-10);
  377. make.centerY.equalTo(_textInputShadowView.mas_centerY).offset(0);
  378. make.height.offset(40);
  379. }];
  380. kViewRadius(_textInputShadowView, 20);
  381. }
  382. return _textView ;
  383. }
  384. - (UIButton *)headLineBtn{
  385. if (_headLineBtn == nil) {
  386. _headLineBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  387. [_headLineBtn setTitle:kLocalizedString(@"头条") forState:UIControlStateNormal];
  388. [_headLineBtn setTitleColor:[UIColor colorWithHexString:@"#CCCCCC" alpha:1] forState:UIControlStateNormal];
  389. [_headLineBtn setTitleColor:[UIColor colorWithHexString:@"#FF198C" alpha:1] forState:UIControlStateSelected];
  390. _headLineBtn.titleLabel.font = [UIFont fontWithName:kPFSCFont size:12];
  391. _headLineBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
  392. _headLineBtn.titleLabel.adjustsFontSizeToFitWidth = YES;
  393. _headLineBtn.titleLabel.minimumScaleFactor = 0.5;
  394. [_headLineBtn addTarget:self action:@selector(headLineBtnAction) forControlEvents:UIControlEventTouchUpInside];
  395. _headLineBtn.selected = NO;
  396. _headLineBtn.hidden = YES;
  397. [self.shadowView addSubview:_headLineBtn];
  398. [_headLineBtn mas_makeConstraints:^(MASConstraintMaker *make) {;
  399. make.left.equalTo(self.shadowView.mas_left).offset(8);
  400. make.top.equalTo(self.shadowView.mas_top).offset(10);
  401. make.width.offset(36);
  402. make.height.offset(20);
  403. }];
  404. [_headLineBtn layoutIfNeeded];
  405. kViewBorderRadius(_headLineBtn, 10, 1, [UIColor colorWithHexString:@"#CCCCCC" alpha:1]);
  406. }
  407. return _headLineBtn;
  408. }
  409. - (UIButton *)balanceBtn{
  410. if (_balanceBtn == nil) {
  411. _balanceBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  412. [_balanceBtn setTitle:[NSString stringWithFormat:@"%@钻石/次",@""] forState:UIControlStateNormal];
  413. if ([[XYHeadlineRoomManage shareInstance].headlineInfo.price integerValue] > 0) {
  414. [_balanceBtn setTitle:[NSString stringWithFormat:@"%@钻石/次",[XYHeadlineRoomManage shareInstance].headlineInfo.price] forState:UIControlStateNormal];
  415. }
  416. [_balanceBtn setTitleColor:[UIColor colorWithHexString:@"#CCCCCC" alpha:1] forState:UIControlStateNormal];
  417. [_balanceBtn setTitleColor:[UIColor colorWithHexString:@"#FF198C" alpha:1] forState:UIControlStateSelected];
  418. _balanceBtn.titleLabel.font = [UIFont fontWithName:kPFSCFont size:8];
  419. _balanceBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
  420. _balanceBtn.titleLabel.adjustsFontSizeToFitWidth = YES;
  421. _balanceBtn.titleLabel.minimumScaleFactor = 0.5;
  422. [_balanceBtn addTarget:self action:@selector(headLineBtnAction) forControlEvents:UIControlEventTouchUpInside];
  423. _balanceBtn.selected = NO;
  424. _balanceBtn.hidden = YES;
  425. [self.shadowView addSubview:_balanceBtn];
  426. [_balanceBtn mas_makeConstraints:^(MASConstraintMaker *make) {;
  427. make.left.equalTo(self.shadowView.mas_left).offset(0);
  428. make.top.equalTo(self.headLineBtn.mas_bottom).offset(1);
  429. make.width.offset(52);
  430. make.height.offset(12);
  431. }];
  432. [_balanceBtn layoutIfNeeded];
  433. }
  434. return _balanceBtn;
  435. }
  436. - (UIButton *)emojiBtn{
  437. // if (_emojiBtn == nil && ([XYLiveManger shareInstance].liveRoomType == HeadLineRoom ||
  438. // [XYLiveManger shareInstance].liveRoomType == QuickMatchingRoom) ) {
  439. // _emojiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  440. // [_emojiBtn setImage:[UIImage imageNamed:@"xy-headlineroom-emojibtn"] forState:UIControlStateNormal];
  441. // [_emojiBtn setImage:[UIImage imageNamed:@"xy-headlineroom-dowmbtn"] forState:UIControlStateSelected];
  442. // [_emojiBtn addTarget:self action:@selector(emojiBtnAction) forControlEvents:UIControlEventTouchUpInside];
  443. // [self.shadowView addSubview:_emojiBtn];
  444. // [_emojiBtn mas_makeConstraints:^(MASConstraintMaker *make) {;
  445. // make.left.equalTo(self.shadowView.mas_left).offset(18);
  446. // make.centerY.equalTo(self.shadowView.mas_centerY).offset(0);
  447. // make.width.offset(20);
  448. // make.height.offset(20);
  449. // }];
  450. // [_emojiBtn layoutIfNeeded];
  451. // }
  452. return _emojiBtn;
  453. }
  454. - (UIButton *)sendBtn{
  455. if (_sendBtn == nil) {
  456. _sendBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  457. if (self.inputGiftNum) {
  458. [_sendBtn setTitle:kLocalizedString(@"确定") forState:UIControlStateNormal];
  459. }else{
  460. [_sendBtn setTitle:kLocalizedString(@"发送") forState:UIControlStateNormal];
  461. }
  462. [_sendBtn setTitleColor:[UIColor colorWithHexString:@"#606266" alpha:1] forState:UIControlStateNormal];
  463. _sendBtn.titleLabel.font = [UIFont fontWithName:kPFSCFont size:18];
  464. _sendBtn.titleLabel.textAlignment = NSTextAlignmentRight;
  465. _sendBtn.titleLabel.adjustsFontSizeToFitWidth = YES;
  466. _sendBtn.titleLabel.minimumScaleFactor = 0.5;
  467. [_sendBtn addTarget:self action:@selector(sendBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  468. [self.shadowView addSubview:_sendBtn];
  469. [_sendBtn mas_makeConstraints:^(MASConstraintMaker *make) {;
  470. make.right.equalTo(self.shadowView.mas_right).offset(-10);
  471. make.centerY.equalTo(self.shadowView.mas_centerY).offset(0);
  472. make.width.offset(56);
  473. make.height.offset(56);
  474. }];
  475. [_sendBtn layoutIfNeeded];
  476. }
  477. return _sendBtn;
  478. }
  479. - (UIButton *)giftBtn{
  480. if (_giftBtn == nil) {
  481. _giftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  482. [_giftBtn setImage:[UIImage imageNamed:@"xy-icon-gift"] forState:UIControlStateNormal];
  483. [_giftBtn addTarget:self action:@selector(giftBtnAction) forControlEvents:UIControlEventTouchUpInside];
  484. [self.shadowView addSubview:_giftBtn];
  485. [_giftBtn mas_makeConstraints:^(MASConstraintMaker *make) {;
  486. make.right.equalTo(self.shadowView.mas_right).offset(-16);
  487. make.centerY.equalTo(self.shadowView.mas_centerY).offset(0);
  488. make.width.offset(40);
  489. make.height.offset(40);
  490. }];
  491. [_giftBtn layoutIfNeeded];
  492. }
  493. return _giftBtn;
  494. }
  495. @end