涂鸦礼物完成

This commit is contained in:
fengshuo
2022-08-23 18:01:34 +08:00
parent fb823c0147
commit 7efc8bd87f
12 changed files with 406 additions and 29 deletions

View File

@@ -845,6 +845,7 @@
E8E20BE828169BDC0033B688 /* XPMineLoginPasswordPresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = E8E20BE728169BDC0033B688 /* XPMineLoginPasswordPresenter.m */; };
E8E20BEC2816A5B90033B688 /* XPMineBlackListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E8E20BEB2816A5B90033B688 /* XPMineBlackListViewController.m */; };
E8E20BEF2816A5FC0033B688 /* XPMineBlackListTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E8E20BEE2816A5FC0033B688 /* XPMineBlackListTableViewCell.m */; };
E8E21A9B28B4BD92008F7C9D /* XPRoomGraffitiGiftAnimationView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8E21A9A28B4BD92008F7C9D /* XPRoomGraffitiGiftAnimationView.m */; };
E8E5E18B27C332EE00F457D8 /* XPHomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E8E5E18A27C332EE00F457D8 /* XPHomeViewController.m */; };
E8E5E18E27C3331E00F457D8 /* XPHomeRecommendViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E8E5E18D27C3331E00F457D8 /* XPHomeRecommendViewController.m */; };
E8E5E19127C369F000F457D8 /* XPHomeRecommendListView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8E5E19027C369F000F457D8 /* XPHomeRecommendListView.m */; };
@@ -2619,6 +2620,8 @@
E8E20BEB2816A5B90033B688 /* XPMineBlackListViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineBlackListViewController.m; sourceTree = "<group>"; };
E8E20BED2816A5FC0033B688 /* XPMineBlackListTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineBlackListTableViewCell.h; sourceTree = "<group>"; };
E8E20BEE2816A5FC0033B688 /* XPMineBlackListTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineBlackListTableViewCell.m; sourceTree = "<group>"; };
E8E21A9928B4BD92008F7C9D /* XPRoomGraffitiGiftAnimationView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomGraffitiGiftAnimationView.h; sourceTree = "<group>"; };
E8E21A9A28B4BD92008F7C9D /* XPRoomGraffitiGiftAnimationView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomGraffitiGiftAnimationView.m; sourceTree = "<group>"; };
E8E5E18927C332EE00F457D8 /* XPHomeViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPHomeViewController.h; sourceTree = "<group>"; };
E8E5E18A27C332EE00F457D8 /* XPHomeViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPHomeViewController.m; sourceTree = "<group>"; };
E8E5E18C27C3331E00F457D8 /* XPHomeRecommendViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPHomeRecommendViewController.h; sourceTree = "<group>"; };
@@ -4968,6 +4971,8 @@
E8998D7F28597B0300C68558 /* XPRoomLuckyBigPrizeView.m */,
E838D99E275E1BF60079E0B5 /* XPRoomAnimationView.h */,
E838D99F275E1BF60079E0B5 /* XPRoomAnimationView.m */,
E8E21A9928B4BD92008F7C9D /* XPRoomGraffitiGiftAnimationView.h */,
E8E21A9A28B4BD92008F7C9D /* XPRoomGraffitiGiftAnimationView.m */,
9BC9DAED27E33B3F009EE409 /* XPRoomGiftAnimationParser.h */,
9BC9DAEE27E33B3F009EE409 /* XPRoomGiftAnimationParser.m */,
);
@@ -8119,6 +8124,7 @@
9BE9F10227FEE5C200667200 /* XPAnchorFansTaskDetailModel.m in Sources */,
E8E0DAE6285C280E00566A2F /* XPSessionFindNewAlertView.m in Sources */,
E86596542701A55500846EBD /* StatisticsServiceHelper.m in Sources */,
E8E21A9B28B4BD92008F7C9D /* XPRoomGraffitiGiftAnimationView.m in Sources */,
E8E70D8C26F2F5A500F03460 /* XPMineHeadItemCollectionViewCell.m in Sources */,
E883E82E28153BDF0000005D /* XPGuildAnchorIncomeSectionView.m in Sources */,
9B17F71827BD150600440843 /* SVGAParserManager.m in Sources */,

