12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- //
- // ModifyNameViewController.m
- // KulexiuForTeacher
- //
- // Created by Kyle on 2022/3/22.
- //
- #import "ModifyNameViewController.h"
- #import "ModifyNameBodyView.h"
- @interface ModifyNameViewController ()
- @property (nonatomic, strong) ModifyNameBodyView *bodyView;
- @property (nonatomic, copy) ModifySuccessCallback callback;
- @end
- @implementation ModifyNameViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- NSString *titleString = [NSString isEmptyString:self.groupId] ? @"修改昵称" : @"修改群名称";
- [self allocTitle:titleString];
- [self configUI];
- }
- - (void)configUI {
- _bodyView = [ModifyNameBodyView shareInstance];
- [self rightButtonTitle:@"保存" color:CLIENT_THEMECOLOR];
- self.bodyView.nameField.tintColor = CLIENT_THEMECOLOR;
-
- BOOL isModifyName = [NSString isEmptyString:self.groupId] ? YES : NO;
- _bodyView.nameField.text = [NSString returnNoNullStringWithString:self.preNickName];
- _bodyView.isNameModify = isModifyName;
- [self.scrollView addSubview:_bodyView];
- [_bodyView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.scrollView.mas_top);
- make.right.left.mas_equalTo(self.view);
- make.height.mas_equalTo(kScreenHeight - kNaviBarHeight - iPhoneXSafeBottomMargin);
- }];
- }
- - (void)successCallback:(ModifySuccessCallback)callback {
- if (callback) {
- self.callback = callback;
- }
- }
- - (void)rightBtnClick {
- [self.view endEditing:YES];
- // 修改昵称
- if ([NSString isEmptyString:self.bodyView.nameField.text]) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"请输入昵称"];
- return;
- }
- // 修改用户昵称
- NSString *avatal = nil;
- NSString *gendar = nil;
- NSString *birthday = nil;
- [LOADING_MANAGER showCustomLoading:@"加载中..."];
- [KSNetworkingManager modifyUserMessage:KS_POST avatal:avatal gender:gendar username:self.bodyView.nameField.text birthdate:birthday success:^(NSDictionary * _Nonnull dic) {
- [LOADING_MANAGER removeCustomLoading];
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- [LOADING_MANAGER KSShowMsg:@"修改成功" promptCompletion:^{
- if (self.callback) {
- self.callback();
- }
- [self backAction];
- }];
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- [LOADING_MANAGER removeCustomLoading];
- }];
-
-
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|