Files
peko-ios/YuMi/Modules/YMTabbar/View/TabbarViewController.m

1058 lines
45 KiB
Mathematica
Raw Normal View History

2023-07-14 18:50:55 +08:00
//
// ViewController.m
// YUMI
//
// Created by admin on 2023/3/9.
//
#import <UIKit/UIKit.h>
///Third
#import <ReactiveObjC/ReactiveObjC.h>
#import <NIMSDK/NIMSDK.h>
#import <Masonry/Masonry.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AFNetworkReachabilityManager.h>
#import <POP.h>
2023-07-18 18:26:10 +08:00
#import <AFNetworking.h>
2023-07-14 18:50:55 +08:00
///Tool
#import "YUMIMacroUitls.h"
#import "DJDKMIMOMColor.h"
#import "UIImage+Utils.h"
#import "NSObject+MJExtension.h"
#import "XNDJTDDLoadingTool.h"
#import "AccountInfoStorage.h"
#import "TTPopup.h"
#import "YUMIConstant.h"
#import "XPRoomMiniManager.h"
#import "ClientConfig.h"
#import "RtcManager.h"
#import "XCCurrentVCStackManager.h"
#import "Api+Home.h"
#import "YUMIConstant.h"
#import "StatisticsServiceHelper.h"
#import "Api+Monents.h"
#import "XPAdImageTool.h"
#import "YYUtility.h"
#import "XPWeakTimer.h"
#import "PLTimeUtil.h"
///Model
#import "AccountModel.h"
#import "RoomInfoModel.h"
#import "AttachmentModel.h"
#import "XPMineVisitorUnReadModel.h"
#import "InviteUserInfoModel.h"
#import "NewUserGreetModel.h"
#import "FindNewGreetMessageModel.h"
#import "XPTabAnchorCardModel.h"
#import "FirstRechargeModel.h"
#import "MonentsUnReadModel.h"
#import "XPReceiveRedPacketModel.h"
#import "GiftReceiveInfoModel.h"
#import "XPVersionUpdateModel.h"
///VC
#import "TabbarViewController.h"
#import "XPBlankViewController.h"
#import "XPLoginViewController.h"
#import "BaseNavigationController.h"
#import "LoginBindPhoneViewController.h"
#import "LoginFullInfoViewController.h"
#import "XPMineViewController.h"
2023-09-22 12:20:43 +08:00
#import "XPSessionMainViewController.h"
2023-07-14 18:50:55 +08:00
#import "XPNewHomeViewController.h"
#import "XPMiniRoomView.h"
#import "XPRoomViewController.h"
#import "XPSessionFindNewAlertView.h"
#import "XPAnchorCardView.h"
#import "XPTaskCompleteTipView.h"
#import "XPWebViewController.h"
#import "XPMineUserInfoViewController.h"
#import "XPMineSimpleUserInfoViewController.h"
#import "XPMonentsRecommendViewController.h"
#import "XPMonentsViewController.h"
#import "XPReceiveRedPacketView.h"
#import "XPRoomYearActivityView.h"
#import "XPUpgradeView.h"
#import "XPMomentListViewController.h"
#import "XPHomeSloganViewController.h"
#import "XPSimpleMineViewController.h"
2023-08-14 14:39:41 +08:00
#import "XPLoginAuthCodeVC.h"
2023-07-14 18:50:55 +08:00
///Present
#import "MainPresenter.h"
#import "MainProtocol.h"
#import "RoomHostDelegate.h"
#import "XPSkillCardPlayerManager.h"
#import "PIFullScreenBannerAnimation.h"
#import <SVGA.h>
2023-07-18 18:26:10 +08:00
#import "Api+Gift.h"
2023-07-14 18:50:55 +08:00
UIKIT_EXTERN NSString * kUserCompleteInfoFinishKey;
NSString * const kUserFirstLoginKey = @"kUserFirstLoginKey";
NSString * const kHadLaunchApp = @"kHadLaunchApp";
NSString * const kLastShowAnchorCardTime = @"kLastShowAnchorCardTime";
NSString * const kNetworkReachabilityKey = @"kNetworkReachabilityKey";
UIKIT_EXTERN NSString * kNewUserRechargeKey;
UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
2023-08-14 14:39:41 +08:00
@interface TabbarViewController () <BaseMvpProtocol, MainProtocol, NIMLoginManagerDelegate, NIMSystemNotificationManagerDelegate, NIMChatManagerDelegate,XPLoginAuthCodeVCDelegate, XPAnchorCardViewDelegate, NIMBroadcastManagerDelegate, XPRoomYearActivityViewDelegate>
2023-07-14 18:50:55 +08:00
{
NSTimer * timer;
}
@property (nonatomic, strong) MainPresenter *presenter;
///
@property (nonatomic,strong) XPMiniRoomView *roomMineView;
///
@property (nonatomic,copy) NSString *inviteCode;
///
@property (nonatomic, assign) BOOL needShowNewUserRecharge;
///(
@property (nonatomic, assign) BOOL needShowAnchorCard;
///
@property (nonatomic, assign) BOOL delayShowAnchorCard;
///
@property (nonatomic, strong) XPAnchorCardView *anchorCardView;
///
@property (nonatomic, strong) XPTaskCompleteTipView *taskTipView;
///广
@property (nonatomic,strong) NSMutableArray<GiftReceiveInfoModel *> *giftBroadcastQueue;
///
@property (nonatomic, assign) BOOL parentMode;
///
@property (nonatomic,assign) BOOL isFirstReachability;
///
@property (nonatomic,assign) BOOL isReload;
2023-09-27 12:35:29 +08:00
///
@property (nonatomic,assign) BOOL isInitReload;
2023-07-14 18:50:55 +08:00
///
@property(nonatomic,strong) PIFullScreenBannerAnimation *roomAnimation;
2023-08-14 19:03:26 +08:00
2023-07-21 14:07:04 +08:00
2023-07-14 18:50:55 +08:00
@end
@implementation TabbarViewController
- (void)viewDidLoad {
2023-07-18 18:26:10 +08:00
[super viewDidLoad];
2023-09-12 17:48:18 +08:00
2023-09-14 11:16:47 +08:00
2023-07-14 18:50:55 +08:00
[self configTheme];
[self initTabs:NO];
2023-07-18 18:26:10 +08:00
[[ClientConfig shareConfig] clientInit];
2023-07-14 18:50:55 +08:00
[[NIMSDK sharedSDK].loginManager addDelegate:self];
2023-07-18 18:26:10 +08:00
[[NIMSDK sharedSDK].chatManager addDelegate:self];
[[NIMSDK sharedSDK].systemNotificationManager addDelegate:self];
[[NIMSDK sharedSDK].broadcastManager addDelegate:self];
[self.presenter juliandAdCallBackApi];
[self networkReachability];
[self.view addSubview:self.roomMineView];
[[NSNotificationCenter defaultCenter] addObserverForName:kRoomMiniNotificationKey object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
[self configRoomMiniNView:note.userInfo];
}];
2023-09-27 12:35:29 +08:00
[[NSNotificationCenter defaultCenter] addObserverForName:@"kLogout" object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
self.isInitReload = NO;
self.isReload = NO;
}];
2023-07-18 18:26:10 +08:00
[[NSNotificationCenter defaultCenter] addObserverForName:kUserCompleteInfoFinishKey object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
[self completeUserInfoFinish:note.object];
}];
[[NSNotificationCenter defaultCenter] addObserverForName:@"reloadnewtab" object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
2023-09-27 12:35:29 +08:00
if (self.isInitReload == NO) {
2023-07-18 18:26:10 +08:00
[self initTabs:YES];
self.isReload = YES;
}
}];
2023-07-14 18:50:55 +08:00
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showNewUserRecharge) name:kNewUserRechargeKey object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showAnchorCardKey:) name:kTabShowAnchorCardKey object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(teenagerStatusChange:) name:kTeenagerStatusChange object:nil];
2023-09-20 18:38:51 +08:00
2023-09-15 16:08:43 +08:00
2023-07-14 18:50:55 +08:00
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:YES];
[self.presenter autoLogin];
2023-07-18 18:26:10 +08:00
if ([XPRoomMiniManager shareManager].getRoomInfo == nil) {
[self.roomMineView hiddenRoomMiniView];
}
2023-07-14 18:50:55 +08:00
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
self.delayShowAnchorCard = NO;
[self.anchorCardView removeFromSuperview];
self.anchorCardView = nil;
}
- (MainPresenter *)presenter {
if (_presenter == nil) {
_presenter = [[MainPresenter alloc] init];
[_presenter attatchView:self];
}
return _presenter;
}
/** tokenticket
2023-07-18 18:26:10 +08:00
1.
2.
3. VP
2023-07-14 18:50:55 +08:00
*/
- (void)autoLoginSuccess {
[self.presenter loginNIM];
[self.presenter getUserInfo];
2023-07-18 18:26:10 +08:00
///
[self.presenter checkTranscation];
///
if ([ClientConfig shareConfig].canOpen) {
[self.presenter getVersionUpdate];
if (self.inviteCode && self.inviteCode.length > 0) {
///
[self.presenter checkInviteUserInfo:self.inviteCode];
}
}
[self requestGiftList];
///
// [self clientStartApp];
// ///
// [[ClientConfig shareConfig] addHeartBratTimer];
XPAdImageTool.shareImageTool.isImLogin = YES;
if ([ClientConfig shareConfig].canOpen) {
if ([self hadLaunchApp] && [self canShowAnchorCard]) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (self.view.window && self.isViewLoaded) {
[self.presenter getAnchorCardInfo];
}
});
}
if (self.needShowAnchorCard && !self.delayShowAnchorCard && !self.parentMode) {
[self.presenter getAnchorCardInfo];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:kHadLaunchApp];///
[[NSUserDefaults standardUserDefaults] synchronize];
}
}
2023-07-14 18:50:55 +08:00
}
/// 12
/// ticket
/// BaseMvpPresenter1415
- (void)getUserInfoSuccess:(UserInfoModel *)userInfo {
if (!userInfo.isBindPhone && [ClientConfig shareConfig].iosPhoneBind) {
LoginBindPhoneViewController * bindPhoneVC = [[LoginBindPhoneViewController alloc] init];
BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:bindPhoneVC];
nav.modalPresentationStyle = UIModalPresentationFullScreen;
[self.navigationController presentViewController:nav animated:YES completion:nil];
return;
}
if (userInfo.nick == nil || userInfo.avatar == nil) {
2023-08-18 10:05:07 +08:00
id type = [[NSUserDefaults standardUserDefaults]valueForKey:@"kLoginSuccessType"];
if(type != nil && [type intValue] == ThirdLoginType_Phone){
2023-08-17 16:10:11 +08:00
[self.presenter getAuthorizationCodeInfo];
}else{
[self completeUserInfo];
}
2023-07-14 18:50:55 +08:00
return;
}
2023-09-27 12:35:29 +08:00
if(self.isReload == NO){
[self initTabs:YES];
self.isInitReload = YES;
}
2023-07-18 18:26:10 +08:00
if ([ClientConfig shareConfig].canOpen) {
if (self.inviteCode.length <= 0) {
[self initQuickEnterRoom];
}
if (self.inviteCode) {
self.inviteCode = nil;
}
[self monentsUnReadCount];
2023-09-22 12:20:43 +08:00
NSArray *recentList = [[NIMSDK sharedSDK].conversationManager.allRecentSessions mutableCopy];
__block NSInteger unreadCount = 0;
NSMutableArray<NSString *> * uids = [[NSMutableArray alloc] init];
[recentList enumerateObjectsUsingBlock:^(NIMRecentSession * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[uids addObject:obj.session.sessionId];
unreadCount += obj.unreadCount;
}];
if(unreadCount > 0){
NSUInteger index = 2;
UITabBarItem *item = self.tabBar.items.count > index ? self.tabBar.items[index] : nil;
[item setBadgeValue:[NSString stringWithFormat:@"%ld",unreadCount]];
}
2023-07-18 18:26:10 +08:00
}
2023-07-14 18:50:55 +08:00
self.parentMode = userInfo.parentMode;
for (BaseViewController *vc in self.viewControllers) {
vc.parentMode = self.parentMode;
}
}
2023-08-14 14:39:41 +08:00
- (void)getAuthorizationCodeInfoWithPhonefail{
[self completeUserInfo];
}
-(void)getAuthorizationCodeInfoWithPhoneSuccess:(BOOL)flag{
if(flag == NO){
XPLoginAuthCodeVC *vc = [[XPLoginAuthCodeVC alloc]init];
vc.delegate = self;
vc.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:vc animated:YES completion:nil];
return;
}
[self completeUserInfo];
}
#pragma mark - XPLoginAuthCodeVCDelegate
- (void)bindCodeSuccess{
[self completeUserInfo];
}
2023-09-22 12:20:43 +08:00
2023-07-18 18:26:10 +08:00
///
-(void)requestGiftList{
2023-07-21 14:07:04 +08:00
[self dealWithDefaultSvga];
2023-08-16 14:21:58 +08:00
///
2023-07-18 18:26:10 +08:00
NSString *time = [NSDate getNowTimeTimestamp];
NSString *curTime = [NSDate timestampSwitchTime:[time integerValue] andFormatter:@"yyyy-MM-dd"];
NSDictionary *timeDic = [[NSUserDefaults standardUserDefaults]valueForKey:@"kRequestGiftList"];
if(timeDic == nil){
2023-07-21 14:07:04 +08:00
NSMutableDictionary *curDic = [[NSMutableDictionary alloc]initWithDictionary:timeDic];
[curDic setValue:@(YES) forKey:curTime];
[[NSUserDefaults standardUserDefaults]setValue:curDic forKey:@"kRequestGiftList"];
2023-07-18 18:26:10 +08:00
[[NSUserDefaults standardUserDefaults]synchronize];
}else{
if(timeDic[curTime]!= nil)return;
NSMutableDictionary *curDic = [[NSMutableDictionary alloc]initWithDictionary:timeDic];
2023-07-21 14:07:04 +08:00
[curDic removeAllObjects];
2023-07-18 18:26:10 +08:00
[curDic setValue:@(YES) forKey:curTime];
[[NSUserDefaults standardUserDefaults]setValue:curDic forKey:@"kRequestGiftList"];
[[NSUserDefaults standardUserDefaults]synchronize];
}
2023-07-21 14:07:04 +08:00
[Api requestCacheGiftList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
2023-07-18 18:26:10 +08:00
if(code == 200){
2023-07-21 14:07:04 +08:00
NSArray *giftList = [GiftInfoModel modelsWithArray:data.data];
2023-07-18 18:26:10 +08:00
for (GiftInfoModel *giftModel in giftList) {
if(giftModel.vggUrl.length > 0){
[self dealWithGiftListWithUrl:giftModel.vggUrl fileName:giftModel.vggUrl isSvga:YES];
}else if(giftModel.viewUrl.length > 0){
[self dealWithGiftListWithUrl:giftModel.viewUrl fileName:giftModel.viewUrl isSvga:NO];
}
}
}
2023-07-21 14:07:04 +08:00
}];
2023-07-18 18:26:10 +08:00
}
2023-07-21 14:07:04 +08:00
-(void)dealWithDefaultSvga{
2023-08-16 14:21:58 +08:00
///
2023-08-14 19:03:26 +08:00
NSArray *loveList = @[@"https://image.hfighting.com/candyTree_light.svga",@"https://image.hfighting.com/candyTree_open.svga",@"https://image.hfighting.com/candyTree_transform.svga"];
for (NSString *url in loveList) {
2023-07-21 14:07:04 +08:00
[self dealWithGiftListWithUrl:url fileName:url isSvga:YES];
}
2023-08-16 14:21:58 +08:00
///
2023-08-14 19:03:26 +08:00
NSArray *elfList = @[@"https://image.hfighting.com/treasure_fairy_trials_middle.mp4",@"https://image.hfighting.com/treasure_fairy_ten.mp4",@"https://image.hfighting.com/treasure_fairy_trials_high.mp4",@"https://image.hfighting.com/treasure_fairy_one.mp4"];
for (NSString *url in elfList) {
[self dealWithGiftListWithUrl:url fileName:url isSvga:NO];
}
2023-07-21 14:07:04 +08:00
}
2023-07-18 18:26:10 +08:00
-(void)dealWithGiftListWithUrl:(NSString *)url fileName:(NSString *)fileName isSvga:(BOOL)isSvga {
NSString *baseFileName = isSvga ? @"/GiftSvga":@"/GiftMp4";
NSString *filePaths = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:fileName];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([[NSFileManager defaultManager] fileExistsAtPath:filePaths])return;
[[[NSURLSession sharedSession] downloadTaskWithURL:[NSURL URLWithString:url] completionHandler:^(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if(!error){
[fileManager createDirectoryAtPath:[filePaths stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:nil error:nil];
NSData *data = [NSData dataWithContentsOfURL:location];
[data writeToFile:filePaths atomically:YES];
}
}] resume];
}
2023-07-14 18:50:55 +08:00
- (void)checkInviteUserInfoSuccess:(InviteUserInfoModel *)inviteInfo {
if (inviteInfo && inviteInfo.isInRoom && !self.parentMode) {
[XPRoomViewController openRoom:inviteInfo.roomUid fromNick:inviteInfo.inviteNick fromType:inviteInfo.fromType fromUid:inviteInfo.inviteUid viewController:self];
} else { //
[self.presenter getShortCutRecommendRoom];
}
}
- (void)getShortCutRecommendRoomSuccces:(NSString *)roomUid {
if (self.parentMode) {
return;
}
if (roomUid.length > 0) {
[XPRoomViewController openRoom:roomUid viewController:self];
}
}
#pragma mark - app
- (void)clientStartApp {
// [self.presenter clientStartApp];
}
#pragma mark -
- (void)networkReachability{
[[AFNetworkReachabilityManager sharedManager] startMonitoring];
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
switch (status) {
case AFNetworkReachabilityStatusUnknown:
self.isFirstReachability = YES;
break;
case AFNetworkReachabilityStatusNotReachable:
self.isFirstReachability = YES;
break;
case AFNetworkReachabilityStatusReachableViaWWAN:
case AFNetworkReachabilityStatusReachableViaWiFi:
{
if (self.isFirstReachability) {
[[NSNotificationCenter defaultCenter] postNotificationName:kNetworkReachabilityKey object:nil userInfo:nil];
[self.presenter autoLogin];
[[ClientConfig shareConfig] clientInit];
}
self.isFirstReachability = YES;
}
break;
default:
break;
}
}];
}
#pragma mark - BaseMvpProtocol
- (void)tokenInvalid {
2023-09-27 12:35:29 +08:00
[[NSNotificationCenter defaultCenter]postNotificationName:@"kLogout" object:nil];
2023-07-14 18:50:55 +08:00
XPLoginViewController *lvc = [[XPLoginViewController alloc] init];
BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:lvc];
nav.modalPresentationStyle = UIModalPresentationFullScreen;
[self.navigationController presentViewController:nav animated:YES completion:nil];
XPAdImageTool.shareImageTool.isImLogin = NO;
}
- (void)completeUserInfo {
LoginFullInfoViewController * bindPhoneVC = [[LoginFullInfoViewController alloc] init];
BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:bindPhoneVC];
nav.modalPresentationStyle = UIModalPresentationFullScreen;
[self.navigationController presentViewController:nav animated:YES completion:nil];
}
///
- (void)getAnchorCardInfoSuccess:(XPTabAnchorCardModel *)cardInfo {
if (self.parentMode) {
return;
}
if (!self.anchorCardView.superview && cardInfo && self.isViewLoaded && self.view.window) {
self.anchorCardView.frame = CGRectMake(0, -90-kStatusBarHeight, KScreenWidth, 90);
[UIView animateWithDuration:0.5 animations:^{
self.anchorCardView.frame = CGRectMake(0, kStatusBarHeight, KScreenWidth, 90);
} completion:nil];
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);//
long time = (long)([[NSDate date] timeIntervalSince1970]*1000);
[[NSUserDefaults standardUserDefaults] setObject:@(time) forKey:kLastShowAnchorCardTime];
[[NSUserDefaults standardUserDefaults] synchronize];
self.anchorCardView.cardInfo = cardInfo;
[self.view addSubview:self.anchorCardView];
UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleAnchorCardSwipeFrom:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionUp)];
[self.anchorCardView addGestureRecognizer:recognizer];
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventPersonalshowTopCardShow];
}
}
///
- (void)getVersionUpdate:(XPVersionUpdateModel *)versionModel {
XPUpgradeView *view = [[XPUpgradeView alloc] init];
view.versionModel = versionModel;
TTPopupService * service = [[TTPopupService alloc] init];
service.contentView = view;
service.shouldDismissOnBackgroundTouch = NO;
[TTPopup popupWithConfig:service];
}
#pragma mark - NIMLoginManagerDelegate
- (void)onAutoLoginFailed:(NSError *)error {
// autoLogin 417
if (error.code == 417) {
@weakify(self);
AccountModel* accountModel = [AccountInfoStorage instance].getCurrentAccountInfo;
[[NIMSDK sharedSDK].loginManager login:accountModel.uid token:accountModel.netEaseToken completion:^(NSError * _Nullable error) {
if (error) {
@strongify(self);
[self.presenter logout];
}
}];
return;
}
[self.presenter logout];
}
- (void)onKickout:(NIMLoginKickoutResult *)result {
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"TabbarViewController0")];
UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
if ([rootViewController presentedViewController]) { //present dismiss
[[rootViewController presentedViewController] dismissViewControllerAnimated:YES completion:^{
if ([[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController.viewControllers.count > 1) {
[[[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController popToRootViewControllerAnimated:YES];
}
if ([[UIApplication sharedApplication].delegate.window.rootViewController isKindOfClass:[UITabBarController class]]) {
UITabBarController *tabVC = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController;
if (tabVC.selectedViewController.navigationController) {
[tabVC.selectedViewController.navigationController popToRootViewControllerAnimated:YES];
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[tabVC setSelectedIndex:0];
});
}
}];
}else { //present rootvcpush navvc pop
if ([[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController.viewControllers.count > 1) {
[[[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController popToRootViewControllerAnimated:YES];
}
if ([[UIApplication sharedApplication].delegate.window.rootViewController isKindOfClass:[UITabBarController class]]) {
UITabBarController *tabVC = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController;
if (tabVC.selectedViewController) {
if ([tabVC.selectedViewController isKindOfClass:[UINavigationController class]]) {
[tabVC.selectedViewController popToRootViewControllerAnimated:YES];
} else {
[tabVC.selectedViewController.navigationController popToRootViewControllerAnimated:YES];
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[tabVC setSelectedIndex:0];
});
}
}
}
if ([XPRoomMiniManager shareManager].getRoomInfo) {
[[RtcManager instance] exitRoom];
[[NIMSDK sharedSDK].chatroomManager exitChatroom:[NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.roomId] completion:nil];
[self.roomMineView hiddenRoomMiniView];
}
[self.presenter logout];
}
#pragma mark - NIMChatManagerDelegate
- (void)onRecvMessages:(NSArray<NIMMessage *> *)messages {
2023-08-16 14:21:58 +08:00
if (self.parentMode || ![ClientConfig shareConfig].canOpen || [AccountInfoStorage instance].getTicket.length == 0) {
2023-07-14 18:50:55 +08:00
return;
}
for (NIMMessage * message in messages) {
if (message.session.sessionType == NIMSessionTypeP2P) {
if(message.messageType == NIMMessageTypeCustom) {
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
2023-08-16 14:21:58 +08:00
AttachmentModel * attachment = (AttachmentModel *)obj.attachment;
2023-07-14 18:50:55 +08:00
if (attachment.first == CustomMessageType_FindNew && attachment.second == Custom_Message_Find_New_Greet_New_User) {
FindNewGreetMessageModel * greetInfo = [FindNewGreetMessageModel modelWithDictionary:attachment.data];
if (greetInfo.uid.integerValue != [AccountInfoStorage instance].getUid.integerValue) {
[TTPopup dismiss];
XPSessionFindNewAlertView * alertView = [[XPSessionFindNewAlertView alloc] init];
alertView.userInfo = greetInfo;
TTPopupService *service = [[TTPopupService alloc] init];
service.contentView = alertView;
service.shouldDismissOnBackgroundTouch = NO;
service.style = TTPopupStyleAlert;
[TTPopup popupWithConfig:service];
}
}
}
}
}
}
}
- (void)onReceiveBroadcastMessage:(NIMBroadcastMessage *)broadcastMessage {
if (![ClientConfig shareConfig].canOpen) {
return;
}
if (broadcastMessage.content) {
NSDictionary *msgDictionary = [broadcastMessage.content toJSONObject];
AttachmentModel *attachment = [AttachmentModel modelWithJSON:msgDictionary[@"body"]];
if (attachment.first == CustomMessageType_RedPacket && attachment.second == Custom_Message_Sub_AllDiamandRedPacket) {
XPReceiveRedPacketModel *data = [XPReceiveRedPacketModel modelWithDictionary:attachment.data];
//
__block BOOL isInRoom;
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj isKindOfClass:[XPRoomViewController class]]) {
XPRoomViewController<RoomHostDelegate> * roomVC = obj;
RoomInfoModel *roomInfo = [roomVC getRoomInfo];
XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
if (roomInfo.uid == data.roomUid.integerValue) {
view.inAllPacketRoom = YES;
} else {
view.inAllPacketRoom = NO;
}
XPReceiveRedPacketModel *data = [XPReceiveRedPacketModel modelWithJSON:attachment.data];
view.redPacketModel = data;
[roomVC.view addSubview:view];
[roomVC.view bringSubviewToFront:view];
*stop = YES;
isInRoom = YES;
}
}];
if (!isInRoom) {
UIViewController *currentVc = [[XCCurrentVCStackManager shareManager] getCurrentVC];
XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
view.inAllPacketRoom = NO;
XPReceiveRedPacketModel *data = [XPReceiveRedPacketModel modelWithJSON:attachment.data];
view.redPacketModel = data;
[currentVc.view addSubview:view];
[currentVc.view bringSubviewToFront:view];
}
} else if (attachment.first == CustomMessageType_Gift && attachment.second == Custom_Message_Sub_Gift_ChannelNotify){///广
[self receiveBroadcastGift:attachment];
}else if(attachment.first == CustomMessageType_Version_Update && attachment.second == Custom_Message_Version_Update_Value){
NSString *osValue = attachment.data[@"updateOs"];
if([osValue isEqualToString:@"ios"] && [AccountInfoStorage instance].getUid.length > 0){
XPVersionUpdateModel *updateModel = [XPVersionUpdateModel modelWithDictionary:attachment.data];
[self getVersionUpdate:updateModel];
}
}else if(attachment.first == CustomMessageType_LuckyBag && attachment.second == Custom_Message_Sub_Room_Gift_LuckBag_FullScree){
2023-07-21 18:53:10 +08:00
if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return;
2023-07-14 18:50:55 +08:00
[self.roomAnimation receiveLuckyGiftBigPrize:attachment];
}else if(attachment.first == CustomMessageType_Graffiti_Star_Kitchen && attachment.second == Custom_Message_Sub_Star_Kitchen_FullScreen){
2023-07-21 18:53:10 +08:00
if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return;
2023-07-14 18:50:55 +08:00
[self.roomAnimation receiveRoomGraffitiStarKitchen:attachment];
}else if(attachment.first == CustomMessageType_Look_Love && attachment.second == Custom_Message_Sub_Look_Love_InRoom_NeedAllMicSend){
2023-07-21 18:53:10 +08:00
if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return;
2023-07-14 18:50:55 +08:00
[self.roomAnimation receiveCandyTreeGiftHighLevle:attachment];
2023-08-16 14:21:58 +08:00
}else if (attachment.first == CustomMessageType_Treasure_Fairy && (attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L4 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L5 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L1 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L2 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L3)) { //
if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return;
[self.roomAnimation receiveTreasureFairyGiftHighLevel:attachment];
2023-09-14 11:16:47 +08:00
}else if (attachment.first == CustomMessageType_Tarot && (attachment.second == Custom_Message_Sub_Tarot_Advanced || attachment.second == Custom_Message_Sub_Tarot_Intermediate)){
if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return;
[self.roomAnimation receiveTarotBanner:attachment];
}else if(attachment.first == CustomMessageType_Common_H5 && (attachment.second == Custom_Message_Sub_Common_H5_Novice || attachment.second == Custom_Message_Sub_Common_H5_Advanced)){
if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return;
[self.roomAnimation receiveCommonH5Banner:attachment];
2023-09-25 16:02:57 +08:00
}else if (attachment.first == CustomMessageType_Anchor_Hour_Rank && attachment.second == Custom_Message_Sub_Anchor_Hour_Rank) {///
if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return;
[self.roomAnimation receiveAnchorHourRank:attachment];
} else if (attachment.first == CustomMessageType_Licnese_Hour_Rank && attachment.second == Custom_Message_Sub_Licnese_Hour_Rank) {///
if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return;
[self.roomAnimation receiveAnchorHourRank:attachment];
2023-07-14 18:50:55 +08:00
}
}
}
///
-(BOOL)isInRoomWithData{
//
__block BOOL isInRoom;
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj isKindOfClass:[XPRoomViewController class]]) {
*stop = YES;
isInRoom = YES;
}
}];
return isInRoom;
}
/**
*
*
* @param notification
* @discusssion
*/
- (void)onRecvRevokeMessageNotification:(NIMRevokeMessageNotification *)notification {
NIMMessage * message = notification.message;
if (message) {
NIMMessage * revokeMessage = [[NIMMessage alloc] init];
[revokeMessage setValue:message.session forKey:@"session"];
[revokeMessage setValue:@(NIMMessageTypeTip) forKey:@"messageType"];
revokeMessage.timestamp = [PLTimeUtil getNowTimeTimestampMillisecond].longLongValue;
revokeMessage.text = YMLocalizedString(@"TabbarViewController1");
[[NIMSDK sharedSDK].conversationManager saveMessage:revokeMessage forSession:message.session completion:nil];
}
}
- (void)configTheme {
2023-09-14 11:16:47 +08:00
self.view.backgroundColor = [DJDKMIMOMColor tabbarViewColor];
[[UITabBar appearance] setBackgroundImage:[UIImage imageWithColor:[DJDKMIMOMColor tabbarViewColor] size:CGSizeMake(KScreenWidth, kTabBarHeight)]];
[[UITabBar appearance] setShadowImage:[[UIImage alloc]init]];
2023-07-14 18:50:55 +08:00
if (@available(iOS 10.0, *)) {
[[UITabBar appearance] setUnselectedItemTintColor:[DJDKMIMOMColor tabbarNormalColor]];
}
}
- (void)initTabs:(BOOL)logined {
self.viewControllers = nil;
NSArray *normalImageNames = @[@"tab_gameHome_normal",@"tab_monents_normal",@"tab_message_normal", @"tab_mine_normal"];
NSArray *selectImageNames = @[@"tab_gameHome_selected",@"tab_monents_select",@"tab_message_selected", @"tab_mine_selected"];
2023-07-19 14:41:04 +08:00
NSArray *tabLabel = @[YMLocalizedString(@"TabbarViewController2"),YMLocalizedString(@"TabbarViewController3"),YMLocalizedString(@"TabbarViewController4"), YMLocalizedString(@"TabbarViewController5")];
2023-07-14 18:50:55 +08:00
UIViewController *game;
UIViewController *msg;
UIViewController *me;
UIViewController * home;
UIViewController * monents;
if (logined) {
2023-09-22 12:20:43 +08:00
msg = [[XPSessionMainViewController alloc] init];
2023-07-14 18:50:55 +08:00
2023-08-16 22:59:40 +08:00
2023-07-14 18:50:55 +08:00
home = [[XPNewHomeViewController alloc] init];
monents = [[XPMonentsViewController alloc] init];
me = [[XPMineViewController alloc] init];
2023-08-16 22:59:40 +08:00
2023-07-14 18:50:55 +08:00
} else {
game = [[XPBlankViewController alloc]init];
2023-09-22 12:20:43 +08:00
msg = [[XPSessionMainViewController alloc]init];
2023-07-14 18:50:55 +08:00
me = [[XPBlankViewController alloc]init];
home = [[XPBlankViewController alloc] init];
monents = [[XPBlankViewController alloc] init];
}
[self createTabBarItem:home title:tabLabel[0] image:normalImageNames[0] selectedImage:selectImageNames[0]];
[self createTabBarItem:monents title:tabLabel[1] image:normalImageNames[1] selectedImage:selectImageNames[1]];
[self createTabBarItem:msg title:tabLabel[2] image:normalImageNames[2] selectedImage:selectImageNames[2]];
[self createTabBarItem:me title:tabLabel[3] image:normalImageNames[3] selectedImage:selectImageNames[3]];
self.viewControllers = @[home,monents,msg,me];
self.selectedIndex = 0;
}
- (BaseNavigationController *)createTabBarItem:(UIViewController *)itemVc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage{
itemVc.title = title;
itemVc.tabBarItem.image = [[UIImage imageNamed:image] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
itemVc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
2023-09-14 11:16:47 +08:00
[itemVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0x1F1B4F)} forState:UIControlStateSelected];
[itemVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0xB8B7C7)} forState:UIControlStateNormal];
2023-07-14 18:50:55 +08:00
BaseNavigationController *nav = [[BaseNavigationController alloc] initWithRootViewController:itemVc];
return nav;
}
- (void)showSuccessToast:(NSString *)msg {
[XNDJTDDLoadingTool showSuccessWithMessage:msg];
}
- (void)showErrorToast:(NSString *)msg {
[XNDJTDDLoadingTool showErrorWithMessage:msg];
}
- (void)showLoading {
[XNDJTDDLoadingTool showLoading];
}
- (void)hideHUD {
[XNDJTDDLoadingTool hideHUD];
}
#pragma mark -
- (void)monentsUnReadCount {
[Api monentsUnReadCount:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
MonentsUnReadModel * model = [MonentsUnReadModel modelWithDictionary:data.data];
NSString *badge = model.total > 0 ? @(model.total).stringValue : nil;
if (model.total > 99) {
badge = @"99+";
}
NSUInteger index = 1;
UITabBarItem *item = self.tabBar.items.count > index ? self.tabBar.items[index] : nil;
[item setBadgeValue:badge];
}
} uid:[AccountInfoStorage instance].getUid];
}
#pragma mark -
- (void)configRoomMiniNView:(NSDictionary *)dic {
UserInfoModel * userInfo = [UserInfoModel modelWithDictionary:dic[@"userInfo"]];
RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:dic[@"roomInfo"]];
NSMutableDictionary * microQueue = dic[@"microQueue"];
[self.roomMineView configRoomMiniView:roomInfo userInfo:userInfo micQueue:microQueue];
}
#pragma mark -
- (void)initQuickEnterRoom {
NSString * key = [NSString stringWithFormat:@"%@_%@", kUserFirstLoginKey, [AccountInfoStorage instance].getUid];
BOOL isNotFirstLogin = [[NSUserDefaults standardUserDefaults] boolForKey:key];
if (!isNotFirstLogin) {
///
// [self.presenter getNewUserGreetInfo];
}
}
/// linkedMe
- (void)completeUserInfoFinish:(NSString *)inviteCode {
self.inviteCode = inviteCode;
}
#pragma mark -NIMSystemNotificationManagerDelegate
- (void)onReceiveCustomSystemNotification:(NIMCustomSystemNotification *)notification {
if (self.parentMode) {
return;
}
if (notification.receiverType == NIMSessionTypeP2P) {
if (notification.content != nil) {
NSData *jsonData = [notification.content dataUsingEncoding:NSUTF8StringEncoding];
NSError *err;
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&err];
if(err) {
NSLog(@"json解析失败%@",err);
return;
}
if ([dic[@"first"] integerValue] == CustomMessageType_First_VisitorRecord){//访
AttachmentModel *attachment = [AttachmentModel modelWithJSON:notification.content];
XPMineVisitorUnReadModel *model = [XPMineVisitorUnReadModel modelWithJSON:attachment.data];
if ([model isKindOfClass:XPMineVisitorUnReadModel.class]) {
[[NSNotificationCenter defaultCenter] postNotificationName:kVisitorUnReadCountNotificationKey object:model];
}
} else if ([dic[@"first"] intValue] == CustomMessageType_Task_Complete && [dic[@"second"] intValue] == Custom_Message_Sub_TaskComplete) {///
if ([dic isKindOfClass:[NSDictionary class]]) {
NSDictionary *dict = dic[@"data"];
[self handleActivityTaskTip:dict[@"taskCompleteMsg"] url:dic[@"taskUrl"]];
}
}
}
}
}
#pragma mark -
//
- (void)showNewUserRecharge {
self.needShowNewUserRecharge = YES;
}
///
- (void)showAnchorCardKey:(NSNotification *)noti {
NSDictionary * dic = noti.object;
self.delayShowAnchorCard = [[dic objectForKey:@"delayShow"] boolValue];
self.needShowAnchorCard = YES;
}
///
- (BOOL)hadLaunchApp {
return [[NSUserDefaults standardUserDefaults] valueForKey:kHadLaunchApp];
}
///
- (void)teenagerStatusChange:(NSNotification *)noti {
NSDictionary * dic = noti.object;
self.parentMode = [[dic objectForKey:@"parentMode"] boolValue];
for (BaseViewController *vc in self.viewControllers) {
vc.parentMode = self.parentMode;
}
if ([XPRoomMiniManager shareManager].getRoomInfo && self.parentMode) {
[[RtcManager instance] exitRoom];
[[NIMSDK sharedSDK].chatroomManager exitChatroom:[NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.roomId] completion:nil];
[self.roomMineView hiddenRoomMiniView];
}
}
- (BOOL)canShowAnchorCard {
if ([[XPRoomMiniManager shareManager] getRoomInfo]) {//
return NO;
}
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSNumber *lastTime = [defaults objectForKey:kLastShowAnchorCardTime];
if ([lastTime longValue] < 1) {
return NO;
}
NSDate *datenow = [NSDate date];//
long time2 = (long)([datenow timeIntervalSince1970]*1000);
long aTime = (time2 - [lastTime longValue]) / 1000;
if (aTime > 15*60) {
return YES;
} else {
return NO;
}
}
#pragma mark -
- (void)handleActivityTaskTip:(NSString *)msg url:(NSString *)url {
if (!self.taskTipView.superview && url.length) {
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventtask_toast_show];
[self.view addSubview:self.taskTipView];
self.taskTipView.desc = msg;
self.taskTipView.url = url;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jumpToTask:)];
[self.taskTipView addGestureRecognizer:tap];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (self.taskTipView.superview) {
[self.taskTipView removeFromSuperview];
}
self.taskTipView = nil;
});
}
}
- (void)jumpToTask:(UITapGestureRecognizer *)ges {
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventtask_toast_click];
XPWebViewController * webVC =[[XPWebViewController alloc] init];
webVC.url = self.taskTipView.url;
[self.selectedViewController.navigationController pushViewController:webVC animated:YES];
if (self.taskTipView.superview) {
[self.taskTipView removeFromSuperview];
}
self.taskTipView = nil;
}
#pragma mark - XPAnchorCardViewDelegate
- (void)xPAnchorCardViewEnterRoom:(NSString *)roomUid {
if (roomUid.length) {
[self.anchorCardView removeFromSuperview];
self.anchorCardView = nil;
self.needShowAnchorCard = NO;
[XPRoomViewController openRoom:roomUid viewController:self];
} else {
[UIView animateWithDuration:0.5 animations:^{
self.anchorCardView.frame = CGRectMake(0, -90-kStatusBarHeight, KScreenWidth, 90);
} completion:^(BOOL finished) {
[self.anchorCardView removeFromSuperview];
self.anchorCardView = nil;
self.needShowAnchorCard = NO;
}];
}
}
- (void)xPAnchorCardViewClickAvatar:(NSString *)uid {
if (uid.length) {
if ([ClientConfig shareConfig].canOpen) {
XPMineUserInfoViewController * userInfoVC = [[XPMineUserInfoViewController alloc] init];
userInfoVC.uid = uid.integerValue;
[self.selectedViewController.navigationController pushViewController:userInfoVC animated:YES];
}else{
XPMineSimpleUserInfoViewController * userInfoVC = [[XPMineSimpleUserInfoViewController alloc] init];
userInfoVC.uid = uid.integerValue;
[self.selectedViewController.navigationController pushViewController:userInfoVC animated:YES];
}
[self.anchorCardView removeFromSuperview];
self.anchorCardView = nil;
self.needShowAnchorCard = NO;
} else {
[self.anchorCardView removeFromSuperview];
self.anchorCardView = nil;
self.needShowAnchorCard = NO;
}
}
- (void)handleAnchorCardSwipeFrom:(UISwipeGestureRecognizer *)recognizer{
if(recognizer.direction == UISwipeGestureRecognizerDirectionUp) {
[UIView animateWithDuration:0.5 animations:^{
self.anchorCardView.frame = CGRectMake(0, -90-kStatusBarHeight, KScreenWidth, 90);
} completion:^(BOOL finished) {
[self.anchorCardView removeFromSuperview];
self.anchorCardView = nil;
self.needShowAnchorCard = NO;
}];
}
}
#pragma mark -
- (void)receiveBroadcastGift:(AttachmentModel *)attachment {
GiftReceiveInfoModel *giftNotifyInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
if (!giftNotifyInfo.ceremonyGift && giftNotifyInfo.isHomeShow == YES) {
2023-07-21 18:53:10 +08:00
if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return;
2023-07-14 18:50:55 +08:00
[self.roomAnimation receiveGift:giftNotifyInfo];
return;
}
if(giftNotifyInfo.isHomeShow == NO)return;
if (self.giftBroadcastQueue.count == 0) {
[self createGiftBroadcastViewAnimation:giftNotifyInfo];
}
[self.giftBroadcastQueue addObject:giftNotifyInfo];
}
- (void)createGiftBroadcastViewAnimation:(GiftReceiveInfoModel *)giftModel {
XPRoomYearActivityView * view = [[XPRoomYearActivityView alloc] init];
view.delegate = self;
view.frame = CGRectMake(KScreenWidth, 35 + statusbarHeight, KScreenWidth, 150);
view.model = giftModel;
[[XCCurrentVCStackManager shareManager].getCurrentVC.view addSubview:view];
[self beginGiftBraodcastViewAnimation:view notifyStaySecond:giftModel.notifyStaySecond];
}
- (void)beginGiftBraodcastViewAnimation:(XPRoomYearActivityView *)view notifyStaySecond:(int)notifyStaySecond{
CGFloat startTime = notifyStaySecond > 0 ? notifyStaySecond : 3.0;
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter];
springAnimation.springSpeed = 12;
springAnimation.springBounciness = 10.f;
springAnimation.fromValue = [NSValue valueWithCGPoint:view.center];
springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(0 + view.frame.size.width / 2, view.center.y)];
[springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
if (finished) {
[self removeGiftBroadcastOutAnimation:view stayTime:startTime];
}
}];
[view pop_addAnimation:springAnimation forKey:@"spingOutAnimation"];
}
- (void)removeGiftBroadcastOutAnimation:(XPRoomYearActivityView *)view stayTime:(CGFloat)stayTime{
POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter];
moveAnimation.fromValue = [NSValue valueWithCGPoint:view.center];
moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, view.center.y)];
moveAnimation.beginTime = CACurrentMediaTime() + stayTime;
moveAnimation.duration = 0.5;
moveAnimation.repeatCount = 1;
moveAnimation.removedOnCompletion = YES;
@kWeakify(self);
[moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
@kStrongify(self);
if (finished) {
[view removeFromSuperview];
if (self.giftBroadcastQueue.count > 0) {
[self.giftBroadcastQueue removeObjectAtIndex:0];
}
if (self.giftBroadcastQueue.count > 0) {
[self createGiftBroadcastViewAnimation:self.giftBroadcastQueue.firstObject];
}
}
}];
[view pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
}
#pragma mark - XPRoomGiftBroadcastViewDelegate
- (void)xPRoomYearActivityViewEnterRoom:(NSString *)roomUid{
if (roomUid.length > 0) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.7 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[XPRoomViewController openRoom:roomUid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
});
}
}
#pragma mark - Getters And Setters
- (XPMiniRoomView *)roomMineView {
if (!_roomMineView) {
_roomMineView = [[XPMiniRoomView alloc] init];
_roomMineView.controller = self;
_roomMineView.hidden = YES;
}
return _roomMineView;
}
- (XPAnchorCardView *)anchorCardView {
if (!_anchorCardView) {
_anchorCardView = [[XPAnchorCardView alloc] init];
_anchorCardView.delegate = self;
}
return _anchorCardView;
}
- (XPTaskCompleteTipView *)taskTipView {
if (!_taskTipView) {
_taskTipView = [[XPTaskCompleteTipView alloc] initWithFrame:CGRectMake(0, KScreenHeight - kSafeAreaBottomHeight-60-20, KScreenWidth, 20)];
}
return _taskTipView;
}
- (NSMutableArray<GiftReceiveInfoModel *> *)giftBroadcastQueue {
if (!_giftBroadcastQueue) {
_giftBroadcastQueue = [NSMutableArray array];
}
return _giftBroadcastQueue;
}
- (PIFullScreenBannerAnimation *)roomAnimation{
if(!_roomAnimation){
_roomAnimation = [[PIFullScreenBannerAnimation alloc]init];
}
return _roomAnimation;
}
2023-08-14 19:03:26 +08:00
2023-07-14 18:50:55 +08:00
@end