WFCUVerifyRequestViewController.m 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //
  2. // WFCUVerifyRequestViewController.m
  3. // WFChatUIKit
  4. //
  5. // Created by WF Chat on 2018/11/4.
  6. // Copyright © 2018 WF Chat. All rights reserved.
  7. //
  8. #import "WFCUVerifyRequestViewController.h"
  9. #import <WFChatClient/WFCChatClient.h>
  10. #import "MBProgressHUD.h"
  11. @interface WFCUVerifyRequestViewController ()
  12. @property(nonatomic, strong)UITextField *verifyField;
  13. @end
  14. @implementation WFCUVerifyRequestViewController
  15. - (void)viewDidLoad {
  16. [super viewDidLoad];
  17. // Do any additional setup after loading the view.
  18. CGRect clientArea = self.view.bounds;
  19. UILabel *hintLabel = [[UILabel alloc] initWithFrame:CGRectMake(8, 8 + kStatusBarAndNavigationBarHeight, clientArea.size.width - 16, 16)];
  20. hintLabel.text = @"请填入申请理由,等等对方同意";
  21. hintLabel.font = [UIFont systemFontOfSize:12];
  22. hintLabel.textColor = [UIColor grayColor];
  23. [self.view addSubview:hintLabel];
  24. [self.view setBackgroundColor:[UIColor colorWithRed:(235) / 255.0f green:(235) / 255.0f blue:(235) / 255.0f alpha:1]];
  25. self.verifyField = [[UITextField alloc] initWithFrame:CGRectMake(0, 32 + kStatusBarAndNavigationBarHeight, clientArea.size.width, 32)];
  26. WFCCUserInfo *me = [[WFCCIMService sharedWFCIMService] getUserInfo:[WFCCNetworkService sharedInstance].userId refresh:NO];
  27. self.verifyField.font = [UIFont systemFontOfSize:16];
  28. self.verifyField.text = [NSString stringWithFormat:@"我是 %@", me.displayName];
  29. self.verifyField.borderStyle = UITextBorderStyleRoundedRect;
  30. self.verifyField.clearButtonMode = UITextFieldViewModeAlways;
  31. [self.view addSubview:self.verifyField];
  32. self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"发送" style:UIBarButtonItemStyleDone target:self action:@selector(onSend:)];
  33. }
  34. - (void)onSend:(id)sender {
  35. MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  36. hud.label.text = @"处理中...";
  37. [hud showAnimated:YES];
  38. __weak typeof(self) ws = self;
  39. [[WFCCIMService sharedWFCIMService] sendFriendRequest:self.userId reason:self.verifyField.text success:^{
  40. dispatch_async(dispatch_get_main_queue(), ^{
  41. [hud hideAnimated:YES];
  42. MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  43. hud.mode = MBProgressHUDModeText;
  44. hud.label.text = @"处理成功";
  45. hud.offset = CGPointMake(0.f, MBProgressMaxOffset);
  46. [hud hideAnimated:YES afterDelay:1.f];
  47. [ws.navigationController popViewControllerAnimated:YES];
  48. });
  49. } error:^(int error_code) {
  50. dispatch_async(dispatch_get_main_queue(), ^{
  51. [hud hideAnimated:YES];
  52. MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  53. hud.mode = MBProgressHUDModeText;
  54. hud.label.text = @"处理失败";
  55. hud.offset = CGPointMake(0.f, MBProgressMaxOffset);
  56. [hud hideAnimated:YES afterDelay:1.f];
  57. });
  58. }];
  59. }
  60. /*
  61. #pragma mark - Navigation
  62. // In a storyboard-based application, you will often want to do a little preparation before navigation
  63. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  64. // Get the new view controller using [segue destinationViewController].
  65. // Pass the selected object to the new view controller.
  66. }
  67. */
  68. @end