123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- //
- // XYCreateFansViewController.m
- // Starbuds
- //
- // Created by 翟玉磊 on 2020/1/9.
- // Copyright © 2020 翟玉磊. All rights reserved.
- //
- #import "XYCreateFansViewController.h"
- #import "XYSearchApplyAgentViewController.h"
- #import "XYApplyAgentViewController.h"
- @interface XYCreateFansViewController ()<UITextFieldDelegate>
- @property (nonatomic, readwrite, strong) UIView *infoView;
- @property (nonatomic, readwrite, strong) UILabel *titleLabel;
- @property (nonatomic, readwrite, strong) UITextField *textField;
- @property (nonatomic, readwrite, strong) UIButton *sureButton;
- @end
- @implementation XYCreateFansViewController
- /// 重写init方法,配置你想要的属性
- - (instancetype)init
- {
- self = [super init];
- if (self) {
- self.prefersNavigationBarBottomLineHidden = YES;
- }
- return self;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- /// 设置
- [self _setup];
-
- /// 设置导航栏
- [self _setupNavigationItem];
-
- /// 设置子控件
- [self _setupSubViews];
-
- /// 布局子空间
- [self _makeSubViewsConstraints];
- }
- #pragma mark — Override
- - (void)bindViewModel {
-
- }
- #pragma mark — UITextFieldDelegate
- - (BOOL)textFieldShouldReturn:(UITextField *)textField {
-
- [self sureButtonAction:nil];
- return YES;
- }
- #pragma mark - 事件处理Or辅助方法
- - (void)sureButtonAction:(id)sender {
- if (StringIsEmpty(self.textField.text)) {
- [SVProgressHUD showInfoWithStatus:kLocalizedString(@"请输入粉丝团名称")];
- return;
- }
-
- [self.textField resignFirstResponder];
-
- [[XYAnchorAPIManager new] setFansNameWithFansName:self.textField.text successHandler:^(ZYLResponseModel *responseModel) {
- [SVProgressHUD showSuccessWithStatus:kLocalizedString(@"创建成功")];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self.navigationController popViewControllerAnimated:YES];
- });
- } failureHandler:^(ZYLNetworkError *error) {
- [SVProgressHUD showInfoWithStatus:error.domain];
- }];
- }
- #pragma mark - 初始化
- - (void)_setup{
- self.title = kLocalizedString(@"粉丝团");
- }
- #pragma mark - 设置导航栏
- - (void)_setupNavigationItem{
-
- }
- #pragma mark - 设置子控件
- - (void)_setupSubViews{
- [self.view addSubview:self.infoView];
- [self.infoView addSubview:self.titleLabel];
- [self.infoView addSubview:self.textField];
- [self.infoView addSubview:self.sureButton];
-
- [self.sureButton addTarget:self action:@selector(sureButtonAction:) forControlEvents:UIControlEventTouchUpInside];
- }
- #pragma mark - 布局子控件
- - (void)_makeSubViewsConstraints{
- [self.infoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.view).offset(NAVGATION_HEIGHT);
- make.left.right.equalTo(self.view);
- make.height.equalTo(@60.0f);
- }];
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.infoView).offset(SPACING_EDGE);
- make.centerY.equalTo(self.infoView);
- }];
- [self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.titleLabel.mas_right).offset(12.0f);
- make.centerY.equalTo(self.infoView);
- make.height.equalTo(@40.0f);
- make.right.equalTo(self.sureButton.mas_left).offset(-10.0f);
- }];
- [self.sureButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.infoView).offset(-SPACING_EDGE);
- make.centerY.equalTo(self.infoView);
- make.width.height.equalTo(@44.0f);
- }];
- }
- #pragma mark - Setter & Getter
- - (UIView *)infoView {
- if (!_infoView) {
- _infoView = [UIView new];
- _infoView.backgroundColor = Color_White;
- }
- return _infoView;
- }
- - (UILabel *)titleLabel {
- if (!_titleLabel) {
- _titleLabel = [UILabel createLabelTextColor:Color_TextFont fount:Font(14)];
- _titleLabel.text = kLocalizedString(@"创建粉丝团");
- }
- return _titleLabel;
- }
- - (UITextField *)textField {
- if (!_textField) {
- _textField = [[UITextField alloc] init];
- _textField.textColor = Color_TextFont;
- _textField.placeholder = kLocalizedString(@"请输入粉丝团名称");
- _textField.font = Font(14);
- _textField.returnKeyType = UIReturnKeyDone;
- _textField.textAlignment = NSTextAlignmentRight;
- _textField.delegate = self;
- }
- return _textField;
- }
- - (UIButton *)sureButton {
- if (!_sureButton) {
- _sureButton = [UIButton createButtonTextColor:Color_TextRed textFont:Font(14)];
- [_sureButton setTitle:kLocalizedString(@"确定") forState:UIControlStateNormal];
- _sureButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
- }
- return _sureButton;
- }
- @end
|