| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- //
- // MOFanClubCreateVC.m
- // MiMoLive
- //
- // Created by SuperC on 2023/10/29.
- //
- #import "MOFanClubCreateVC.h"
- #import "MOGuildInputBaseCell.h"
- #import "MONameplateCell.h"
- #import "MOEidtNameplateVC.h"
- @interface MOFanClubCreateVC ()
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *backBtnTop;
- @property (weak, nonatomic) IBOutlet UILabel *titleLab;
- @property (weak, nonatomic) IBOutlet UIImageView *bgImgView;
- @property (weak, nonatomic) IBOutlet UITableView *tableView;
- @property (weak, nonatomic) IBOutlet UIButton *submitBtn;
- /** 粉丝团名称 */
- @property (nonatomic, copy) NSString *fanClubName;
- /** 铭牌名称 */
- @property (nonatomic, copy) NSString *nameplateName;
- @property (weak, nonatomic) IBOutlet UILabel *tipLab;
- @end
- @implementation MOFanClubCreateVC
- - (void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- [self.navigationController setNavigationBarHidden:NO animated:animated];
-
- [self mo_setNavLeftItemWithImage:[UIImage imageNamed:@"icon_new_left_gray"] andBackgroundImg:[UIImage imageNamed:@"icon_mine_base_bg"]];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view from its nib.
-
- if(self.isEdit){
- self.navigationItem.title = NSLocalString(@"mimo_fans_club_settings");
- }
- else{
- self.navigationItem.title = @"Create Fan Club";
- }
- // [self setNavLeftItemWithImage:[UIImage imageNamed:@"icon_nav_back"]];
- self.titleLab.text = NSLocalString(@"mimo_fans_club_create_club");
- self.tipLab.text = NSLocalString(@"mimo_fans_fans_club_create_condition");
-
- [self setupUI];
- }
- - (IBAction)closeBtnClick:(id)sender {
- [self.navigationController popViewControllerAnimated:YES];
- }
- #pragma mark - UITableViewDelegate,UITableViewDataSource
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return 2.0;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 55.0;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- if(indexPath.row == 0){
- MOGuildInputBaseCell *cell = [tableView dequeueReusableCellWithIdentifier:MOGuildInputBaseCell_ID];
- cell.titleLab.text = NSLocalString(@"mimo_fans_fans_club_name");
- cell.titleLab.textColor = [UIColor blackColor];
- cell.backgroundColor = [UIColor clearColor];
- cell.inputTxf.text = self.fanClubName;
- WEAKSELF
- cell.returnTxFText = ^(NSString * _Nonnull txfString) {
- weakSelf.fanClubName = txfString;
- };
-
- return cell;
- }
- else{
- MONameplateCell *cell = [tableView dequeueReusableCellWithIdentifier:MONameplateCell_ID];
- cell.backgroundColor = [UIColor clearColor];
- cell.titleLab.text = NSLocalString(@"mimo_fans_fans_club_nameplate_name");
- cell.titleLab.textColor = [UIColor blackColor];
- cell.nameString = self.nameplateName;
- return cell;
- }
-
-
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
-
- if(indexPath.row == 1){
- MOEidtNameplateVC *vc = [[MOEidtNameplateVC alloc] init];
- WEAKSELF
- vc.tempNameplateString = weakSelf.nameplateName;
- vc.saveBlock = ^(NSString * _Nonnull nameplateString) {
- weakSelf.nameplateName = nameplateString;
- [weakSelf.tableView reloadData];
- };
- [self.navigationController pushViewController:vc animated:YES];
- }
- }
- - (void)setupUI{
-
- NSArray *bgColorArr = @[[MOTools colorWithHexString:@"#EEF2FD" alpha:1.0],[MOTools colorWithHexString:@"#FAFAFC" alpha:1.0]];
- UIImage *bgImage = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, SCREENWIDTH, (SCREENHEIGHT - NAV_BAR_HEIGHT)) Colors:bgColorArr GradientType:1];
- [self.bgImgView setImage:bgImage];
-
- self.tipLab.font = [MOTextTools getTheFontWithSize:14.0 AndFontName:kNormalContentFontStr];
- [self.submitBtn setFont:[MOTextTools getTheFontWithSize:20.0 AndFontName:kNormalContentFontStr]];
-
- if(self.isEdit){
- self.titleLab.text = NSLocalString(@"mimo_fans_club_settings");
- self.fanClubName = self.fanClubData.clubName;
- self.nameplateName = self.fanClubData.nameplate;
- }
-
- NSArray *colorArr = @[kBaseBtnBgColor,kBaseBtnBgColor];
- UIImage *image = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, (SCREENWIDTH - 36.0 * 2), 50.0) Colors:colorArr GradientType:0];
- [self.submitBtn setBackgroundImage:image forState:UIControlStateNormal];
- self.submitBtn.layer.cornerRadius = 44.0 / 2;
- self.submitBtn.layer.masksToBounds = YES;
-
- self.tableView.estimatedRowHeight = 0;
- self.tableView.estimatedSectionHeaderHeight = 0;
- self.tableView.estimatedSectionFooterHeight = 0;
-
- //iOS15适配
- if (@available(iOS 15.0, *))
- {
- self.tableView.sectionHeaderTopPadding = 0;
- }
-
- [self.tableView registerNib:[UINib nibWithNibName:@"MONameplateCell" bundle:nil] forCellReuseIdentifier:MONameplateCell_ID];
- [self.tableView registerNib:[UINib nibWithNibName:@"MOGuildInputBaseCell" bundle:nil] forCellReuseIdentifier:MOGuildInputBaseCell_ID];
- }
- //提交按钮
- - (IBAction)submitBtnClick:(id)sender {
- if(self.fanClubName.length <= 0){
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_fans_fans_club_name_tips")];
- return;
- }
-
- if(self.fanClubName.length > 16){
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_fans_fans_club_name_limit_tip")];
- return;
- }
-
-
- if(self.nameplateName.length <= 0){
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_fans_fans_club_nameplate_name_tips")];
- return;
- }
-
- if(self.nameplateName.length > 9){
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_fans_fans_club_nameplate_limit_tip")];
- return;
- }
-
- WEAKSELF
- if(!self.isEdit){
- //创建
- NSDictionary *dict = @{@"name":self.fanClubName,
- @"nameplate":self.nameplateName};
-
-
- [kHttpManager toCreateFansClubWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- __strong typeof(weakSelf) self = weakSelf;
- if(kCode_Success){
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_common_success")];
-
- //已经创建过粉丝团更新
- [[NSUserDefaults standardUserDefaults] setBool:YES forKey:kIsCreatFansClub];
- [[NSUserDefaults standardUserDefaults] synchronize];
-
- [self performSelector:@selector(backToRootVC) withObject:nil afterDelay:1.5];
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- else{
- //编辑
-
- NSDictionary *dict = @{@"name":self.fanClubName,
- @"nameplate":self.nameplateName,
- @"id":self.fanClubData.id,
- @"show":@(YES)};
-
- [kHttpManager toEditFansClubInfoWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- __strong typeof(weakSelf) self = weakSelf;
- if(kCode_Success){
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_common_success")];
- weakSelf.changeSuccessBlock ? weakSelf.changeSuccessBlock() : nil;
- [self performSelector:@selector(closeBtnClick:) withObject:nil afterDelay:1.5];
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- }
- - (void)backToRootVC{
- [self.navigationController popToRootViewControllerAnimated:YES];
- }
- @end
|