礼物面板的优化
This commit is contained in:
@@ -19,6 +19,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@end
|
||||
|
||||
@interface XPGiftBarView : UIView
|
||||
///涂鸦礼物的个数
|
||||
@property (nonatomic,assign) NSInteger drawGiftCount;
|
||||
///代理
|
||||
@property (nonatomic,weak) id<XPGiftBarViewDelegate> delegate;
|
||||
///不同的tabbar
|
||||
|
@@ -28,8 +28,8 @@
|
||||
@property (nonatomic,strong) UILabel *rechargeLabel;
|
||||
///去充值
|
||||
@property (nonatomic,strong) UIImageView *rechageImageView;
|
||||
///
|
||||
@property (nonatomic,strong) UIView *sendOperationView;
|
||||
//赠送
|
||||
@property (nonatomic,strong) UIStackView *sendOperationView;
|
||||
///个数
|
||||
@property (nonatomic,strong) UILabel *countLabel;
|
||||
///箭头
|
||||
@@ -67,6 +67,9 @@
|
||||
}
|
||||
#pragma mark - Response
|
||||
- (void)sendButtonAction:(UIButton *)sender {
|
||||
if (self.type == GiftSegmentType_Graffiti && self.drawGiftCount < 10) {
|
||||
return;
|
||||
}
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(xPGiftBarView:didClickSendGift:)]) {
|
||||
[self.delegate xPGiftBarView:self didClickSendGift:self.giftCountModel];
|
||||
}
|
||||
@@ -119,9 +122,9 @@
|
||||
[self.rechargeStackView addArrangedSubview:self.rechargeLabel];
|
||||
[self.rechargeStackView addArrangedSubview:self.rechageImageView];
|
||||
|
||||
[self.sendOperationView addSubview:self.countLabel];
|
||||
[self.sendOperationView addSubview:self.arrowButton];
|
||||
[self.sendOperationView addSubview:self.sendGiftButton];
|
||||
[self.sendOperationView addArrangedSubview:self.countLabel];
|
||||
[self.sendOperationView addArrangedSubview:self.arrowButton];
|
||||
[self.sendOperationView addArrangedSubview:self.sendGiftButton];
|
||||
|
||||
[self.customCountView addSubview:self.editTextFiled];
|
||||
[self.customCountView addSubview:self.sureButton];
|
||||
@@ -153,24 +156,20 @@
|
||||
make.right.mas_equalTo(self).offset(-15);
|
||||
make.bottom.mas_equalTo(-11);
|
||||
make.height.mas_equalTo(30);
|
||||
make.left.mas_equalTo(self.countLabel.mas_left).offset(-13);
|
||||
}];
|
||||
|
||||
[self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.mas_equalTo(self.sendGiftButton);
|
||||
make.right.mas_equalTo(self.arrowButton.mas_left).offset(-2);
|
||||
make.width.mas_equalTo(40);
|
||||
make.height.mas_equalTo(30);
|
||||
}];
|
||||
|
||||
|
||||
[self.arrowButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(30, 30));
|
||||
make.centerY.mas_equalTo(self.sendGiftButton);
|
||||
make.right.mas_equalTo(self.sendGiftButton.mas_left).offset(0);
|
||||
}];
|
||||
|
||||
[self.sendGiftButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(67, 30));
|
||||
make.right.centerY.mas_equalTo(self.sendOperationView);
|
||||
}];
|
||||
|
||||
|
||||
@@ -267,6 +266,17 @@
|
||||
return NO;
|
||||
}
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setDrawGiftCount:(NSInteger)drawGiftCount {
|
||||
_drawGiftCount = drawGiftCount;
|
||||
if (_drawGiftCount >= 10) {
|
||||
self.sendGiftButton.selected = NO;
|
||||
self.sendOperationView.layer.borderWidth = 1;
|
||||
} else {
|
||||
self.sendGiftButton.selected = YES;
|
||||
self.sendOperationView.layer.borderWidth = 0;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setSendButtonIsEnable:(BOOL)sendButtonIsEnable {
|
||||
_sendButtonIsEnable = sendButtonIsEnable;
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
@@ -279,9 +289,18 @@
|
||||
}
|
||||
|
||||
- (void)setType:(GiftSegmentType)type {
|
||||
_type = type;
|
||||
if (!self.giftCountView.hidden) {
|
||||
self.giftCountView.hidden = YES;
|
||||
self.arrowButton.selected = NO;
|
||||
} else {
|
||||
if (_type == GiftSegmentType_Graffiti) {
|
||||
self.countLabel.hidden = YES;
|
||||
self.arrowButton.hidden = YES;
|
||||
} else {
|
||||
self.countLabel.hidden = NO;
|
||||
self.arrowButton.hidden = NO;
|
||||
}
|
||||
}
|
||||
self.giftCountView.segmentType = type;
|
||||
}
|
||||
@@ -345,9 +364,13 @@
|
||||
}
|
||||
|
||||
|
||||
- (UIView *)sendOperationView {
|
||||
- (UIStackView *)sendOperationView {
|
||||
if (!_sendOperationView) {
|
||||
_sendOperationView = [[UIView alloc] init];
|
||||
_sendOperationView = [[UIStackView alloc] init];
|
||||
_sendOperationView.axis = UILayoutConstraintAxisHorizontal;
|
||||
_sendOperationView.distribution = UIStackViewDistributionFill;
|
||||
_sendOperationView.alignment = UIStackViewAlignmentCenter;
|
||||
_sendOperationView.spacing = 0;
|
||||
_sendOperationView.layer.masksToBounds = YES;
|
||||
_sendOperationView.layer.cornerRadius = 15;
|
||||
_sendOperationView.layer.borderColor = [ThemeColor appMainColor].CGColor;
|
||||
@@ -356,6 +379,7 @@
|
||||
return _sendOperationView;
|
||||
}
|
||||
|
||||
|
||||
- (UILabel *)countLabel {
|
||||
if (!_countLabel) {
|
||||
_countLabel = [[UILabel alloc] init];
|
||||
@@ -363,6 +387,7 @@
|
||||
_countLabel.textColor = [ThemeColor giftCountTitleColor];
|
||||
_countLabel.text = @"1";
|
||||
_countLabel.font = [UIFont systemFontOfSize:13];
|
||||
_countLabel.textAlignment = NSTextAlignmentCenter;
|
||||
}
|
||||
return _countLabel;
|
||||
}
|
||||
@@ -384,8 +409,11 @@
|
||||
[_sendGiftButton setTitleColor:[ThemeColor confirmButtonTextColor] forState:UIControlStateNormal];
|
||||
[_sendGiftButton setTitle:@"赠送中..." forState:UIControlStateDisabled];
|
||||
[_sendGiftButton setTitleColor:[ThemeColor disableButtonTextColor] forState:UIControlStateDisabled];
|
||||
[_sendGiftButton setTitle:@"赠送" forState:UIControlStateSelected];
|
||||
[_sendGiftButton setTitleColor:[ThemeColor disableButtonTextColor] forState:UIControlStateSelected];
|
||||
[_sendGiftButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor], [ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
|
||||
[_sendGiftButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor disableButtonColor], [ThemeColor disableButtonColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateDisabled];
|
||||
[_sendGiftButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor disableButtonColor], [ThemeColor disableButtonColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateSelected];
|
||||
_sendGiftButton.titleLabel.font = [UIFont systemFontOfSize:12];
|
||||
_sendGiftButton.layer.masksToBounds = YES;
|
||||
_sendGiftButton.layer.cornerRadius = 15;
|
||||
|
@@ -214,6 +214,13 @@
|
||||
- (NSInteger)changeHeightDraw:(CGFloat)number {
|
||||
return number / KScreenHeight * 1000;
|
||||
}
|
||||
|
||||
- (void)clearData {
|
||||
[self.viewsArray makeObjectsPerformSelector:@selector(removeFromSuperview)];
|
||||
[self.viewsArray removeAllObjects];
|
||||
[self.pointArray removeAllObjects];
|
||||
[self.indexArray removeAllObjects];
|
||||
}
|
||||
#pragma mark - Event Response
|
||||
- (void)changeButtonAction{
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(xPGraffitiGiftView:didClickChange:)]) {
|
||||
@@ -232,29 +239,47 @@
|
||||
[array makeObjectsPerformSelector:@selector(removeFromSuperview)];
|
||||
}
|
||||
[self.indexArray removeLastObject];
|
||||
[self cratePriceAttribute];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(xPGraffitiGiftView:didDrawCompletion:)]) {
|
||||
[self.delegate xPGraffitiGiftView:self didDrawCompletion:self.pointArray];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)deleteButtonAction:(UIButton *)sender {
|
||||
[self.viewsArray makeObjectsPerformSelector:@selector(removeFromSuperview)];
|
||||
[self.pointArray removeAllObjects];
|
||||
[self.indexArray removeAllObjects];
|
||||
[self clearData];
|
||||
[self cratePriceAttribute];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(xPGraffitiGiftView:didDrawCompletion:)]) {
|
||||
[self.delegate xPGraffitiGiftView:self didDrawCompletion:self.pointArray];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)closeButtonAction:(UIButton *)sender {
|
||||
[self clearData];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(xPGraffitiGiftView:didDrawCompletion:)]) {
|
||||
[self.delegate xPGraffitiGiftView:self didDrawCompletion:self.pointArray];
|
||||
}
|
||||
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(xPGraffitiGiftView:didClickClose:)]) {
|
||||
[self.delegate xPGraffitiGiftView:self didClickClose:sender];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)cratePriceAttribute {
|
||||
NSString * count = [NSString stringWithFormat:@"%ld", self.viewsArray.count];
|
||||
NSString * price = [NSString stringWithFormat:@"%.0f", self.viewsArray.count * self.price];
|
||||
NSString * title = [NSString stringWithFormat:@"已画%@个,需花费%@钻石", count, price];
|
||||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14], NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
||||
[attribute addAttribute:NSForegroundColorAttributeName value:[ThemeColor appMainColor] range:[title rangeOfString:count]];
|
||||
[attribute addAttribute:NSForegroundColorAttributeName value:[ThemeColor appMainColor] range:[title rangeOfString:price]];
|
||||
self.titleLabel.attributedText = attribute;
|
||||
if (self.viewsArray.count < 10) {
|
||||
NSString * title = @"至少画10个才能送出";
|
||||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14], NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
||||
self.titleLabel.attributedText = attribute;
|
||||
} else {
|
||||
NSString * count = [NSString stringWithFormat:@"%ld", self.viewsArray.count];
|
||||
NSString * price = [NSString stringWithFormat:@"%.0f", self.viewsArray.count * self.price];
|
||||
NSString * title = [NSString stringWithFormat:@"已画%@个,需花费%@钻石", count, price];
|
||||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14], NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
||||
[attribute addAttribute:NSForegroundColorAttributeName value:[ThemeColor appMainColor] range:[title rangeOfString:count]];
|
||||
[attribute addAttribute:NSForegroundColorAttributeName value:[ThemeColor appMainColor] range:[title rangeOfString:price]];
|
||||
self.titleLabel.attributedText = attribute;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
@@ -270,6 +295,7 @@
|
||||
if (!_drawView) {
|
||||
_drawView = [[UIView alloc] init];
|
||||
_drawView.backgroundColor = [UIColor clearColor];
|
||||
_drawView.layer.masksToBounds = YES;
|
||||
}
|
||||
return _drawView;
|
||||
}
|
||||
|
@@ -287,6 +287,10 @@
|
||||
} else {
|
||||
count = model.giftNumber;
|
||||
}
|
||||
|
||||
if (self.segmentType == GiftSegmentType_Graffiti) {
|
||||
count = [NSString stringWithFormat:@"%ld", self.graffitiPoint.count];
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -422,6 +426,7 @@
|
||||
self.giftInfoView.hidden = YES;
|
||||
self.graffitiView.hidden = NO;
|
||||
self.graffitiView.price = info.goldPrice;
|
||||
self.giftBarView.drawGiftCount = 0;
|
||||
[[SDWebImageManager sharedManager] loadImageWithURL:[NSURL URLWithString:info.giftUrl] options:SDWebImageProgressiveLoad progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
|
||||
if (error == nil && image) {
|
||||
self.graffitiView.image = image;
|
||||
@@ -429,6 +434,8 @@
|
||||
self.giftInfoView.hidden = NO;
|
||||
}
|
||||
}];
|
||||
} else {
|
||||
self.giftBarView.drawGiftCount = 10;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,6 +456,7 @@
|
||||
|
||||
- (void)xPGraffitiGiftView:(XPGraffitiGiftView *)view didDrawCompletion:(NSArray *)pointArray {
|
||||
self.graffitiPoint = pointArray;
|
||||
self.giftBarView.drawGiftCount = self.graffitiPoint.count;
|
||||
}
|
||||
|
||||
#pragma mark - XPGiftProtocol
|
||||
|
Reference in New Issue
Block a user