Files
peko-ios/YuMi/Modules/YMRoom/View/CandyTree/View/XPCandyTreeViewController.m
2023-11-01 20:42:47 +08:00

692 lines
26 KiB
Objective-C

//
// XPCandyTreeViewController.m
// xplan-ios
//
// Created by 冯硕 on 2021/12/9.
//
#import "XPCandyTreeViewController.h"
///Third
#import <Masonry/Masonry.h>
#import <SVGA.h>
#import <NIMSDK/NIMSDK.h>
///Tool
#import "TTPopup.h"
///Model
#import "RoomInfoModel.h"
#import "AttachmentModel.h"
#import "CandyTreeInfoModel.h"
#import "CandyTreeResultModel.h"
#import "UserInfoModel.h"
#import "PICandyTreeSetModel.h"
///View
#import "XPRoomHalfWebView.h"
#import "XPCandyTreeMoreView.h"
#import "XPCandyRankContainerView.h"
#import "XPCandyTreeGiftView.h"
#import "XPMineUserInfoViewController.h"
#import "XCCurrentVCStackManager.h"
#import "XPCandyTreeInsufficientBalanceView.h"
#import "XPWebViewController.h"
#import "XPCandyTreeBuyView.h"
#import "XPCandyTreeConfirmBuyView.h"
#import "XPCandyTreeBuySuccessView.h"
///P
#import "XPCandyTreePresenter.h"
#import "XPCandyTreeProtocol.h"
#import "Api+Room.h"
#define KitemHeight (20 + 5)
UIKIT_EXTERN NSString * const kRoomReceivedCandyNotificationKey;
@interface XPCandyTreeViewController ()<XPCandyTreeInsufficientBalanceViewDelegate,XPCandyRankContainerViewDelegate,XPCandyTreeProtocol, NIMSystemNotificationManagerDelegate,XPCandyTreeBuyViewDelegate,XPCandyTreeConfirmBuyViewDelegate>
@property(nonatomic,strong) UIButton *backView;
///中间内容的容器
@property (nonatomic,strong) UIImageView * bgImageView;
///排行榜
@property (nonatomic,strong) UIImageView * rankImageView;
///获得糖果
@property (nonatomic,strong) UIImageView *moreImageView;
///动画管理类
@property (strong, nonatomic) SVGAParser *parser;
///糖果树魔天輪
@property (nonatomic,strong) UIImageView *candyTreeView;
///送礼物的特效
@property (nonatomic,strong) SVGAImageView *candyTreeLightView;
///糖果树开启特效
@property (nonatomic,strong) SVGAImageView *candyTreeOpenView;
///光
@property (nonatomic,strong) SVGAImageView *candyTreeTransView;
///寻爱一次
@property(nonatomic,strong) UIButton *fristLoveBtn;
///寻爱十次
@property(nonatomic,strong) UIButton *tenthLoveBtn;
///寻爱百次
@property(nonatomic,strong) UIButton *hundredthLoveBtn;
///动画的容器
@property (nonatomic,strong) UIView * animationView;
///糖果的信息
@property (nonatomic,strong) CandyTreeInfoModel *candyInfo;
///host代理
@property (nonatomic,weak) id<RoomHostDelegate>hostDelegate;
///是否正在采摘
@property (nonatomic,assign) BOOL isPicking;
@property(nonatomic,strong) XPCandyTreeBuyView *buyView;
@property(nonatomic,strong) PICandyTreeSetModel *setModel;
@end
@implementation XPCandyTreeViewController
- (void)dealloc {
[[NIMSDK sharedSDK].systemNotificationManager removeDelegate:self];
[[NSNotificationCenter defaultCenter]postNotificationName:kRoomReceivedCandyNotificationKey object:nil userInfo:@{@"isHidden":@(YES)}];
}
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
if (self = [super init]) {
self.hostDelegate = delegate;
[[NIMSDK sharedSDK].systemNotificationManager addDelegate:self];
}
return self;
}
- (XPCandyTreePresenter *)createPresenter {
return [[XPCandyTreePresenter alloc] init];
}
- (BOOL)isHiddenNavBar {
return YES;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self initSubViews];
[self initSubViewConstraints];
[self.presenter getCandyTreeInfo];
[self.presenter getLoveSettingInfo];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[self.view endEditing:YES];
}
#pragma mark -XPCandyRankContainerViewDelegate
- (void)didClickHeadHandle:(NSInteger)uid{
[TTPopup dismiss];
XPMineUserInfoViewController * userInfoVC = [[XPMineUserInfoViewController alloc] init];
userInfoVC.uid = uid;
[self.hostDelegate.getCurrentNav pushViewController:userInfoVC animated:YES];
}
#pragma mark - XPCandyTreeProtocol
- (void)getCandyTreeInfoSuccess:(CandyTreeInfoModel *)info {
[self hideHUD];
self.candyInfo = info;
}
-(void)getLoveSettingInfoSuccess:(PICandyTreeSetModel *)setModel{
self.setModel = setModel;
self.buyView.num = self.setModel.ticketNum;
}
- (void)buyLoveTicketSuccessWithNum:(NSString *)num{
NSString *time = [NSDate getNowTimeTimestamp];
NSString *curTime = [NSDate timestampSwitchTime:[time integerValue] andFormatter:@"yyyy-MM-dd"];
NSDictionary *timeDic = [[NSUserDefaults standardUserDefaults]valueForKey:@"kBuyLoveNumSuccessNoPrompt"];
BOOL isShow = YES;
if(timeDic != nil){
isShow = timeDic[curTime] == nil;
}
if(isShow == NO){
[self.presenter getLoveSettingInfo];
return;
};
XPCandyTreeBuySuccessView *successView = [[XPCandyTreeBuySuccessView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
successView.num = num;
[TTPopup popupView:successView style:TTPopupStyleAlert];
[self.presenter getLoveSettingInfo];
}
- (void)pickCandyFail {
[self hideHUD];
self.isPicking = NO;
}
-(void)pickCandyPay{
[self hideHUD];
self.isPicking = NO;
XPCandyTreeInsufficientBalanceView *balanceView = [[XPCandyTreeInsufficientBalanceView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
balanceView.delegate = self;
[self.view addSubview:balanceView];
}
- (void)pickCandySuccess:(NSArray<CandyTreeGiftInfoModel *> *)result {
[self hideHUD];
self.isPicking = NO;
[self.presenter getLoveSettingInfo];
[result enumerateObjectsUsingBlock:^(CandyTreeGiftInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if (obj.level > 0) {
///取消所有的延迟加载的方法
[NSObject cancelPreviousPerformRequestsWithTarget:self];
XPCandyTreeGiftView * newAnimaView = [[XPCandyTreeGiftView alloc] init];
newAnimaView.giftInfo = obj;
newAnimaView.frame = CGRectMake(0, 0,200,kGetScaleWidth(18));
[self.animationView addSubview:newAnimaView];
if (self.animationView.subviews.count > 5) {
[self.animationView.subviews.firstObject removeFromSuperview];
}
for (int i=0; i < self.animationView.subviews.count; i++) {
XPCandyTreeGiftView * view = [self.animationView.subviews safeObjectAtIndex1:i];
NSInteger offsetY= (self.animationView.subviews.count - i) * kGetScaleWidth(23);
[UIView animateWithDuration:0.1 animations:^{
CGRect rect = view.frame;
rect.origin.y = kGetScaleWidth(23) * 5 - offsetY;
view.frame = rect;
} completion:^(BOOL finished) {
if (i == (self.animationView.subviews.count -1)) {
[self.animationView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[self performSelector:@selector(giftViewRemoveFromSuperView:) withObject:obj afterDelay:3];
}];
}
}];
}
}
}];
@kWeakify(self);
NSString * lightName = [NSString stringWithFormat:@"https://image.hfighting.com/candyTree_light.svga"];
NSString *baseFileName = @"/GiftSvga";
NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:lightName];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:filePath]){
NSData *data=[NSData dataWithContentsOfFile:filePath options:0 error:NULL];
[self.parser parseWithData:data cacheKey:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
if (videoItem != nil) {
self.candyTreeLightView.loops = 1;
self.candyTreeLightView.clearsAfterStop = YES;
self.candyTreeLightView.videoItem = videoItem;
[self.candyTreeLightView startAnimation];
}
} failureBlock:^(NSError * _Nonnull error) {
}];
}else{
[self.parser parseWithURL:[NSURL URLWithString:lightName] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
@kStrongify(self);
self.candyTreeLightView.loops = 1;
self.candyTreeLightView.clearsAfterStop = YES;
self.candyTreeLightView.videoItem = videoItem;
[self.candyTreeLightView startAnimation];
} failureBlock:^(NSError * _Nonnull error) {
}];
};
NSString * openName = [NSString stringWithFormat:@"https://image.hfighting.com/candyTree_open.svga"];
NSString *openFilePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:openName];
if ([fileManager fileExistsAtPath:openFilePath]){
NSData *data=[NSData dataWithContentsOfFile:openFilePath options:0 error:NULL];
[self.parser parseWithData:data cacheKey:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
if (videoItem != nil) {
self.candyTreeOpenView.loops = 1;
self.candyTreeOpenView.clearsAfterStop = YES;
self.candyTreeOpenView.videoItem = videoItem;
[self.candyTreeOpenView startAnimation];
}
} failureBlock:^(NSError * _Nonnull error) {
}];
}else{
[self.parser parseWithURL:[NSURL URLWithString:lightName] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
@kStrongify(self);
self.candyTreeOpenView.loops = 1;
self.candyTreeOpenView.clearsAfterStop = YES;
self.candyTreeOpenView.videoItem = videoItem;
[self.candyTreeOpenView startAnimation];
} failureBlock:^(NSError * _Nonnull error) {
}];
};
NSString * transformName = [NSString stringWithFormat:@"https://image.hfighting.com/candyTree_transform.svga"];
NSString *transformFilePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:transformName];
if ([fileManager fileExistsAtPath:transformFilePath]){
NSData *data=[NSData dataWithContentsOfFile:transformFilePath options:0 error:NULL];
[self.parser parseWithData:data cacheKey:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
if (videoItem != nil) {
self.candyTreeTransView.loops = 1;
self.candyTreeTransView.clearsAfterStop = YES;
self.candyTreeTransView.videoItem = videoItem;
[self.candyTreeTransView startAnimation];
}
} failureBlock:^(NSError * _Nonnull error) {
}];
}else{
[self.parser parseWithURL:[NSURL URLWithString:lightName] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
@kStrongify(self);
self.candyTreeTransView.loops = 1;
self.candyTreeTransView.clearsAfterStop = YES;
self.candyTreeTransView.videoItem = videoItem;
[self.candyTreeTransView startAnimation];
self.candyTreeTransView.backgroundColor = [UIColor redColor];
} failureBlock:^(NSError * _Nonnull error) {
}];
};
}
#pragma mark - NIMSystemNotificationManagerDelegate
- (void)onReceiveCustomSystemNotification:(NIMCustomSystemNotification *)notification {
if (notification.receiverType == NIMSessionTypeP2P) {
AttachmentModel *attachment = [AttachmentModel modelWithJSON:notification.content];
if (attachment.first == CustomMessageType_Account && attachment.second == Custom_Message_Sub_Account_Changed){
if (attachment.second == Custom_Message_Sub_Account_Changed) {
[self.presenter getCandyTreeInfo];
}
}
}
}
#pragma mark - Private Method
- (void)initSubViews {
[[NSNotificationCenter defaultCenter]postNotificationName:kRoomReceivedCandyNotificationKey object:nil userInfo:@{@"isHidden":@(NO)}];
self.view.backgroundColor = [UIColor clearColor];
[self.view addSubview:self.backView];
[self.view addSubview:self.bgImageView];
[self.bgImageView addSubview:self.rankImageView];
[self.bgImageView addSubview:self.moreImageView];
[self.bgImageView addSubview:self.candyTreeView];
[self.bgImageView addSubview:self.fristLoveBtn];
[self.bgImageView addSubview:self.tenthLoveBtn];
[self.bgImageView addSubview:self.hundredthLoveBtn];
[self.bgImageView addSubview:self.candyTreeLightView];
[self.bgImageView addSubview:self.candyTreeOpenView];
[self.bgImageView addSubview:self.candyTreeTransView];
[self.bgImageView addSubview:self.animationView];
[self.bgImageView addSubview:self.buyView];
// @kWeakify(self);
// [self.parser parseWithNamed:@"candyTree" inBundle:[NSBundle mainBundle] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
// @kStrongify(self);
// self.candyTreeView.loops = INT_MAX;
// self.candyTreeView.clearsAfterStop = NO;
// self.candyTreeView.videoItem = videoItem;
// [self.candyTreeView startAnimation];
// } failureBlock:^(NSError * _Nonnull error) {
//
// }];
}
- (void)initSubViewConstraints {
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view);
}];
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(311));
make.height.mas_equalTo(kGetScaleWidth(474));
make.center.equalTo(self.view);
}];
[self.rankImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(kGetScaleWidth(36));
make.leading.mas_equalTo(kGetScaleWidth(16));
make.top.mas_equalTo(kGetScaleWidth(48));
}];
[self.moreImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(30));
make.height.mas_equalTo(kGetScaleWidth(28));
make.trailing.mas_equalTo(-kGetScaleWidth(16));
make.top.mas_equalTo(kGetScaleWidth(48));
}];
[self.candyTreeView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.bgImageView).offset(kGetScaleWidth(84));
make.centerX.mas_equalTo(self.bgImageView);
make.size.mas_equalTo(CGSizeMake(kGetScaleWidth(295), kGetScaleWidth(327)));
}];
[self.candyTreeLightView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.candyTreeView);
}];
[self.candyTreeOpenView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.candyTreeView);
}];
[self.fristLoveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.candyTreeView.mas_bottom).mas_offset(-kGetScaleWidth(7));
make.leading.mas_equalTo(kGetScaleWidth(15));
make.width.mas_equalTo(kGetScaleWidth(94));
make.height.mas_equalTo(kGetScaleWidth(55));
}];
[self.tenthLoveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.candyTreeView.mas_bottom).mas_offset(-kGetScaleWidth(7));
make.leading.mas_equalTo(kGetScaleWidth(109));
make.width.mas_equalTo(kGetScaleWidth(94));
make.height.mas_equalTo(kGetScaleWidth(55));
}];
[self.hundredthLoveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.candyTreeView.mas_bottom).mas_offset(-kGetScaleWidth(7));
make.leading.mas_equalTo(kGetScaleWidth(201));
make.width.mas_equalTo(kGetScaleWidth(94));
make.height.mas_equalTo(kGetScaleWidth(55));
}];
CGFloat kscale = (CGFloat)350 / (CGFloat)755;
[self.candyTreeTransView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.candyTreeView);
make.bottom.trailing.mas_equalTo(self.view);
make.width.mas_equalTo(self.candyTreeTransView.mas_height).multipliedBy(kscale);
}];
[self.buyView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(-kGetScaleWidth(23));
make.height.mas_equalTo(kGetScaleWidth(28));
make.width.mas_equalTo(kGetScaleWidth(288));
make.centerX.equalTo(self.bgImageView);
}];
[self.animationView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(kGetScaleWidth(8));
make.bottom.mas_equalTo(self.bgImageView.mas_bottom).offset(-kGetScaleWidth(142));
make.trailing.mas_equalTo(-kGetScaleWidth(8));
make.height.mas_equalTo(kGetScaleWidth(23) * 5);
}];
}
- (void)giftViewRemoveFromSuperView:(UIView *)view {
[view removeFromSuperview];
}
#pragma mark - Event Response
- (void)moreTapRecognizer:(UITapGestureRecognizer *)tap {
UserInfoModel * userInfo = self.hostDelegate.getUserInfo;
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
XPCandyTreeMoreView * moreView = [[XPCandyTreeMoreView alloc] init];
moreView.sendMessageSwitchLevel = roomInfo.findLoveDrawSwitchVo.sendMsgLevel;
moreView.showMessageSwitch = userInfo.userLevelVo.experLevelSeq >= roomInfo.findLoveDrawSwitchVo.sendMsgLevel;
[TTPopup popupView:moreView style:TTPopupStyleActionSheet];
}
- (void)rankTapRecognizer:(UITapGestureRecognizer *)tap {
XPCandyRankContainerView * rankView = [[XPCandyRankContainerView alloc] init];
rankView.delegate = self;
[TTPopup popupView:rankView style:TTPopupStyleActionSheet];
}
#pragma mark -XPCandyTreeInsufficientBalanceViewDelegate
- (void)payBalanceAction{
XPWebViewController * webVC =[[XPWebViewController alloc] init];
webVC.url = [NSString stringWithFormat:URLWithType(kThirdPartyPay),@"4",[YYUtility deviceID]];
webVC.isPush = YES;
@kWeakify(self)
webVC.CloseWebViewBlock = ^(BOOL result){
@kStrongify(self)
[self.presenter getCandyTreeInfo];
};
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES];
}
-(void)paySuccess{
[self.presenter getLoveSettingInfo];
}
- (void)pickButtonActionWithNum:(NSInteger)num{
if (self.isPicking) return;
self.isPicking = YES;
///摘
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
NSString * candyNumber = [NSString stringWithFormat:@"%ld", num];
BOOL showMessageSwitch = self.hostDelegate.getUserInfo.userLevelVo.experLevelSeq >= roomInfo.findLoveDrawSwitchVo.sendMsgLevel;
[self.presenter pickCandy:candyNumber roomUid:roomUid isSendMessage:showMessageSwitch];
}
- (void)dismissTapRecognizer{
[[NSNotificationCenter defaultCenter]postNotificationName:kRoomReceivedCandyNotificationKey object:nil userInfo:@{@"isHidden":@(YES)}];
[self willMoveToParentViewController:nil]; //1
[self.view removeFromSuperview]; //2
[self removeFromParentViewController]; //3
}
#pragma mark - XPCandyTreeBuyViewDelegate
- (void)buyLoveNumWithNum:(NSString *)num{
NSString *time = [NSDate getNowTimeTimestamp];
NSString *curTime = [NSDate timestampSwitchTime:[time integerValue] andFormatter:@"yyyy-MM-dd"];
NSDictionary *timeDic = [[NSUserDefaults standardUserDefaults]valueForKey:@"kBuyLoveNoPrompt"];
BOOL isShow = YES;
if(timeDic != nil){
isShow = timeDic[curTime] == nil;
}
if(isShow == NO){
NSInteger price = num.integerValue * self.setModel.ticketPrice.integerValue;
if(price > self.setModel.diamond.integerValue){
[self pickCandyPay];
return;
}
if(num.integerValue <= 0){
[self showErrorToast:YMLocalizedString(@"XPCandyTreeViewController2")];
return;
}
[self.presenter buyLoveTicket:num];
return;
};
XPCandyTreeConfirmBuyView *buyView = [[XPCandyTreeConfirmBuyView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight) type:0];
buyView.delegate = self;
buyView.loveNum = num;
buyView.price = self.setModel.ticketPrice;
[TTPopup popupView:buyView style:TTPopupStyleAlert];
}
#pragma mark -XPCandyTreeConfirmBuyViewDelegate
-(void)buyLoveNumWithType:(int)type num:(NSString *)num{
NSInteger price = num.integerValue * self.setModel.ticketPrice.integerValue;
if(price > self.setModel.diamond.integerValue){
[self pickCandyPay];
return;
}
if(num.integerValue <= 0){
[self showErrorToast:YMLocalizedString(@"XPCandyTreeViewController2")];
return;
}
[self.presenter buyLoveTicket:num];
}
-(void)fineLoveAction:(UIButton *)sender{
NSInteger num = 1;
if(sender == self.fristLoveBtn){
num = 1;
}else if(sender == self.tenthLoveBtn){
num = 10;
}else{
num = 100;
}
if(self.setModel.ticketNum.integerValue >= num){
[self pickButtonActionWithNum:num];
return;
}
XPCandyTreeConfirmBuyView *buyView = [[XPCandyTreeConfirmBuyView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight) type:1];
buyView.delegate = self;
buyView.loveNum = @(num).stringValue;
buyView.price = self.setModel.ticketPrice;
[TTPopup popupView:buyView style:TTPopupStyleAlert];
}
#pragma mark - Getters And Setters
- (void)setIsPicking:(BOOL)isPicking {
_isPicking = isPicking;
}
- (UIButton *)backView{
if(!_backView){
_backView = [UIButton new];
[_backView addTarget:self action:@selector(dismissTapRecognizer) forControlEvents:UIControlEventTouchUpInside];
}
return _backView;
}
- (UIImageView *)bgImageView {
if (!_bgImageView) {
_bgImageView = [[UIImageView alloc] init];
_bgImageView.userInteractionEnabled = YES;
_bgImageView.image = [UIImage imageNamed:@"room_candy_tree_back"];
}
return _bgImageView;
}
- (UIImageView *)rankImageView {
if (!_rankImageView) {
_rankImageView = [[UIImageView alloc] init];
_rankImageView.userInteractionEnabled = YES;
_rankImageView.image = [UIImage imageNamed:@"room_candy_tree_rank"];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(rankTapRecognizer:)];
[_rankImageView addGestureRecognizer:tap];
}
return _rankImageView;
}
- (UIImageView *)moreImageView {
if (!_moreImageView) {
_moreImageView = [[UIImageView alloc] init];
_moreImageView.userInteractionEnabled = YES;
_moreImageView.image = [UIImage imageNamed:@"room_candy_tree_more"];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(moreTapRecognizer:)];
[_moreImageView addGestureRecognizer:tap];
}
return _moreImageView;
}
- (UIImageView *)candyTreeView {
if (!_candyTreeView) {
_candyTreeView = [[UIImageView alloc]init];
_candyTreeView.backgroundColor = [UIColor clearColor];
_candyTreeView.userInteractionEnabled = NO;
_candyTreeView.image = [UIImage imageNamed:@"room_candy_tree_bg"];
}
return _candyTreeView;
}
- (SVGAImageView *)candyTreeLightView {
if (!_candyTreeLightView) {
_candyTreeLightView = [[SVGAImageView alloc]init];
_candyTreeLightView.backgroundColor = [UIColor clearColor];
_candyTreeLightView.userInteractionEnabled = NO;
}
return _candyTreeLightView;
}
- (SVGAImageView *)candyTreeOpenView {
if (!_candyTreeOpenView) {
_candyTreeOpenView = [[SVGAImageView alloc]init];
_candyTreeOpenView.backgroundColor = [UIColor clearColor];
_candyTreeOpenView.userInteractionEnabled = NO;
}
return _candyTreeOpenView;
}
- (SVGAImageView *)candyTreeTransView {
if (!_candyTreeTransView) {
_candyTreeTransView = [[SVGAImageView alloc]init];
_candyTreeTransView.backgroundColor = [UIColor clearColor];
_candyTreeTransView.userInteractionEnabled = NO;
}
return _candyTreeTransView;
}
- (SVGAParser *)parser {
if (!_parser) {
_parser = [[SVGAParser alloc]init];
}
return _parser;
}
- (UIView *)animationView {
if (!_animationView) {
_animationView = [[UIView alloc] init];
_animationView.backgroundColor = [UIColor clearColor];
}
return _animationView;
}
- (UIButton *)fristLoveBtn{
if(!_fristLoveBtn){
_fristLoveBtn = [UIButton new];
[_fristLoveBtn setBackgroundImage:kImage(@"room_candy_tree_frist_tap_bg") forState:UIControlStateNormal];
[_fristLoveBtn addTarget:self action:@selector(fineLoveAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _fristLoveBtn;
}
- (UIButton *)tenthLoveBtn{
if(!_tenthLoveBtn){
_tenthLoveBtn = [UIButton new];
[_tenthLoveBtn setBackgroundImage:kImage(@"room_candy_tree_ten_tap_bg") forState:UIControlStateNormal];
[_tenthLoveBtn addTarget:self action:@selector(fineLoveAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _tenthLoveBtn;
}
- (UIButton *)hundredthLoveBtn{
if(!_hundredthLoveBtn){
_hundredthLoveBtn = [UIButton new];
[_hundredthLoveBtn setBackgroundImage:kImage(@"room_candy_tree_hundredth_tap_bg") forState:UIControlStateNormal];
[_hundredthLoveBtn addTarget:self action:@selector(fineLoveAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _hundredthLoveBtn;
}
- (XPCandyTreeBuyView *)buyView{
if(!_buyView){
_buyView = [[XPCandyTreeBuyView alloc]initWithFrame:CGRectZero];
_buyView.delegate = self;
}
return _buyView;
}
@end