View File

@@ -86,6 +86,8 @@ typedef NS_ENUM(NSUInteger, CustomMessageType) {
CustomMessageType_Task_Complete = 92,
///礼物合成
CustomMessageType_Gift_Compound = 93,
///涂鸦礼物
CustomMessageType_Graffiti_Gift = 94,
};
@@ -458,6 +460,12 @@ typedef NS_ENUM(NSUInteger, CustomMessageGiftCompound) {
Custom_Message_Sub_Gift_Compound = 931,
};
///first = CustomMessageType_Graffiti_Gift
typedef NS_ENUM(NSUInteger, CustomMessageGraffitiGift) {
///涂鸦礼物
Custom_Message_Sub_Graffiti_Gift = 941,
};
@interface AttachmentModel : NSObject<NIMCustomAttachment>
@property (nonatomic,assign) int first;
@property (nonatomic,assign) int second;

View File

@@ -17,6 +17,7 @@ typedef NS_ENUM(NSUInteger, GiftType) {
GiftType_LuckyPool = 5, //福袋奖池礼物
GiftType_Noble = 7, // 贵族礼物
GiftType_WeekStar = 8, //周星礼物
GiftType_Graffiti = 10, //涂鸦礼物
};
//礼物类型

View File

@@ -62,12 +62,14 @@
NSArray *luckyPoolGift = [GiftInfoModel modelsWithArray:data.data[@"luckyPoolGift"]];//
NSArray *normalGift = [GiftInfoModel modelsWithArray:data.data[@"normalGift"]]; //
NSArray *weekStarGift = [GiftInfoModel modelsWithArray:data.data[@"weekStarGift"]]; //
NSArray *drawGift = [GiftInfoModel modelsWithArray:data.data[@"drawGift"]]; //
NSMutableArray *info = [NSMutableArray array];
NSMutableArray *totalInfo = [NSMutableArray array];
[info addObjectsFromArray:luckyBagGift];
[info addObjectsFromArray:vipGift];
[info addObjectsFromArray:normalGift];
[info addObjectsFromArray:weekStarGift];
[info addObjectsFromArray:drawGift];
[totalInfo addObjectsFromArray:info];
[totalInfo addObjectsFromArray:luckyPoolGift];
///

View File

