125 lines
6.0 KiB
Objective-C
125 lines
6.0 KiB
Objective-C
//
|
|
// QXPhotosDetailTopView.m
|
|
// QXLive
|
|
//
|
|
// Created by 启星 on 2025/6/5.
|
|
//
|
|
|
|
#import "QXPhotosDetailTopView.h"
|
|
#import "QXMineNetwork.h"
|
|
#import "QXCreatPhotosViewController.h"
|
|
|
|
@interface QXPhotosDetailTopView()
|
|
@property (nonatomic,strong)UIImageView*bgImageView;
|
|
@property (nonatomic,strong)UIView*coverView;
|
|
@property (nonatomic,strong)UILabel*titleLabel;
|
|
@property (nonatomic,strong)UIButton*editBtn;
|
|
@property (nonatomic,strong)UIButton*countBtn;
|
|
|
|
@property (nonatomic,strong)UIButton*likeBtn;
|
|
@property (nonatomic,strong)UIButton*seeBtn;
|
|
@end
|
|
@implementation QXPhotosDetailTopView
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
{
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
[self initSubview];
|
|
}
|
|
return self;
|
|
}
|
|
-(void)initSubview{
|
|
self.bgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height)];
|
|
self.bgImageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
self.bgImageView.clipsToBounds = YES;
|
|
[self addSubview:self.bgImageView];
|
|
|
|
// self.coverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height)];
|
|
// self.coverView.backgroundColor = RGB16A(0xffffff, 0.65);
|
|
// [self addSubview:self.coverView];
|
|
UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
|
|
UIVisualEffectView *blurView = [[UIVisualEffectView alloc] initWithEffect:effect];
|
|
UIVibrancyEffect *vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:effect];
|
|
UIVisualEffectView *vibrancyView = [[UIVisualEffectView alloc] initWithEffect:vibrancyEffect];
|
|
vibrancyView.frame = self.bgImageView.frame;
|
|
[blurView.contentView addSubview:vibrancyView];
|
|
blurView.frame = self.bgImageView.frame;
|
|
[self.bgImageView addSubview:blurView];
|
|
|
|
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, (self.height-25)/2, self.width, 25)];
|
|
self.titleLabel.font = [UIFont boldSystemFontOfSize:18];
|
|
self.titleLabel.textColor = RGB16(0x333333);
|
|
self.titleLabel.textAlignment = NSTextAlignmentCenter;
|
|
[self addSubview:self.titleLabel];
|
|
|
|
self.editBtn = [[UIButton alloc] initWithFrame:CGRectMake((self.height-45)/2, 0, 45, 45)];
|
|
self.editBtn.centerY = self.titleLabel.centerY;
|
|
[self.editBtn setImage:[[UIImage imageNamed:@"photo_eidt"] imageByTintColor:RGB16(0x666666)] forState:(UIControlStateNormal)];
|
|
[self.editBtn addTarget:self action:@selector(editAction) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self addSubview:self.editBtn];
|
|
|
|
self.countBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, self.titleLabel.bottom+2, self.width, 25)];
|
|
[self.countBtn setTitleColor:RGB16(0x666666) forState:(UIControlStateNormal)];
|
|
[self.countBtn setTitle:[NSString localizedStringWithFormat:QXText(@"%@张照片"),@"0"] forState:(UIControlStateNormal)];
|
|
self.countBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
[self addSubview:self.countBtn];
|
|
|
|
self.likeBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, self.height-40-5, self.width/2, 40)];
|
|
[self.likeBtn setImage:[UIImage imageNamed:@"photos_like"] forState:(UIControlStateNormal)];
|
|
[self.likeBtn setImage:[[UIImage imageNamed:@"photos_like"] imageByTintColor:RGB16(0xFB4344)] forState:(UIControlStateSelected)];
|
|
[self.likeBtn setTitleColor:RGB16(0x333333) forState:(UIControlStateNormal)];
|
|
self.likeBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
[self.likeBtn setTitle:@" 0" forState:(UIControlStateNormal)];
|
|
[self.likeBtn addTarget:self action:@selector(likeAction) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self addSubview:self.likeBtn];
|
|
|
|
self.seeBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.width/2, self.height-40-5, self.width/2, 40)];
|
|
[self.seeBtn setImage:[UIImage imageNamed:@"photos_see"] forState:(UIControlStateNormal)];
|
|
[self.seeBtn setTitleColor:RGB16(0x333333) forState:(UIControlStateNormal)];
|
|
self.seeBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
[self.seeBtn setTitle:@" 0" forState:(UIControlStateNormal)];
|
|
[self addSubview:self.seeBtn];
|
|
}
|
|
|
|
-(void)editAction{
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickEditWith:)]) {
|
|
[self.delegate didClickEditWith:self.model];
|
|
}
|
|
}
|
|
-(void)likeAction{
|
|
MJWeakSelf
|
|
[QXMineNetwork photosLikeWithAlbumId:self.model.id successBlock:^(NSDictionary * _Nonnull dict) {
|
|
weakSelf.likeBtn.selected = !weakSelf.likeBtn.selected;
|
|
if (weakSelf.likeBtn.selected) {
|
|
[weakSelf.likeBtn setTitle:[NSString stringWithFormat:@" %ld", weakSelf.likeBtn.titleLabel.text.integerValue+1] forState:UIControlStateNormal];
|
|
}else{
|
|
[weakSelf.likeBtn setTitle:[NSString stringWithFormat:@" %ld", weakSelf.likeBtn.titleLabel.text.integerValue-1] forState:UIControlStateNormal];
|
|
}
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
|
|
}];
|
|
}
|
|
-(void)setIsMe:(BOOL)isMe{
|
|
_isMe = isMe;
|
|
self.editBtn.hidden = !isMe;
|
|
}
|
|
-(void)setModel:(QXPhotoDetailModel *)model{
|
|
_model = model;
|
|
[self.bgImageView sd_setImageWithURL:[NSURL URLWithString:model.image]];
|
|
self.titleLabel.text = model.name;
|
|
self.likeBtn.selected = model.is_like.intValue == 1;
|
|
[self.titleLabel sizeToFit];
|
|
self.titleLabel.frame = CGRectMake((self.width-self.titleLabel.width)/2, (self.height-25)/2, self.titleLabel.width, 25);
|
|
self.editBtn.frame = CGRectMake(self.titleLabel.right, self.titleLabel.top-10, 45, 45);
|
|
if (model.pwd.length > 0) {
|
|
[self.countBtn setImage:[UIImage imageNamed:@"photos_lock_state"] forState:(UIControlStateNormal)];
|
|
}else{
|
|
[self.countBtn setImage:nil forState:(UIControlStateNormal)];
|
|
}
|
|
[self.countBtn setTitle:[NSString localizedStringWithFormat:QXText(@"%@张照片"),model.count] forState:(UIControlStateNormal)];
|
|
[self.likeBtn setTitle:[NSString stringWithFormat:@" %@",model.like_num] forState:(UIControlStateNormal)];
|
|
[self.seeBtn setTitle:[NSString stringWithFormat:@" %@",model.read_num] forState:(UIControlStateNormal)];
|
|
}
|
|
@end
|