HostCheckMickAlertView.m 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. //
  2. // HostCheckMickAlertView.m
  3. // BuguLive
  4. //
  5. // Created by xfg on 2017/9/26.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "HostCheckMickAlertView.h"
  9. @interface HostCheckMickAlertView ()
  10. @property (nonatomic, strong) UIView *backView;
  11. @property (nonatomic, strong) UIButton *closeBtn;
  12. @property (nonatomic, strong) UIImageView *headerImgView;
  13. @property (nonatomic, strong) UILabel *nameLabel;
  14. @property (nonatomic, strong) UIButton *closeMickBtn;
  15. @property (nonatomic, copy) CloseMickBlock closeMickBlock;
  16. @property (nonatomic, strong) UserModel *userModel;
  17. @end
  18. @implementation HostCheckMickAlertView
  19. - (instancetype)initAlertView:(UserModel *)userModel closeMickBlock:(CloseMickBlock)closeMickBlock
  20. {
  21. self = [super init];
  22. if ( self )
  23. {
  24. self.type = MMPopupTypeCustom;
  25. self.userModel = userModel;
  26. self.closeMickBlock = closeMickBlock;
  27. FWWeakify(self)
  28. [self mas_makeConstraints:^(MASConstraintMaker *make) {
  29. make.size.mas_equalTo(CGSizeMake(280, 230));
  30. }];
  31. [self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.edges.equalTo(self);
  33. }];
  34. [self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.top.right.equalTo(self.backView).insets(UIEdgeInsetsMake(0, 0, 0, 0));
  36. make.size.mas_equalTo(CGSizeMake(40, 40));
  37. }];
  38. [self.headerImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  39. FWStrongify(self)
  40. make.top.equalTo(self.backView).with.offset(30);
  41. make.centerX.equalTo(self.backView);
  42. make.size.mas_equalTo(CGSizeMake(80, 80));
  43. }];
  44. [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  45. FWStrongify(self)
  46. make.top.equalTo(self.headerImgView.mas_bottom).with.offset(10);
  47. make.left.equalTo(self.backView).with.offset(10);
  48. make.right.equalTo(self.backView).with.offset(-10);
  49. make.height.offset(20);
  50. }];
  51. [self.closeMickBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.top.equalTo(self.nameLabel.mas_bottom).with.offset(30);
  53. make.left.equalTo(self.backView).with.offset(10);
  54. make.right.equalTo(self.backView).with.offset(-10);
  55. make.height.offset(30);
  56. }];
  57. [self setupMessage:userModel.user_id];
  58. }
  59. return self;
  60. }
  61. - (void)setupMessage:(NSString *)podcast_id
  62. {
  63. NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
  64. [mDict setObject:@"user" forKey:@"ctl"];
  65. [mDict setObject:@"userinfo" forKey:@"act"];
  66. if (podcast_id)
  67. {
  68. [mDict setObject:podcast_id forKey:@"to_user_id"];
  69. }
  70. FWWeakify(self)
  71. [[NetHttpsManager manager] POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson) {
  72. FWStrongify(self)
  73. NSDictionary *tmpDict = [responseJson objectForKey:@"user"];
  74. self.nameLabel.text = [tmpDict toString:@"nick_name"];
  75. [self.headerImgView sd_setImageWithURL:[NSURL URLWithString:[tmpDict toString:@"head_image"]]];
  76. } FailureBlock:^(NSError *error) {
  77. }];
  78. }
  79. - (void)actionClose
  80. {
  81. [self hide];
  82. }
  83. - (void)closeMickAction
  84. {
  85. if (self.closeMickBlock)
  86. {
  87. self.closeMickBlock(self.userModel);
  88. }
  89. [self actionClose];
  90. }
  91. #pragma mark - ----------------------- GET -----------------------
  92. - (UIView *)backView
  93. {
  94. if (!_backView)
  95. {
  96. _backView = [[UIView alloc] init];
  97. [self addSubview:_backView];
  98. _backView.layer.cornerRadius = 5.0f;
  99. _backView.clipsToBounds = YES;
  100. _backView.backgroundColor = [UIColor whiteColor];
  101. }
  102. return _backView;
  103. }
  104. - (UIButton *)closeBtn
  105. {
  106. if (!_closeBtn)
  107. {
  108. _closeBtn = [UIButton mm_buttonWithTarget:self action:@selector(actionClose)];
  109. [self.backView addSubview:_closeBtn];
  110. [_closeBtn setImage:[UIImage imageNamed:@"com_close_1"] forState:UIControlStateNormal];
  111. }
  112. return _closeBtn;
  113. }
  114. - (UIImageView *)headerImgView
  115. {
  116. if (!_headerImgView)
  117. {
  118. _headerImgView = [[UIImageView alloc] init];
  119. [self addSubview:_headerImgView];
  120. _headerImgView.layer.cornerRadius = 40;
  121. _headerImgView.clipsToBounds = YES;
  122. [_headerImgView setImage:[UIImage imageNamed:@"com_preload_head_img"]];
  123. }
  124. return _headerImgView;
  125. }
  126. - (UILabel *)nameLabel
  127. {
  128. if (!_nameLabel)
  129. {
  130. _nameLabel = [[UILabel alloc] init];
  131. [self addSubview:_nameLabel];
  132. _nameLabel.textAlignment = NSTextAlignmentCenter;
  133. _nameLabel.font = kAppMiddleTextFont;
  134. _nameLabel.textColor = kAppGrayColor2;
  135. }
  136. return _nameLabel;
  137. }
  138. - (UIButton *)closeMickBtn
  139. {
  140. if (!_closeMickBtn)
  141. {
  142. _closeMickBtn = [UIButton mm_buttonWithTarget:self action:@selector(closeMickAction)];
  143. [self.backView addSubview:_closeMickBtn];
  144. [_closeMickBtn setTitle:ASLocalizedString(@"关闭连麦")forState:UIControlStateNormal];
  145. [_closeMickBtn setTitleColor:kAppGrayColor1 forState:UIControlStateNormal];
  146. _closeMickBtn.titleLabel.font = kAppLargeTextFont;
  147. }
  148. return _closeMickBtn;
  149. }
  150. @end