@@ -23,7 +23,8 @@
#import "XPWeekStarInfoView.h"
@interface XPGiftInfoView ()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, XPWeekStarInfoViewDelegate, XPGiftWeekStarCollectionViewCellDelegate>
///
///
@property (nonatomic,strong) UIScrollView *scrollView;
@property (nonatomic,strong) UIStackView *segmentStackView;
///
@property (nonatomic,strong) UIButton *normalGiftButton;
@@ -131,8 +132,10 @@
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.segmentStackView];
[self addSubview:self.scrollView];
[self addSubview:self.giftStackView];
[self.scrollView addSubview:self.segmentStackView];
///
[self.segmentStackView addArrangedSubview:self.normalGiftButton];
[self.segmentStackView addArrangedSubview:self.luckyGiftButton];
@@ -154,9 +157,12 @@
[self mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(30 + 108 * 2 + 10 + 10 + 15);
}];
[self.segmentStackView mas_makeConstraints:^(MASConstraintMaker *make) {
[self.segmentStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.bottom.leading.trailing.height.mas_equalTo(self.scrollView);
}];
[self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self).inset(15);
make.top.mas_equalTo(self);
make.height.mas_equalTo(30);
@@ -394,6 +400,10 @@
if (self.delegate && [self.delegate respondsToSelector:@selector(xPGiftInfoView:didClickSegment:)]) {
[self.delegate xPGiftInfoView:self didClickSegment:_segmentType];
}
if (self.delegate && [self.delegate respondsToSelector:@selector(xPGiftInfoView:didClickItem:type:)]) {
[self.delegate xPGiftInfoView:self didClickItem:self.lastSelectGift type:_segmentType];
}
}
- (void)setNormalOriginArray:(NSArray *)normalOriginArray {
@@ -402,6 +412,7 @@
NSMutableArray * normaleArray = [NSMutableArray array];
NSMutableArray * nobleArray = [NSMutableArray array];
NSMutableArray * weekStarArray = [NSMutableArray array];
NSMutableArray * graffiti = [NSMutableArray array];
[_normalOriginArray enumerateObjectsUsingBlock:^(GiftInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if (obj.giftType == GiftType_Lucky) {
[luckyArray addObject:obj];
@@ -411,13 +422,15 @@
[nobleArray addObject:obj];
} else if (obj.giftType == GiftType_WeekStar) {
[weekStarArray addObject:obj];
}
} else if (obj.giftType == GiftType_Graffiti) {
[graffiti addObject:obj];
}
}];
self.giftArray = normaleArray;
self.giftLuckyArray = luckyArray;
self.giftNobleArray = nobleArray;
self.giftWeekStarArray = weekStarArray;
self.giftGraffitiArray = luckyArray;
self.giftGraffitiArray = graffiti;
if (self.defaultSelectGiftId.length) {
for (GiftInfoModel *gift in self.normalOriginArray) {
if (gift.giftId == [self.defaultSelectGiftId integerValue]) {
@@ -469,6 +482,7 @@
_usingplaceType = usingplaceType;
if (_usingplaceType == SendGiftType_User) {
self.luckyGiftButton.hidden = YES;
self.graffitiButton.hidden = YES;
}
}
@@ -669,5 +683,14 @@
return _datasource;
}
- (UIScrollView *)scrollView {
if (!_scrollView) {
_scrollView = [[UIScrollView alloc] init];
_scrollView.backgroundColor = [UIColor clearColor];
_scrollView.showsHorizontalScrollIndicator = NO;
}
return _scrollView;
}
@end

View File

@@ -8,9 +8,24 @@
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class XPGraffitiGiftView;
@protocol XPGraffitiGiftViewDelegate <NSObject>
///点击切换
- (void)xPGraffitiGiftView:(XPGraffitiGiftView *)view didClickChange:(UILabel *)sender;
///点击了关闭
- (void)xPGraffitiGiftView:(XPGraffitiGiftView *)view didClickClose:(UIButton *)sender;
///绘画完成了
- (void)xPGraffitiGiftView:(XPGraffitiGiftView *)view didDrawCompletion:(NSArray *)pointArray;
@end
@interface XPGraffitiGiftView : UIView
@property (nonatomic,strong) UIImage *image;
///代理
@property (nonatomic,weak) id<XPGraffitiGiftViewDelegate> delegate;
///价格
@property (nonatomic,assign) double price;
///动画的数据
@property (nonatomic,strong) NSArray *animationArray;
@end
NS_ASSUME_NONNULL_END

View File

@@ -11,10 +11,14 @@
///Tool
#import "ThemeColor.h"
#import "XPMacro.h"
#import "XCHUDTool.h"
#import "XPHomeGradientLabel.h"
@interface XPGraffitiGiftView ()
///
@property (nonatomic,strong) UIView * contentView;
///view
@property (nonatomic,strong) UIView * drawView;
///
@property (nonatomic,strong) UIStackView *tipsStackView;
///🏻
@@ -28,23 +32,27 @@
///
@property (nonatomic,strong) UIStackView *toolStackView;
///
@property (nonatomic,strong) UIButton *changeButton;
@property (nonatomic,strong) XPHomeGradientLabel *changeButton;
///
@property (nonatomic,strong) UIButton *repealButton;
///
@property (nonatomic,strong) UIButton *deleteButton;
///
@property (nonatomic,strong) UIButton *closeButton;
///point
@property (nonatomic,assign) CGPoint panPoint;
///
///point
@property (nonatomic,assign) CGPoint beginPoint;
///
///
@property (nonatomic,assign) CGFloat step;
///
@property (nonatomic,strong) NSMutableArray *datasource;
///
@property (nonatomic,assign) int index;
///
@property (nonatomic,assign) BOOL isShowMaxToast;
@property (nonatomic,strong) NSMutableArray<UIImageView *> *viewsArray;
@property (nonatomic,strong) NSMutableArray<NSNumber *> *indexArray;
@property (nonatomic,strong) NSMutableArray<NSArray<NSNumber *> *> *pointArray;
@end
@implementation XPGraffitiGiftView
@@ -60,12 +68,15 @@
#pragma mark - Private Method
- (void)initSubViews {
self.step = 20;
self.isShowMaxToast = YES;
self.step = 10;
UIPanGestureRecognizer * panGes = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panAction:)];
[self addGestureRecognizer:panGes];
self.backgroundColor = [UIColor clearColor];
[self addSubview:self.contentView];
[self.contentView addSubview:self.tipsStackView];
[self.contentView addSubview:self.drawView];
[self.contentView addSubview:self.toolView];
[self.tipsStackView addArrangedSubview:self.handImageView];
@@ -98,6 +109,11 @@
make.width.mas_equalTo(KScreenWidth);
}];
[self.drawView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.contentView).offset(kSafeAreaTopHeight);
make.left.right.mas_equalTo(self.contentView);
make.bottom.mas_equalTo(self.toolView.mas_top);
}];
[self.handImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(78, 93));
@@ -142,12 +158,23 @@
UITouch *touch = touches.anyObject;
CGPoint point = [touch locationInView:self.contentView];
self.beginPoint = point;
NSLog(@"beginPoint:X:%.2f, Y:%.2f", point.x, point.y);
}
- (void)panAction:(UIPanGestureRecognizer *)tap {
if (self.pointArray.count >= 300) {
if (self.isShowMaxToast) {
[XCHUDTool showErrorWithMessage:@"最多只能画300个呦"];
self.isShowMaxToast = YES;
}
return;
}
if (tap.state == UIGestureRecognizerStateBegan) {
[self.indexArray addObject:[NSNumber numberWithInteger:self.viewsArray.count]];
} else if(tap.state == UIGestureRecognizerStateEnded) {
self.isShowMaxToast = YES;
}
CGPoint point = [tap translationInView:self.contentView];
NSLog(@"panAction:X:%.2f, Y:%.2f", point.x, point.y);
CGFloat dx = [self myAbs:point.x - self.panPoint.x];
CGFloat dy = [self myAbs:point.y - self.panPoint.y];
CGPoint drawPoint = CGPointMake(self.beginPoint.x + point.x , self.beginPoint.y + point.y);
@@ -171,24 +198,63 @@
imageView.layer.masksToBounds = YES;
imageView.image = self.image;
imageView.frame = CGRectMake(point.x, point.y, 20, 20);
[self.contentView addSubview:imageView];
[self.drawView addSubview:imageView];
[self.viewsArray addObject:imageView];
[self.pointArray addObject:@[@([self changeWidthDraw:point.x]), @([self changeHeightDraw:point.y])]];
[self cratePriceAttribute];
if (self.pointArray.count > 10 && self.delegate && [self.delegate respondsToSelector:@selector(xPGraffitiGiftView:didDrawCompletion:)]) {
[self.delegate xPGraffitiGiftView:self didDrawCompletion:self.pointArray];
}
}
#pragma mark - Event Response
- (void)changeButtonAction:(UIButton *)sender {
- (NSInteger)changeWidthDraw:(CGFloat)number {
return number / KScreenWidth * 1000;
}
- (NSInteger)changeHeightDraw:(CGFloat)number {
return number / KScreenHeight * 1000;
}
#pragma mark - Event Response
- (void)changeButtonAction{
if (self.delegate && [self.delegate respondsToSelector:@selector(xPGraffitiGiftView:didClickChange:)]) {
[self.delegate xPGraffitiGiftView:self didClickChange:self.changeButton];
}
}
- (void)repealButtonAction:(UIButton *)sender {
NSInteger index = [self.indexArray lastObject].integerValue;
if (index < self.viewsArray.count) {
NSArray<UIImageView *> * array = [self.viewsArray subarrayWithRange:NSMakeRange(index, self.viewsArray.count - index)];
NSArray * array2 = [self.pointArray subarrayWithRange:NSMakeRange(index, self.pointArray.count - index)];
[self.pointArray removeObjectsInArray:array2];
[self.viewsArray removeObjectsInArray:array];
if (array.count) {
[array makeObjectsPerformSelector:@selector(removeFromSuperview)];
}
[self.indexArray removeLastObject];
}
}
- (void)deleteButtonAction:(UIButton *)sender {
[self.viewsArray makeObjectsPerformSelector:@selector(removeFromSuperview)];
[self.pointArray removeAllObjects];
[self.indexArray removeAllObjects];
}
- (void)closeButtonAction:(UIButton *)sender {
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;
}
#pragma mark - Getters And Setters
@@ -200,6 +266,14 @@
return _contentView;
}
- (UIView *)drawView {
if (!_drawView) {
_drawView = [[UIView alloc] init];
_drawView.backgroundColor = [UIColor clearColor];
}
return _drawView;
}
- (UIStackView *)tipsStackView {
if (!_tipsStackView) {
_tipsStackView = [[UIStackView alloc] init];
@@ -262,13 +336,15 @@
return _toolStackView;
}
- (UIButton *)changeButton {
- (XPHomeGradientLabel *)changeButton {
if (!_changeButton) {
_changeButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_changeButton setTitle:@"切换涂鸦" forState:UIControlStateNormal];
[_changeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
_changeButton.titleLabel.font = [UIFont systemFontOfSize:12];
[_changeButton addTarget:self action:@selector(changeButtonAction:) forControlEvents:UIControlEventTouchUpInside];
_changeButton = [[XPHomeGradientLabel alloc] init];
_changeButton.font = [UIFont systemFontOfSize:12];
_changeButton.gradientColor = @[(id)UIColorFromRGB(0x33ECFF).CGColor, (id)UIColorFromRGB(0x57CF99).CGColor];
_changeButton.text = @"切换涂鸦";
_changeButton.userInteractionEnabled = YES;
UITapGestureRecognizer * tap= [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(changeButtonAction)];
[_changeButton addGestureRecognizer:tap];
}
return _changeButton;
}
@@ -303,5 +379,25 @@
return _closeButton;
}
- (NSMutableArray *)indexArray {
if (!_indexArray) {
_indexArray = [NSMutableArray array];
}
return _indexArray;
}
- (NSMutableArray *)pointArray {
if (!_pointArray) {
_pointArray = [NSMutableArray array];
}
return _pointArray;
}
- (NSMutableArray *)viewsArray {
if (!_viewsArray) {
_viewsArray = [NSMutableArray array];
}
return _viewsArray;
}
@end

View File

@@ -40,7 +40,7 @@
#import "XPFirstRechargeViewController.h"
#import "XPNobleCenterViewController.h"
@interface XPSendGiftView ()< XPGiftBarViewDelegate, XPGiftProtocol, XPGiftInfoViewDelegate>
@interface XPSendGiftView ()< XPGiftBarViewDelegate, XPGiftProtocol, XPGiftInfoViewDelegate, XPGraffitiGiftViewDelegate>
///
@property (nonatomic,strong) UIView * topView;
///
@@ -66,6 +66,10 @@
///
@property (nonatomic,assign) int packGiftRetryCount;
@property (nonatomic,strong) NSArray<XPGiftUserInfoModel *> *userArray;
///
@property (nonatomic,strong) NSArray *graffitiPoint;
///
@property (nonatomic,assign) GiftSegmentType segmentType;
@end
@implementation XPSendGiftView
@@ -130,6 +134,19 @@
}
#pragma mark - Send Custom Message
- (void)sendGraffitiGiftMessage {
if (self.segmentType == GiftSegmentType_Graffiti && self.graffitiPoint.count > 0) {
AttachmentModel * attachment = [[AttachmentModel alloc] init];
attachment.first = CustomMessageType_Graffiti_Gift;
attachment.second = Custom_Message_Sub_Graffiti_Gift;
NSMutableDictionary * dic = [NSMutableDictionary dictionary];
[dic setValue:@(self.giftInfoView.lastSelectGift.giftId) forKey:@"giftId"];
[dic setValue:self.graffitiPoint forKey:@"drawFixedArray"];
attachment.data = dic;
[self sendCustomMessage:attachment];
}
}
- (void)sendCustomMessage:(GiftReceiveInfoModel *)receiveModel oringinDic:(NSDictionary *)originDic {
NSDictionary * dict = originDic;
if (receiveModel.roomSendGiftType == RoomSendGiftType_AllMic) { //
@@ -381,6 +398,7 @@
}
- (void)xPGiftInfoView:(XPGiftInfoView *)view didClickSegment:(GiftSegmentType)type {
self.segmentType = type;
self.giftBarView.type = type;
}
@@ -403,6 +421,7 @@
if (type == GiftSegmentType_Graffiti) {
self.giftInfoView.hidden = YES;
self.graffitiView.hidden = NO;
self.graffitiView.price = info.goldPrice;
[[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;
@@ -413,6 +432,25 @@
}
}
#pragma mark - XPGraffitiGiftViewDelegate
- (void)xPGraffitiGiftView:(XPGraffitiGiftView *)view didClickClose:(UIButton *)sender {
[UIView animateWithDuration:0.2 animations:^{
self.graffitiView.hidden = YES;
self.giftInfoView.hidden = NO;
}];
}
- (void)xPGraffitiGiftView:(XPGraffitiGiftView *)view didClickChange:(UIButton *)sender {
[UIView animateWithDuration:0.2 animations:^{
self.graffitiView.hidden = YES;
self.giftInfoView.hidden = NO;
}];
}
- (void)xPGraffitiGiftView:(XPGraffitiGiftView *)view didDrawCompletion:(NSArray *)pointArray {
self.graffitiPoint = pointArray;
}
#pragma mark - XPGiftProtocol
- (void)onGetUserInfoSuccess:(UserInfoModel *)userInfo {
self.giftBarView.isShowFirstRecharge = userInfo.isFirstCharge;
@@ -459,6 +497,13 @@
[self.presenter getUserWallInfo];
}
[self sendCustomMessage:receiveInfo oringinDic:originDic];
///
[self sendGraffitiGiftMessage];
if (self.segmentType == GiftSegmentType_Graffiti) {
NSString * title = [NSString stringWithFormat:@"发送涂鸦礼物:%@成功",self.giftInfoView.lastSelectGift.giftName];
[self showSuccessToast:title];
[self dismissViewControllerAnimated:YES completion:nil];
}
}
///
@@ -573,6 +618,7 @@
if (!_graffitiView) {
_graffitiView = [[XPGraffitiGiftView alloc] init];
_graffitiView.hidden = YES;
_graffitiView.delegate = self;
}
return _graffitiView;
}

