提交
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// QXCreatPhotosViewController.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/29.
|
||||
//
|
||||
|
||||
#import "QXBaseViewController.h"
|
||||
#import "QXPhotoModel.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXCreatPhotosViewController : QXBaseViewController
|
||||
@property (nonatomic,copy)void(^createSuccessBlock)(void);
|
||||
@property (nonatomic,strong)QXPhotoDetailModel *model;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
288
QXLive/Mine(音域)/Controller/个人主页/QXCreatPhotosViewController.m
Normal file
288
QXLive/Mine(音域)/Controller/个人主页/QXCreatPhotosViewController.m
Normal file
@@ -0,0 +1,288 @@
|
||||
//
|
||||
// QXCreatPhotosViewController.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/29.
|
||||
//
|
||||
|
||||
#import "QXCreatPhotosViewController.h"
|
||||
#import "QXUserInfoEditFooterView.h"
|
||||
#import "QXMineNetwork.h"
|
||||
#import "QXPhotosDetailVC.h"
|
||||
#import <TZImagePickerController/TZImageManager.h>
|
||||
#import <TZImagePickerController/TZImagePickerController.h>
|
||||
#import "QXOSSManager.h"
|
||||
#import "UIImage+QX.h"
|
||||
|
||||
@interface QXCreatPhotosViewController ()<QXUserInfoImageCellDelegate,UITextFieldDelegate>
|
||||
@property (nonatomic,strong)UIView *topBgView;
|
||||
@property (nonatomic,strong)UITextField *textField;
|
||||
@property (nonatomic,strong)UIButton *selectedBtn;
|
||||
@property (nonatomic,strong)UILabel *messageLabel;
|
||||
|
||||
@property (nonatomic,strong)UILabel *priviteLabel;
|
||||
@property (nonatomic,strong)UIButton *priviteBtn;
|
||||
|
||||
@property (nonatomic,strong)UIButton *commitBtn;
|
||||
@property (nonatomic,strong)UIButton *deleteBtn;
|
||||
@property (nonatomic,strong)NSString *avartar;
|
||||
|
||||
@property (nonatomic,strong)UIView *bottomBgView;
|
||||
@property (nonatomic,strong)UITextField *passwordTextField;
|
||||
@end
|
||||
|
||||
@implementation QXCreatPhotosViewController
|
||||
|
||||
- (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(@"新建相册");
|
||||
}
|
||||
|
||||
|
||||
- (void)initSubViews{
|
||||
self.selectedBtn = [[UIButton alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-150)/2, NavContentHeight+12, 150, 150)];
|
||||
[self.selectedBtn setBackgroundImage:[UIImage imageNamed:@"mine_room_cover_add"] forState:(UIControlStateNormal)];
|
||||
self.selectedBtn.imageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
[self.selectedBtn addTarget:self action:@selector(selectAlbumPhoto) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.selectedBtn addRoundedCornersWithRadius:6];
|
||||
[self.view addSubview:self.selectedBtn];
|
||||
|
||||
self.messageLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, self.selectedBtn.bottom+8, SCREEN_WIDTH-16-16, 20)];
|
||||
self.messageLabel.textAlignment = NSTextAlignmentCenter;
|
||||
self.messageLabel.textColor = QXConfig.textColor;
|
||||
self.messageLabel.font = [UIFont systemFontOfSize:12];
|
||||
self.messageLabel.text = QXText(@"相册封面");
|
||||
[self.view addSubview:self.messageLabel];
|
||||
|
||||
|
||||
self.topBgView = [[UIView alloc] initWithFrame:CGRectMake(16, self.messageLabel.bottom+24, SCREEN_WIDTH-32, 44)];
|
||||
[self.topBgView addRoundedCornersWithRadius:11];
|
||||
self.topBgView.backgroundColor = RGB16(0xEFF2F8);
|
||||
[self.view addSubview:self.topBgView];
|
||||
|
||||
self.textField = [[UITextField alloc] initWithFrame:CGRectMake(12, 0, self.topBgView.width-34, 44)];
|
||||
self.textField.placeholder = QXText(@"请输入相册名称");
|
||||
self.textField.font = [UIFont systemFontOfSize:16];
|
||||
self.textField.delegate = self;
|
||||
[self.topBgView addSubview:self.textField];
|
||||
|
||||
self.priviteBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-16-40, self.topBgView.bottom+2, 40, 35)];
|
||||
[self.priviteBtn setImage:[UIImage imageNamed:@"home_switch_off"] forState:(UIControlStateNormal)];
|
||||
[self.priviteBtn setImage:[UIImage imageNamed:@"home_switch_on"] forState:(UIControlStateSelected)];
|
||||
[self.priviteBtn addTarget:self action:@selector(priviteAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.view addSubview:self.priviteBtn];
|
||||
|
||||
self.priviteLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, self.priviteBtn.top, SCREEN_WIDTH-16-40-5-16, 35)];
|
||||
self.priviteLabel.textAlignment = NSTextAlignmentRight;
|
||||
self.priviteLabel.textColor = QXConfig.textColor;
|
||||
self.priviteLabel.font = [UIFont systemFontOfSize:13];
|
||||
self.priviteLabel.text = QXText(@"是否设置密码");
|
||||
[self.view addSubview:self.priviteLabel];
|
||||
|
||||
|
||||
|
||||
self.bottomBgView = [[UIView alloc] initWithFrame:CGRectMake(16, self.priviteBtn.bottom+2, SCREEN_WIDTH-32, 44)];
|
||||
[self.bottomBgView addRoundedCornersWithRadius:11];
|
||||
self.bottomBgView.backgroundColor = RGB16(0xEFF2F8);
|
||||
[self.view addSubview:self.bottomBgView];
|
||||
self.passwordTextField = [[UITextField alloc] initWithFrame:CGRectMake(12, 0, self.bottomBgView.width-34, 44)];
|
||||
self.passwordTextField.placeholder = QXText(@"请输入相册密码");
|
||||
self.passwordTextField.font = [UIFont systemFontOfSize:16];
|
||||
self.passwordTextField.secureTextEntry = YES;
|
||||
self.passwordTextField.delegate = self;
|
||||
[self.bottomBgView addSubview:self.passwordTextField];
|
||||
self.bottomBgView.hidden = YES;
|
||||
|
||||
|
||||
|
||||
self.commitBtn = [[UIButton alloc] initWithFrame:CGRectMake(38, self.view.height-kSafeAreaBottom-10-42, SCREEN_WIDTH-38*2, 42)];
|
||||
[self.commitBtn setTitle:QXText(@"确认") forState:(UIControlStateNormal)];
|
||||
[self.commitBtn addRoundedCornersWithRadius:21];
|
||||
[self.commitBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
||||
self.commitBtn.backgroundColor = QXConfig.themeColor;
|
||||
self.commitBtn.needEventInterval = 0.5;
|
||||
self.commitBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.commitBtn addTarget:self action:@selector(commitAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.view addSubview:self.commitBtn];
|
||||
if (self.model != nil) {
|
||||
self.avartar = self.model.image;
|
||||
[self.selectedBtn sd_setImageWithURL:[NSURL URLWithString:self.model.image] forState:(UIControlStateNormal)];
|
||||
self.textField.text = self.model.name;
|
||||
if (self.model.pwd.length > 0) {
|
||||
self.priviteBtn.selected = YES;
|
||||
self.bottomBgView.hidden = NO;
|
||||
self.passwordTextField.text = self.model.pwd;
|
||||
}else{
|
||||
self.priviteBtn.selected = NO;
|
||||
self.bottomBgView.hidden = YES;
|
||||
self.passwordTextField.text = @"";
|
||||
}
|
||||
self.deleteBtn = [[UIButton alloc] initWithFrame:CGRectMake(38, self.view.height-kSafeAreaBottom-10-42-12-42, SCREEN_WIDTH-38*2, 42)];
|
||||
[self.deleteBtn setTitle:QXText(@"删除") forState:(UIControlStateNormal)];
|
||||
[self.deleteBtn addRoundedCornersWithRadius:21];
|
||||
[self.deleteBtn setTitleColor:UIColor.whiteColor forState:(UIControlStateNormal)];
|
||||
self.deleteBtn.backgroundColor = QXConfig.btnTextColor;
|
||||
self.deleteBtn.needEventInterval = 0.5;
|
||||
self.deleteBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.deleteBtn addTarget:self action:@selector(deleteAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.view addSubview:self.deleteBtn];
|
||||
}
|
||||
}
|
||||
-(void)setModel:(QXPhotoDetailModel *)model{
|
||||
_model = model;
|
||||
}
|
||||
|
||||
-(void)deleteAction{
|
||||
MJWeakSelf
|
||||
[QXMineNetwork delePhotosWithAlbum_id:self.model.id successBlock:^(NSDictionary * _Nonnull dict) {
|
||||
for (UIViewController*vc in weakSelf.navigationController.viewControllers) {
|
||||
if ([vc isKindOfClass:[NSClassFromString(@"QXPhotosDetailVC") class]]) {
|
||||
[vc removeFromParentViewController];
|
||||
}
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:noticePhotosStatusChange object:nil];
|
||||
[weakSelf.navigationController popViewControllerAnimated:YES];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)priviteAction{
|
||||
self.priviteBtn.selected = !self.priviteBtn.selected;
|
||||
if (self.priviteBtn.selected) {
|
||||
self.bottomBgView.hidden = NO;
|
||||
}else{
|
||||
self.bottomBgView.hidden = YES;
|
||||
self.passwordTextField.text = @"";
|
||||
}
|
||||
}
|
||||
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
|
||||
if (textField.text.length == 8) {
|
||||
if ([string isEqualToString:@""]) {
|
||||
return YES;
|
||||
}else{
|
||||
return NO;
|
||||
}
|
||||
}else{
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
-(void)selectAlbumPhoto {
|
||||
TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:1 delegate:nil];
|
||||
imagePickerVc.maxImagesCount = 1;
|
||||
imagePickerVc.allowCameraLocation = NO;
|
||||
imagePickerVc.allowPickingOriginalPhoto = NO;
|
||||
|
||||
imagePickerVc.allowTakeVideo = NO;
|
||||
imagePickerVc.allowPickingVideo = NO;
|
||||
imagePickerVc.showSelectBtn = NO;
|
||||
imagePickerVc.allowCrop = NO;
|
||||
MJWeakSelf
|
||||
[imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
|
||||
if (photos.count) {
|
||||
NSData *imageData = [photos.firstObject qx_compressImageQualityWithToByte:(SCREEN_WIDTH*SCREEN_HEIGHT*2)];
|
||||
|
||||
[weakSelf OSSUploadPhotoWithFileData:imageData contentType:[NSString contentTypeWithImageData:imageData]];
|
||||
}
|
||||
}];
|
||||
imagePickerVc.modalPresentationStyle = UIModalPresentationFullScreen;
|
||||
[imagePickerVc.navigationBar setBackgroundImage:[UIImage qx_imageWithColor:RGB16(0x333333)] forBarMetrics:UIBarMetricsDefault];
|
||||
[self presentViewController:imagePickerVc animated:YES completion:nil];
|
||||
}
|
||||
- (void)OSSUploadPhotoWithFileData:(NSData *)fileData contentType:(NSString *)contentType {
|
||||
[self OSSUploadPhotoWithFileData:fileData contentType:contentType isVideoCover:NO];
|
||||
}
|
||||
- (void)OSSUploadPhotoWithFileData:(NSData *)fileData contentType:(NSString *)contentType isVideoCover:(BOOL)isVideoCover {
|
||||
if (!fileData || !contentType) {
|
||||
showToastInView(QXText(@"资源加载错误"), self.view);
|
||||
return;
|
||||
}
|
||||
if (fileData.length > 1024*1024 && [contentType isEqualToString:IMG_FILE_BASE_PATH]) {
|
||||
showToastInView(QXText(@"请不要上传超过1M的头像"), self.view);
|
||||
return;
|
||||
}
|
||||
NSMutableArray *files = [[NSMutableArray alloc] initWithObjects:fileData, nil];
|
||||
|
||||
NSString *fileBasePath = IMG_FILE_BASE_PATH;// 默认图片上传
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,contentType];
|
||||
NSMutableArray *fileNames = [[NSMutableArray alloc] initWithObjects:fileName, nil];
|
||||
__weak typeof(self)weakSelf = self;
|
||||
showLoadingInView(self.view);
|
||||
[[QXOSSManager sharedInstance] uploadFile:files withObjectKey:fileNames isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
hideLoadingInView(weakSelf.view);
|
||||
});
|
||||
if (state == UploadImageSuccess) {
|
||||
NSString *fileName = [names lastObject];
|
||||
NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
weakSelf.avartar = fileUrl;
|
||||
[weakSelf.selectedBtn sd_setImageWithURL:[NSURL URLWithString:fileUrl] forState:(UIControlStateNormal)];
|
||||
}else{
|
||||
showToastInView(QXText(@"文件上传失败,请重新尝试"), weakSelf.view);
|
||||
}
|
||||
}];
|
||||
}
|
||||
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
|
||||
[self.view endEditing:YES];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
-(void)commitAction{
|
||||
if (self.textField.text.length == 0) {
|
||||
showToast(@"请输入相册名称");
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.avartar.length == 0) {
|
||||
showToast(@"您还未上传封面");
|
||||
return;
|
||||
}
|
||||
if (self.priviteBtn.selected) {
|
||||
if (self.passwordTextField.text.length < 4) {
|
||||
showToast(@"密码至少需要4位");
|
||||
return;
|
||||
}
|
||||
}
|
||||
MJWeakSelf
|
||||
if (self.model != nil) {
|
||||
[QXMineNetwork photosEditWithNewAlbumId:self.model.id name:self.textField.text pwd:self.passwordTextField.text image:self.avartar successBlock:^(NSDictionary * _Nonnull dict) {
|
||||
if (weakSelf.createSuccessBlock) {
|
||||
weakSelf.createSuccessBlock();
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:noticePhotosStatusChange object:nil];
|
||||
[weakSelf.navigationController popViewControllerAnimated:YES];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
|
||||
}];
|
||||
}else{
|
||||
[QXMineNetwork createPhotosWithName:self.textField.text
|
||||
pwd:self.passwordTextField.text
|
||||
image:self.avartar
|
||||
successBlock:^(NSDictionary * _Nonnull dict) {
|
||||
if (weakSelf.createSuccessBlock) {
|
||||
weakSelf.createSuccessBlock();
|
||||
}
|
||||
[weakSelf.navigationController popViewControllerAnimated:YES];
|
||||
// QXPhotosDetailVC *vc = [[QXPhotosDetailVC alloc] init];
|
||||
|
||||
}
|
||||
failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
}
|
||||
@end
|
||||
20
QXLive/Mine(音域)/Controller/个人主页/QXPhotosDetailVC.h
Normal file
20
QXLive/Mine(音域)/Controller/个人主页/QXPhotosDetailVC.h
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// QXPhotosDetailVC.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by dangkai on 2025/5/31.
|
||||
//
|
||||
|
||||
#import "QXBaseViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXPhotosDetailVC : QXBaseViewController
|
||||
@property (nonatomic,strong)NSString*userId;
|
||||
@property (nonatomic,strong)NSString*albumId;
|
||||
@property (nonatomic,strong)NSString*name;
|
||||
@property (nonatomic,strong)NSString* pwd;
|
||||
@property (nonatomic,strong)NSArray* photoList;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
489
QXLive/Mine(音域)/Controller/个人主页/QXPhotosDetailVC.m
Normal file
489
QXLive/Mine(音域)/Controller/个人主页/QXPhotosDetailVC.m
Normal file
@@ -0,0 +1,489 @@
|
||||
//
|
||||
// QXPhotosDetailVC.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by dangkai on 2025/5/31.
|
||||
//
|
||||
|
||||
#import "QXPhotosDetailVC.h"
|
||||
#import "QXMineNetwork.h"
|
||||
#import "QXImageCollectionViewCell.h"
|
||||
#import "QXPhotosDetailTopView.h"
|
||||
#import <TZImagePickerController/TZImageManager.h>
|
||||
#import <TZImagePickerController/TZImagePickerController.h>
|
||||
#import "UIImage+QX.h"
|
||||
#import "NSString+QX.h"
|
||||
#import "QXOSSManager.h"
|
||||
#import "YBImageBrowser/YBImageBrowser.h"
|
||||
#import "QXPhotosSectionView.h"
|
||||
#import "QXPhotosToolsView.h"
|
||||
#import "QXCreatPhotosViewController.h"
|
||||
#import "QXPhotosMoveListView.h"
|
||||
|
||||
@interface QXPhotosDetailVC ()<UICollectionViewDelegate,UICollectionViewDataSource,QXPhotosToolsViewDelegate,QXPhotosDetailTopViewDelegate>
|
||||
@property(nonatomic,strong)QXPhotosDetailTopView *topView;
|
||||
@property(nonatomic,strong)UICollectionView *collectionView;
|
||||
@property(nonatomic,strong)UIButton *uploadBtn;
|
||||
@property(nonatomic,strong)QXPhotoDetailModel*model;
|
||||
|
||||
/// 处理列表数组
|
||||
@property(nonatomic,strong)NSMutableDictionary *photoDict;
|
||||
@property(nonatomic,strong)NSMutableArray *valueArray;
|
||||
|
||||
|
||||
// 上传相关数组
|
||||
@property (nonatomic,strong)NSMutableArray *keyArray;
|
||||
@property (nonatomic,strong)NSMutableArray *uploadArray;
|
||||
@property (nonatomic,strong)NSMutableArray *urlArray;
|
||||
|
||||
// 查看数组
|
||||
@property (nonatomic,strong)NSMutableArray *selectedArray;
|
||||
|
||||
// 选择处理
|
||||
@property (nonatomic,strong)NSMutableArray *browserArray;
|
||||
@property (nonatomic,assign)BOOL isSelectedState;
|
||||
@property (nonatomic,assign)BOOL isMe;
|
||||
|
||||
@property (nonatomic,strong)QXPhotosToolsView *toolsView;
|
||||
@end
|
||||
|
||||
@implementation QXPhotosDetailVC
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
}
|
||||
|
||||
-(void)viewWillAppear:(BOOL)animated{
|
||||
[super viewWillAppear:animated];
|
||||
}
|
||||
|
||||
-(void)viewDidAppear:(BOOL)animated{
|
||||
[super viewDidAppear:animated];
|
||||
for (UIViewController*vc in self.navigationController.viewControllers) {
|
||||
if ([vc isKindOfClass:[NSClassFromString(@"QXCreatPhotosViewController") class]]) {
|
||||
[vc removeFromParentViewController];
|
||||
}
|
||||
}
|
||||
}
|
||||
-(void)setNavgationItems{
|
||||
[super setNavgationItems];
|
||||
// self.navigationItem.title = self.name;
|
||||
|
||||
}
|
||||
-(void)selectedAction:(UIButton*)sender{
|
||||
sender.selected = !sender.selected;
|
||||
self.isSelectedState = sender.selected;
|
||||
if (!self.isSelectedState) {
|
||||
for (QXPhotoModel*md in self.selectedArray) {
|
||||
md.isSelected = NO;
|
||||
}
|
||||
[self.selectedArray removeAllObjects];
|
||||
[UIView animateWithDuration:0.15 animations:^{
|
||||
self.toolsView.y = SCREEN_HEIGHT;
|
||||
} completion:^(BOOL finished) {
|
||||
[self.toolsView removeFromSuperview];
|
||||
}];
|
||||
self.collectionView.contentInset = UIEdgeInsetsZero;
|
||||
}else{
|
||||
MJWeakSelf
|
||||
[self.view addSubview:self.toolsView];
|
||||
[UIView animateWithDuration:0.15 animations:^{
|
||||
weakSelf.toolsView.y = SCREEN_HEIGHT-TabbarContentHeight;
|
||||
}];
|
||||
self.collectionView.contentInset = UIEdgeInsetsMake(0, 0, TabbarContentHeight, 0);
|
||||
}
|
||||
[self.collectionView reloadData];
|
||||
}
|
||||
|
||||
-(void)getData{
|
||||
MJWeakSelf
|
||||
[QXMineNetwork photosDetailWithAlbumId:self.albumId pwd:self.pwd?self.pwd:@"" successBlock:^(QXPhotoDetailModel*model) {
|
||||
weakSelf.topView.model = model;
|
||||
if (weakSelf.page == 1) {
|
||||
[weakSelf.dataArray removeAllObjects];
|
||||
[weakSelf.valueArray removeAllObjects];
|
||||
[weakSelf.photoDict removeAllObjects];
|
||||
[weakSelf.selectedArray removeAllObjects];
|
||||
weakSelf.model = model;
|
||||
}else{
|
||||
NSMutableArray *arr = [NSMutableArray arrayWithArray:weakSelf.model.image_list];
|
||||
[arr addObjectsFromArray:model.image_list];
|
||||
model.image_list = arr;
|
||||
weakSelf.model = model;
|
||||
}
|
||||
for (QXPhotoModel*md in model.image_list) {
|
||||
NSDate *date = [NSDate dateWithTimeIntervalSince1970:md.createtime.longLongValue]; //此处根据项目需求,选择是否除以1000 , 如果时间戳精确到秒则去掉1000
|
||||
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
|
||||
formatter.dateFormat = @"yyyy-MM-dd";
|
||||
NSString*time = [formatter stringFromDate:date];
|
||||
NSArray *keyArray = weakSelf.photoDict.allKeys;
|
||||
if ([keyArray containsObject:time]) {
|
||||
weakSelf.valueArray = [NSMutableArray arrayWithArray:[weakSelf.photoDict objectForKey:time]];
|
||||
[weakSelf.valueArray addObject:md];
|
||||
[weakSelf.photoDict setObject:[NSArray arrayWithArray:self.valueArray] forKey:time];
|
||||
}else{
|
||||
[weakSelf.valueArray removeAllObjects];
|
||||
[weakSelf.valueArray addObject:md];
|
||||
[weakSelf.photoDict setObject:[NSArray arrayWithArray:self.valueArray] forKey:time];
|
||||
[weakSelf.dataArray addObject:time];
|
||||
}
|
||||
}
|
||||
[weakSelf.collectionView reloadData];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)getPhotoList{
|
||||
if (self.userId.length == 0) {
|
||||
return;
|
||||
}
|
||||
MJWeakSelf
|
||||
[QXMineNetwork photosListWithUserId:self.userId page:0 successBlock:^(NSArray<QXPhotoModel *> * _Nonnull hotos) {
|
||||
weakSelf.photoList = hotos;
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)initSubViews{
|
||||
self.page = 1;
|
||||
self.topView = [[QXPhotosDetailTopView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 216)];
|
||||
self.topView.delegate = self;
|
||||
[self.view addSubview:self.topView];
|
||||
_isMe = [self.userId isEqualToString:[QXGlobal shareGlobal].loginModel.user_id];
|
||||
self.topView.isMe = _isMe;
|
||||
if (!_isMe) {
|
||||
self.navigationItem.rightBarButtonItem = nil;
|
||||
self.uploadBtn.hidden = YES;
|
||||
}else{
|
||||
UIButton*selectedBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 80, 44)];
|
||||
// [selectedBtn setImage:[UIImage imageNamed:@"back"] forState:(UIControlStateNormal)];
|
||||
selectedBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentTrailing;
|
||||
[selectedBtn setTitle:QXText(@"选择") forState:(UIControlStateNormal)];
|
||||
[selectedBtn setTitle:QXText(@"取消选择") forState:(UIControlStateSelected)];
|
||||
selectedBtn.titleLabel.font = [UIFont systemFontOfSize:15];
|
||||
[selectedBtn setTitleColor:RGB16(0xFF8ACC) forState:UIControlStateNormal];
|
||||
[selectedBtn addTarget:self action:@selector(selectedAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:selectedBtn];
|
||||
}
|
||||
|
||||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||||
layout.minimumLineSpacing = 8;
|
||||
layout.minimumInteritemSpacing = 17;
|
||||
int itemWidth = (SCREEN_WIDTH-16*2-17*2)/3;
|
||||
layout.itemSize = CGSizeMake(itemWidth, itemWidth);
|
||||
layout.sectionInset = UIEdgeInsetsMake(0, 16, 0, 16);
|
||||
layout.headerReferenceSize = CGSizeMake(SCREEN_WIDTH, 40);
|
||||
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, self.topView.bottom, SCREEN_WIDTH, SCREEN_HEIGHT-self.topView.bottom) collectionViewLayout:layout];
|
||||
self.collectionView.backgroundColor = [UIColor clearColor];
|
||||
self.collectionView.delegate = self;
|
||||
self.collectionView.dataSource = self;
|
||||
[self.collectionView registerClass:[QXImageCollectionViewCell class] forCellWithReuseIdentifier:@"QXImageCollectionViewCell"];
|
||||
[self.collectionView registerClass:[QXPhotosSectionView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"QXPhotosSectionView"];
|
||||
[self.view addSubview:self.collectionView];
|
||||
[self.view addSubview:self.uploadBtn];
|
||||
}
|
||||
#pragma mark - QXPhotosToolsViewDelegate
|
||||
-(void)didClickActionType:(QXPhotosToolsActionType)type{
|
||||
switch (type) {
|
||||
case QXPhotosToolsActionShare:
|
||||
[self sharePhoto];
|
||||
break;
|
||||
case QXPhotosToolsActionMove:
|
||||
[self movePhotoToOther];
|
||||
break;
|
||||
case QXPhotosToolsActionDelete:
|
||||
[self deletePhoto];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
-(void)sharePhoto{
|
||||
if (self.selectedArray.count == 0) {
|
||||
showToast(@"请选择图片");
|
||||
return;
|
||||
}
|
||||
if (self.selectedArray.count > 1) {
|
||||
showToast(@"分享图片不得超过1张");
|
||||
return;
|
||||
}
|
||||
MJWeakSelf
|
||||
QXPhotoModel*md = self.selectedArray[0];
|
||||
UIImageView *imgV = [[UIImageView alloc] init];
|
||||
[imgV sd_setImageWithURL:[NSURL URLWithString:md.image] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
QXShareView *share = [[QXShareView alloc] init];
|
||||
share.shareType = QXShareViewTypeSharePhoto;
|
||||
share.imageData = UIImageJPEGRepresentation(image, 0.7);
|
||||
[share showInView:weakSelf.view];
|
||||
}];
|
||||
|
||||
}
|
||||
-(void)movePhotoToOther{
|
||||
MJWeakSelf
|
||||
if (self.selectedArray.count == 0) {
|
||||
showToast(@"请选择图片");
|
||||
return;
|
||||
}
|
||||
NSString *Id = @"";
|
||||
for (QXPhotoModel*md in self.selectedArray) {
|
||||
if (Id.length == 0) {
|
||||
Id = md.id;
|
||||
}else{
|
||||
Id = [Id stringByAppendingFormat:@",%@",md.id];
|
||||
}
|
||||
}
|
||||
QXPhotosMoveListView *listView = [[QXPhotosMoveListView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(400))];
|
||||
listView.selecctedModelBlock = ^(QXPhotoModel * _Nonnull model) {
|
||||
[QXMineNetwork photosMoveWithNewAlbumId:model.id Id:Id successBlock:^(NSDictionary * _Nonnull dict) {
|
||||
weakSelf.page = 1;
|
||||
[weakSelf getData];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
|
||||
}];
|
||||
};
|
||||
[[QXGlobal shareGlobal] showView:listView popType:(PopViewTypeBottomToUpActionSheet) tapDismiss:YES finishBlock:^{
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)deletePhoto{
|
||||
if (self.selectedArray.count == 0) {
|
||||
showToast(@"请选择图片");
|
||||
return;
|
||||
}
|
||||
NSString *Id = @"";
|
||||
for (QXPhotoModel*md in self.selectedArray) {
|
||||
if (Id.length == 0) {
|
||||
Id = md.id;
|
||||
}else{
|
||||
Id = [Id stringByAppendingFormat:@",%@",md.id];
|
||||
}
|
||||
}
|
||||
MJWeakSelf
|
||||
[QXMineNetwork photosDeletePictureWithId:Id successBlock:^(NSDictionary * _Nonnull dict) {
|
||||
weakSelf.page = 1;
|
||||
[weakSelf getData];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)didClickEditWith:(QXPhotoDetailModel *)model{
|
||||
MJWeakSelf
|
||||
QXCreatPhotosViewController *vc = [[QXCreatPhotosViewController alloc] init];
|
||||
vc.createSuccessBlock = ^{
|
||||
weakSelf.page = 1;
|
||||
[weakSelf getData];
|
||||
};
|
||||
vc.model = self.model;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
|
||||
return self.dataArray.count;
|
||||
}
|
||||
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||||
NSString *key = self.dataArray[section];
|
||||
NSArray *arr = self.photoDict[key];
|
||||
return arr.count;
|
||||
}
|
||||
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXImageCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXImageCollectionViewCell" forIndexPath:indexPath];
|
||||
NSString *key = self.dataArray[indexPath.section];
|
||||
NSArray *arr = self.photoDict[key];
|
||||
QXPhotoModel*md = arr[indexPath.row];
|
||||
cell.model = md;
|
||||
cell.selectedState = self.isSelectedState;
|
||||
return cell;
|
||||
}
|
||||
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
|
||||
if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
|
||||
QXPhotosSectionView *sectionView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"QXPhotosSectionView" forIndexPath:indexPath];
|
||||
NSString *key = self.dataArray[indexPath.section];
|
||||
sectionView.titleLabel.text = key;
|
||||
return sectionView;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
if (self.isSelectedState) {
|
||||
NSString *key = self.dataArray[indexPath.section];
|
||||
NSArray *arr = self.photoDict[key];
|
||||
QXPhotoModel*md = arr[indexPath.row];
|
||||
md.isSelected = !md.isSelected;
|
||||
if (md.isSelected) {
|
||||
[self.selectedArray addObject:md];
|
||||
}else{
|
||||
[self.selectedArray removeObject:md];
|
||||
}
|
||||
QXImageCollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
|
||||
cell.model = md;
|
||||
}else{
|
||||
YBImageBrowser *browser = [YBImageBrowser new];
|
||||
[self.browserArray removeAllObjects];
|
||||
NSString *key = self.dataArray[indexPath.section];
|
||||
NSArray *arr = self.photoDict[key];
|
||||
QXPhotoModel*model = arr[indexPath.row];
|
||||
NSInteger currentPage = 0;
|
||||
for (int i = 0 ;i < self.model.image_list.count ; i++) {
|
||||
QXPhotoModel*md = self.model.image_list[i];
|
||||
YBIBImageData *data = [[YBIBImageData alloc] init];
|
||||
data.imageURL = [NSURL URLWithString:md.image];
|
||||
QXImageCollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
|
||||
data.projectiveView = cell.imageView;
|
||||
[self.browserArray addObject:data];
|
||||
if ([md.id isEqualToString:model.id]) {
|
||||
currentPage = i;
|
||||
}
|
||||
}
|
||||
browser.dataSourceArray = self.browserArray;
|
||||
browser.currentPage = currentPage;
|
||||
[browser show];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)uploadAction{
|
||||
[self selectAlbumPhoto];
|
||||
}
|
||||
-(void)selectAlbumPhoto {
|
||||
TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:9 columnNumber:4 delegate:nil pushPhotoPickerVc:YES];
|
||||
imagePickerVc.allowCameraLocation = NO;
|
||||
imagePickerVc.allowPickingOriginalPhoto = NO;
|
||||
imagePickerVc.showSelectedIndex = YES;
|
||||
imagePickerVc.allowTakeVideo = NO;
|
||||
imagePickerVc.allowPickingVideo = NO;
|
||||
imagePickerVc.showSelectBtn = NO;
|
||||
imagePickerVc.allowCrop = NO;
|
||||
imagePickerVc.allowPickingGif = NO;
|
||||
MJWeakSelf
|
||||
[imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
|
||||
[weakSelf.uploadArray removeAllObjects];
|
||||
[weakSelf.keyArray removeAllObjects];
|
||||
for (int i = 0 ;i < assets.count ;i ++) {
|
||||
PHAsset*asset = assets[i];
|
||||
[[TZImageManager manager] getOriginalPhotoDataWithAsset:asset completion:^(NSData *data, NSDictionary *info, BOOL isDegraded) {
|
||||
// NSString *imageType = [NSString contentTypeWithImageData:data];
|
||||
// NSData *imgData = data;
|
||||
// if ([imageType isEqualToString:@"HEIC"] || [imageType isEqualToString:@"HEIF"] || [imageType isEqualToString:@"tiff"] || [imageType isEqualToString:@"webp"]) {
|
||||
UIImage *dataImg = [UIImage imageWithData:data];
|
||||
NSData *imgData = UIImageJPEGRepresentation(dataImg, 0.5);
|
||||
// }
|
||||
[weakSelf.uploadArray addObject:imgData];
|
||||
[weakSelf.keyArray addObject:[weakSelf imagePathWithKey:[NSString contentTypeWithImageData:imgData]]];
|
||||
if (weakSelf.uploadArray.count == assets.count) {
|
||||
[weakSelf OSSUploadPhoto];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
}];
|
||||
imagePickerVc.modalPresentationStyle = UIModalPresentationFullScreen;
|
||||
[imagePickerVc.navigationBar setBackgroundImage:[UIImage qx_imageWithColor:RGB16(0x333333)] forBarMetrics:UIBarMetricsDefault];
|
||||
[self presentViewController:imagePickerVc animated:YES completion:nil];
|
||||
}
|
||||
- (void)OSSUploadPhoto{
|
||||
__weak typeof(self)weakSelf = self;
|
||||
showLoadingInView(self.view);
|
||||
[[QXOSSManager sharedInstance] activityUploadFile:self.uploadArray withObjectKey:self.keyArray isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
dispatch_async_and_wait(dispatch_get_main_queue(), ^{
|
||||
[weakSelf.urlArray removeAllObjects];
|
||||
hideLoadingInView(weakSelf.view);
|
||||
if (state == UploadImageSuccess) {
|
||||
showToast(QXText(@"上传成功"));
|
||||
for (int i = 0; i < names.count; i++) {
|
||||
NSString *name = names[i];
|
||||
NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,name];
|
||||
[weakSelf.urlArray addObject:fileUrl];
|
||||
}
|
||||
[weakSelf uploadImages];
|
||||
}else{
|
||||
showToast(QXText(@"上传失败"));
|
||||
}
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)uploadImages{
|
||||
if (self.urlArray.count == 0) {
|
||||
return;
|
||||
}
|
||||
MJWeakSelf
|
||||
showLoadingInView(self.view);
|
||||
NSString *images = [self.urlArray componentsJoinedByString:@","];
|
||||
[QXMineNetwork addPhotosWithAlbumId:self.albumId images:images successBlock:^(NSDictionary * _Nonnull dict) {
|
||||
hideLoadingInView(weakSelf.view);
|
||||
weakSelf.page = 1;
|
||||
[weakSelf getData];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
hideLoadingInView(weakSelf.view);
|
||||
}];
|
||||
}
|
||||
- (NSString *)imagePathWithKey:(NSString *)keyPath {
|
||||
NSString *fileBasePath = IMG_FILE_BASE_PATH;
|
||||
return [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,keyPath];
|
||||
}
|
||||
|
||||
-(NSMutableArray *)valueArray{
|
||||
if (!_valueArray) {
|
||||
_valueArray = [NSMutableArray array];
|
||||
}
|
||||
return _valueArray;
|
||||
}
|
||||
-(NSMutableArray *)uploadArray{
|
||||
if (!_uploadArray) {
|
||||
_uploadArray = [NSMutableArray array];
|
||||
}
|
||||
return _uploadArray;
|
||||
}
|
||||
-(NSMutableArray *)keyArray{
|
||||
if (!_keyArray) {
|
||||
_keyArray = [NSMutableArray array];
|
||||
}
|
||||
return _keyArray;
|
||||
}
|
||||
-(NSMutableArray *)urlArray{
|
||||
if (!_urlArray) {
|
||||
_urlArray = [NSMutableArray array];
|
||||
}
|
||||
return _urlArray;
|
||||
}
|
||||
-(NSMutableDictionary *)photoDict{
|
||||
if (!_photoDict) {
|
||||
_photoDict = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return _photoDict;
|
||||
}
|
||||
-(NSMutableArray *)selectedArray{
|
||||
if (!_selectedArray) {
|
||||
_selectedArray = [NSMutableArray array];
|
||||
}
|
||||
return _selectedArray;
|
||||
}
|
||||
-(NSMutableArray *)browserArray{
|
||||
if (!_browserArray) {
|
||||
_browserArray = [NSMutableArray array];
|
||||
}
|
||||
return _browserArray;
|
||||
}
|
||||
-(UIButton *)uploadBtn{
|
||||
if (!_uploadBtn) {
|
||||
_uploadBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-48-16, SCREEN_HEIGHT-86-48, 48, 48)];
|
||||
[_uploadBtn setImage:[UIImage imageNamed:@"photos_upload"] forState:(UIControlStateNormal)];
|
||||
[_uploadBtn addTarget:self action:@selector(uploadAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
}
|
||||
return _uploadBtn;
|
||||
}
|
||||
|
||||
-(QXPhotosToolsView *)toolsView{
|
||||
if (!_toolsView) {
|
||||
_toolsView = [[QXPhotosToolsView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, TabbarContentHeight)];
|
||||
_toolsView.backgroundColor = [UIColor whiteColor];
|
||||
_toolsView.delegate = self;
|
||||
}
|
||||
return _toolsView;
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// QXUserHomePageViewController.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/12.
|
||||
//
|
||||
|
||||
#import "QXBaseViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXUserHomePageViewController : QXBaseViewController
|
||||
@property (nonatomic,strong)NSString *user_id;
|
||||
@property (nonatomic,assign)BOOL isGiftWall;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
186
QXLive/Mine(音域)/Controller/个人主页/QXUserHomePageViewController.m
Normal file
186
QXLive/Mine(音域)/Controller/个人主页/QXUserHomePageViewController.m
Normal file
@@ -0,0 +1,186 @@
|
||||
//
|
||||
// QXUserHomePageViewController.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/12.
|
||||
//
|
||||
|
||||
#import "QXUserHomePageViewController.h"
|
||||
#import "QXUserHomeHeaderView.h"
|
||||
#import <JXPagingView/JXPagerView.h>
|
||||
#import <JXCategoryView/JXCategoryView.h>
|
||||
#import "QXUserDynamicView.h"
|
||||
#import "QXUserGiftWallView.h"
|
||||
#import "QXUserPhotosView.h"
|
||||
#import <SDCycleScrollView/SDCycleScrollView.h>
|
||||
#import "QXCreatPhotosViewController.h"
|
||||
#import "QXMineNetwork.h"
|
||||
#import "QXPhotosDetailVC.h"
|
||||
|
||||
@interface QXUserHomePageViewController ()<JXCategoryViewDelegate,JXPagerViewDelegate,SDCycleScrollViewDelegate>
|
||||
@property (nonatomic,strong)UIImageView * backgourdImageView;
|
||||
@property (nonatomic,strong)SDCycleScrollView * cycleScrollView;
|
||||
@property (nonatomic,strong)UIButton *backBtn;
|
||||
@property (nonatomic,strong)QXUserHomeHeaderView *headerView;
|
||||
@property (nonatomic, strong) JXPagerView *pagingView;
|
||||
@property (nonatomic, strong) UIView *sectionView;
|
||||
@property (nonatomic, strong) JXCategoryTitleView *categoryView;
|
||||
@property (nonatomic, strong) NSArray <NSString *> *titles;
|
||||
@property (nonatomic, assign)CGRect cycleScrollViewFrame;
|
||||
@end
|
||||
|
||||
@implementation QXUserHomePageViewController
|
||||
|
||||
- (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.navigationController.navigationBar.backgroundColor = [UIColor clearColor];
|
||||
}
|
||||
- (void)initSubViews{
|
||||
self.cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, self.view.width, 121+NavContentHeight+16) delegate:self placeholderImage:[UIImage imageNamed:@"user_header_placehoulder"]];
|
||||
|
||||
self.cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
|
||||
self.cycleScrollView.imageURLStringsGroup = @[@"user_header_placehoulder"];
|
||||
self.cycleScrollView.backgroundColor = QXConfig.themeColor;
|
||||
[self.view addSubview:self.cycleScrollView];
|
||||
|
||||
self.backgourdImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"user_header_placehoulder"]];
|
||||
self.backgourdImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
self.backgourdImageView.frame = CGRectMake(0, 0, self.view.width, 121+NavContentHeight+16);
|
||||
self.cycleScrollViewFrame = self.backgourdImageView.frame;
|
||||
[self.view addSubview:self.backgourdImageView];
|
||||
|
||||
self.titles = @[QXText(@"动态"),QXText(@"礼物墙"),QXText(@"我的相册")];
|
||||
_categoryView = [[JXCategoryTitleView alloc] init];
|
||||
self.categoryView.frame = CGRectMake(0, 0, 200, 48);
|
||||
self.categoryView.titles = self.titles;
|
||||
self.categoryView.delegate = self;
|
||||
self.categoryView.titleSelectedColor = QXConfig.textColor;
|
||||
self.categoryView.titleColor = RGB16(0x666666);
|
||||
self.categoryView.titleFont = [UIFont boldSystemFontOfSize:12];
|
||||
self.categoryView.titleSelectedFont = [UIFont boldSystemFontOfSize:16];
|
||||
self.categoryView.titleColorGradientEnabled = YES;
|
||||
self.categoryView.titleLabelZoomEnabled = YES;
|
||||
self.categoryView.cellWidth = JXCategoryViewAutomaticDimension;
|
||||
self.categoryView.cellSpacing = 12;
|
||||
if (self.isGiftWall) {
|
||||
self.categoryView.defaultSelectedIndex = 1;
|
||||
}
|
||||
self.categoryView.backgroundColor = [UIColor clearColor];
|
||||
JXCategoryIndicatorImageView *indicatorView = [[JXCategoryIndicatorImageView alloc] init];
|
||||
indicatorView.indicatorImageView.image = [UIImage imageNamed:@"home_slider"];
|
||||
indicatorView.indicatorImageViewSize = CGSizeMake(30, 8);
|
||||
indicatorView.verticalMargin = 11;
|
||||
self.categoryView.indicators = @[indicatorView];
|
||||
self.sectionView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 48)];
|
||||
self.sectionView.backgroundColor = RGB16(0xf6f6f6);
|
||||
[self.sectionView addSubview:self.categoryView];
|
||||
_pagingView = [[JXPagerView alloc] initWithDelegate:self];
|
||||
_pagingView.mainTableView.backgroundColor = [UIColor clearColor];
|
||||
self.pagingView.backgroundColor = [UIColor clearColor];
|
||||
[self.view addSubview:self.pagingView];
|
||||
|
||||
self.categoryView.listContainer = (id<JXCategoryViewListContainer>)self.pagingView.listContainerView;
|
||||
|
||||
self.navigationController.interactivePopGestureRecognizer.enabled = (self.categoryView.selectedIndex == 0);
|
||||
|
||||
|
||||
// self.backBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, kSafeAreaTop, 40, 40)];
|
||||
// [self.backBtn setImage:[UIImage imageNamed:@"back"] forState:(UIControlStateNormal)];
|
||||
// [self.backBtn addTarget:self action:@selector(backAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
// [self.view addSubview:self.backBtn];
|
||||
[self getUserInfo];
|
||||
}
|
||||
- (void)viewDidLayoutSubviews {
|
||||
[super viewDidLayoutSubviews];
|
||||
|
||||
self.pagingView.frame = CGRectMake(0, NavContentHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavContentHeight);
|
||||
}
|
||||
-(void)getUserInfo{
|
||||
MJWeakSelf
|
||||
[QXMineNetwork userHomePageWithUserId:self.user_id successBlock:^(QXUserHomeModel * _Nonnull userModel) {
|
||||
weakSelf.headerView.model = userModel;
|
||||
NSArray *imgs;
|
||||
if (userModel.home_bgimages.length > 0) {
|
||||
imgs = [userModel.home_bgimages componentsSeparatedByString:@","];
|
||||
}
|
||||
if (imgs.count == 0) {
|
||||
weakSelf.backgourdImageView.hidden = NO;
|
||||
[weakSelf.backgourdImageView sd_setImageWithURL:[NSURL URLWithString:userModel.avatar] placeholderImage:[UIImage imageNamed:@"user_header_placehoulder"]];
|
||||
weakSelf.cycleScrollView.hidden = YES;
|
||||
}else if(imgs.count == 1){
|
||||
weakSelf.backgourdImageView.hidden = NO;
|
||||
[weakSelf.backgourdImageView sd_setImageWithURL:[NSURL URLWithString:imgs.firstObject] placeholderImage:[UIImage imageNamed:@"user_header_placehoulder"]];
|
||||
weakSelf.cycleScrollView.hidden = YES;
|
||||
}else{
|
||||
weakSelf.cycleScrollView.hidden = NO;
|
||||
weakSelf.backgourdImageView.hidden = YES;
|
||||
weakSelf.cycleScrollView.imageURLStringsGroup = imgs;
|
||||
}
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
|
||||
}];
|
||||
}
|
||||
#pragma mark - JXPagingViewDelegate
|
||||
|
||||
- (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
|
||||
return self.headerView;
|
||||
}
|
||||
- (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
|
||||
return 215;
|
||||
}
|
||||
|
||||
- (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
|
||||
return 48;
|
||||
}
|
||||
- (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
|
||||
return self.sectionView;
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView {
|
||||
return self.titles.count;
|
||||
}
|
||||
|
||||
- (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
|
||||
if (index == 0) {
|
||||
QXUserDynamicView *dynamicView = [[QXUserDynamicView alloc] init];
|
||||
dynamicView.user_id = self.user_id;
|
||||
dynamicView.backgroundColor = RGB16(0xf6f6f6);
|
||||
return dynamicView;
|
||||
}else if(index == 1){
|
||||
QXUserGiftWallView *giftWallView = [[QXUserGiftWallView alloc] init];
|
||||
giftWallView.backgroundColor = RGB16(0xf6f6f6);
|
||||
giftWallView.user_id = self.user_id;
|
||||
return giftWallView;
|
||||
}else{
|
||||
QXUserPhotosView *photosView = [[QXUserPhotosView alloc] init];
|
||||
photosView.user_id = self.user_id;
|
||||
photosView.backgroundColor = RGB16(0xf6f6f6);
|
||||
return photosView;
|
||||
}
|
||||
}
|
||||
-(void)pagerView:(JXPagerView *)pagerView mainTableViewDidScroll:(UIScrollView *)scrollView{
|
||||
CGFloat contentOffsetY = scrollView.contentOffset.y;
|
||||
if (contentOffsetY > 0) {
|
||||
return;
|
||||
}
|
||||
CGRect frame = self.cycleScrollViewFrame;
|
||||
frame.size.height -= contentOffsetY;
|
||||
// frame.origin.y = contentOffsetY;
|
||||
self.backgourdImageView.frame = frame;
|
||||
}
|
||||
-(QXUserHomeHeaderView *)headerView{
|
||||
if (!_headerView) {
|
||||
_headerView = [[QXUserHomeHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 215)];
|
||||
}
|
||||
return _headerView;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user