// // QXChangeIntroduceViewController.m // QXLive // // Created by 启星 on 2025/5/21. // #import "QXChangeIntroduceViewController.h" #import "QXTextView.h" #import "QXSearchCell.h" #import "QXMineNetwork.h" @interface QXChangeIntroduceViewController () @property (nonatomic,strong)QXTextView *textView; @property (nonatomic,strong)UICollectionView *collectionView; @property (nonatomic,strong)NSString *tag_id; @end @implementation QXChangeIntroduceViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:NO animated:YES]; } -(void)setNavgationItems{ [super setNavgationItems]; self.navigationItem.title = QXText(@"修改简介"); UIButton *btn = [[UIButton alloc] init]; [btn setTitle:QXText(@"保存") forState:(UIControlStateNormal)]; btn.titleLabel.font = [UIFont systemFontOfSize:14.f]; [btn setTitleColor:QXConfig.themeColor forState:(UIControlStateNormal)]; [btn addTarget:self action:@selector(saveAction) forControlEvents:(UIControlEventTouchUpInside)]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn]; } - (void)initSubViews{ self.tag_id = @""; self.textView = [[QXTextView alloc] initWithFrame:CGRectMake(16, NavContentHeight+12, SCREEN_WIDTH-32, 180)]; if (self.introduce.length > 0) { self.textView.placehoulder = QXText(@"介绍喜好、个性,让大家认识你"); self.textView.text = self.introduce; }else{ self.textView.placehoulder = QXText(@"介绍喜好、个性,让大家认识你"); } [self.textView becomeFirstResponder]; self.textView.backgroundColor = UIColor.whiteColor; [self.textView addRoundedCornersWithRadius:7]; self.textView.font = [UIFont systemFontOfSize:13]; [self.view addSubview:self.textView]; [self.view addSubview:self.collectionView]; } -(void)getData{ MJWeakSelf [QXMineNetwork getUserTagListSuccessBlock:^(NSArray * _Nonnull users) { [weakSelf.dataArray removeAllObjects]; [weakSelf.dataArray addObjectsFromArray:users]; [weakSelf.collectionView reloadData]; } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { }]; } -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ [self.view endEditing:YES]; } - (void)saveAction{ [self.view endEditing:YES]; NSString *introduce = self.textView.text; QXLOG(@"修改简介%@",introduce); MJWeakSelf [QXMineNetwork editUserInfoWithNickname:@"" birthday:@"" sex:@"" avatar:@"" images:@"" profile:introduce tag_id:self.tag_id successBlock:^(NSDictionary * _Nonnull dict) { [weakSelf.navigationController popViewControllerAnimated:YES]; } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { }]; } -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ return self.dataArray.count; } -(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ QXSearchCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:[QXSearchCell cellIdentifier] forIndexPath:indexPath]; cell.cellType = QXSearchCellTypeChangeIntroduce; cell.userTag = self.dataArray[indexPath.row]; return cell; } -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ QXUserTag *model = self.dataArray[indexPath.row]; model.isSelected = !model.isSelected; if (model.isSelected) { if (self.tag_id.length == 0) { self.tag_id = model.id; }else{ self.tag_id = [self.tag_id stringByAppendingFormat:@",%@",model.id]; } } [collectionView reloadData]; } -(UICollectionView *)collectionView{ if (!_collectionView) { UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; flowLayout.minimumLineSpacing = 12; flowLayout.minimumInteritemSpacing = 12; flowLayout.sectionInset = UIEdgeInsetsMake(0, 16, 0, 16); flowLayout.itemSize = CGSizeMake((SCREEN_WIDTH-16*2-12*3)/4, 22); _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, self.textView.bottom+12, SCREEN_WIDTH, SCREEN_HEIGHT-self.textView.bottom-12) collectionViewLayout:flowLayout]; _collectionView.delegate = self; _collectionView.dataSource = self; _collectionView.backgroundColor = [UIColor clearColor]; [_collectionView registerClass:[QXSearchCell class] forCellWithReuseIdentifier:[QXSearchCell cellIdentifier]]; _collectionView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag; } return _collectionView; } /* #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