// // EditSloganViewController.m // Youth // // Created by mambaxie on 2022/1/2. // #import "EditSloganViewController.h" #import "FSTextInputView.h" @interface EditSloganViewController () @property (nonatomic, strong) FSTextInputView *inputView; @end @implementation EditSloganViewController - (void)viewDidLoad { [super viewDidLoad]; self.title = @"个人简介"; FSTextInputView *inputView = [[FSTextInputView alloc] init]; inputView.placeHolderLabel.text = @"可以填写自己的兴趣爱好、心情愿望,有趣的介绍可以让更多酒友关注你哦~"; inputView.x = FIX_SIZE(15); inputView.y = NAVIGATION_BAR_HEIGHT + FIX_SIZE(10); inputView.width = self.view.width - inputView.x * 2; inputView.height = inputView.width; inputView.maxTextLength = 1024; [self.view addSubview:inputView]; inputView.backgroundColor = SUB_BG_COLOR; inputView.textview.font = MT_FONT_REGULAR_SIZE(13); inputView.layer.cornerRadius = FIX_SIZE(13); inputView.layer.borderWidth = 0.5; inputView.layer.borderColor = COLOR_WITH_RGB(0x383A4A).CGColor; self.inputView = inputView; WeakSelf(self); UIButton *okButton = [UIButton buttonWithType:UIButtonTypeSystem]; [okButton setTitle:@"保存" forState:UIControlStateNormal]; okButton.titleLabel.font = MT_FONT_REGULAR_SIZE(15); [okButton addTouchUpInsideWithAction:^(UIButton * _Nullable button) { [UserService updateUserToRemoteWithParams:@{ @"introduction": weakself.inputView.content ?:@"" } completion:^(id _Nullable rsp, NSError * _Nullable error) { [UserService currentUser].introduce = weakself.inputView.content; [SVProgressHUD showSuccessWithStatus:@"设置成功"]; [weakself.navigationController popViewControllerAnimated:YES]; }]; }]; inputView.textview.text = [UserService currentUser].introduce; inputView.didChangeText = ^(FSTextInputView *inputView) { okButton.enabled = inputView.content.length > 0; }; [okButton setTitleColor:COLOR_WITH_RGB(0xB3B3B3) forState:UIControlStateDisabled]; [okButton setTitleColor:THEME_COLOR forState:UIControlStateNormal]; dispatch_async(dispatch_get_main_queue(), ^{ okButton.enabled = NO; }); okButton.width = FIX_SIZE(30); self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:okButton]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [self.inputView.textview becomeFirstResponder]; } @end