View File

@@ -14,6 +14,7 @@
#import "QGVAPConfigModel.h"
#import "UIView+VAP.h"
#import <YYText/YYText.h>
#import <UIImageView+WebCache.h>
///Tool
#import "XPGiftStorage.h"
#import "XPMacro.h"
@@ -53,8 +54,9 @@
#import "XPRoomLuckyBigPrizeView.h"
#import "XPRoomGiftCompoundView.h"
#import "XPSailingAnimationView.h"
#import "XPRoomGraffitiGiftAnimationView.h"
@interface XPRoomAnimationView ()<SVGAPlayerDelegate,NIMBroadcastManagerDelegate, XPRoomGiftBroadcastViewDelegate, HWDMP4PlayDelegate, XPRoomLuckyBigPrizeViewDelegate,XPRoomLicneseHourRankViewDelegate>
@interface XPRoomAnimationView ()<SVGAPlayerDelegate,NIMBroadcastManagerDelegate, XPRoomGiftBroadcastViewDelegate, HWDMP4PlayDelegate, XPRoomLuckyBigPrizeViewDelegate,XPRoomLicneseHourRankViewDelegate, XPRoomGraffitiGiftAnimationViewDelegate>
///
///
@property (nonatomic,strong) XPRoomAnimationHitView * lowLevelView;
@@ -124,6 +126,8 @@
@property (nonatomic, strong) NSMutableArray<AcrossRoomPKPrizeModel *> *acrossRoomPKQueue;
#pragma mark -
@property (nonatomic, strong) NSMutableArray<AttachmentModel *> *sailingQueue;
#pragma mark -
@property (nonatomic, strong) NSMutableArray<AttachmentModel *> *graffitiGiftQueue;
///
@property (nonatomic,assign) BOOL isLuckyGiftAnimation;
@end
@@ -277,6 +281,8 @@
[self receiveGiftCompound:attachment];
} else if(attachment.first == CustomMessageType_Room_Sailing) {
[self receiveRoomSailing:attachment];
} else if(attachment.first == CustomMessageType_Graffiti_Gift) {///
[self receiveRoomGraffitiGift:attachment];
}
}
}
@@ -298,6 +304,57 @@
[self userEnterRoom:content ext:extModel];
}
}
#pragma mark -
- (void)receiveRoomGraffitiGift:(AttachmentModel *)attacment {
if (self.graffitiGiftQueue.count == 0) {
[self startGraffitiGiftAnimation:attacment];
}
[self.graffitiGiftQueue addObject:attacment];
}
- (void)startGraffitiGiftAnimation:(AttachmentModel *)model {
NSDictionary * dic = model.data;
NSNumber * giftId = dic[@"giftId"];
GiftInfoModel * giftInfo = [[XPGiftStorage shareStorage] findGiftInfo:giftId.stringValue];
NSArray * array = dic[@"drawFixedArray"];
if (giftInfo.giftUrl.length > 0 && array.count > 0) {
[[SDWebImageManager sharedManager] loadImageWithURL:[NSURL URLWithString:giftInfo.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) {
XPRoomGraffitiGiftAnimationView *graffitiView = [[XPRoomGraffitiGiftAnimationView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
graffitiView.giftImage = image;
graffitiView.delegate = self;
graffitiView.model = model;
graffitiView.pointArray = array;
[graffitiView beginDrawAnimation];
[self.highLevleView addSubview:graffitiView];
} else {
[self.graffitiGiftQueue removeObject:model];
if (self.graffitiGiftQueue.count > 0) {
[self startGraffitiGiftAnimation:self.graffitiGiftQueue.firstObject];
}
}
}];
} else {
[self.graffitiGiftQueue removeObject:model];
if (self.graffitiGiftQueue.count > 0) {
[self startGraffitiGiftAnimation:self.graffitiGiftQueue.firstObject];
}
}
}
- (void)xPRoomGraffitiGiftAnimationViewCompletion:(XPRoomGraffitiGiftAnimationView *)view attachment:(nonnull AttachmentModel *)attachment{
[view removeFromSuperview];
if ([self.graffitiGiftQueue containsObject:attachment]) {
[self.graffitiGiftQueue removeObject:attachment];
}
if (self.graffitiGiftQueue.count > 0) {
[self startGraffitiGiftAnimation:self.graffitiGiftQueue.firstObject];
}
}
#pragma mark - PK
- (void)acrossRoomPKBannerAnimation:(AttachmentModel *)attacment {
AcrossRoomPKPrizeModel * prizeModel = [AcrossRoomPKPrizeModel modelWithJSON:attacment.data];
@@ -1822,5 +1879,12 @@
return _sailingQueue;
}
- (NSMutableArray<AttachmentModel *> *)graffitiGiftQueue {
if (!_graffitiGiftQueue) {
_graffitiGiftQueue = [NSMutableArray array];
}
return _graffitiGiftQueue;
}
@end

View File

@@ -0,0 +1,31 @@
//
// XPRoomGraffitiGiftAnimationView.h
// xplan-ios
//
// Created by 冯硕 on 2022/8/23.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class XPRoomGraffitiGiftAnimationView, AttachmentModel;
@protocol XPRoomGraffitiGiftAnimationViewDelegate <NSObject>
///动画完成
- (void)xPRoomGraffitiGiftAnimationViewCompletion:(XPRoomGraffitiGiftAnimationView *)view attachment:(AttachmentModel *)attachment;
@end
@interface XPRoomGraffitiGiftAnimationView : UIView
@property (nonatomic,strong) UIImage *giftImage;
///代理
@property (nonatomic,weak) id<XPRoomGraffitiGiftAnimationViewDelegate> delegate;
@property (nonatomic,strong) NSArray *pointArray;
@property (nonatomic,strong) AttachmentModel *model;
///开始涂鸦动画
- (void)beginDrawAnimation;
///结束涂鸦动画
- (void)endDrawAnimation;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,82 @@
//
// XPRoomGraffitiGiftAnimationView.m
// xplan-ios
//
// Created by on 2022/8/23.
//
#import "XPRoomGraffitiGiftAnimationView.h"
#import "XPWeakTimer.h"
#import "XPMacro.h"
@interface XPRoomGraffitiGiftAnimationView ()
@property (nonatomic,strong) NSTimer *timer;
@property (nonatomic,assign) int index;
///
@property (nonatomic,strong) NSMutableArray *datasource;
@end
@implementation XPRoomGraffitiGiftAnimationView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.timer = [XPWeakTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(dramGraffitiAnimationView) userInfo:@"" repeats:YES];
}
return self;
}
- (void)beginDrawAnimation {
self.index = 0;
for (int i = 0; i < self.pointArray.count; i++) {
NSArray * pointArray = self.pointArray[i];
NSNumber * first = [pointArray firstObject];
NSNumber * second = [pointArray lastObject];
CGFloat x = first.floatValue / 1000.0 * KScreenWidth;
CGFloat y = second.floatValue / 1000.0 * KScreenHeight;
if (x <= 0 || x >= KScreenWidth || y <= 0 || y >= KScreenHeight) {
continue;
}
CGPoint point = CGPointMake(x, y);
[self.datasource addObject:[NSValue valueWithCGPoint:point]];
}
self.timer.fireDate = NSDate.distantPast;
}
- (void)endDrawAnimation {
self.timer.fireDate = NSDate.distantFuture;
[self.datasource removeAllObjects];
self.index = 0;
}
- (void)dramGraffitiAnimationView {
if (self.index > (self.datasource.count -1)) {
self.timer.fireDate = NSDate.distantFuture;
[self.datasource removeAllObjects];
self.index = 0;
[self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
if (self.delegate && [self.delegate respondsToSelector:@selector(xPRoomGraffitiGiftAnimationViewCompletion:attachment:)]) {
[self.delegate xPRoomGraffitiGiftAnimationViewCompletion:self attachment:self.model];
}
return;
}
NSValue * valeu= [self.datasource objectAtIndex:self.index];
CGPoint point = valeu.CGPointValue;
UIImageView * imageView = [[UIImageView alloc] init];
imageView.layer.masksToBounds = YES;
imageView.contentMode = UIViewContentModeScaleAspectFill;
imageView.image = self.giftImage;
imageView.frame = CGRectMake(point.x, point.y, 20, 20);
[self addSubview:imageView];
self.index++;
}
- (NSMutableArray *)datasource {
if (!_datasource) {
_datasource = [NSMutableArray array];
}
return _datasource;
}
@end

View File

@@ -618,6 +618,7 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出
if (!self.menuContainerView.superview) {
[self.view addSubview:self.menuContainerView];
}
[self.view bringSubviewToFront:self.animationView];
[self updateViewConstraintsOnAnchorRoom];
[self changeStageViewOnAnchorRoom];
@@ -893,6 +894,7 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出
[self.anchorScrollView addSubview:self.roomHeaderView];
[self.anchorScrollView addSubview:self.functionView];
[self.anchorScrollView addSubview:self.menuContainerView];
[self.view bringSubviewToFront:self.animationView];
[self updateViewConstraintsOnAnchorRoom];
[self changeStageViewOnAnchorRoom];
@@ -1481,6 +1483,7 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出
if (!self.menuContainerView.superview) {
[self.view addSubview:self.menuContainerView];
}
[self.view bringSubviewToFront:self.animationView];
[self updateViewConstraintsOnAnchorRoom];
[self changeStageViewOnAnchorRoom];