ModifyNameViewController.m 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // ModifyNameViewController.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by Kyle on 2022/3/22.
  6. //
  7. #import "ModifyNameViewController.h"
  8. #import "ModifyNameBodyView.h"
  9. @interface ModifyNameViewController ()
  10. @property (nonatomic, strong) ModifyNameBodyView *bodyView;
  11. @property (nonatomic, copy) ModifySuccessCallback callback;
  12. @end
  13. @implementation ModifyNameViewController
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. // Do any additional setup after loading the view.
  17. NSString *titleString = [NSString isEmptyString:self.groupId] ? @"修改昵称" : @"修改群名称";
  18. [self allocTitle:titleString];
  19. [self configUI];
  20. }
  21. - (void)configUI {
  22. _bodyView = [ModifyNameBodyView shareInstance];
  23. [self rightButtonTitle:@"保存" color:CLIENT_THEMECOLOR];
  24. self.bodyView.nameField.tintColor = CLIENT_THEMECOLOR;
  25. BOOL isModifyName = [NSString isEmptyString:self.groupId] ? YES : NO;
  26. _bodyView.nameField.text = [NSString returnNoNullStringWithString:self.preNickName];
  27. _bodyView.isNameModify = isModifyName;
  28. [self.scrollView addSubview:_bodyView];
  29. [_bodyView mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.top.mas_equalTo(self.scrollView.mas_top);
  31. make.right.left.mas_equalTo(self.view);
  32. make.height.mas_equalTo(kScreenHeight - kNaviBarHeight - iPhoneXSafeBottomMargin);
  33. }];
  34. }
  35. - (void)successCallback:(ModifySuccessCallback)callback {
  36. if (callback) {
  37. self.callback = callback;
  38. }
  39. }
  40. - (void)rightBtnClick {
  41. [self.view endEditing:YES];
  42. // 修改昵称
  43. if ([NSString isEmptyString:self.bodyView.nameField.text]) {
  44. [LOADING_MANAGER MBShowAUTOHidingInWindow:@"请输入昵称"];
  45. return;
  46. }
  47. // 修改用户昵称
  48. NSString *avatal = nil;
  49. NSString *gendar = nil;
  50. NSString *birthday = nil;
  51. [LOADING_MANAGER showCustomLoading:@"加载中..."];
  52. [KSNetworkingManager modifyUserMessage:KS_POST avatal:avatal gender:gendar username:self.bodyView.nameField.text birthdate:birthday success:^(NSDictionary * _Nonnull dic) {
  53. [LOADING_MANAGER removeCustomLoading];
  54. if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
  55. [LOADING_MANAGER KSShowMsg:@"修改成功" promptCompletion:^{
  56. if (self.callback) {
  57. self.callback();
  58. }
  59. [self backAction];
  60. }];
  61. }
  62. else {
  63. [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
  64. }
  65. } faliure:^(NSError * _Nonnull error) {
  66. [LOADING_MANAGER removeCustomLoading];
  67. }];
  68. }
  69. /*
  70. #pragma mark - Navigation
  71. // In a storyboard-based application, you will often want to do a little preparation before navigation
  72. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  73. // Get the new view controller using [segue destinationViewController].
  74. // Pass the selected object to the new view controller.
  75. }
  76. */
  77. @end