主播卡片
This commit is contained in:
@@ -296,6 +296,9 @@
|
||||
9BEE3D1727858E5700C83219 /* XPNobleAuthorityDescView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BEE3D1627858E5700C83219 /* XPNobleAuthorityDescView.m */; };
|
||||
9BF5192628801D4700B6BE92 /* XPAcrossRoomPKCountDownView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BF5192528801D4700B6BE92 /* XPAcrossRoomPKCountDownView.m */; };
|
||||
9BFB10162897AAB300B3985E /* XPNewUserRechargeSucessView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BFB10152897AAB300B3985E /* XPNewUserRechargeSucessView.m */; };
|
||||
9BFB101F2897CC4300B3985E /* XPAnchorCardView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BFB101E2897CC4300B3985E /* XPAnchorCardView.m */; };
|
||||
9BFB10222897D68400B3985E /* XPTabAnchorCardModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BFB10212897D68400B3985E /* XPTabAnchorCardModel.m */; };
|
||||
9BFE0D8E2898C8C300F53C24 /* XPAnchorCardSkillCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BFE0D8D2898C8C300F53C24 /* XPAnchorCardSkillCollectionViewCell.m */; };
|
||||
9BFE992E288142FD009DA429 /* RoomClassifyModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BFE992D288142FD009DA429 /* RoomClassifyModel.m */; };
|
||||
E80016232803CA5D00D6D17A /* XPMineGuildIncomeRecordViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E80016222803CA5D00D6D17A /* XPMineGuildIncomeRecordViewController.m */; };
|
||||
E80016262803CB2800D6D17A /* XPGuildIncomeHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = E80016252803CB2800D6D17A /* XPGuildIncomeHeaderView.m */; };
|
||||
@@ -1478,6 +1481,12 @@
|
||||
9BF5192528801D4700B6BE92 /* XPAcrossRoomPKCountDownView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPAcrossRoomPKCountDownView.m; sourceTree = "<group>"; };
|
||||
9BFB10142897AAB300B3985E /* XPNewUserRechargeSucessView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPNewUserRechargeSucessView.h; sourceTree = "<group>"; };
|
||||
9BFB10152897AAB300B3985E /* XPNewUserRechargeSucessView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPNewUserRechargeSucessView.m; sourceTree = "<group>"; };
|
||||
9BFB101D2897CC4300B3985E /* XPAnchorCardView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPAnchorCardView.h; sourceTree = "<group>"; };
|
||||
9BFB101E2897CC4300B3985E /* XPAnchorCardView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPAnchorCardView.m; sourceTree = "<group>"; };
|
||||
9BFB10202897D68400B3985E /* XPTabAnchorCardModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPTabAnchorCardModel.h; sourceTree = "<group>"; };
|
||||
9BFB10212897D68400B3985E /* XPTabAnchorCardModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPTabAnchorCardModel.m; sourceTree = "<group>"; };
|
||||
9BFE0D8C2898C8C300F53C24 /* XPAnchorCardSkillCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPAnchorCardSkillCollectionViewCell.h; sourceTree = "<group>"; };
|
||||
9BFE0D8D2898C8C300F53C24 /* XPAnchorCardSkillCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPAnchorCardSkillCollectionViewCell.m; sourceTree = "<group>"; };
|
||||
9BFE992C288142FD009DA429 /* RoomClassifyModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RoomClassifyModel.h; sourceTree = "<group>"; };
|
||||
9BFE992D288142FD009DA429 /* RoomClassifyModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RoomClassifyModel.m; sourceTree = "<group>"; };
|
||||
B66633E061B1B34177CD011C /* Pods-xplan-ios.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-xplan-ios.release.xcconfig"; path = "Target Support Files/Pods-xplan-ios/Pods-xplan-ios.release.xcconfig"; sourceTree = "<group>"; };
|
||||
@@ -4174,6 +4183,8 @@
|
||||
children = (
|
||||
9BE01AF52893E7F500B50299 /* XPNewUserRechargeCollectionViewCell.h */,
|
||||
9BE01AF62893E7F500B50299 /* XPNewUserRechargeCollectionViewCell.m */,
|
||||
9BFE0D8C2898C8C300F53C24 /* XPAnchorCardSkillCollectionViewCell.h */,
|
||||
9BFE0D8D2898C8C300F53C24 /* XPAnchorCardSkillCollectionViewCell.m */,
|
||||
);
|
||||
path = Cell;
|
||||
sourceTree = "<group>";
|
||||
@@ -4191,6 +4202,15 @@
|
||||
path = NewUserRecharge;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9BFB101C2897CC3300B3985E /* AnchorCard */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9BFB101D2897CC4300B3985E /* XPAnchorCardView.h */,
|
||||
9BFB101E2897CC4300B3985E /* XPAnchorCardView.m */,
|
||||
);
|
||||
path = AnchorCard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
BFB922F5D81845AC32D1E1ED /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -6117,6 +6137,7 @@
|
||||
E8B3E8042848B842009746AB /* View */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9BFB101C2897CC3300B3985E /* AnchorCard */,
|
||||
9BFB10172897C95200B3985E /* NewUserRecharge */,
|
||||
9BE01AF42893E7E000B50299 /* Cell */,
|
||||
189DD53226DE255300AB55B1 /* TabbarViewController.h */,
|
||||
@@ -6143,6 +6164,8 @@
|
||||
E8B3E80B2848BA40009746AB /* NewUserGreetModel.m */,
|
||||
9BE01AEE2893E31700B50299 /* NewUserRechargeModel.h */,
|
||||
9BE01AEF2893E31700B50299 /* NewUserRechargeModel.m */,
|
||||
9BFB10202897D68400B3985E /* XPTabAnchorCardModel.h */,
|
||||
9BFB10212897D68400B3985E /* XPTabAnchorCardModel.m */,
|
||||
);
|
||||
path = Model;
|
||||
sourceTree = "<group>";
|
||||
@@ -7988,10 +8011,12 @@
|
||||
E878894C273A607C00BF1D57 /* XPGiftUserCollectionViewCell.m in Sources */,
|
||||
181D7F212727D9DB00B7C059 /* SocialStageView.m in Sources */,
|
||||
187EEEF026E89FE8002833B2 /* AccountInfoStorage.m in Sources */,
|
||||
9BFE0D8E2898C8C300F53C24 /* XPAnchorCardSkillCollectionViewCell.m in Sources */,
|
||||
E8998D852859B4FA00C68558 /* XPMineUserInfoGiftView.m in Sources */,
|
||||
9BB5495C2782E79E0090CD26 /* NobleCenterModel.m in Sources */,
|
||||
186A536B26FC6F2E00D67B2C /* XPShareItemCell.m in Sources */,
|
||||
E8B846C526FDB41A00A777FE /* XPMineUserInfolbumPresenter.m in Sources */,
|
||||
9BFB101F2897CC4300B3985E /* XPAnchorCardView.m in Sources */,
|
||||
E8D34D532808037E009C4835 /* XPMineDataSkillDataCollectionViewCell.m in Sources */,
|
||||
E8E859C528264C2300EE4857 /* HTTPFileResponse.m in Sources */,
|
||||
E83DB47D2746372300D8CBD1 /* XPRoomGiftBannerView.m in Sources */,
|
||||
@@ -8107,6 +8132,7 @@
|
||||
E8001635280410BD00D6D17A /* XPGuildIncomeSectionView.m in Sources */,
|
||||
E8395339276A0CC100CF2F24 /* XPMineHeadwearTableViewCell.m in Sources */,
|
||||
E875FA8727D619820086ED04 /* ClientDataModel.m in Sources */,
|
||||
9BFB10222897D68400B3985E /* XPTabAnchorCardModel.m in Sources */,
|
||||
18E7B29026EA0E6B0064BC9B /* FlutterBoost+Xplan.m in Sources */,
|
||||
E8B846DC26FDE24300A777FE /* RechargeListModel.m in Sources */,
|
||||
9B1B7292280010E8003FACE9 /* Api+FansTeam.m in Sources */,
|
||||
|
@@ -23,6 +23,8 @@ NSString * const kRoomBackMusicPlayMusicFinishKey = @"kRoomBackMusicPlayMusicFin
|
||||
NSString * const kUserCompleteInfoFinishKey = @"kUserCompleteInfoFinishKey";///补全资料完成
|
||||
NSString * const kHadShowNewUserGiftKey = @"kHadShowNewUserGiftKey";//新用户房间礼物
|
||||
NSString * const kNewUserRechargeKey = @"kNewUserRechargeKey";//新用户充值优惠 不同于房间内首充
|
||||
NSString * const kFromSearchToHomeViewKey = @"kFromSearchToHomeViewKey";//用户第一次从搜索页返回首页
|
||||
NSString * const kTabShowAnchorCardKey = @"kTabShowAnchorCardKey"; //tab展示主播卡片
|
||||
|
||||
///在里面进行判断当前环境是什么
|
||||
NSString * const KeyWithType(KeyType type) {
|
||||
|
@@ -21,6 +21,10 @@
|
||||
///VC
|
||||
#import "XPRoomViewController.h"
|
||||
#import "XPMineUserInfoViewController.h"
|
||||
|
||||
UIKIT_EXTERN NSString *kFromSearchToHomeViewKey;
|
||||
UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
|
||||
|
||||
@interface XPHomeSearchViewController ()<UITableViewDelegate, UITableViewDataSource,XPHomeSearchProtocol>
|
||||
///列表
|
||||
@property (nonatomic,strong) UITableView *tableView;
|
||||
@@ -83,7 +87,13 @@
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
HomeSearchResultModel * resultModel = [self.datasource objectAtIndex:indexPath.row];
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
BOOL result = [[NSUserDefaults standardUserDefaults] boolForKey:kFromSearchToHomeViewKey];
|
||||
if (!result) {
|
||||
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:kFromSearchToHomeViewKey];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kTabShowAnchorCardKey object:@{@"delayShow" : @(YES)}];
|
||||
}
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
if (self.type == SearchType_Room) {
|
||||
if (resultModel.valid) {
|
||||
[XPRoomViewController openRoom:resultModel.uid viewController:self.presentingViewController];
|
||||
|
@@ -16,6 +16,10 @@
|
||||
#import "XPHomeSearchNavView.h"
|
||||
///View
|
||||
#import "XPHomeSearchViewController.h"
|
||||
|
||||
UIKIT_EXTERN NSString *kFromSearchToHomeViewKey;
|
||||
UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
|
||||
|
||||
@interface XPRoomSearchContainerViewController ()<JXCategoryViewDelegate, JXCategoryListContainerViewDelegate, XPHomeSearchNavViewDelegate,UITextFieldDelegate>
|
||||
///分页标题
|
||||
@property (nonatomic, strong) NSArray<NSString *> *titles;
|
||||
@@ -109,7 +113,13 @@
|
||||
|
||||
- (void)xPHomeSearchNavView:(XPHomeSearchNavView *)view didClickBack:(UIButton *)sender {
|
||||
[view.searchTextField resignFirstResponder];
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
BOOL result = [[NSUserDefaults standardUserDefaults] boolForKey:kFromSearchToHomeViewKey];
|
||||
if (!result) {
|
||||
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:kFromSearchToHomeViewKey];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kTabShowAnchorCardKey object:nil];
|
||||
}
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
|
@@ -39,6 +39,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/// @param completion 完成
|
||||
+ (void)requestNewUserRechargeList:(HttpRequestHelperCompletion)completion;
|
||||
|
||||
/// 获取主播卡片信息
|
||||
/// @param completion 完成
|
||||
+ (void)requestAnchorCardInfo:(HttpRequestHelperCompletion)completion;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -77,4 +77,10 @@
|
||||
[self makeRequest:@"first/charge/limit/list" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, nil];
|
||||
}
|
||||
|
||||
/// 获取主播卡片信息
|
||||
/// @param completion 完成
|
||||
+ (void)requestAnchorCardInfo:(HttpRequestHelperCompletion)completion {
|
||||
[self makeRequest:@"user/get/userCard" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
28
xplan-ios/Main/Tabbar/Model/XPTabAnchorCardModel.h
Normal file
28
xplan-ios/Main/Tabbar/Model/XPTabAnchorCardModel.h
Normal file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// XPTabAnchorCardModel.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by GreenLand on 2022/8/1.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "XPEnum.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class MineSkillCardListInfoModel;
|
||||
@interface XPTabAnchorCardModel : NSObject
|
||||
|
||||
@property (nonatomic , assign) GenderType gender;
|
||||
@property (nonatomic, strong) NSArray *absCardPics;
|
||||
@property (nonatomic , assign) NSInteger uid;
|
||||
@property (nonatomic , assign) NSInteger erbanNo;
|
||||
@property (nonatomic, copy) NSString *nick;
|
||||
@property (nonatomic, copy) NSString *avatar;
|
||||
@property (nonatomic, copy) NSString *signture;
|
||||
|
||||
@property (nonatomic, strong) MineSkillCardListInfoModel *voiceCard;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
12
xplan-ios/Main/Tabbar/Model/XPTabAnchorCardModel.m
Normal file
12
xplan-ios/Main/Tabbar/Model/XPTabAnchorCardModel.m
Normal file
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// XPTabAnchorCardModel.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by GreenLand on 2022/8/1.
|
||||
//
|
||||
|
||||
#import "XPTabAnchorCardModel.h"
|
||||
|
||||
@implementation XPTabAnchorCardModel
|
||||
|
||||
@end
|
@@ -32,6 +32,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
///获取新用户充值优惠
|
||||
- (void)getNewUserRechargeList;
|
||||
|
||||
///获取主播卡片信息
|
||||
- (void)getAnchorCardInfo;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#import "InviteUserInfoModel.h"
|
||||
#import "NewUserGreetModel.h"
|
||||
#import "NewUserRechargeModel.h"
|
||||
#import "XPTabAnchorCardModel.h"
|
||||
|
||||
@implementation MainPresenter
|
||||
|
||||
@@ -112,4 +113,13 @@
|
||||
}]];
|
||||
}
|
||||
|
||||
///获取主播卡片信息
|
||||
- (void)getAnchorCardInfo {
|
||||
[Api requestAnchorCardInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||||
XPTabAnchorCardModel *model = [XPTabAnchorCardModel modelWithDictionary:data.data];
|
||||
[[self getView] getAnchorCardInfoSuccess:model];
|
||||
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
||||
} errorToast:NO]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "UserInfoModel.h"
|
||||
@class InviteUserInfoModel, NewUserGreetModel, NewUserRechargeModel;
|
||||
@class InviteUserInfoModel, NewUserGreetModel, NewUserRechargeModel, XPTabAnchorCardModel;
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol MainProtocol <NSObject>
|
||||
@@ -25,6 +25,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
///获取新用户充值列表成功
|
||||
- (void)getNewUserRechargeInfoSuccess:(NewUserRechargeModel *)rechargeInfo;
|
||||
|
||||
///获取主播卡片信息成功
|
||||
- (void)getAnchorCardInfoSuccess:(XPTabAnchorCardModel *)cardInfo;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
23
xplan-ios/Main/Tabbar/View/AnchorCard/XPAnchorCardView.h
Normal file
23
xplan-ios/Main/Tabbar/View/AnchorCard/XPAnchorCardView.h
Normal file
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// XPAnchorCardView.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by GreenLand on 2022/8/1.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "XPTabAnchorCardModel.h"
|
||||
|
||||
@protocol XPAnchorCardViewDelegate <NSObject>
|
||||
|
||||
- (void)xPAnchorCardViewEnterRoom:(NSString *)roomUid;
|
||||
|
||||
@end
|
||||
|
||||
@interface XPAnchorCardView : UIView
|
||||
|
||||
@property (nonatomic, strong) XPTabAnchorCardModel *cardInfo;
|
||||
|
||||
@property (nonatomic, weak) id<XPAnchorCardViewDelegate> delegate;
|
||||
|
||||
@end
|
458
xplan-ios/Main/Tabbar/View/AnchorCard/XPAnchorCardView.m
Normal file
458
xplan-ios/Main/Tabbar/View/AnchorCard/XPAnchorCardView.m
Normal file
@@ -0,0 +1,458 @@
|
||||
//
|
||||
// XPAnchorCardView.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by GreenLand on 2022/8/1.
|
||||
//
|
||||
|
||||
#import "XPAnchorCardView.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
///Tool
|
||||
#import "ThemeColor.h"
|
||||
#import "NetImageView.h"
|
||||
#import "XPMacro.h"
|
||||
#import "UIImage+Utils.h"
|
||||
#import "UIButton+EnlargeTouchArea.h"
|
||||
#import "XPSkillCardPlayerManager.h"
|
||||
#import <AFNetworking.h>
|
||||
///View
|
||||
#import "XPAnchorCardSkillCollectionViewCell.h"
|
||||
///Model
|
||||
#import "MineSkillCardListInfoModel.h"
|
||||
|
||||
@interface XPAnchorCardView ()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
|
||||
|
||||
@property (nonatomic, strong) UICollectionView *collectionView;
|
||||
///背景图
|
||||
@property (nonatomic,strong) UIImageView *backImageView;
|
||||
///头像
|
||||
@property (nonatomic,strong) NetImageView *avatarImageView;
|
||||
///性别
|
||||
@property (nonatomic, strong) UIImageView *genderImageView;
|
||||
///昵称
|
||||
@property (nonatomic,strong) UIButton *nickButton;
|
||||
///签名
|
||||
@property (nonatomic,strong) UILabel *descLabel;
|
||||
///进入房间
|
||||
@property (nonatomic, strong) UIButton *enterRoomButton;
|
||||
///倒计时背景
|
||||
@property (nonatomic, strong) UIView *countBgView;
|
||||
///倒计时
|
||||
@property (nonatomic, strong) UILabel *countLabel;
|
||||
///倒计时
|
||||
@property (strong, nonatomic) dispatch_source_t timer;
|
||||
///播放
|
||||
@property (nonatomic,strong) UIButton *playButton;
|
||||
///音符
|
||||
@property (nonatomic,strong) UIImageView *noteImaegView;
|
||||
///播放完成
|
||||
@property (nonatomic,assign) BOOL isPlaying;
|
||||
|
||||
@end
|
||||
|
||||
@implementation XPAnchorCardView
|
||||
|
||||
- (void)dealloc {
|
||||
if (self.timer) {
|
||||
dispatch_source_cancel(self.timer);
|
||||
self.timer = nil;
|
||||
}
|
||||
self.isPlaying = NO;
|
||||
[self.noteImaegView stopAnimating];
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
[self addSubview:self.backImageView];
|
||||
[self addSubview:self.avatarImageView];
|
||||
[self addSubview:self.genderImageView];
|
||||
[self addSubview:self.nickButton];
|
||||
[self addSubview:self.descLabel];;
|
||||
[self addSubview:self.enterRoomButton];
|
||||
[self.backImageView addSubview:self.countBgView];
|
||||
[self.backImageView addSubview:self.countLabel];
|
||||
[self addSubview:self.collectionView];
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.bottom.mas_equalTo(0);
|
||||
make.left.right.mas_equalTo(self).inset(10);
|
||||
}];
|
||||
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(66, 66));
|
||||
make.top.mas_equalTo(14);
|
||||
make.left.mas_equalTo(20);
|
||||
}];
|
||||
[self.nickButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.avatarImageView);
|
||||
make.left.mas_equalTo(self.avatarImageView.mas_right).mas_offset(8);
|
||||
make.height.mas_equalTo(20);
|
||||
}];
|
||||
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.mas_equalTo(self.nickButton);
|
||||
make.left.mas_equalTo(self.nickButton.mas_right).mas_offset(4);
|
||||
make.right.mas_equalTo(self.countBgView.mas_left);
|
||||
make.height.mas_equalTo(15);
|
||||
}];
|
||||
[self.genderImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(14, 14));
|
||||
make.right.bottom.mas_equalTo(self.avatarImageView).mas_offset(-4);
|
||||
}];
|
||||
[self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.nickButton);
|
||||
make.top.mas_equalTo(self.nickButton.mas_bottom).mas_offset(4);
|
||||
make.height.mas_equalTo(17);
|
||||
}];
|
||||
[self.enterRoomButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(79, 24));
|
||||
make.top.mas_equalTo(51);
|
||||
make.right.mas_equalTo(-20);
|
||||
}];
|
||||
[self.countBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.right.mas_equalTo(self.backImageView);
|
||||
make.size.mas_equalTo(CGSizeMake(48, 20));
|
||||
}];
|
||||
[self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.countBgView);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Event Response
|
||||
- (void)enterRoomButtonClick:(UIButton *)sender {
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(xPAnchorCardViewEnterRoom:)]) {
|
||||
[self.delegate xPAnchorCardViewEnterRoom:[NSString stringWithFormat:@"%zd", self.cardInfo.uid]];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - 倒计时
|
||||
- (void)openCountdownWithTime:(long)time {
|
||||
__block long tempTime = time; //倒计时时间
|
||||
if (self.timer == nil) {
|
||||
@kWeakify(self);
|
||||
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
||||
self.timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
|
||||
dispatch_source_set_timer(self.timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒执行
|
||||
dispatch_source_set_event_handler(self.timer, ^{
|
||||
@kStrongify(self);
|
||||
if(tempTime <= 0){ //倒计时结束,关闭
|
||||
dispatch_source_cancel(self.timer);
|
||||
self.timer = nil;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(xPAnchorCardViewEnterRoom:)]) {
|
||||
[self.delegate xPAnchorCardViewEnterRoom:nil];
|
||||
}
|
||||
});
|
||||
} else {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
//设置按钮显示读秒效果
|
||||
self.countLabel.text = [NSString stringWithFormat:@"剩余%zds", tempTime];
|
||||
});
|
||||
tempTime--;
|
||||
}
|
||||
});
|
||||
dispatch_resume(self.timer);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UICollectionViewDelegate
|
||||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
||||
return self.cardInfo.absCardPics.count;
|
||||
}
|
||||
|
||||
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||
XPAnchorCardSkillCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPAnchorCardSkillCollectionViewCell class]) forIndexPath:indexPath];
|
||||
cell.imageView.imageUrl = [self.cardInfo.absCardPics objectAtIndex:indexPath.item];
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||
CGFloat height = 15;
|
||||
CGFloat width = 30;
|
||||
XPAnchorCardSkillCollectionViewCell * cell = (XPAnchorCardSkillCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
|
||||
|
||||
UIImage* image = cell.imageView.image;
|
||||
if (image) {
|
||||
CGFloat scale = image.size.width / image.size.height;
|
||||
return CGSizeMake(15 * scale, height);
|
||||
} else {
|
||||
NSURL *imgUrl = [NSURL URLWithString:[self.cardInfo.absCardPics objectAtIndex:indexPath.item]];
|
||||
UIImage *myImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgUrl]];
|
||||
CGFloat scale = myImage.size.width / myImage.size.height;
|
||||
if (scale == 0) {
|
||||
return CGSizeMake(30, height);
|
||||
}else {
|
||||
return CGSizeMake(15 * scale, height);
|
||||
}
|
||||
}
|
||||
return CGSizeMake(width, height);
|
||||
}
|
||||
|
||||
#pragma mark - private
|
||||
- (void)playButtonAction:(UIButton *)sender {
|
||||
sender.selected = !sender.selected;
|
||||
if (!self.isPlaying) {
|
||||
if(self.cardInfo.voiceCard.propVals.count) {
|
||||
NSString *fileName = [[self.cardInfo.voiceCard.name componentsSeparatedByString:@"/"] lastObject];
|
||||
NSString * url = [self.cardInfo.voiceCard.propVals objectAtIndex:0];
|
||||
NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"mineSkillCardVoice"];
|
||||
NSString *fullPath = [filePath stringByAppendingPathComponent:fileName];
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]) {
|
||||
self.isPlaying = YES;
|
||||
sender.selected = YES;
|
||||
[self pauseTimer];
|
||||
[self.noteImaegView startAnimating];
|
||||
[[XPSkillCardPlayerManager shareInstance] playerVoiceWithPath:fullPath completionBlock:^{
|
||||
self.isPlaying = NO;
|
||||
[self.noteImaegView stopAnimating];
|
||||
sender.selected = NO;
|
||||
[self resumeTimer];
|
||||
self.noteImaegView.image = [UIImage imageNamed:@"mine_voice_shengyin_32"];
|
||||
[[XPSkillCardPlayerManager shareInstance] stopMusic];
|
||||
}];
|
||||
} else {
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
|
||||
NSFileManager *fileMgr = [[NSFileManager alloc] init];
|
||||
[fileMgr createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes:nil error:nil];
|
||||
}
|
||||
[self downloadAudioWithFileName:fileName musicUrl:url completion:^(BOOL isSuccess, NSString *editAudioPath) {
|
||||
self.isPlaying = YES;
|
||||
sender.selected = YES;
|
||||
[self.noteImaegView startAnimating];
|
||||
[self pauseTimer];
|
||||
[[XPSkillCardPlayerManager shareInstance] playerVoiceWithPath:editAudioPath completionBlock:^{
|
||||
self.isPlaying = NO;
|
||||
sender.selected = NO;
|
||||
[self.noteImaegView stopAnimating];
|
||||
[self resumeTimer];
|
||||
self.noteImaegView.image = [UIImage imageNamed:@"mine_voice_shengyin_32"];
|
||||
[[XPSkillCardPlayerManager shareInstance] stopMusic];
|
||||
}];
|
||||
}];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.isPlaying = NO;
|
||||
sender.selected = NO;
|
||||
[self.noteImaegView stopAnimating];
|
||||
self.noteImaegView.image = [UIImage imageNamed:@"mine_voice_shengyin_32"];
|
||||
[[XPSkillCardPlayerManager shareInstance] stopMusic];
|
||||
[self resumeTimer];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)downloadAudioWithFileName:(NSString *)fileName musicUrl:(NSString *)musicUrl completion:(void (^) (BOOL isSuccess, NSString *editAudioPath))completion {
|
||||
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
|
||||
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:musicUrl]];
|
||||
NSURLSessionDownloadTask *download = [manager downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull downloadProgress) {
|
||||
} destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) {
|
||||
NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"mineSkillCardVoice"] stringByAppendingPathComponent:fileName];
|
||||
return [NSURL fileURLWithPath:filePath];
|
||||
} completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
|
||||
if (!error) {
|
||||
completion(YES, filePath.absoluteString);
|
||||
} else {
|
||||
completion(NO, nil);
|
||||
}
|
||||
}];
|
||||
[download resume];
|
||||
}
|
||||
|
||||
- (void)pauseTimer{
|
||||
if(self.timer){
|
||||
dispatch_suspend(_timer);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)resumeTimer{
|
||||
if(self.timer){
|
||||
dispatch_resume(_timer);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)stopTimer{
|
||||
if(self.timer){
|
||||
dispatch_source_cancel(_timer);
|
||||
_timer = nil;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setCardInfo:(XPTabAnchorCardModel *)cardInfo {
|
||||
_cardInfo = cardInfo;
|
||||
if (_cardInfo) {
|
||||
self.avatarImageView.imageUrl = cardInfo.avatar;
|
||||
NSString * nick = cardInfo.nick;
|
||||
if (nick.length > 6) {
|
||||
nick = [nick substringToIndex:6];
|
||||
}
|
||||
[self.nickButton setTitle:nick forState:UIControlStateNormal];
|
||||
self.descLabel.text = cardInfo.signture;
|
||||
self.genderImageView.image = cardInfo.gender == GenderType_Female ? [UIImage imageNamed:@"common_female"] : [UIImage imageNamed:@"common_male"];
|
||||
[self openCountdownWithTime:11];
|
||||
[self.collectionView reloadData];
|
||||
if (cardInfo.voiceCard.propVals.count) {
|
||||
[self addSubview:self.playButton];
|
||||
[self addSubview:self.noteImaegView];
|
||||
[self.playButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.height.mas_equalTo(18);
|
||||
make.left.mas_equalTo(self.nickButton);
|
||||
make.top.mas_equalTo(self.descLabel.mas_bottom).mas_offset(4);
|
||||
}];
|
||||
|
||||
[self.noteImaegView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(79, 12));
|
||||
make.centerY.mas_equalTo(self.playButton);
|
||||
make.left.mas_equalTo(self.playButton.mas_right).offset(5);
|
||||
}];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (UIImageView *)backImageView {
|
||||
if (!_backImageView) {
|
||||
_backImageView = [[UIImageView alloc] init];
|
||||
_backImageView.image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xDAF8FC), UIColorFromRGB(0xF2F6DF)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(KScreenWidth - 20, 90)];
|
||||
_backImageView.layer.cornerRadius = 8;
|
||||
_backImageView.layer.masksToBounds = YES;
|
||||
}
|
||||
return _backImageView;
|
||||
}
|
||||
|
||||
- (NetImageView *)avatarImageView {
|
||||
if (!_avatarImageView) {
|
||||
NetImageConfig * config = [[NetImageConfig alloc]init];
|
||||
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
||||
_avatarImageView = [[NetImageView alloc] initWithConfig:config];
|
||||
_avatarImageView.layer.masksToBounds = YES;
|
||||
_avatarImageView.layer.cornerRadius = 66/2;
|
||||
}
|
||||
return _avatarImageView;
|
||||
}
|
||||
|
||||
- (UIImageView *)genderImageView {
|
||||
if (!_genderImageView) {
|
||||
_genderImageView = [[UIImageView alloc] init];
|
||||
}
|
||||
return _genderImageView;
|
||||
}
|
||||
|
||||
- (UIButton *)nickButton {
|
||||
if (!_nickButton) {
|
||||
_nickButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_nickButton setTitleColor:[ThemeColor mainTextColor] forState:UIControlStateNormal];
|
||||
_nickButton.titleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightBold];
|
||||
}
|
||||
return _nickButton;
|
||||
}
|
||||
|
||||
- (UILabel *)descLabel {
|
||||
if (!_descLabel) {
|
||||
_descLabel = [[UILabel alloc] init];
|
||||
_descLabel.font = [UIFont systemFontOfSize:12];
|
||||
_descLabel.textColor = [UIColor whiteColor];
|
||||
}
|
||||
return _descLabel;
|
||||
}
|
||||
|
||||
- (UIButton *)enterRoomButton {
|
||||
if (!_enterRoomButton) {
|
||||
_enterRoomButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_enterRoomButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
||||
_enterRoomButton.titleLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightBold];
|
||||
[_enterRoomButton setTitle:@"进入房间" forState:UIControlStateNormal];
|
||||
[_enterRoomButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xFFD436), UIColorFromRGB(0xFFB733)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
|
||||
[_enterRoomButton addTarget:self action:@selector(enterRoomButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
_enterRoomButton.layer.cornerRadius = 12;
|
||||
_enterRoomButton.layer.masksToBounds = YES;
|
||||
}
|
||||
return _enterRoomButton;
|
||||
}
|
||||
|
||||
- (UIView *)countBgView {
|
||||
if (!_countBgView) {
|
||||
_countBgView = [[UIView alloc] init];
|
||||
_countBgView.backgroundColor = [UIColor whiteColor];
|
||||
UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 48, 20) byRoundingCorners:UIRectCornerBottomLeft cornerRadii:CGSizeMake(10, 10)];
|
||||
CAShapeLayer * layer = [CAShapeLayer layer];
|
||||
layer.path = path.CGPath;
|
||||
_countBgView.layer.masksToBounds = YES;
|
||||
_countBgView.layer.mask = layer;;
|
||||
}
|
||||
return _countBgView;
|
||||
}
|
||||
|
||||
- (UILabel *)countLabel {
|
||||
if (!_countLabel) {
|
||||
_countLabel = [[UILabel alloc] init];
|
||||
_countLabel.font = [UIFont systemFontOfSize:10 weight:UIFontWeightMedium];
|
||||
_countLabel.textColor = [ThemeColor textThirdColor];
|
||||
_countLabel.textAlignment = NSTextAlignmentCenter;
|
||||
}
|
||||
return _countLabel;
|
||||
}
|
||||
|
||||
- (UICollectionView *)collectionView{
|
||||
if (!_collectionView) {
|
||||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||||
layout.itemSize = CGSizeMake(30, 15);
|
||||
layout.minimumLineSpacing = 0;
|
||||
layout.minimumInteritemSpacing = 4;
|
||||
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
||||
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
||||
_collectionView.showsHorizontalScrollIndicator = NO;
|
||||
_collectionView.dataSource = self;
|
||||
_collectionView.delegate = self;
|
||||
_collectionView.backgroundColor = [UIColor clearColor];
|
||||
[_collectionView registerClass:[XPAnchorCardSkillCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPAnchorCardSkillCollectionViewCell class])];
|
||||
}
|
||||
return _collectionView;
|
||||
}
|
||||
|
||||
- (UIButton *)playButton {
|
||||
if (!_playButton) {
|
||||
_playButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_playButton setImage:[UIImage imageNamed:@"mine_user_info_skill_card_voice_play"] forState:UIControlStateNormal];
|
||||
[_playButton setImage:[UIImage imageNamed:@"mine_user_info_skill_card_voice_pause"] forState:UIControlStateSelected];
|
||||
[_playButton addTarget:self action:@selector(playButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[_playButton setEnlargeEdgeWithTop:8 right:10 bottom:8 left:10];
|
||||
}
|
||||
return _playButton;
|
||||
}
|
||||
|
||||
- (UIImageView *)noteImaegView {
|
||||
if (!_noteImaegView) {
|
||||
_noteImaegView = [[UIImageView alloc] init];
|
||||
_noteImaegView.userInteractionEnabled = YES;
|
||||
_noteImaegView.image = [UIImage imageNamed:@"mine_voice_shengyin_32"];
|
||||
NSMutableArray * array = [NSMutableArray array];
|
||||
for (int i = 0 ; i< 40; i++) {
|
||||
UIImage * image;
|
||||
if ( i < 10) {
|
||||
image = [UIImage imageNamed:[NSString stringWithFormat:@"mine_voice_shengyin_0%d", i]];
|
||||
} else {
|
||||
image = [UIImage imageNamed:[NSString stringWithFormat:@"mine_voice_shengyin_%d", i]];
|
||||
}
|
||||
if (image) {
|
||||
[array addObject:image];
|
||||
}
|
||||
|
||||
}
|
||||
_noteImaegView.animationImages = array;
|
||||
_noteImaegView.animationDuration = 1.2;
|
||||
_noteImaegView.animationRepeatCount = HUGE;
|
||||
}
|
||||
return _noteImaegView;
|
||||
}
|
||||
|
||||
@end
|
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// XPAnchorCardSkillCollectionViewCell.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by GreenLand on 2022/8/2.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "NetImageView.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XPAnchorCardSkillCollectionViewCell : UICollectionViewCell
|
||||
|
||||
@property (nonatomic, strong) NetImageView *imageView;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// XPAnchorCardSkillCollectionViewCell.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by GreenLand on 2022/8/2.
|
||||
//
|
||||
|
||||
#import "XPAnchorCardSkillCollectionViewCell.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
|
||||
@implementation XPAnchorCardSkillCollectionViewCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
[self.contentView addSubview:self.imageView];
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.mas_equalTo(0);
|
||||
make.top.bottom.mas_equalTo(self.contentView);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (NetImageView *)imageView {
|
||||
if (!_imageView) {
|
||||
_imageView = [[NetImageView alloc] init];
|
||||
_imageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
}
|
||||
return _imageView;
|
||||
}
|
||||
|
||||
@end
|
@@ -9,6 +9,7 @@
|
||||
#import <flutter_boost/FlutterBoost.h>
|
||||
#import <ReactiveObjC/ReactiveObjC.h>
|
||||
#import <NIMSDK/NIMSDK.h>
|
||||
#import <Masonry/Masonry.h>
|
||||
///Tool
|
||||
#import "XPMacro.h"
|
||||
#import "ThemeColor.h"
|
||||
@@ -33,6 +34,7 @@
|
||||
#import "InviteUserInfoModel.h"
|
||||
#import "NewUserGreetModel.h"
|
||||
#import "FindNewGreetMessageModel.h"
|
||||
#import "XPTabAnchorCardModel.h"
|
||||
///VC
|
||||
#import "TabbarViewController.h"
|
||||
#import "BaseViewController.h"
|
||||
@@ -52,6 +54,7 @@
|
||||
#import "XPSessionFindNewAlertView.h"
|
||||
#import "XPHomeLivesViewController.h"
|
||||
#import "XPNewUserRechargeViewController.h"
|
||||
#import "XPAnchorCardView.h"
|
||||
///Present
|
||||
#import "MainPresenter.h"
|
||||
#import "MainProtocol.h"
|
||||
@@ -61,8 +64,9 @@ UIKIT_EXTERN NSString * kUserCompleteInfoFinishKey;
|
||||
NSString * const kUserFirstLoginKey = @"kUserFirstLoginKey";
|
||||
UIKIT_EXTERN NSString * kHomeMoreScrollPageKey;
|
||||
UIKIT_EXTERN NSString * kNewUserRechargeKey;
|
||||
UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
|
||||
|
||||
@interface TabbarViewController () <BaseMvpProtocol, MainProtocol, NIMLoginManagerDelegate, NIMSystemNotificationManagerDelegate, NIMChatManagerDelegate>
|
||||
@interface TabbarViewController () <BaseMvpProtocol, MainProtocol, NIMLoginManagerDelegate, NIMSystemNotificationManagerDelegate, NIMChatManagerDelegate, XPAnchorCardViewDelegate>
|
||||
|
||||
@property (nonatomic, strong) MainPresenter *presenter;
|
||||
///房间最小化
|
||||
@@ -71,6 +75,14 @@ UIKIT_EXTERN NSString * kNewUserRechargeKey;
|
||||
@property (nonatomic,copy) NSString *inviteCode;
|
||||
///需要显示新用户充值优惠弹窗
|
||||
@property (nonatomic, assign) BOOL needShowNewUserRecharge;
|
||||
///需要展示主播卡片(首次)
|
||||
@property (nonatomic, assign) BOOL needShowAnchorCard;
|
||||
///延迟弹出主播卡片
|
||||
@property (nonatomic, assign) BOOL delayShowAnchorCard;
|
||||
///第二次启动弹出主播卡片
|
||||
@property (nonatomic, assign) BOOL secondLaunchShowAnchorCard;
|
||||
///主播卡片
|
||||
@property (nonatomic, strong) XPAnchorCardView *anchorCardView;
|
||||
|
||||
@end
|
||||
|
||||
@@ -86,6 +98,7 @@ UIKIT_EXTERN NSString * kNewUserRechargeKey;
|
||||
[[NIMSDK sharedSDK].systemNotificationManager addDelegate:self];
|
||||
[self.presenter juliandAdCallBackApi];
|
||||
[self.view addSubview:self.roomMineView];
|
||||
[self configSecondLaunchShowAnchorCard];
|
||||
[[NSNotificationCenter defaultCenter] addObserverForName:kRoomMiniNotificationKey object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
|
||||
[self configRoomMiniNView:note.userInfo];
|
||||
}];
|
||||
@@ -95,11 +108,7 @@ UIKIT_EXTERN NSString * kNewUserRechargeKey;
|
||||
}];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recommendMoreNotification:) name:kHomeMoreScrollPageKey object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showNewUserRecharge) name:kNewUserRechargeKey object:nil];
|
||||
}
|
||||
|
||||
//新用户专享充值弹窗
|
||||
- (void)showNewUserRecharge {
|
||||
self.needShowNewUserRecharge = YES;
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showAnchorCardKey:) name:kTabShowAnchorCardKey object:nil];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
@@ -111,6 +120,12 @@ UIKIT_EXTERN NSString * kNewUserRechargeKey;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated {
|
||||
[super viewWillDisappear:animated];
|
||||
self.delayShowAnchorCard = NO;
|
||||
self.secondLaunchShowAnchorCard = NO;
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated {
|
||||
[super viewDidAppear:animated];
|
||||
if (self.needShowNewUserRecharge) {
|
||||
@@ -118,6 +133,14 @@ UIKIT_EXTERN NSString * kNewUserRechargeKey;
|
||||
XPNewUserRechargeViewController *vc = [[XPNewUserRechargeViewController alloc] initWithNavigation:self.selectedViewController.navigationController];
|
||||
[self.selectedViewController.navigationController presentViewController:vc animated:YES completion:nil];
|
||||
}
|
||||
if (self.needShowAnchorCard && !self.delayShowAnchorCard) {
|
||||
[self.presenter getAnchorCardInfo];;
|
||||
}
|
||||
if (self.secondLaunchShowAnchorCard) {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self.presenter getAnchorCardInfo];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (MainPresenter *)presenter {
|
||||
@@ -217,6 +240,21 @@ UIKIT_EXTERN NSString * kNewUserRechargeKey;
|
||||
[self.navigationController presentViewController:nav animated:YES completion:nil];
|
||||
}
|
||||
|
||||
///获取主播卡片信息成功
|
||||
- (void)getAnchorCardInfoSuccess:(XPTabAnchorCardModel *)cardInfo {
|
||||
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);
|
||||
}];
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - NIMLoginManagerDelegate
|
||||
- (void)onAutoLoginFailed:(NSError *)error {
|
||||
// 如果非上次登录设备 autoLogin 会返回 417
|
||||
@@ -456,6 +494,64 @@ UIKIT_EXTERN NSString * kNewUserRechargeKey;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - 主播卡片弹窗
|
||||
//新用户专享充值弹窗
|
||||
- (void)showNewUserRecharge {
|
||||
self.needShowNewUserRecharge = YES;
|
||||
}
|
||||
|
||||
///展示主播卡片
|
||||
- (void)showAnchorCardKey:(NSNotification *)noti {
|
||||
NSDictionary * dic = noti.object;
|
||||
self.delayShowAnchorCard = [[dic objectForKey:@"delayShow"] boolValue];
|
||||
self.needShowAnchorCard = YES;
|
||||
}
|
||||
|
||||
///判断第二次启动时弹出主播卡片
|
||||
- (void)configSecondLaunchShowAnchorCard {
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
NSNumber *launch = [defaults valueForKey:@"secondLaunchApp"];
|
||||
if (!launch) {///第一次启动
|
||||
[defaults setValue:@(1) forKey:@"secondLaunchApp"];
|
||||
[defaults synchronize];
|
||||
} else if([launch integerValue] == 1){///第二次启动
|
||||
[[NSUserDefaults standardUserDefaults] setValue:@(2) forKey:@"secondLaunchApp"];
|
||||
[defaults synchronize];
|
||||
self.secondLaunchShowAnchorCard = YES;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - XPAnchorCardViewDelegate
|
||||
- (void)xPAnchorCardViewEnterRoom:(NSString *)roomUid {
|
||||
if (roomUid) {
|
||||
[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)handleAnchorCardSwipeFrom:(UISwipeGestureRecognizer *)recognizer{
|
||||
if(recognizer.direction == UISwipeGestureRecognizerDirectionUp) {
|
||||
NSLog(@"swipe up");
|
||||
[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 - Getters And Setters
|
||||
- (XPMiniRoomView *)roomMineView {
|
||||
if (!_roomMineView) {
|
||||
@@ -466,4 +562,13 @@ UIKIT_EXTERN NSString * kNewUserRechargeKey;
|
||||
return _roomMineView;
|
||||
}
|
||||
|
||||
- (XPAnchorCardView *)anchorCardView {
|
||||
if (!_anchorCardView) {
|
||||
_anchorCardView = [[XPAnchorCardView alloc] init];
|
||||
_anchorCardView.delegate = self;
|
||||
|
||||
}
|
||||
return _anchorCardView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
Reference in New Issue
Block a user