MOReportSomeOneView.m 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. //
  2. // MOReportSomeOneView.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2024/1/16.
  6. //
  7. #import "MOReportSomeOneView.h"
  8. #import "MOReportTableViewCell.h"
  9. @interface MOReportSomeOneView ()<UITableViewDelegate,UITableViewDataSource>
  10. @property (weak, nonatomic) IBOutlet UIImageView *bgImgView;
  11. @property (weak, nonatomic) IBOutlet UILabel *titleLab;
  12. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  13. @property (weak, nonatomic) IBOutlet UITextView *textView;
  14. @property (weak, nonatomic) IBOutlet UIButton *cancelBtn;
  15. @property (weak, nonatomic) IBOutlet UIButton *submitBtn;
  16. @property (nonatomic, strong) NSArray *dataArr;
  17. @property (nonatomic, assign) NSInteger selectIndex;
  18. @end
  19. @implementation MOReportSomeOneView
  20. + (instancetype)moReportSomeOneView{
  21. return [[[NSBundle mainBundle] loadNibNamed:@"MOReportSomeOneView" owner:self options:nil] firstObject];
  22. }
  23. - (void)awakeFromNib{
  24. [super awakeFromNib];
  25. self.titleLab.font = [MOTextTools getTheFontWithSize:16.0 AndFontName:kNormalTitleFontStr];
  26. self.cancelBtn.font = [MOTextTools getTheFontWithSize:20.0 AndFontName:kNormalContentFontStr];
  27. self.submitBtn.font = [MOTextTools getTheFontWithSize:20.0 AndFontName:kNormalContentFontStr];
  28. self.layer.cornerRadius = 16.0;
  29. self.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner;
  30. self.layer.masksToBounds = YES;
  31. self.tableView.delegate = self;
  32. self.tableView.dataSource = self;
  33. self.tableView.layer.cornerRadius = 16.0;
  34. self.tableView.layer.masksToBounds = YES;
  35. [self.tableView registerNib:[UINib nibWithNibName:@"MOReportTableViewCell" bundle:nil] forCellReuseIdentifier:MOReportTableViewCell_ID];
  36. NSArray *bgColorArr = @[[MOTools colorWithHexString:@"#EDF1FD" alpha:1.0],[MOTools colorWithHexString:@"#FAFAFC" alpha:1.0]];
  37. UIImage *bgImage = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, 120.0, 50.0) Colors:bgColorArr GradientType:0];
  38. [self.bgImgView setImage:bgImage];
  39. NSArray *colorArr = @[[MOTools colorWithHexString:@"#B0B0B0" alpha:1.0],[MOTools colorWithHexString:@"#B0B0B0" alpha:1.0]];
  40. UIImage *image = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, 120.0, 50.0) Colors:colorArr GradientType:0];
  41. self.cancelBtn.layer.cornerRadius = 40.0 / 2.0;
  42. self.cancelBtn.layer.masksToBounds = YES;
  43. [self.cancelBtn setBackgroundImage:image forState:UIControlStateNormal];
  44. NSArray *submitColorArr = @[kBaseBtnBgColor,kBaseBtnBgColor];
  45. UIImage *submitImage = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, 120.0, 50.0) Colors:submitColorArr GradientType:0];
  46. self.submitBtn.layer.cornerRadius = 40.0 / 2.0;
  47. self.submitBtn.layer.masksToBounds = YES;
  48. [self.submitBtn setBackgroundImage:submitImage forState:UIControlStateNormal];
  49. self.textView.layer.cornerRadius = 12.0;
  50. self.textView.layer.masksToBounds = YES;
  51. self.dataArr = @[NSLocalString(@"mimo_Report_sq"),NSLocalString(@"mimo_Report_sj"),NSLocalString(@"mimo_Report_bl"),NSLocalString(@"mimo_Report_wr"),NSLocalString(@"mimo_Report_gg"),NSLocalString(@"mimo_Report_qz")];
  52. self.selectIndex = 0;
  53. }
  54. - (IBAction)backBtnClick:(id)sender {
  55. [self dismissReportSomeOneView];
  56. }
  57. - (IBAction)cancelBtnClick:(id)sender {
  58. [self dismissReportSomeOneView];
  59. }
  60. - (IBAction)submitBtnClick:(id)sender {
  61. if(self.userId.length == 0){
  62. return;
  63. }
  64. NSString *contentStr = self.textView.text;
  65. if(contentStr.length == 0){
  66. contentStr = @"";
  67. }
  68. WEAKSELF
  69. NSDictionary *dict = @{@"target":self.userId,
  70. @"type":@(self.selectIndex + 1),
  71. @"content":contentStr};
  72. [kHttpManager toSubmitFeedbackReportWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  73. if(kCode_Success){
  74. [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_common_success")];
  75. weakSelf.textView.text = @"";
  76. [weakSelf dismissReportSomeOneView];
  77. }
  78. else{
  79. MOLogV(@"getGiftHttpDataWith 接口报错了");
  80. kShowNetError(data)
  81. }
  82. }];
  83. }
  84. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
  85. {
  86. UITouch *touch = [touches anyObject];
  87. if (![touch.view isEqual:self.textView])
  88. {
  89. [self.textView resignFirstResponder];
  90. }
  91. }
  92. #pragma mark - UITableViewDelegate,UITableViewDataSource
  93. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  94. return 1;
  95. }
  96. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  97. return self.dataArr.count;
  98. }
  99. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  100. NSString *tempStr = self.dataArr[indexPath.row];
  101. MOReportTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MOReportTableViewCell_ID];
  102. cell.titleLab.text = tempStr;
  103. if(indexPath.row == self.selectIndex){
  104. cell.isSelect = YES;
  105. }
  106. else{
  107. cell.isSelect = NO;
  108. }
  109. return cell;
  110. }
  111. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  112. {
  113. return 30.0;
  114. }
  115. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  116. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  117. [self.textView resignFirstResponder];
  118. self.selectIndex = indexPath.row;
  119. [self.tableView reloadData];
  120. }
  121. - (void)showReportSomeOneView{
  122. self.frame = CGRectMake(0, 0, SCREENWIDTH, 445);
  123. if(self.isAnimationTwo){
  124. CGRect actionViewRect = self.frame;
  125. actionViewRect.origin.y = SCREENHEIGHT;
  126. self.frame = actionViewRect;
  127. WEAKSELF
  128. [UIView animateWithDuration:0.3 animations:^{
  129. CGRect actionViewRect = weakSelf.frame;
  130. actionViewRect.origin.y = (SCREENHEIGHT - 445);
  131. weakSelf.frame = actionViewRect;
  132. }];
  133. }
  134. else{
  135. CGRect actionViewRect = self.frame;
  136. actionViewRect.origin.x = SCREENWIDTH;
  137. self.frame = actionViewRect;
  138. WEAKSELF
  139. [UIView animateWithDuration:0.3 animations:^{
  140. CGRect actionViewRect = weakSelf.frame;
  141. actionViewRect.origin.x = 0;
  142. weakSelf.frame = actionViewRect;
  143. }];
  144. }
  145. [self.tableView reloadData];
  146. }
  147. - (void)dismissReportSomeOneView{
  148. [self.textView resignFirstResponder];
  149. self.dismissReportViewBlock ? self.dismissReportViewBlock() : nil;
  150. //完成下移动画
  151. WEAKSELF
  152. if(self.isAnimationTwo){
  153. [UIView animateWithDuration:0.3 animations:^
  154. {
  155. CGRect actionSheetViewRect = weakSelf.frame;
  156. actionSheetViewRect.origin.y = SCREENHEIGHT;
  157. weakSelf.frame = actionSheetViewRect;
  158. } completion:^(BOOL finished)
  159. {
  160. [self removeFromSuperview];
  161. }];
  162. }
  163. else{
  164. [UIView animateWithDuration:0.3 animations:^
  165. {
  166. CGRect actionSheetViewRect = weakSelf.frame;
  167. actionSheetViewRect.origin.x = SCREENWIDTH;
  168. weakSelf.frame = actionSheetViewRect;
  169. } completion:^(BOOL finished)
  170. {
  171. [self removeFromSuperview];
  172. }];
  173. }
  174. }
  175. @end