新增夺宝精灵

This commit is contained in:
liyuhua
2023-08-10 10:12:19 +08:00
parent 00e4fd98bd
commit 8bda1a7f8a
482 changed files with 16034 additions and 440 deletions

View File

@@ -98,6 +98,8 @@ typedef NS_ENUM(NSUInteger, CustomMessageType) {
CustomMessageType_Graffiti_Gift = 94,
///星级厨房飘屏
CustomMessageType_Graffiti_Star_Kitchen = 95,
///精灵密藏
CustomMessageType_Treasure_Fairy = 97,
///寻爱之旅
CustomMessageType_Look_Love = 98,
};
@@ -527,6 +529,41 @@ typedef NS_ENUM(NSUInteger, CustomMessageGraffitiStarKitchen) {
/// // 星级厨房礼物全服飘屏通知
Custom_Message_Sub_Star_Kitchen_FullScreen = 952,
};
///夺宝精灵 CustomMessageType_Treasure_Fairy = 97,
typedef NS_ENUM(NSInteger, CustomMessageTreasureFairy) {
///精灵赠送
Custom_Message_Sub_Treasure_Fairy_Send_Fairy = 9701,
///索要精灵
Custom_Message_Sub_Treasure_Fairy_Ask_Fairy = 9702,
///抽奖礼物
///抽奖L1礼物
Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L1 = 9711,
///抽奖L2礼物
Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L2 = 9712,
///抽奖L3礼物
Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L3 = 9713,
///抽奖L4礼物
Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L4 = 9714,
///抽奖L5礼物
Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L5 = 9715,
///抽奖获得的精灵球的
/// 抽奖L1精灵球
Custom_Message_Sub_Treasure_Fairy_Draw_Ball_L1 = 9721,
/// 抽奖L2精灵球
Custom_Message_Sub_Treasure_Fairy_Draw_Ball_L2 = 9722,
/// 抽奖L3精灵球
Custom_Message_Sub_Treasure_Fairy_Draw_Ball_L3 = 9723,
///精灵球召唤礼物
///召唤L1
Custom_Message_Sub_Treasure_Fairy_Convert_L1 = 9731,
///召唤L2
Custom_Message_Sub_Treasure_Fairy_Convert_L2 = 9732,
///召唤L3
Custom_Message_Sub_Treasure_Fairy_Convert_L3 = 9733,
};
///first = CustomMessageType_Candy_Tree
typedef NS_ENUM(NSUInteger, CustomMessageSubLookLove) {

View File

@@ -0,0 +1,33 @@
//
// ContentTreasureFairyModel.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/23.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface ContentTreasureFairyModel : NSObject
///用户uid
@property (nonatomic,copy) NSString *uid;
///目标用户的uid
@property (nonatomic,copy) NSString *targetUid;
///精灵的id
@property (nonatomic,copy) NSString *elfId;
///精灵的图片
@property (nonatomic,copy) NSString *elfPicUrl;
///显示的内容
@property (nonatomic,copy) NSString *msgContent;
///精灵的名称
@property (nonatomic,copy) NSString *elfName;
///目标用户的昵称
@property (nonatomic,copy) NSString *targetNick;
///用户的昵称
@property (nonatomic,copy) NSString *nick;
///是否已经赠送过了
@property (nonatomic,assign) BOOL isSended;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,12 @@
//
// ContentTreasureFairyModel.m
// xplan-ios
//
// Created by on 2023/2/23.
//
#import "ContentTreasureFairyModel.h"
@implementation ContentTreasureFairyModel
@end

View File

@@ -0,0 +1,16 @@
//
// MessageContentTreasureFairyView.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/23.
//
#import "MessageContentCustomView.h"
NS_ASSUME_NONNULL_BEGIN
@interface MessageContentTreasureFairyView : MessageContentCustomView
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,154 @@
//
// MessageContentTreasureFairyView.m
// xplan-ios
//
// Created by on 2023/2/23.
//
#import "MessageContentTreasureFairyView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "NetImageView.h"
#import "NSObject+MJExtension.h"
#import "TTPopup.h"
#import "MessageTreasureFairyModel.h"
///Model
#import "TreasureFairyBallInfoModel.h"
#import "ContentTreasureFairyModel.h"
///View
#import "XPTreasureFairyMessageSendView.h"
@interface MessageContentTreasureFairyView ()
///
@property (nonatomic,strong) NetImageView *ballImageView;
///
@property (nonatomic,strong) UIStackView *stackView;
///
@property (nonatomic,strong) UILabel *titleLabel;
///
@property (nonatomic,strong) UILabel *checkLabel;
///
@property (nonatomic,strong) NIMMessage *message;
@property (nonatomic,strong) ContentTreasureFairyModel *fairyInfo;
@end
@implementation MessageContentTreasureFairyView
+ (CGFloat)measureHeight:(NIMMessage *)message {
return 78 + CONTENT_PADDING_V_TOTAL;
}
- (void)initSubViews {
[super initSubViews];
[self addSubview:self.backView];
[self.backView addSubview:self.ballImageView];
[self.backView addSubview:self.stackView];
[self.stackView addArrangedSubview:self.titleLabel];
[self.stackView addArrangedSubview:self.checkLabel];
}
- (void)initSubViewConstraints {
[super initSubViewConstraints];
[self.backView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.bottom.right.equalTo(self);
make.left.mas_equalTo(self).offset(10);
make.height.mas_equalTo(78);
make.width.mas_equalTo(235);
}];
[self.ballImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(62, 62));
make.left.mas_equalTo(self.backView);
make.centerY.mas_equalTo(self.backView);
}];
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.ballImageView.mas_right).offset(12);
make.centerY.mas_equalTo(self.ballImageView);
make.right.mas_equalTo(self.backView).offset(-10);
}];
}
- (void)render:(MessageTreasureFairyModel *)model {
self.message = model.message;
NIMCustomObject *obj = (NIMCustomObject *)model.message.messageObject;
AttachmentModel * attach = (AttachmentModel *)obj.attachment;
ContentTreasureFairyModel * info;
if (model.message.localExt) {
info = [ContentTreasureFairyModel modelWithDictionary:model.message.localExt];
} else {
info = [ContentTreasureFairyModel modelWithDictionary:attach.data];
}
self.fairyInfo = info;
self.checkLabel.hidden = (attach.second == Custom_Message_Sub_Treasure_Fairy_Send_Fairy || info.isSended || self.message.isOutgoingMsg);
self.ballImageView.imageUrl = info.elfPicUrl;
self.titleLabel.text = info.msgContent;
}
- (void)checkRecognizer {
if (!self.titleLabel.isHidden) {
XPTreasureFairyMessageSendView * view = [[XPTreasureFairyMessageSendView alloc] init];
view.fairyInfo = self.fairyInfo;
@kWeakify(self);
view.finish = ^(BOOL success,ContentTreasureFairyModel * fairyInfo) {
@kStrongify(self);
fairyInfo.isSended = YES;
self.fairyInfo.isSended = fairyInfo;
self.message.localExt = [self.fairyInfo model2dictionary];
[[NIMSDK sharedSDK].conversationManager updateMessage:self.message forSession:self.message.session completion:^(NSError * _Nullable error) {
if (self.delegate && [self.delegate respondsToSelector:@selector(updateMessageSuccess:)]) {
[self.delegate updateMessageSuccess:self.message];
}
}];
};
[TTPopup popupView:view style:TTPopupStyleAlert];
}
}
- (NetImageView *)ballImageView {
if (!_ballImageView) {
NetImageConfig * config = [[NetImageConfig alloc]init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
_ballImageView = [[NetImageView alloc] initWithConfig:config];
_ballImageView.contentMode = UIViewContentModeScaleAspectFill;
_ballImageView.layer.masksToBounds = YES;
}
return _ballImageView;
}
- (UIStackView *)stackView {
if (!_stackView) {
_stackView = [[UIStackView alloc] init];
_stackView.axis = UILayoutConstraintAxisVertical;
_stackView.distribution = UIStackViewDistributionFill;
_stackView.alignment = UIStackViewAlignmentFill;
_stackView.spacing = 10;
}
return _stackView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont systemFontOfSize:13];
_titleLabel.textColor = [DJDKMIMOMColor mainTextColor];
_titleLabel.numberOfLines = 2;
}
return _titleLabel;
}
- (UILabel *)checkLabel {
if (!_checkLabel) {
_checkLabel = [[UILabel alloc] init];
_checkLabel.text = YMLocalizedString(@"MessageContentTreasureFairyView0");
_checkLabel.textColor = [DJDKMIMOMColor colorWithHexString:@"#5FCCE4"];
_checkLabel.font = [UIFont systemFontOfSize:13];
_checkLabel.textAlignment = NSTextAlignmentLeft;
_checkLabel.userInteractionEnabled = YES;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(checkRecognizer)];
[_checkLabel addGestureRecognizer:tap];
}
return _checkLabel;
}
@end

View File

@@ -0,0 +1,16 @@
//
// MessageTreasureFairyModel.h
// YuMi
//
// Created by duoban on 2023/8/9.
//
#import "MessageBaseModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface MessageTreasureFairyModel : MessageBaseModel
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,28 @@
//
// MessageTreasureFairyModel.m
// YuMi
//
// Created by duoban on 2023/8/9.
//
#import "MessageTreasureFairyModel.h"
#import <YYText/YYText.h>
#import "AttachmentModel.h"
#import "GuildMessageModel.h"
#import "DJDKMIMOMColor.h"
#import "NSObject+MJExtension.h"
@implementation MessageTreasureFairyModel
- (instancetype)initWithMessage:(NIMMessage *)message {
if (self = [super initWithMessage:message]) {
self.messageType = SessionMessageType_Custom;
self.height = 78 + CONTENT_PADDING_V_TOTAL;
self.contentSize = CGSizeMake(CONTENT_WIDTH_MAX, 78 + 20 + 15 + 15);
}
return self;
}
- (NSString *)cellContent:(MessageBaseModel *)model {
return @"MessageContentTreasureFairyView";
}
@end

View File

@@ -56,6 +56,7 @@
#import "MessageOpenLiveModel.h"
#import "MessageRevokeModel.h"
#import "MessageTipsModel.h"
#import "MessageTreasureFairyModel.h"
///View
#import "XPMineUserInfoViewController.h"
#import "XPMineSimpleUserInfoViewController.h"
@@ -269,7 +270,9 @@
model = [[MessageMonentsAutoModel alloc] initWithMessage:message];
} else if (attachment.first == CustomMessageType_RedPacket && attachment.second == Custom_Message_Sub_AllDiamandRedPacket) {
model = [[MessageRedPacketModel alloc] initWithMessage:message];
} else {
}else if (attachment.first == CustomMessageType_Treasure_Fairy && (attachment.second == Custom_Message_Sub_Treasure_Fairy_Ask_Fairy || attachment.second == Custom_Message_Sub_Treasure_Fairy_Send_Fairy)) {
model = [[MessageTreasureFairyModel alloc] initWithMessage:message];
} else {
model = [[MessageUnSupportModel alloc] initWithMessage:message];
}
return model;

View File

@@ -7,10 +7,18 @@
#import "MvpViewController.h"
NS_ASSUME_NONNULL_BEGIN
@protocol XPIAPRechargeViewControllerDelegate <NSObject>
@interface XPIAPRechargeViewController : MvpViewController
-(void)paySuccess;
@end
NS_ASSUME_NONNULL_BEGIN
@interface XPIAPRechargeViewController : MvpViewController
@property(nonatomic,weak) id<XPIAPRechargeViewControllerDelegate>delegate;
///是否从精灵页面过来
@property (nonatomic,assign) BOOL isFairyPay;
@end
NS_ASSUME_NONNULL_END

View File

@@ -152,6 +152,15 @@
///
- (void)backBtnAction {
if(self.isFairyPay){
[UIView animateWithDuration:0.5 animations:^{
self.view.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight);
}completion:^(BOOL finished) {
[self.view removeFromSuperview];
[self removeFromParentViewController];
}];
return;
}
[self.navigationController popViewControllerAnimated:YES];
}
@@ -267,6 +276,9 @@
[self getUserWalletBalanceInfo];
self.orderId = nil;
[self hideHUD];
if(self.delegate && [self.delegate respondsToSelector:@selector(paySuccess)]){
[self.delegate paySuccess];
}
}
- (void)getUserWalletInfo:(WalletInfoModel *)balanceInfo {

View File

@@ -1,8 +1,8 @@
//
// XPRoomActivityView.m
// YuMi
// xplan-ios
//
// Created by YuMi on 2021/10/12.
// Created by on 2021/10/12.
//
#import "XPRoomActivityContainerView.h"
@@ -12,17 +12,18 @@
///Tool
#import "AccountInfoStorage.h"
#import "Api+Room.h"
#import "Api+TreasureFairy.h"
#import "ClientConfig.h"
#import "NetImageView.h"
#import "TTPopup.h"
#import "XNDJTDDLoadingTool.h"
#import "YUMIMacroUitls.h"
///Model
#import "UserInfoModel.h"
#import "RoomInfoModel.h"
#import "ActivityInfoModel.h"
#import "AttachmentModel.h"
#import "FirstRechargeModel.h"
#import "TreasureFairyLimitModel.h"
///View
#import "XPRoomHalfWebView.h"
#import "XPCandyTreeViewController.h"
@@ -32,16 +33,21 @@
#import "XPArrangeMicViewController.h"
#import "XPSailingViewController.h"
#import "XCCurrentVCStackManager.h"
#import "XPTreasureFairyViewController.h"
UIKIT_EXTERN NSString *kShowFirstRechargeView;
@interface XPRoomActivityContainerView ()<SDCycleScrollViewDelegate>
///
@property (nonatomic,strong) UIStackView *stackView;
///
@property (nonatomic,strong) SDCycleScrollView *pi_BannerView;
@property (nonatomic,strong) SDCycleScrollView *cycleScrollView;
///
@property (nonatomic,strong) UIView * placeHolderView;
///
@property (nonatomic,strong) NetImageView *lookLoveImageView;
///
@property (nonatomic,strong) TreasureFairyLimitModel *fairyModel;
///
@property (nonatomic,strong) UIImageView *firstRechargeImageView;
///
@@ -50,6 +56,9 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView;
@property (nonatomic,weak) id<RoomHostDelegate>hostDelegate;
///
@property (nonatomic,copy) NSMutableArray<ActivityInfoModel *> *activityList;
///
@property (nonatomic,strong) UIImageView *sailingImageView;
///
@property (nonatomic,assign) BOOL isLoadActivity;
///
@@ -63,413 +72,505 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView;
@implementation XPRoomActivityContainerView
- (instancetype)initWithdelegate:(id<RoomHostDelegate>)delegate {
self = [super init];
if (self) {
self.hostDelegate = delegate;
[self initSubViews];
[self initSubViewConstraints];
[self requestActivityList];
[self configLookLove];
}
return self;
self = [super init];
if (self) {
self.hostDelegate = delegate;
[self initSubViews];
[self initSubViewConstraints];
[self requestActivityList];
[self configLookLove];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.stackView];
[self.stackView addArrangedSubview:self.pi_BannerView];
[self.stackView addArrangedSubview:self.placeHolderView];
[self.stackView addArrangedSubview:self.firstRechargeImageView];
[self.stackView addArrangedSubview:self.lookLoveImageView];
[self.stackView addArrangedSubview:self.joinDatingView];
[self addSubview:self.stackView];
[self.stackView addArrangedSubview:self.cycleScrollView];
[self.stackView addArrangedSubview:self.placeHolderView];
[self.stackView addArrangedSubview:self.firstRechargeImageView];
[self.stackView addArrangedSubview:self.lookLoveImageView];
[self.stackView addArrangedSubview:self.joinDatingView];
}
- (void)initSubViewConstraints {
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
CGFloat itemWidth = KScreenHeight > 667 ? 65 : 55 * kScreenHeightScale;
[self.pi_BannerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(itemWidth , itemWidth));
}];
[self.firstRechargeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(itemWidth, itemWidth));
}];
[self.lookLoveImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(itemWidth, itemWidth));
}];
[self.joinDatingView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(35* kScreenHeightScale);
}];
CGFloat itemWidth = KScreenHeight > 667 ? 65 : 55 * kScreenHeightScale;
[self.cycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(itemWidth , itemWidth));
}];
[self.firstRechargeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(itemWidth, itemWidth));
}];
[self.lookLoveImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(itemWidth, itemWidth));
}];
[self.joinDatingView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(35* kScreenHeightScale);
}];
}
- (void)requestActivityList {
///
dispatch_group_t group =dispatch_group_create();
//
dispatch_queue_t queue =dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0);
dispatch_group_enter(group);
dispatch_group_async(group, queue, ^{
NSString * roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId];
[Api roomActivityList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
NSArray <ActivityInfoModel *>* array = [ActivityInfoModel modelsWithArray:data.data];
[self.activityList addObjectsFromArray:array];
}
dispatch_group_leave(group);
} roomId:roomId type:@"2"];
});
dispatch_group_notify(group,dispatch_get_main_queue(), ^{
self.isLoadActivity = YES;
self.pi_BannerView.hidden = NO;
///
[self configfirstRecharge];
NSMutableArray *picArray = [NSMutableArray array];
for (ActivityInfoModel *model in self.activityList) {
[picArray addObject:model.bannerPic];
}
self.pi_BannerView.imageURLStringsGroup = picArray;
if (self.activityList.count > 1) {
[self.pi_BannerView setAutoScroll:YES];
self.pi_BannerView.autoScrollTimeInterval = 3;
} else {
[self.pi_BannerView setAutoScroll:NO];
}
});
///
dispatch_group_t group =dispatch_group_create();
//
dispatch_queue_t queue =dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0);
dispatch_group_enter(group);
dispatch_group_async(group, queue, ^{
NSString * roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId];
[Api roomActivityList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
NSArray <ActivityInfoModel *>* array = [ActivityInfoModel modelsWithArray:data.data];
[self.activityList addObjectsFromArray:array];
}
dispatch_group_leave(group);
} roomId:roomId type:@"2"];
});
dispatch_group_enter(group);
dispatch_group_async(group, queue, ^{
[Api treasureFailyLimitInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if(code == 200){
TreasureFairyLimitModel * info =[TreasureFairyLimitModel modelWithDictionary:data.data];
self.fairyModel = info;
}
dispatch_group_leave(group);
}];
});
dispatch_group_notify(group,dispatch_get_main_queue(), ^{
self.isLoadActivity = YES;
self.cycleScrollView.hidden = NO;
if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) {
[self configLittleGameActivity];
} else {
///
[self configFairy];
[self configfirstRecharge];
NSMutableArray *picArray = [NSMutableArray array];
for (ActivityInfoModel *model in self.activityList) {
[picArray addObject:model.bannerPic];
}
self.cycleScrollView.imageURLStringsGroup = picArray;
if (self.activityList.count > 1) {
[self.cycleScrollView setAutoScroll:YES];
self.cycleScrollView.autoScrollTimeInterval = 3;
} else {
[self.cycleScrollView setAutoScroll:NO];
}
}
});
}
///
-(void)configfirstRecharge{
UserInfoModel * userInfo = self.hostDelegate.getUserInfo;
if (userInfo.isFirstCharge == YES) {
if(![self.activityList containsObject:self.firstRechargeModel]){
[self.activityList insertObject:self.firstRechargeModel atIndex:0];
}
}else{
if([self.activityList containsObject:self.firstRechargeModel]){
[self.activityList removeObject:self.firstRechargeModel];
}
}
UserInfoModel * userInfo = self.hostDelegate.getUserInfo;
if (userInfo.isFirstCharge == YES) {
if(![self.activityList containsObject:self.firstRechargeModel]){
[self.activityList insertObject:self.firstRechargeModel atIndex:0];
}
}else{
if([self.activityList containsObject:self.firstRechargeModel]){
[self.activityList removeObject:self.firstRechargeModel];
}
}
}
///
-(void)configFairy{
if (self.fairyModel.open == YES && self.fairyModel.levelLimit <= self.hostDelegate.getUserInfo.userLevelVo.experLevelSeq) {
if(![self.activityList containsObject:self.fairyActivityModel]){
[self.activityList insertObject:self.fairyActivityModel atIndex:0];
}
}else{
if([self.activityList containsObject:self.fairyActivityModel]){
[self.activityList removeObject:self.fairyActivityModel];
}
}
}
///
- (void)configLookLove {
UserInfoModel * userInfo = self.hostDelegate.getUserInfo;
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
if (userInfo.userLevelVo.experLevelSeq >= roomInfo.findLoveDrawSwitchVo.openLevel && roomInfo.findLoveDrawSwitchVo.open == YES) {
self.lookLoveImageView.hidden = NO;
self.lookLoveImageView.image = [UIImage imageNamed:@"room_candy_tree_enter"];
} else {
self.lookLoveImageView.hidden = YES;
}
UserInfoModel * userInfo = self.hostDelegate.getUserInfo;
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
if (userInfo.userLevelVo.experLevelSeq >= roomInfo.findLoveDrawSwitchVo.openLevel && roomInfo.findLoveDrawSwitchVo.open == YES) {
self.lookLoveImageView.hidden = NO;
self.lookLoveImageView.image = [UIImage imageNamed:@"room_candy_tree_enter"];
} else {
self.lookLoveImageView.hidden = YES;
}
}
- (void)configLittleGameActivity {
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
UserInfoModel * userInfo = self.hostDelegate.getUserInfo;
if (userInfo.userLevelVo.experLevelSeq >= roomInfo.findLoveDrawSwitchVo.openLevel && roomInfo.findLoveDrawSwitchVo.open == YES) {
self.lookLoveModel.bannerPic = @"room_candy_tree_enter";
if(![self.activityList containsObject:self.lookLoveModel]){
[self.activityList insertObject:self.lookLoveModel atIndex:0];
}
}
NSMutableArray *picArray = [NSMutableArray array];
for (ActivityInfoModel *model in self.activityList) {
[picArray addObject:model.bannerPic];
}
self.cycleScrollView.imageURLStringsGroup = picArray;
if (self.activityList.count > 1) {
[self.cycleScrollView setAutoScroll:YES];
self.cycleScrollView.autoScrollTimeInterval = 3;
}else{
[self.cycleScrollView setAutoScroll:NO];
}
}
#pragma mark - RoomGuestDelegat
- (void)onRoomUpdate {
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
if (roomInfo.type == RoomType_MiniGame) {
self.firstRechargeImageView.hidden = YES;
self.lookLoveImageView.hidden = YES;
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
if (roomInfo.type == RoomType_MiniGame) {
self.firstRechargeImageView.hidden = YES;
self.lookLoveImageView.hidden = YES;
self.sailingImageView.hidden = YES;
if (self.isLoadActivity) {
[self configLittleGameActivity];
} else {
[self requestActivityList];
}
} else {
if([self.activityList containsObject:self.lookLoveModel]){
[self.activityList removeObject:self.lookLoveModel];
}
[self configLookLove];
self.firstRechargeImageView.hidden = YES;
[self configFairy];
[self configfirstRecharge];
NSMutableArray *picArray = [NSMutableArray array];
for (ActivityInfoModel *model in self.activityList) {
[picArray addObject:model.bannerPic];
}
self.cycleScrollView.imageURLStringsGroup = picArray;
if (self.activityList.count > 1) {
[self.cycleScrollView setAutoScroll:YES];
self.cycleScrollView.autoScrollTimeInterval = 3;
} else {
[self.cycleScrollView setAutoScroll:NO];
}
if (roomInfo.roomModeType == RoomModeType_Open_Blind || roomInfo.roomModeType == RoomModeType_Open_PK_Mode || roomInfo.roomModeType == RoomModeType_Open_Micro_Mode) {
if (roomInfo.roomModeType == RoomModeType_Open_PK_Mode ) {
self.joinDatingView.image = [UIImage imageNamed:@"room_pk_normal_member_enter"];
} else {
self.joinDatingView.image = [UIImage imageNamed:@"room_mode_dating_enter"];
}
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
request.roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
request.userIds = @[[AccountInfoStorage instance].getUid];
[[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray<NIMChatroomMember *> * _Nullable members) {
if (error == nil) {
NIMChatroomMember * member = members.firstObject;
if (member.type == NIMTeamMemberTypeOwner || member.type == NIMTeamMemberTypeManager) {
self.joinDatingView.hidden = YES;
return;
}
}
self.joinDatingView.hidden = NO;
}];
} else {
self.joinDatingView.hidden = YES;
}
[self requestActivityList];
} else {
if([self.activityList containsObject:self.lookLoveModel]){
[self.activityList removeObject:self.lookLoveModel];
}
[self configLookLove];
self.firstRechargeImageView.hidden = YES;
[self configfirstRecharge];
NSMutableArray *picArray = [NSMutableArray array];
for (ActivityInfoModel *model in self.activityList) {
[picArray addObject:model.bannerPic];
}
self.pi_BannerView.imageURLStringsGroup = picArray;
if (self.activityList.count > 1) {
[self.pi_BannerView setAutoScroll:YES];
self.pi_BannerView.autoScrollTimeInterval = 3;
} else {
[self.pi_BannerView setAutoScroll:NO];
}
if (roomInfo.roomModeType == RoomModeType_Open_Blind || roomInfo.roomModeType == RoomModeType_Open_PK_Mode || roomInfo.roomModeType == RoomModeType_Open_Micro_Mode) {
if (roomInfo.roomModeType == RoomModeType_Open_PK_Mode ) {
self.joinDatingView.image = [UIImage imageNamed:@"room_pk_normal_member_enter"];
} else {
self.joinDatingView.image = [UIImage imageNamed:@"room_mode_dating_enter"];
}
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
request.roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
request.userIds = @[[AccountInfoStorage instance].getUid];
[[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray<NIMChatroomMember *> * _Nullable members) {
if (error == nil) {
NIMChatroomMember * member = members.firstObject;
if (member.type == NIMTeamMemberTypeOwner || member.type == NIMTeamMemberTypeManager) {
self.joinDatingView.hidden = YES;
return;
}
}
self.joinDatingView.hidden = NO;
}];
} else {
self.joinDatingView.hidden = YES;
}
}
if ([ClientConfig shareConfig].configInfo.linearlyPoolOpenLevel <= self.hostDelegate.getUserInfo.userLevelVo.experLevelSeq) {
self.sailingImageView.hidden = NO;
} else {
self.sailingImageView.hidden = YES;
}
}
}
- (void)onRoomEntered {
[self onRoomUpdate];
[self onRoomUpdate];
}
- (void)handleNIMCustomMessage:(NIMMessage *)message {
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
if (attachment.first == CustomMessageType_First_Recharge_Reward && attachment.second == Custom_Message_Sub_Room_First_Recharge_Reward) {
FirstRechargeModel *model = [FirstRechargeModel modelWithJSON:attachment.data];
XPFirstRechargeSuccessView * firstRechargeView= [[XPFirstRechargeSuccessView alloc] init];
firstRechargeView.rechargeInfo = model;
[TTPopup popupView:firstRechargeView style:TTPopupStyleAlert];
}
}
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
if (attachment.first == CustomMessageType_First_Recharge_Reward && attachment.second == Custom_Message_Sub_Room_First_Recharge_Reward) {
FirstRechargeModel *model = [FirstRechargeModel modelWithJSON:attachment.data];
XPFirstRechargeSuccessView * firstRechargeView= [[XPFirstRechargeSuccessView alloc] init];
firstRechargeView.rechargeInfo = model;
[TTPopup popupView:firstRechargeView style:TTPopupStyleAlert];
}
}
}
- (void)handleNIMNotificationMessage:(NIMMessage *)message {
NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject;
NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content;
switch (content.eventType) {
case NIMChatroomEventTypeAddManager:
{
if (self.hostDelegate.getRoomInfo.roomModeType == RoomModeType_Open_Blind || self.hostDelegate.getRoomInfo.roomModeType == RoomModeType_Open_PK_Mode) {
for (NIMChatroomNotificationMember * member in content.targets) {
if (member.userId.intValue == [AccountInfoStorage instance].getUid.integerValue) {
self.joinDatingView.hidden = YES;
break;
}
}
}
}
break;
case NIMChatroomEventTypeRemoveManager:
{
if (self.hostDelegate.getRoomInfo.roomModeType == RoomModeType_Open_Blind || self.hostDelegate.getRoomInfo.roomModeType == RoomModeType_Open_PK_Mode) {
for (NIMChatroomNotificationMember * member in content.targets) {
if (member.userId.intValue == [AccountInfoStorage instance].getUid.integerValue) {
self.joinDatingView.hidden = NO;
break;
}
}
}
}
break;
default:
break;
}
NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject;
NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content;
switch (content.eventType) {
case NIMChatroomEventTypeAddManager:
{
if (self.hostDelegate.getRoomInfo.roomModeType == RoomModeType_Open_Blind || self.hostDelegate.getRoomInfo.roomModeType == RoomModeType_Open_PK_Mode) {
for (NIMChatroomNotificationMember * member in content.targets) {
if (member.userId.intValue == [AccountInfoStorage instance].getUid.integerValue) {
self.joinDatingView.hidden = YES;
break;
}
}
}
}
break;
case NIMChatroomEventTypeRemoveManager:
{
if (self.hostDelegate.getRoomInfo.roomModeType == RoomModeType_Open_Blind || self.hostDelegate.getRoomInfo.roomModeType == RoomModeType_Open_PK_Mode) {
for (NIMChatroomNotificationMember * member in content.targets) {
if (member.userId.intValue == [AccountInfoStorage instance].getUid.integerValue) {
self.joinDatingView.hidden = NO;
break;
}
}
}
}
break;
default:
break;
}
}
#pragma mark - SDCycleScrollViewDelegate
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
NSArray *imageUrlList = cycleScrollView.imageURLStringsGroup;
if (imageUrlList.count > index) {
NSString *pic = imageUrlList[index];
ActivityInfoModel * info;
for (ActivityInfoModel * getInfo in self.activityList) {
if([getInfo.bannerPic isEqualToString:pic]){
info = getInfo;
break;;
}
}
if(info == nil)return;
if (info.activityType == ActivityType_Love) {
[self lookLoveTapRecognizer];
} else if(info.activityType == ActivityType_First) {
[self firstRechargeTapRecognizer];
}else {
if (info.skipType == ActivitySkipType_Room) {
[self.hostDelegate exitRoom];
[XPRoomViewController openRoom:info.skipUri viewController:self.hostDelegate.getCurrentNav];
} else if(info.skipType == ActivitySkipType_Web) {
if (info.showType == ActivityShowType_Half) {
XPRoomHalfWebView * webView = [[XPRoomHalfWebView alloc] init];
webView.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
webView.url = info.skipUri;
webView.isPush = YES;
[TTPopup popupView:webView style:TTPopupStyleActionSheet];
return;
}
XPWebViewController * webVC = [[XPWebViewController alloc] init];
webVC.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
webVC.url = info.skipUri;
NSArray *imageUrlList = cycleScrollView.imageURLStringsGroup;
if (imageUrlList.count > index) {
NSString *pic = imageUrlList[index];
ActivityInfoModel * info;
for (ActivityInfoModel * getInfo in self.activityList) {
if([getInfo.bannerPic isEqualToString:pic]){
info = getInfo;
break;;
}
}
if(info == nil)return;
if (info.activityType == ActivityType_Love) {
[self lookLoveTapRecognizer];
} else if(info.activityType == ActivityType_First) {
[self firstRechargeTapRecognizer];
}else if(info.activityType == ActivityType_Fairy){
XPTreasureFairyViewController * fairyVC = [[XPTreasureFairyViewController alloc] initWithdelegate:self.hostDelegate];
fairyVC.roomUid =[NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
fairyVC.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self.hostDelegate.getCurrentNav presentViewController:fairyVC animated:YES completion:nil];
}else {
if (info.skipType == ActivitySkipType_Room) {
[self.hostDelegate exitRoom];
[XPRoomViewController openRoom:info.skipUri viewController:self.hostDelegate.getCurrentNav];
} else if(info.skipType == ActivitySkipType_Web) {
if (info.showType == ActivityShowType_Half) {
XPRoomHalfWebView * webView = [[XPRoomHalfWebView alloc] init];
webView.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
webView.url = info.skipUri;
[TTPopup popupView:webView style:TTPopupStyleActionSheet];
return;
}
XPWebViewController * webVC = [[XPWebViewController alloc] init];
webVC.isPush = YES;
[self.hostDelegate.getCurrentNav pushViewController:webVC animated:YES];
}
}
}
webVC.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
webVC.url = info.skipUri;
[self.hostDelegate.getCurrentNav pushViewController:webVC animated:YES];
}
}
}
}
#pragma mark - Event Response
- (void)lookLoveTapRecognizer {
XPCandyTreeViewController * candyTreeVC = [[XPCandyTreeViewController alloc] initWithDelegate:self.hostDelegate];
candyTreeVC.view.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
[[XCCurrentVCStackManager shareManager].getCurrentVC addChildViewController:candyTreeVC];
[candyTreeVC.navigationController setNavigationBarHidden:YES animated:NO];
[[XCCurrentVCStackManager shareManager].getCurrentVC.view addSubview:candyTreeVC.view];
XPCandyTreeViewController * candyTreeVC = [[XPCandyTreeViewController alloc] initWithDelegate:self.hostDelegate];
candyTreeVC.view.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
[[XCCurrentVCStackManager shareManager].getCurrentVC addChildViewController:candyTreeVC];
[candyTreeVC.navigationController setNavigationBarHidden:YES animated:NO];
[[XCCurrentVCStackManager shareManager].getCurrentVC.view addSubview:candyTreeVC.view];
}
- (void)firstRechargeTapRecognizer {
[[NSNotificationCenter defaultCenter]postNotificationName:kShowFirstRechargeView object:nil];
[[NSNotificationCenter defaultCenter]postNotificationName:kShowFirstRechargeView object:nil];
}
- (void)didTapJoinDatingRecognizer {
if (self.hostDelegate.getRoomInfo.roomModeType == RoomModeType_Open_PK_Mode && self.hostDelegate.isRoomPKPlaying) {
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"XPRoomActivityContainerView2")];
return;
}
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
request.roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId];
request.userIds = @[[AccountInfoStorage instance].getUid];
[[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray<NIMChatroomMember *> * _Nullable members) {
NIMChatroomMember * member;
if (error == nil) {
member = members.firstObject;
}
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
XPArrangeMicInfoModel * info = [[XPArrangeMicInfoModel alloc] init];
info.roomUid = [NSString stringWithFormat:@"%ld", roomInfo.uid];
info.roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
info.nick = roomInfo.nick;
info.roomAvatar = roomInfo.avatar;
info.roomTitle = roomInfo.title;
info.micQueue = [self.hostDelegate getMicroQueue];
info.isManager = (member.type == NIMChatroomMemberTypeCreator || member.type == NIMChatroomMemberTypeManager);
info.type = roomInfo.roomModeType == RoomModeType_Open_Blind ? ArrangeMicType_Dating : roomInfo.roomModeType == RoomModeType_Open_PK_Mode ? ArrangeMicType_Room_PK : ArrangeMicType_Normal;
XPArrangeMicViewController * arrangeMicVC = [[XPArrangeMicViewController alloc] initWithInfo:info];
[self.hostDelegate.getCurrentNav presentViewController:arrangeMicVC animated:YES completion:nil];
}];
if (self.hostDelegate.getRoomInfo.roomModeType == RoomModeType_Open_PK_Mode && self.hostDelegate.isRoomPKPlaying) {
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"XPRoomActivityContainerView2")];
return;
}
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
request.roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId];
request.userIds = @[[AccountInfoStorage instance].getUid];
[[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray<NIMChatroomMember *> * _Nullable members) {
NIMChatroomMember * member;
if (error == nil) {
member = members.firstObject;
}
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
XPArrangeMicInfoModel * info = [[XPArrangeMicInfoModel alloc] init];
info.roomUid = [NSString stringWithFormat:@"%ld", roomInfo.uid];
info.roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
info.nick = roomInfo.nick;
info.roomAvatar = roomInfo.avatar;
info.roomTitle = roomInfo.title;
info.micQueue = [self.hostDelegate getMicroQueue];
info.isManager = (member.type == NIMChatroomMemberTypeCreator || member.type == NIMChatroomMemberTypeManager);
info.type = roomInfo.roomModeType == RoomModeType_Open_Blind ? ArrangeMicType_Dating : roomInfo.roomModeType == RoomModeType_Open_PK_Mode ? ArrangeMicType_Room_PK : ArrangeMicType_Normal;
XPArrangeMicViewController * arrangeMicVC = [[XPArrangeMicViewController alloc] initWithInfo:info];
[self.hostDelegate.getCurrentNav presentViewController:arrangeMicVC animated:YES completion:nil];
}];
}
- (void)sailTapRecognizer {
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
XPSailingViewController * sailingVC = [[XPSailingViewController alloc] initWithRoomUid:roomUid];
[self.hostDelegate.getCurrentNav presentViewController:sailingVC animated:YES completion:nil];
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
XPSailingViewController * sailingVC = [[XPSailingViewController alloc] initWithRoomUid:roomUid];
[self.hostDelegate.getCurrentNav presentViewController:sailingVC animated:YES completion:nil];
}
#pragma mark - Getters And Setters
- (SDCycleScrollView *)pi_BannerView{
if (!_pi_BannerView) {
_pi_BannerView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:nil];
_pi_BannerView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
_pi_BannerView.currentPageDotColor = [UIColor whiteColor];
_pi_BannerView.pageDotColor = [UIColor colorWithWhite:1 alpha:0.2];
_pi_BannerView.pageControlDotSize = CGSizeMake(5, 2);
_pi_BannerView.pageControlStyle = SDCycleScrollViewPageContolStyleClassic;
_pi_BannerView.currentPageDotImage = [UIImage imageNamed:@"room_activity_banner_select"];
_pi_BannerView.pageDotImage = [UIImage imageNamed:@"room_activity_banner_normal"];
_pi_BannerView.backgroundColor = [UIColor colorWithWhite:1 alpha:0.00];
_pi_BannerView.bannerImageViewContentMode = UIViewContentModeScaleAspectFit;
_pi_BannerView.pageControlBottomOffset = -10;
_pi_BannerView.hidden = YES;
}
return _pi_BannerView;
- (SDCycleScrollView *)cycleScrollView {
if (!_cycleScrollView) {
_cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:nil];
_cycleScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
_cycleScrollView.currentPageDotColor = [UIColor whiteColor];
_cycleScrollView.pageDotColor = [UIColor colorWithWhite:1 alpha:0.2];
_cycleScrollView.pageControlDotSize = CGSizeMake(5, 2);
_cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleClassic;
_cycleScrollView.currentPageDotImage = [UIImage imageNamed:@"room_activity_banner_select"];
_cycleScrollView.pageDotImage = [UIImage imageNamed:@"room_activity_banner_normal"];
_cycleScrollView.backgroundColor = [UIColor colorWithWhite:1 alpha:0.00];
_cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFit;
_cycleScrollView.pageControlBottomOffset = -10;
_cycleScrollView.hidden = YES;
}
return _cycleScrollView;
}
- (UIView *)placeHolderView {
if (!_placeHolderView) {
_placeHolderView = [[UIView alloc] init];
_placeHolderView.backgroundColor = [UIColor clearColor];
[_placeHolderView setContentHuggingPriority:UILayoutPriorityDragThatCanResizeScene forAxis:UILayoutConstraintAxisHorizontal];
[_placeHolderView setContentCompressionResistancePriority:UILayoutPriorityFittingSizeLevel forAxis:UILayoutConstraintAxisHorizontal];
}
return _placeHolderView;
if (!_placeHolderView) {
_placeHolderView = [[UIView alloc] init];
_placeHolderView.backgroundColor = [UIColor clearColor];
[_placeHolderView setContentHuggingPriority:UILayoutPriorityDragThatCanResizeScene forAxis:UILayoutConstraintAxisHorizontal];
[_placeHolderView setContentCompressionResistancePriority:UILayoutPriorityFittingSizeLevel forAxis:UILayoutConstraintAxisHorizontal];
}
return _placeHolderView;
}
- (UIStackView *)stackView {
if (!_stackView) {
_stackView = [[UIStackView alloc] init];
_stackView.axis = UILayoutConstraintAxisVertical;
_stackView.distribution = UIStackViewDistributionFill;
_stackView.alignment = UIStackViewAlignmentCenter;
_stackView.spacing = 5;
}
return _stackView;
if (!_stackView) {
_stackView = [[UIStackView alloc] init];
_stackView.axis = UILayoutConstraintAxisVertical;
_stackView.distribution = UIStackViewDistributionFill;
_stackView.alignment = UIStackViewAlignmentCenter;
_stackView.spacing = 5;
}
return _stackView;
}
- (UIImageView *)lookLoveImageView {
if (!_lookLoveImageView) {
NetImageConfig * config = [[NetImageConfig alloc] init];
config.placeHolder = [UIImage imageNamed:@"room_candy_tree_enter"];
config.imageType = ImageTypeUserIcon;
_lookLoveImageView = [[NetImageView alloc] initWithConfig:config];
_lookLoveImageView.userInteractionEnabled = YES;
_lookLoveImageView.hidden = YES;
_lookLoveImageView.image = [UIImage imageNamed:@"room_candy_tree_enter"];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(lookLoveTapRecognizer)];
[_lookLoveImageView addGestureRecognizer:tap];
}
return _lookLoveImageView;
if (!_lookLoveImageView) {
NetImageConfig * config = [[NetImageConfig alloc] init];
config.placeHolder = [UIImage imageNamed:@"room_candy_tree_enter"];
config.imageType = ImageTypeUserIcon;
_lookLoveImageView = [[NetImageView alloc] initWithConfig:config];
_lookLoveImageView.userInteractionEnabled = YES;
_lookLoveImageView.hidden = YES;
_lookLoveImageView.image = [UIImage imageNamed:@"room_candy_tree_enter"];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(lookLoveTapRecognizer)];
[_lookLoveImageView addGestureRecognizer:tap];
}
return _lookLoveImageView;
}
- (UIImageView *)firstRechargeImageView {
if (!_firstRechargeImageView) {
_firstRechargeImageView = [[UIImageView alloc] init];
_firstRechargeImageView.image = [UIImage imageNamed:@"room_first_recharge_enter"];
_firstRechargeImageView.userInteractionEnabled = YES;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(firstRechargeTapRecognizer)];
[_firstRechargeImageView addGestureRecognizer:tap];
}
return _firstRechargeImageView;
if (!_firstRechargeImageView) {
_firstRechargeImageView = [[UIImageView alloc] init];
_firstRechargeImageView.image = [UIImage imageNamed:@"room_first_recharge_enter"];
_firstRechargeImageView.userInteractionEnabled = YES;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(firstRechargeTapRecognizer)];
[_firstRechargeImageView addGestureRecognizer:tap];
}
return _firstRechargeImageView;
}
- (UIImageView *)joinDatingView {
if (!_joinDatingView) {
_joinDatingView = [[UIImageView alloc] init];
_joinDatingView.image = [UIImage imageNamed:@"room_mode_dating_enter"];
_joinDatingView.userInteractionEnabled = YES;
_joinDatingView.hidden = YES;
_joinDatingView.contentMode = UIViewContentModeScaleAspectFit;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapJoinDatingRecognizer)];
[_joinDatingView addGestureRecognizer:tap];
}
return _joinDatingView;
if (!_joinDatingView) {
_joinDatingView = [[UIImageView alloc] init];
_joinDatingView.image = [UIImage imageNamed:@"room_mode_dating_enter"];
_joinDatingView.userInteractionEnabled = YES;
_joinDatingView.hidden = YES;
_joinDatingView.contentMode = UIViewContentModeScaleAspectFit;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapJoinDatingRecognizer)];
[_joinDatingView addGestureRecognizer:tap];
}
return _joinDatingView;
}
- (NSMutableArray<ActivityInfoModel *> *)activityList {
if (!_activityList) {
_activityList = [NSMutableArray array];
}
return _activityList;
if (!_activityList) {
_activityList = [NSMutableArray array];
}
return _activityList;
}
- (UIImageView *)sailingImageView {
if (!_sailingImageView) {
_sailingImageView = [[UIImageView alloc] init];
_sailingImageView.image = [UIImage imageNamed:@"room_sailiing_enter"];
_sailingImageView.userInteractionEnabled = YES;
_sailingImageView.hidden = YES;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(sailTapRecognizer)];
[_sailingImageView addGestureRecognizer:tap];
}
return _sailingImageView;
}
- (ActivityInfoModel *)fairyActivityModel{
if (!_fairyActivityModel){
ActivityInfoModel *fairyModel = [ActivityInfoModel new];
fairyModel.bannerName = YMLocalizedString(@"XPRoomActivityContainerView3");
fairyModel.bannerPic = @"room_treasure_fairy_enter";
_fairyActivityModel = fairyModel;
_fairyActivityModel.activityType = ActivityType_Fairy;
}
return _fairyActivityModel;
}
- (ActivityInfoModel *)firstRechargeModel{
if (!_firstRechargeModel){
ActivityInfoModel * activityInfo = [[ActivityInfoModel alloc] init];
activityInfo.bannerPic = @"room_first_recharge_enter";
activityInfo.bannerName = YMLocalizedString(@"XPRoomActivityContainerView0");
_firstRechargeModel = activityInfo;
_firstRechargeModel.activityType = ActivityType_First;
}
return _firstRechargeModel;
if (!_firstRechargeModel){
ActivityInfoModel * activityInfo = [[ActivityInfoModel alloc] init];
activityInfo.bannerPic = @"room_first_recharge_enter";
activityInfo.bannerName = YMLocalizedString(@"XPRoomActivityContainerView0");
_firstRechargeModel = activityInfo;
_firstRechargeModel.activityType = ActivityType_First;
}
return _firstRechargeModel;
}
-(ActivityInfoModel *)lookLoveModel{
if (!_lookLoveModel){
ActivityInfoModel * activityInfo = [[ActivityInfoModel alloc] init];
activityInfo.bannerName = YMLocalizedString(@"XPRoomActivityContainerView1");
_lookLoveModel = activityInfo;
_lookLoveModel.activityType = ActivityType_Love;
}
return _lookLoveModel;
if (!_lookLoveModel){
ActivityInfoModel * activityInfo = [[ActivityInfoModel alloc] init];
activityInfo.bannerName = YMLocalizedString(@"XPRoomActivityContainerView1");
_lookLoveModel = activityInfo;
_lookLoveModel.activityType = ActivityType_Love;
}
return _lookLoveModel;
}
@end

View File

@@ -13,6 +13,7 @@ typedef enum : NSUInteger {
GiftBannerType_kitchen,///厨房
GiftBannerType_AnchorHour,///个播小时榜
GiftBannerType_LicneseHour,///牌照房小时榜
GiftBannerType_Fairy,///夺宝精灵
} GiftBannerType;
NS_ASSUME_NONNULL_BEGIN

View File

@@ -60,6 +60,7 @@
#import "XPWebViewController.h"
#import "PIBaseAnimationViewModel.h"
#import "PIFullScreenBannerAnimation.h"
#import "XPTreasureFairyGiftView.h"
@interface XPRoomAnimationView ()<SVGAPlayerDelegate,NIMBroadcastManagerDelegate, XPRoomGiftBroadcastViewDelegate, HWDMP4PlayDelegate, XPRoomLuckyBigPrizeViewDelegate,XPRoomLicneseHourRankViewDelegate, XPRoomGraffitiGiftAnimationViewDelegate, XPRoomStarKitchenBannerViewDelegate>
///
///
@@ -222,6 +223,8 @@
[self receiveRoomGraffitiStarKitchen:attachment];
}else if(attachment.first == CustomMessageType_Look_Love && attachment.second == Custom_Message_Sub_Look_Love_InRoom_NeedAllMicSend){
[self receiveCandyTreeGiftHighLevle:attachment];
}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)) { //
[self receiveTreasureFairyGiftHighLevel:attachment];
}
}
}
@@ -414,6 +417,76 @@
[self.delegate.getCurrentNav pushViewController:webVC animated:YES];
}
#pragma mark -
- (void)receiveTreasureFairyGiftHighLevel:(AttachmentModel *)attatchment {
if ([self isInSudGame]) {return;}
if ([self isInSudGame]) {return;}
PIBaseAnimationViewModel *giftModel = [PIBaseAnimationViewModel new];
giftModel.data = attatchment.data;
giftModel.second = attatchment.second;
giftModel.first = attatchment.first;
giftModel.type = GiftBannerType_Fairy;
if (self.animationListB.count == 0 && self.isPlayOfB == NO) {
[self createTreasureFairyBannerAnimation:giftModel];
}
[self.animationListB addObject:giftModel];
}
- (void)createTreasureFairyBannerAnimation:(PIBaseAnimationViewModel *)attatchment {
CGFloat kscale = (CGFloat)60 / (CGFloat)375;
CGFloat top = self.isPlayOfA == YES ? (190 + statusbarHeight) : (kNavigationHeight + 15);
XPTreasureFairyGiftView *treasureView = [[XPTreasureFairyGiftView alloc] initWithFrame:CGRectMake(KScreenWidth, top, KScreenWidth , KScreenWidth * kscale)];
//
if ((attatchment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L5) || (attatchment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L3)) {
treasureView.isMaxLargeGift = YES;
}else{
treasureView.isMaxLargeGift = NO;
}
if ((attatchment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L4) || (attatchment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L5)) {
treasureView.isDrawGift = YES; //
}else{
treasureView.isDrawGift = NO; //
}
treasureView.treasureInfo = attatchment.data;
[self.middleLevelView addSubview:treasureView];
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter];
springAnimation.springSpeed = 12;
springAnimation.springBounciness = 10.f;
springAnimation.fromValue = [NSValue valueWithCGPoint:treasureView.center];
springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(treasureView.frame.size.width / 2, treasureView.center.y)];
[springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
if (finished) {
POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter];
moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, treasureView.center.y)];
moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, treasureView.center.y)];
moveAnimation.beginTime = CACurrentMediaTime() + 3;
moveAnimation.duration = 0.5;
moveAnimation.repeatCount = 1;
moveAnimation.removedOnCompletion = YES;
@kWeakify(self);
[moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
@kStrongify(self);
if (finished) {
[treasureView removeFromSuperview];
self.isPlayOfB = NO;
if (self.animationListB.count > 0) {
[self.animationListB removeObjectAtIndex:0];
}
// if(self. isAnimationListAFinish == YES){
//
// [self playAnimationWithModel];
// self.isAnimationListAFinish = NO;
// return;
// }
[self playAnimationWithModel];
}
}];
[treasureView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
}
}];
[treasureView pop_addAnimation:springAnimation forKey:@"candyTreespingOutAnimation"];
}
#pragma mark -
- (void)receiveRoomGraffitiGift:(AttachmentModel *)attacment {
if (self.graffitiGiftQueue.count == 0) {
@@ -1457,6 +1530,8 @@
[self createAnchorHourRankAnimation:model];
}else if(model.type == GiftBannerType_LicneseHour){
[self createLicneseHourRankAnimation:model];
}else if(model.type == GiftBannerType_Fairy){
[self createTreasureFairyBannerAnimation:model];
}
}

View File

@@ -0,0 +1,23 @@
//
// XPTreasureFairyGiftView.h
// xplan-ios
//
// Created by XY on 2023/3/1.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPTreasureFairyGiftView : UIView
///是否是动态飘屏
@property (nonatomic,assign) BOOL isMaxLargeGift;
/// 是否是抽奖(抽奖、召唤)
@property (nonatomic,assign) BOOL isDrawGift;
///夺宝信息
@property (nonatomic,copy) NSDictionary *treasureInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,193 @@
//
// XPTreasureFairyGiftView.m
// xplan-ios
//
// Created by XY on 2023/3/1.
//
#import "XPTreasureFairyGiftView.h"
///Third
#import <Masonry/Masonry.h>
#import <SVGA.h>
#import "XPSVGAPlayer.h"
#import "ThemeColor+Room.h"
#import "TreasureFailryMessageModel.h"
#import "NSObject+MJExtension.h"
@interface XPTreasureFairyGiftView()
///
@property (strong, nonatomic) SVGAParser *parser;
///
@property (nonatomic,strong) XPSVGAPlayer *treasureView;
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,strong) UIView *titleView;
///
@property (nonatomic,strong) UILabel *titleLabel;
@end
@implementation XPTreasureFairyGiftView
- (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.treasureView];
[self addSubview:self.backImageView];
[self.backImageView addSubview:self.titleView];
[self.titleView addSubview:self.titleLabel];
}
- (void)initSubViewConstraints {
[self.treasureView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.backImageView).inset(20);
make.height.mas_equalTo(28);
make.top.mas_equalTo(self.backImageView).offset(23);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.titleView);
make.centerY.mas_equalTo(self.titleView);
}];
}
- (NSAttributedString *)createAttribute:(NSString * )text color:(UIColor *)color fontSize:(CGFloat)fonSize {
NSDictionary * attribute = @{NSFontAttributeName:[UIFont systemFontOfSize:fonSize], NSForegroundColorAttributeName:color};
NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:text attributes:attribute];
return attr;
}
#pragma mark - Getters And Setters
- (void)setTreasureInfo:(NSDictionary *)treasureInfo {
if (treasureInfo) {
TreasureFailryMessageModel * giftInfo = [TreasureFailryMessageModel modelWithDictionary:treasureInfo];
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
CGFloat fontSize = self.isMaxLargeGift ? 22 : 13;
// CGFloat fontSize = 13;
if (self.isDrawGift) {
[attribute appendAttributedString:[self createAttribute:YMLocalizedString(@"XPTreasureFairyGiftView0") color:[DJDKMIMOMColor colorWithHexString:@"#8C4700"] fontSize:fontSize]];
NSString * nick = giftInfo.nick;
if (nick.length > 6) {
nick = [nick substringToIndex:6];
}
[attribute appendAttributedString:[self createAttribute:nick color:[DJDKMIMOMColor colorWithHexString:@"#EC4613"] fontSize:fontSize]];
[attribute appendAttributedString:[self createAttribute:YMLocalizedString(@"XPTreasureFairyGiftView1") color:[DJDKMIMOMColor colorWithHexString:@"#8C4700"] fontSize:fontSize]];
[attribute appendAttributedString:[self createAttribute:giftInfo.rewardName color:[DJDKMIMOMColor colorWithHexString:@"#EC4613"] fontSize:fontSize]];
if (giftInfo.rewardNum > 1) {
[attribute appendAttributedString:[self createAttribute:[NSString stringWithFormat:@" X%ld", giftInfo.rewardNum] color:[DJDKMIMOMColor colorWithHexString:@"#EC4613"] fontSize:fontSize]];
}
}else{
[attribute appendAttributedString:[self createAttribute:YMLocalizedString(@"XPTreasureFairyGiftView2") color:[DJDKMIMOMColor colorWithHexString:@"#8C4700"] fontSize:fontSize]];
[attribute appendAttributedString:[self createAttribute:giftInfo.nick color:[DJDKMIMOMColor colorWithHexString:@"#EC4613"] fontSize:fontSize]];
[attribute appendAttributedString:[self createAttribute:YMLocalizedString(@"XPTreasureFairyGiftView3") color:[DJDKMIMOMColor colorWithHexString:@"#8C4700"] fontSize:fontSize]];
NSString *level = @"";
if (giftInfo.rewardLevel == 1) {
level = YMLocalizedString(@"XPTreasureFairyGiftView4");
}else if (giftInfo.rewardLevel == 2) {
level = YMLocalizedString(@"XPTreasureFairyGiftView5");
}else if (giftInfo.rewardLevel == 3) {
level = YMLocalizedString(@"XPTreasureFairyGiftView6");
}
[attribute appendAttributedString:[self createAttribute:level color:[DJDKMIMOMColor colorWithHexString:@"#8C4700"] fontSize:fontSize]];
[attribute appendAttributedString:[self createAttribute:YMLocalizedString(@"XPTreasureFairyGiftView7") color:[DJDKMIMOMColor colorWithHexString:@"#8C4700"] fontSize:fontSize]];
[attribute appendAttributedString:[self createAttribute:[NSString stringWithFormat:@"%ld",giftInfo.rewardShowValue] color:[DJDKMIMOMColor colorWithHexString:@"#F1390A"] fontSize:fontSize]];
if ([giftInfo.rewardType isEqualToString:@"gift"]) {
[attribute appendAttributedString:[self createAttribute:YMLocalizedString(@"XPTreasureFairyGiftView8") color:[DJDKMIMOMColor colorWithHexString:@"#F1390A"] fontSize:fontSize]];
}else{
[attribute appendAttributedString:[self createAttribute:giftInfo.rewardUnit color:[DJDKMIMOMColor colorWithHexString:@"#F1390A"] fontSize:fontSize]];
}
[attribute appendAttributedString:[self createAttribute:giftInfo.rewardName color:[DJDKMIMOMColor colorWithHexString:@"#F1390A"] fontSize:fontSize]];
}
NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
paragraphStyle.lineBreakMode = NSLineBreakByCharWrapping;
paragraphStyle.lineSpacing = 0.0f;//
paragraphStyle.alignment = NSTextAlignmentCenter;
paragraphStyle.baseWritingDirection = NSWritingDirectionLeftToRight;
[attribute addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, attribute.length)];
[self.treasureView setAttributedText:attribute forKey:@"touming_text_name"];
if (self.isMaxLargeGift) {
self.backImageView.hidden = YES;
self.treasureView.hidden = NO;
@kWeakify(self);
[self.parser parseWithNamed:@"treasure_fairy_gift_bg" inBundle:[NSBundle mainBundle] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
@kStrongify(self);
self.treasureView.loops = 1;
self.treasureView.clearsAfterStop = NO;
self.treasureView.videoItem = videoItem;
[self.treasureView startAnimation];
} failureBlock:^(NSError * _Nonnull error) {
}];
} else {
self.backImageView.hidden = NO;
self.treasureView.hidden = YES;
self.titleLabel.attributedText = attribute;
self.titleLabel.textAlignment = NSTextAlignmentCenter;
}
}
}
- (XPSVGAPlayer *)treasureView {
if (!_treasureView) {
_treasureView = [[XPSVGAPlayer alloc]init];
_treasureView.backgroundColor = [UIColor clearColor];
_treasureView.userInteractionEnabled = NO;
}
return _treasureView;
}
- (SVGAParser *)parser {
if (!_parser) {
_parser = [[SVGAParser alloc]init];
}
return _parser;
}
- (UIView *)titleView {
if (!_titleView) {
_titleView = [[UIView alloc] init];
_titleView.backgroundColor = [UIColor clearColor];
}
return _titleView;
}
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.image = [UIImage imageNamed:@"room_treaseure_fairy_normal_gift_bg"];
}
return _backImageView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.numberOfLines = 2;
}
return _titleLabel;
}
@end

View File

@@ -42,6 +42,7 @@
#import "XPOpenRedPacketModel.h"
#import "XPMessageInfoModel.h"
#import "XPRoomStarKitchenModel.h"
#import "TreasureFailryMessageModel.h"
#import "NetImageView.h"
#import "XPUserCardViewController.h"
@@ -50,6 +51,7 @@
#import "XPRoomPKResultView.h"
#import "XPWebViewController.h"
#import "XCCurrentVCStackManager.h"
#import "XPTreasureFairyViewController.h"
@implementation XPRoomMessageParser
- (XPMessageInfoModel*)parseMessageAttribute:(NIMMessage *)message {
@@ -126,6 +128,8 @@
return [self createRedPacketAttribute:attachment messageInfo:messageInfo];
} else if (first == CustomMessageType_Graffiti_Star_Kitchen){
return [self createStarredKitchenAttribute:attachment messageInfo:messageInfo];
}else if (first == CustomMessageType_Treasure_Fairy) {
return [self createTreasureFairyAttribute:attachment messageInfo:messageInfo];
}
return nil;
}
@@ -297,7 +301,82 @@
}
return nil;
}
#pragma mark -
- (XPMessageInfoModel *)createTreasureFairyAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
TreasureFailryMessageModel *info = [TreasureFailryMessageModel modelWithDictionary:attachment.data];
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
if (attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L1 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L2 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L3) {///
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser104") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
NSMutableAttributedString * nickAttriibute = [self createTextAttribute:info.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont];
[self attributeAddHihtLight:nickAttriibute uid:info.uid.integerValue];
[attribute appendAttributedString:nickAttriibute];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser105") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:info.rewardName color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
if (info.rewardNum > 1) {
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"X%ld", info.rewardNum] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
}
} else if (attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L4 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L5) {///
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser106") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
NSMutableAttributedString * nickAttriibute = [self createTextAttribute:info.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont];
[self attributeAddHihtLight:nickAttriibute uid:info.uid.integerValue];
[attribute appendAttributedString:nickAttriibute];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser105") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:info.rewardName color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
if (info.rewardNum > 1) {
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"X%ld", info.rewardNum] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
}
} else if (attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Ball_L1) {///
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser104") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
NSMutableAttributedString * nickAttriibute = [self createTextAttribute:info.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont];
[self attributeAddHihtLight:nickAttriibute uid:info.uid.integerValue];
[attribute appendAttributedString:nickAttriibute];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser105") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:info.rewardName color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
} else if (attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Ball_L2 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Ball_L3) {///
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser107") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
NSMutableAttributedString * nickAttriibute = [self createTextAttribute:info.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont];
[self attributeAddHihtLight:nickAttriibute uid:info.uid.integerValue];
[attribute appendAttributedString:nickAttriibute];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser105") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:info.rewardName color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
} else if (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) {///
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser104") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
NSMutableAttributedString * nickAttriibute = [self createTextAttribute:info.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont];
[self attributeAddHihtLight:nickAttriibute uid:info.uid.integerValue];
[attribute appendAttributedString:nickAttriibute];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser105") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
if(attachment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L3) {
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser108") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
} else if (attachment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L2) {
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser109") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
} else {
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser110") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
}
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser111") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"%ld", info.rewardShowValue] color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
if ([info.rewardType isEqualToString:@"gift"]){
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser112") color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
} else {
[attribute appendAttributedString:[self createTextAttribute:info.rewardUnit color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
}
[attribute appendAttributedString:[self createTextAttribute:info.rewardName color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
}
if (self.hostDelegate.getUserInfo.userLevelVo.experLevelSeq >= info.userLevelLimit) {
NSMutableAttributedString * nickAttriibute = [self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser113") color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont];
@kWeakify(self);
[nickAttriibute yy_setTextHighlightRange:NSMakeRange(0, nickAttriibute.length) color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
@kStrongify(self);
XPTreasureFairyViewController * fairyVC = [[XPTreasureFairyViewController alloc] initWithdelegate:self.hostDelegate];
fairyVC.roomUid =[NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
fairyVC.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self.hostDelegate.getCurrentNav presentViewController:fairyVC animated:YES completion:nil];
}];
[attribute appendAttributedString:nickAttriibute];
}
messageInfo.content = attribute;
return messageInfo;
}
#pragma mark -
//- (NSAttributedString *)createStarKitchenAttribute:(AttachmentModel *)attachment{
// XPRoomStarKitchenModel *starModel = [XPRoomStarKitchenModel modelWithDictionary:attachment.data];

View File

@@ -489,7 +489,20 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
[NSSet setWithObjects:
@(Custom_Message_Sub_OpenRedPacketSuccess),
nil],
@(CustomMessageType_Treasure_Fairy):
[NSSet setWithObjects:
@(Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L1),
@(Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L2),
@(Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L3),
@(Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L4),
@(Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L5),
@(Custom_Message_Sub_Treasure_Fairy_Draw_Ball_L1),
@(Custom_Message_Sub_Treasure_Fairy_Draw_Ball_L2),
@(Custom_Message_Sub_Treasure_Fairy_Draw_Ball_L3),
@(Custom_Message_Sub_Treasure_Fairy_Convert_L1),
@(Custom_Message_Sub_Treasure_Fairy_Convert_L2),
@(Custom_Message_Sub_Treasure_Fairy_Convert_L3),
nil]
};
}

View File

@@ -0,0 +1,123 @@
//
// Api+TreasureFairy.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/15.
//
#import "Api.h"
NS_ASSUME_NONNULL_BEGIN
@interface Api (TreasureFairy)
/// 夺宝限制
/// - Parameter completion: 完成
+ (void)treasureFailyLimitInfo:(HttpRequestHelperCompletion)completion;
/// 夺宝奖池
/// - Parameter completion: 完成
+ (void)treasureFailyDrawList:(HttpRequestHelperCompletion)completion;
/// 夺宝信息
/// - Parameter completion: 完成
+ (void)treasureFailyDrawInfo:(HttpRequestHelperCompletion)completion;
/// 开始夺宝
/// - Parameters:
/// - completion: 完成
/// - roomUid: 房主的uid
/// - drawNum: 个数
+ (void)treasureFailyDraw:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid drawNum:(NSString *)drawNum;
/// 森林抽奖
/// - Parameters:
/// - completion: 完成
/// - roomUid: 抽奖次数
/// - poolLevel: 奖池类型 1:初级2:中级3:高级;
+ (void)treasureFailyForestDraw:(HttpRequestHelperCompletion)completion drawNum:(NSString *)drawNum poolLevel:(NSString *)poolLevel;
/// 森林抽奖记录
/// - Parameters:
/// - completion: 完成
/// - page: 页数
/// - pageSize: 一页多少个
+ (void)treasureFairyForestDrawRecord:(HttpRequestHelperCompletion)completion page:(NSString *)page pageSize:(NSString *)pageSize;
/// 用户森林信息
/// - Parameter completion: 完成
+ (void)treasureFailyForestUserInfo:(HttpRequestHelperCompletion)completion;
/// 猛犸森林奖池配置列表
/// - Parameter completion: 完成
/// - Parameter poolLevel: 奖池等级
+ (void)treasureFailyForestItems:(HttpRequestHelperCompletion)completion poolLevel:(NSString *)poolLevel;
/// 我的精灵
/// - Parameter completion: 完成
+ (void)treasureFairyMyBallList:(HttpRequestHelperCompletion)completion;
/// 我的好友
/// - Parameters:
/// - completion: 完成
/// - nick: 昵称
+ (void)treasureFairyFansFriendList:(HttpRequestHelperCompletion)completion nick:(NSString *)nick;
/// 精灵赠送
/// - Parameters:
/// - completion: 完成
/// - elfId: 精灵id
/// - targetUid: 目标用户的uid
+ (void)treasureFairySendFairyBall:(HttpRequestHelperCompletion)completion elfId:(NSString *)elfId targetUid:(NSString *)targetUid;
/// 索要
/// - Parameters:
/// - completion: 完成
/// - elfId: 精灵id
/// - targetUid: 目标用户的uid
+ (void)treasureFairyAskForFairyBall:(HttpRequestHelperCompletion)completion elfId:(NSString *)elfId targetUid:(NSString *)targetUid;
/// 赠与和获赠记录
/// - Parameter completion: 完成
/// - Parameter page: 页数
/// - Parameter page: 一页多少个
+ (void)treasureFailySendAndAskRecordList:(HttpRequestHelperCompletion)completion page:(NSString *)page pageSize:(NSString *)pageSize;
/// 精灵试炼
/// - Parameter completion: 完成
/// - Parameter page: 页数
/// - Parameter page: 一页多少个
+ (void)treasureFailyCompoundBall:(HttpRequestHelperCompletion)completion compoundLevel:(NSInteger)compoundLevel compoundReqs:(NSArray *)compoundReqs;
/// 精灵试炼记录
/// - Parameter completion: 完成
/// - Parameter page: 页数
/// - Parameter pageSize: 一页多少个
+ (void)treasureFailyCompoundBallRecord:(HttpRequestHelperCompletion)completion page:(NSString *)page pageSize:(NSString *)pageSize;
/// 兑换-精灵召回列表
/// - Parameter completion: 完成
/// - Parameter page: 页数
/// - Parameter pageSize: 一页多少个
+ (void)treasureFailyConvertElfList:(HttpRequestHelperCompletion)completion;
/// 兑换-精灵
/// - Parameter completion: 完成
/// - Parameter itemId: id
+ (void)treasureFailyConvert:(HttpRequestHelperCompletion)completion itemId:(NSString *)itemId roomUid:(NSString *)roomUid;
/// 兑换-碎片兑换列表
/// - Parameter completion: 完成
/// - Parameter page: 页数
/// - Parameter pageSize: 一页多少个
+ (void)treasureFailyFragmentExchangeList:(HttpRequestHelperCompletion)completion;
/// 兑换记录
/// - Parameters:
/// - completion: 完成
/// - convertType: 1:精灵召唤 2:碎片兑换
/// - page: 页数
/// - pageSize: 一页多少个
+ (void)treasureFairyConvertRecord:(HttpRequestHelperCompletion)completion convertType:(NSString *)convertType page:(NSString *)page pageSize:(NSString *)pageSize;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,164 @@
//
// Api+TreasureFairy.m
// xplan-ios
//
// Created by on 2023/2/15.
//
#import "Api+TreasureFairy.h"
#import "NSMutableDictionary+Saft.h"
@implementation Api (TreasureFairy)
///
/// - Parameter completion:
+ (void)treasureFailyLimitInfo:(HttpRequestHelperCompletion)completion {
[self makeRequest:@"act/seize-treasure/status" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, nil];
}
///
/// - Parameter completion:
+ (void)treasureFailyDrawList:(HttpRequestHelperCompletion)completion {
[self makeRequest:@"act/seize-treasure/draw/pool/list" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, nil];
}
///
/// - Parameter completion:
+ (void)treasureFailyDrawInfo:(HttpRequestHelperCompletion)completion {
[self makeRequest:@"act/seize-treasure/user/draw/info" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, nil];
}
///
/// - Parameters:
/// - completion:
/// - roomUid: uid
/// - drawNum:
+ (void)treasureFailyDraw:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid drawNum:(NSString *)drawNum {
[self makeRequest:@"act/seize-treasure/draw" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, roomUid, drawNum, nil];
}
///
/// - Parameters:
/// - completion:
/// - roomUid:
/// - poolLevel: 1:2:3:
+ (void)treasureFailyForestDraw:(HttpRequestHelperCompletion)completion drawNum:(NSString *)drawNum poolLevel:(NSString *)poolLevel {
[self makeRequest:@"act/seize-treasure/forest/draw" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, drawNum, poolLevel, nil];
}
///
/// - Parameters:
/// - completion:
/// - page:
/// - pageSize:
+ (void)treasureFairyForestDrawRecord:(HttpRequestHelperCompletion)completion page:(NSString *)page pageSize:(NSString *)pageSize {
[self makeRequest:@"act/seize-treasure/forest/draw/record" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, page, pageSize, nil];
}
///
/// - Parameter completion:
+ (void)treasureFailyForestUserInfo:(HttpRequestHelperCompletion)completion {
[self makeRequest:@"act/seize-treasure/user/forest/info" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, nil];
}
///
/// - Parameter completion:
/// - Parameter poolLevel:
+ (void)treasureFailyForestItems:(HttpRequestHelperCompletion)completion poolLevel:(NSString *)poolLevel {
[self makeRequest:@"act/seize-treasure/draw/forest/item" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__,poolLevel, nil];
}
///
/// - Parameter completion:
+ (void)treasureFairyMyBallList:(HttpRequestHelperCompletion)completion {
[self makeRequest:@"act/seize-treasure/elf/user/info" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, nil];
}
///
/// - Parameters:
/// - completion:
/// - nick:
+ (void)treasureFairyFansFriendList:(HttpRequestHelperCompletion)completion nick:(NSString *)nick {
NSMutableDictionary * params = [NSMutableDictionary dictionary];
[params safeSetObject:nick forKey:@"nick"];
[HttpRequestHelper request:@"fans/friend/list" method:HttpRequestHelperMethodGET params:params completion:completion];
}
///
/// - Parameters:
/// - completion:
/// - elfId: id
/// - targetUid: uid
+ (void)treasureFairySendFairyBall:(HttpRequestHelperCompletion)completion elfId:(NSString *)elfId targetUid:(NSString *)targetUid {
[self makeRequest:@"act/seize-treasure/elf/send" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__,elfId, targetUid, nil];
}
///
/// - Parameters:
/// - completion:
/// - elfId: id
/// - targetUid: uid
+ (void)treasureFairyAskForFairyBall:(HttpRequestHelperCompletion)completion elfId:(NSString *)elfId targetUid:(NSString *)targetUid {
[self makeRequest:@"act/seize-treasure/elf/askFor" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__,elfId, targetUid, nil];
}
///
/// - Parameter completion:
/// - Parameter page:
/// - Parameter page:
+ (void)treasureFailySendAndAskRecordList:(HttpRequestHelperCompletion)completion page:(NSString *)page pageSize:(NSString *)pageSize {
[self makeRequest:@"act/seize-treasure/elf/record" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, page, pageSize,nil];
}
///
/// - Parameter completion:
/// - Parameter page:
/// - Parameter page:
+ (void)treasureFailyCompoundBall:(HttpRequestHelperCompletion)completion compoundLevel:(NSInteger)compoundLevel compoundReqs:(NSArray *)compoundReqs {
NSMutableDictionary * dic = [NSMutableDictionary dictionary];
[dic safeSetObject:@(compoundLevel) forKey:@"level"];
[dic safeSetObject:compoundReqs forKey:@"expendList"];
[HttpRequestHelper postSkillCard:@"act/seize-treasure/elf/compound" params:dic.toJSONString completion:completion];
}
///
/// - Parameter completion:
/// - Parameter page:
/// - Parameter pageSize:
+ (void)treasureFailyCompoundBallRecord:(HttpRequestHelperCompletion)completion page:(NSString *)page pageSize:(NSString *)pageSize {
[self makeRequest:@"act/seize-treasure/elf/compound/record" method:HttpRequestHelperMethodGET completion:completion,__FUNCTION__, page, pageSize, nil];
}
/// -
/// - Parameter completion:
/// - Parameter page:
/// - Parameter pageSize:
+ (void)treasureFailyConvertElfList:(HttpRequestHelperCompletion)completion {
[self makeRequest:@"act/seize-treasure/convert/elf/list" method:HttpRequestHelperMethodGET completion:completion,__FUNCTION__, nil];
}
/// -
/// - Parameter completion:
/// - Parameter itemId: id
+ (void)treasureFailyConvert:(HttpRequestHelperCompletion)completion itemId:(NSString *)itemId roomUid:(nonnull NSString *)roomUid {
[self makeRequest:@"act/seize-treasure/convert" method:HttpRequestHelperMethodPOST completion:completion,__FUNCTION__, itemId, roomUid,nil];
}
/// -
/// - Parameter completion:
/// - Parameter page:
/// - Parameter pageSize:
+ (void)treasureFailyFragmentExchangeList:(HttpRequestHelperCompletion)completion {
[self makeRequest:@"act/seize-treasure/convert/chip/list" method:HttpRequestHelperMethodGET completion:completion,__FUNCTION__, nil];
}
///
/// - Parameters:
/// - completion:
/// - convertType: 1: 2:
/// - page:
/// - pageSize:
+ (void)treasureFairyConvertRecord:(HttpRequestHelperCompletion)completion convertType:(NSString *)convertType page:(NSString *)page pageSize:(NSString *)pageSize {
[self makeRequest:@"act/seize-treasure/convert/record" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, convertType, page, pageSize, nil];
}
@end

View File

@@ -0,0 +1,35 @@
//
// TreasureFailryMessageModel.h
// xplan-ios
//
// Created by 冯硕 on 2023/3/1.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface TreasureFailryMessageModel : NSObject
///奖励的名称
@property (nonatomic,copy) NSString *rewardName;
///奖励的个数
@property (nonatomic,assign) NSInteger rewardNum;
///用户的uid
@property (nonatomic,copy) NSString *uid;
///昵称
@property (nonatomic,copy) NSString *nick;
///所在房间的Uid
@property (nonatomic,copy) NSString *roomUid;
///奖励等级
@property (nonatomic,assign) NSInteger rewardLevel;
///奖励类型
@property (nonatomic,copy) NSString *rewardType;
///限制等级
@property (nonatomic,assign) NSInteger userLevelLimit;
///礼物价值
@property (nonatomic,assign) NSInteger rewardShowValue;
/// 奖励单位
@property (nonatomic, copy) NSString *rewardUnit;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,12 @@
//
// TreasureFailryMessageModel.m
// xplan-ios
//
// Created by on 2023/3/1.
//
#import "TreasureFailryMessageModel.h"
@implementation TreasureFailryMessageModel
@end

View File

@@ -0,0 +1,25 @@
//
// TreasureFailyKeyInfoModel.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/17.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface TreasureFailyKeyInfoModel : NSObject
///门票数
@property (nonatomic,assign) NSInteger drawTicketNum;
///幸运值
@property (nonatomic,assign) NSInteger luckyNum;
///写一个幸运值
@property (nonatomic,assign) NSInteger nextBallNum;
///需要幸运值
@property (nonatomic,assign) NSInteger needLuckyNum;
///保存我的精灵选择的精灵等级0初级1史诗2传说
@property (nonatomic,assign) NSInteger spriteLevel;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,12 @@
//
// TreasureFailyKeyInfoModel.m
// xplan-ios
//
// Created by on 2023/2/17.
//
#import "TreasureFailyKeyInfoModel.h"
@implementation TreasureFailyKeyInfoModel
@end

View File

@@ -0,0 +1,50 @@
//
// TreasureFairyBallInfoModel.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/22.
//
#import <Foundation/Foundation.h>
#import "TreasureFairyInfoModel.h"
NS_ASSUME_NONNULL_BEGIN
@class TreasureFairyBallModel;
@interface TreasureFairyBallInfoModel : NSObject
///头像
@property (nonatomic,copy) NSString *avatar;
///昵称
@property (nonatomic,copy) NSString *nick;
///精灵碎片
@property (nonatomic,assign) NSInteger chipNum;
///史诗
@property (nonatomic,copy) NSArray<TreasureFairyBallModel *> *middleElves;
///普通
@property (nonatomic,copy) NSArray<TreasureFairyBallModel *> *lowElves;
///传说
@property (nonatomic,copy) NSArray<TreasureFairyBallModel *> *highElves;
@end
@interface TreasureFairyBallModel : NSObject
///id
@property (nonatomic,assign) NSInteger elfId;
///精灵名称
@property (nonatomic,copy) NSString *elfName;
///精灵数量
@property (nonatomic,assign) NSInteger elfNum;
///精灵图片
@property (nonatomic,copy) NSString *elfPicUrl;
///精灵等级
@property (nonatomic,assign) TreasureFairyStoreType elfLevel;
///是否翻转了 本地字段
@property (nonatomic,assign) BOOL isFlip;
///选中的个数 最大为3
@property (nonatomic,assign) NSInteger chooseNum;
///消息中使用的
///昵称 赠送的时候使用
@property (nonatomic,copy) NSString *nick;
///赠送的人的uid
@property (nonatomic,assign) NSInteger uid;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,26 @@
//
// TreasureFairyBallInfoModel.m
// xplan-ios
//
// Created by on 2023/2/22.
//
#import "TreasureFairyBallInfoModel.h"
@implementation TreasureFairyBallInfoModel
+ (NSDictionary *)objectClassInArray {
return @{
@"highElves":TreasureFairyBallModel.class,
@"lowElves":TreasureFairyBallModel.class,
@"middleElves":TreasureFairyBallModel.class,
};
}
@end
@implementation TreasureFairyBallModel
@end

View File

@@ -0,0 +1,27 @@
//
// TreasureFairyConvertRecordModel.h
// xplan-ios
//
// Created by XY on 2023/3/1.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface TreasureFairyConvertRecordModel : NSObject
@property (nonatomic, assign) NSInteger convertLevel;
@property (nonatomic, assign) NSInteger convertType;
@property (nonatomic, copy) NSString *createTime;
@property (nonatomic, assign) NSInteger recordId;
@property (nonatomic, copy) NSString *rewardName;
@property (nonatomic, copy) NSString *rewardNum;
@property (nonatomic, copy) NSString *rewardPicUrl;
@property (nonatomic, copy) NSString *rewardShowValue;
@property (nonatomic, copy) NSString *rewardType;
@property (nonatomic, copy) NSString *rewardUnit;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,12 @@
//
// TreasureFairyConvertRecordModel.m
// xplan-ios
//
// Created by XY on 2023/3/1.
//
#import "TreasureFairyConvertRecordModel.h"
@implementation TreasureFairyConvertRecordModel
@end

View File

@@ -0,0 +1,39 @@
//
// TreasureFairyFragmentModel.h
// xplan-ios
//
// Created by XY on 2023/2/28.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface TreasureFairyFragmentModel : NSObject
/// 消耗数量
@property (nonatomic, assign) NSInteger expendNum;
/// 兑换项id
@property (nonatomic, assign) NSInteger itemId;
/// 兑换等级
@property (nonatomic, assign) NSInteger level;
/// 奖励id
@property (nonatomic, assign) NSInteger rewardId;
/// 奖励名称
@property (nonatomic, copy) NSString *rewardName;
/// 奖励数量
@property (nonatomic, assign) NSInteger rewardNum;
/// 奖励图片url
@property (nonatomic, copy) NSString *rewardPicUrl;
/// 奖励价值
@property (nonatomic, copy) NSString *rewardShowValue;
/// 奖励类型 activityProps:活动道具;gift:礼物;namePlate:铭牌;car:座驾;headwear:头饰;chatBubble:气泡;infoCard:资料卡;
@property (nonatomic, copy) NSString *rewardType;
/// 奖励单位
@property (nonatomic, copy) NSString *rewardUnit;
/// 兑换类型
@property (nonatomic, assign) NSInteger type;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,12 @@
//
// TreasureFairyFragmentModel.m
// xplan-ios
//
// Created by XY on 2023/2/28.
//
#import "TreasureFairyFragmentModel.h"
@implementation TreasureFairyFragmentModel
@end

View File

@@ -0,0 +1,54 @@
//
// TreasureFairyInfoModel.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/15.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, TreasureFairyStoreType) {
///普通
TreasureFairyStoreType_Normal = 1,
///史诗
TreasureFairyStoreType_Middle = 2,
///传说
TreasureFairyStoreType_High = 3
};
typedef NS_ENUM(NSInteger, TreasureFairyPropType) {
///碎片
TreasureFairyPropType_Piece = 1,
///精灵球
TreasureFairyPropType_Ball = 2,
///精灵
TreasureFairyPropType_Fairy = 3
};
@interface TreasureFairyInfoModel : NSObject
///奖励id
@property (nonatomic,assign) NSInteger rewardId;
///奖励的名称
@property (nonatomic,copy) NSString *rewardName;
///奖励的个数
@property (nonatomic,assign) NSInteger rewardNum;
///奖励的图片
@property (nonatomic,copy) NSString *rewardPicUrl;
/// 展示概率
@property (nonatomic,assign) CGFloat showRatio;
///礼物的等级
@property (nonatomic,assign) NSInteger rewardLevel;
///礼物的index
@property (nonatomic,assign) NSInteger itemIndex;
#pragma mark - 夺宝记录
///奖池等级
@property (nonatomic,assign) TreasureFairyStoreType poolLevel;
///时间戳
@property (nonatomic,copy) NSString *drawTime;
///森林开出的礼物类型
@property (nonatomic,assign) TreasureFairyPropType propType;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,12 @@
//
// TreasureFairyInfoModel.m
// xplan-ios
//
// Created by on 2023/2/15.
//
#import "TreasureFairyInfoModel.h"
@implementation TreasureFairyInfoModel
@end

View File

@@ -0,0 +1,19 @@
//
// TreasureFairyLimitModel.h
// xplan-ios
//
// Created by 冯硕 on 2023/3/1.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface TreasureFairyLimitModel : NSObject
///是否开启
@property (nonatomic,assign) BOOL open;
///等级限制
@property (nonatomic,assign) NSInteger levelLimit;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,12 @@
//
// TreasureFairyLimitModel.m
// xplan-ios
//
// Created by on 2023/3/1.
//
#import "TreasureFairyLimitModel.h"
@implementation TreasureFairyLimitModel
@end

View File

@@ -0,0 +1,30 @@
//
// TreasureFairyRewardModel.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/28.
//
#import <Foundation/Foundation.h>
#import "TreasureFairyInfoModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface TreasureFairyRewardModel : NSObject
@property (nonatomic,assign) NSInteger itemId;
///奖励id
@property (nonatomic,assign) NSInteger rewardId;
///奖励的名称
@property (nonatomic,copy) NSString *rewardName;
///奖励的个数
@property (nonatomic,assign) NSInteger rewardNum;
///奖励的图片
@property (nonatomic,copy) NSString *rewardPicUrl;
///奖励的价值
@property (nonatomic,assign) NSInteger rewardShowValue;
///奖励的单位
@property (nonatomic,assign) NSInteger rewardUnit;
///类型
@property (nonatomic,assign) TreasureFairyStoreType level;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,12 @@
//
// TreasureFairyRewardModel.m
// xplan-ios
//
// Created by on 2023/2/28.
//
#import "TreasureFairyRewardModel.h"
@implementation TreasureFairyRewardModel
@end

View File

@@ -0,0 +1,34 @@
//
// TreasureFairySendRecordModel.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/23.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, TreasureFairySendRecordType) {
///赠与
TreasureFairySendRecordModel_Send = 2,
///获赠
TreasureFairySendRecordModel_Receive =3,
};
@interface TreasureFairySendRecordModel : NSObject
///时间戳
@property (nonatomic,copy) NSString *createTime;
///图片
@property (nonatomic,copy) NSString *elfPicUrl;
///头像
@property (nonatomic,copy) NSString *targetAvatar;
///昵称
@property (nonatomic,copy) NSString *targetNick;
///类型
@property (nonatomic,assign) TreasureFairySendRecordType type;
///精灵名称
@property (nonatomic,copy) NSString *elfName;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,12 @@
//
// TreasureFairySendRecordModel.m
// xplan-ios
//
// Created by on 2023/2/23.
//
#import "TreasureFairySendRecordModel.h"
@implementation TreasureFairySendRecordModel
@end

View File

@@ -0,0 +1,24 @@
//
// TreasureFairyTrialsRecordModel.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/27.
//
#import <Foundation/Foundation.h>
#import "TreasureFairyInfoModel.h"
#import "TreasureFairyBallInfoModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface TreasureFairyTrialsRecordModel : NSObject
///精灵等级
@property (nonatomic,assign) TreasureFairyStoreType compoundLevel;
///创建的时间
@property (nonatomic,copy) NSString *createTime;
///奖励的名称
@property (nonatomic,copy) NSString *elfName;
///合成的元素
@property (nonatomic,strong) NSArray<TreasureFairyBallModel *> *expendList;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,16 @@
//
// TreasureFairyTrialsRecordModel.m
// xplan-ios
//
// Created by on 2023/2/27.
//
#import "TreasureFairyTrialsRecordModel.h"
@implementation TreasureFairyTrialsRecordModel
+ (NSDictionary *)objectClassInArray {
return @{
@"expendList":TreasureFairyBallModel.class
};
}
@end

View File

@@ -0,0 +1,25 @@
//
// TreasureFairyUserInfoModel.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/21.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface TreasureFairyUserInfoModel : NSObject
///奖励的名称
@property (nonatomic,copy) NSString *avatar;
///奖励的名称
@property (nonatomic,copy) NSString *nick;
///高级精灵球个数
@property (nonatomic,assign) NSInteger highBallNum;
///初级精灵球个数
@property (nonatomic,assign) NSInteger lowBallNum;
///中级精灵球个数
@property (nonatomic,assign) NSInteger middleBallNum;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,12 @@
//
// TreasureFairyUserInfoModel.m
// xplan-ios
//
// Created by on 2023/2/21.
//
#import "TreasureFairyUserInfoModel.h"
@implementation TreasureFairyUserInfoModel
@end

View File

@@ -0,0 +1,21 @@
//
// TreasureFailyPresenter.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/15.
//
#import "BaseMvpPresenter.h"
NS_ASSUME_NONNULL_BEGIN
@interface XPTreasureFailyPresenter : BaseMvpPresenter
///获取夺宝信息
- (void)getTreasureFailyInfo;
///夺宝奖励列表
- (void)getTreasureFailyDrawList;
///开始夺宝
- (void)drawTreasureFaily:(NSString *)roomUid drawNum:(NSInteger)drawNum;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,42 @@
//
// TreasureFailyPresenter.m
// xplan-ios
//
// Created by on 2023/2/15.
//
#import "XPTreasureFailyPresenter.h"
#import "Api+TreasureFairy.h"
#import "TreasureFailyKeyInfoModel.h"
#import "TreasureFairyInfoModel.h"
#import "XPTreasureFailyProtocol.h"
@implementation XPTreasureFailyPresenter
///
- (void)getTreasureFailyInfo {
[Api treasureFailyDrawInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
TreasureFailyKeyInfoModel * info = [TreasureFailyKeyInfoModel modelWithDictionary:data.data];
[[self getView] getTreasureFailyInfoSuccess:info];
}]];
}
///
- (void)getTreasureFailyDrawList {
[Api treasureFailyDrawList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
NSArray * array = [TreasureFairyInfoModel modelsWithArray:data.data];
[[self getView] getTreasureFailyDrawListSuccess:array];
}]];
}
///
- (void)drawTreasureFaily:(NSString *)roomUid drawNum:(NSInteger)drawNum {
NSString * drawStr = [NSString stringWithFormat:@"%ld", drawNum];
[Api treasureFailyDraw:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
NSArray * array = [TreasureFairyInfoModel modelsWithArray:data.data];
[[self getView] drawTreasureFailySuccess:array];
} fail:^(NSInteger code, NSString * _Nullable msg) {
[[self getView] drawTreasureFailyFail:code];
}] roomUid:roomUid drawNum:drawStr];
}
@end

View File

@@ -0,0 +1,25 @@
//
// XPTreasureFailyProtocol.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/15.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class TreasureFailyKeyInfoModel;
@protocol XPTreasureFailyProtocol <NSObject>
///获取夺宝精灵用户信息成功
- (void)getTreasureFailyInfoSuccess:(TreasureFailyKeyInfoModel *)info;
///夺宝精灵奖励列表
- (void)getTreasureFailyDrawListSuccess:(NSArray *)list;
///夺宝精灵 开始夺宝
- (void)drawTreasureFailySuccess:(NSArray *)array;
- (void)drawTreasureFailyFail:(NSInteger)code;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,17 @@
//
// XPTreasureFailyResultGiftView.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/16.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class TreasureFairyInfoModel;
@interface XPTreasureFailyResultGiftCell : UICollectionViewCell
///奖励信息
@property (nonatomic,strong) TreasureFairyInfoModel *prizeInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,121 @@
//
// XPTreasureFailyResultGiftView.m
// xplan-ios
//
// Created by on 2023/2/16.
//
#import "XPTreasureFailyResultGiftCell.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "NetImageView.h"
///Model
#import "TreasureFairyInfoModel.h"
@interface XPTreasureFailyResultGiftCell ()
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,strong) NetImageView *giftImageView;
///
@property (nonatomic,strong) UIButton *countButton;
///
@property (nonatomic,strong) UILabel *nameLabel;
@end
@implementation XPTreasureFailyResultGiftCell
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
self.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:self.backImageView];
[self.contentView addSubview:self.nameLabel];
[self.backImageView addSubview:self.giftImageView];
[self.backImageView addSubview:self.countButton];
}
- (void)initSubViewConstraints {
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.mas_equalTo(self);
make.height.mas_equalTo(self.backImageView.mas_width);
}];
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.backImageView).inset(10);
}];
[self.countButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(29.5, 30.5));
make.bottom.right.mas_equalTo(self.backImageView);
}];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self);
make.top.mas_equalTo(self.backImageView.mas_bottom).offset(7);
}];
}
#pragma mark - Getters And Setters
- (void)setPrizeInfo:(TreasureFairyInfoModel *)prizeInfo {
_prizeInfo = prizeInfo;
if (_prizeInfo) {
self.giftImageView.imageUrl = prizeInfo.rewardPicUrl;
[self.countButton setTitle:[NSString stringWithFormat:@"%ld", _prizeInfo.rewardNum] forState:UIControlStateNormal];
self.nameLabel.text = _prizeInfo.rewardName;
}
}
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.image = [UIImage imageNamed:@"room_treasure_faily_result_gift_bg"];
}
return _backImageView;
}
- (NetImageView *)giftImageView {
if (!_giftImageView) {
NetImageConfig * config = [[NetImageConfig alloc]init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
_giftImageView = [[NetImageView alloc] initWithConfig:config];
_giftImageView.layer.masksToBounds = YES;
_giftImageView.contentMode = UIViewContentModeScaleAspectFill;
}
return _giftImageView;
}
- (UIButton *)countButton {
if (!_countButton) {
_countButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_countButton setTitleColor:[DJDKMIMOMColor colorWithHexString:@"#1F5764"] forState:UIControlStateNormal];
_countButton.titleLabel.font = [UIFont systemFontOfSize:10];
[_countButton setBackgroundImage:[UIImage imageNamed:@"room_treasure_fairy_result_coung_bg"] forState:UIControlStateNormal];
}
return _countButton;
}
- (UILabel *)nameLabel {
if (!_nameLabel) {
_nameLabel = [[UILabel alloc] init];
_nameLabel.font = [UIFont systemFontOfSize:13];
_nameLabel.textAlignment = NSTextAlignmentCenter;
_nameLabel.textColor = [DJDKMIMOMColor colorWithHexString:@"#FFE8AA"];
}
return _nameLabel;
}
@end

View File

@@ -0,0 +1,16 @@
//
// XPTreasureFairyFriendCell.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/23.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class UserInfoModel;
@interface XPTreasureFairyFriendCell : UITableViewCell
@property (nonatomic,strong) UserInfoModel *userInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,122 @@
//
// XPTreasureFairyFriendCell.m
// xplan-ios
//
// Created by on 2023/2/23.
//
#import "XPTreasureFairyFriendCell.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "NetImageView.h"
///Model
#import "UserInfoModel.h"
@interface XPTreasureFairyFriendCell ()
///
@property (nonatomic,strong) UIView *backView;
///
@property (nonatomic,strong) NetImageView *avatarImageView;
///
@property (nonatomic,strong) UILabel *nickLabel;
///
@property (nonatomic,strong) UILabel *signLabel;
@end
@implementation XPTreasureFairyFriendCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
self.backgroundColor = [UIColor clearColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self.contentView addSubview:self.backView];
[self.backView addSubview:self.avatarImageView];
[self.backView addSubview:self.nickLabel];
[self.backView addSubview:self.signLabel];
}
- (void)initSubViewConstraints {
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.contentView).inset(15);
make.top.mas_equalTo(self.contentView);
make.height.mas_equalTo(55);
}];
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(49, 49));
make.left.mas_equalTo(self.backView).offset(12);
make.centerY.mas_equalTo(self.backView);
}];
[self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.avatarImageView.mas_right).offset(8);
make.right.mas_lessThanOrEqualTo(self.backView).offset(-5);
make.bottom.mas_equalTo(self.avatarImageView.mas_centerY).offset(-3);
}];
[self.signLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.nickLabel);
make.top.mas_equalTo(self.nickLabel.mas_bottom).offset(3);
}];
}
#pragma mark - Getters And Setters
- (void)setUserInfo:(UserInfoModel *)userInfo {
_userInfo = userInfo;
if (_userInfo) {
self.avatarImageView.imageUrl = _userInfo.avatar;
self.nickLabel.text = _userInfo.nick;
self.signLabel.text = _userInfo.userDesc.length > 0 ? _userInfo.userDesc : YMLocalizedString(@"XPTreasureFairyFriendCell0");
}
}
- (UIView *)backView {
if (!_backView) {
_backView = [[UIView alloc] init];
_backView.backgroundColor = [DJDKMIMOMColor colorWithHexString:@"#00A69D"];
_backView.layer.cornerRadius = 4;
_backView.layer.masksToBounds = YES;
}
return _backView;
}
- (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 = 49/2;
_avatarImageView.layer.borderWidth = 0.5;
_avatarImageView.layer.borderColor = [DJDKMIMOMColor colorWithHexString:@"#FFE8AA"].CGColor;
}
return _avatarImageView;
}
- (UILabel *)nickLabel {
if (!_nickLabel) {
_nickLabel = [[UILabel alloc] init];
_nickLabel.font = [UIFont systemFontOfSize:14];
_nickLabel.textColor = [UIColor whiteColor];
}
return _nickLabel;
}
- (UILabel *)signLabel {
if (!_signLabel) {
_signLabel = [[UILabel alloc] init];
_signLabel.font = [UIFont systemFontOfSize:12];
_signLabel.textColor = [DJDKMIMOMColor colorWithHexString:@"#59FDFF"];
}
return _signLabel;
}
@end

View File

@@ -0,0 +1,17 @@
//
// XPTreasureFairyPrizePoolCell.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/21.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class TreasureFairyInfoModel;
@interface XPTreasureFairyPrizePoolCell : UICollectionViewCell
@property (nonatomic,strong) TreasureFairyInfoModel *info;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,106 @@
//
// XPTreasureFairyPrizePoolCell.m
// xplan-ios
//
// Created by on 2023/2/21.
//
#import "XPTreasureFairyPrizePoolCell.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "NetImageView.h"
#import "UIImage+Utils.h"
#import "TreasureFairyInfoModel.h"
@interface XPTreasureFairyPrizePoolCell ()
///
@property (nonatomic,strong) NetImageView *giftImageView;
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,strong) UILabel *nameLabel;
@end
@implementation XPTreasureFairyPrizePoolCell
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
self.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:self.backImageView];
[self.contentView addSubview:self.giftImageView];
[self.contentView addSubview:self.nameLabel];
}
- (void)initSubViewConstraints {
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(94, 115));
make.centerX.mas_equalTo(self.contentView);
make.top.mas_equalTo(self.contentView);
}];
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(65, 65));
make.centerX.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.backImageView).offset(18);
}];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.backImageView);
make.bottom.mas_equalTo(self.backImageView).offset(-8);
}];
}
#pragma mark - Getters And Setters
- (void)setInfo:(TreasureFairyInfoModel *)info {
_info = info;
if (_info) {
self.giftImageView.imageUrl = _info.rewardPicUrl;
self.nameLabel.text = _info.rewardName;
}
}
- (NetImageView *)giftImageView {
if (!_giftImageView) {
NetImageConfig * config = [[NetImageConfig alloc]init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
_giftImageView = [[NetImageView alloc] initWithConfig:config];
_giftImageView.layer.masksToBounds = YES;
_giftImageView.contentMode = UIViewContentModeScaleAspectFill;
}
return _giftImageView;
}
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.image = [UIImage imageNamed:@"room_treasure_fairy_prize_pool_bg"];
}
return _backImageView;
}
- (UILabel *)nameLabel {
if (!_nameLabel) {
_nameLabel = [[UILabel alloc] init];
_nameLabel.font = [UIFont systemFontOfSize:15];
_nameLabel.textColor = [DJDKMIMOMColor colorWithHexString:@"#1F5764"];
_nameLabel.textAlignment = NSTextAlignmentCenter;
}
return _nameLabel;
}
@end

View File

@@ -0,0 +1,23 @@
//
// XPTreasureFairyPrizeRecordCell.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/21.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class TreasureFairyInfoModel;
@interface XPTreasureFairyPrizeRecordCell : UITableViewCell
///礼物信息
@property (nonatomic,strong) TreasureFairyInfoModel *recordInfo;
///时间
@property (nonatomic,strong, readonly) UILabel *timeLabel;
///等级
@property (nonatomic,strong, readonly) UILabel *levelLabel;
///奖励
@property (nonatomic,strong, readonly) UILabel * prizeLabel;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,134 @@
//
// XPTreasureFairyPrizeRecordCell.m
// xplan-ios
//
// Created by on 2023/2/21.
//
#import "XPTreasureFairyPrizeRecordCell.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "PLTimeUtil.h"
///Model
#import "TreasureFairyInfoModel.h"
@interface XPTreasureFairyPrizeRecordCell ()
///
@property (nonatomic,strong) UIStackView *stackView;
///
@property (nonatomic,strong) UILabel *timeLabel;
///
@property (nonatomic,strong) UILabel *levelLabel;
///
@property (nonatomic,strong) UILabel * prizeLabel;
@end
@implementation XPTreasureFairyPrizeRecordCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
self.backgroundColor = [UIColor clearColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self.contentView addSubview:self.stackView];
[self.stackView addArrangedSubview:self.timeLabel];
[self.stackView addArrangedSubview:self.levelLabel];
[self.stackView addArrangedSubview:self.prizeLabel];
}
- (void)initSubViewConstraints {
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.contentView);
}];
}
- (NSString *)getDateWithHHMMSS:(NSString *)time {
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
formatter.timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
[formatter setDateStyle:NSDateFormatterMediumStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
[formatter setDateFormat:@"HH:mm:ss"];
NSDate* date = [NSDate dateWithTimeIntervalSince1970:[time doubleValue]/ 1000.0];
NSString* dateString = [formatter stringFromDate:date];
return dateString;
}
- (NSString *)getDateWithYYMM:(NSString *)time {
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
formatter.timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
[formatter setDateStyle:NSDateFormatterMediumStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
[formatter setDateFormat:@"yyyy:MM:dd"];
NSDate* date = [NSDate dateWithTimeIntervalSince1970:[time doubleValue]/ 1000.0];
NSString* dateString = [formatter stringFromDate:date];
return dateString;
}
#pragma mark - Getters And Setters
- (void)setRecordInfo:(TreasureFairyInfoModel *)recordInfo {
_recordInfo = recordInfo;
if (_recordInfo) {
NSString * time = [NSString stringWithFormat:@"%@\n%@", [self getDateWithYYMM:_recordInfo.drawTime], [self getDateWithHHMMSS:_recordInfo.drawTime]];
self.timeLabel.text = time;
if (_recordInfo.poolLevel == TreasureFairyStoreType_Normal) {
self.levelLabel.text = YMLocalizedString(@"XPTreasureFairyPrizeRecordCell0");
} else if (_recordInfo.poolLevel == TreasureFairyStoreType_Middle) {
self.levelLabel.text = YMLocalizedString(@"XPTreasureFairyPrizeRecordCell1");
} else {
self.levelLabel.text = YMLocalizedString(@"XPTreasureFairyPrizeRecordCell2");
}
self.prizeLabel.text = [NSString stringWithFormat:@"%@x%ld", _recordInfo.rewardName, _recordInfo.rewardNum];
}
}
- (UIStackView *)stackView {
if (!_stackView) {
_stackView = [[UIStackView alloc] init];
_stackView.axis = UILayoutConstraintAxisHorizontal;
_stackView.distribution = UIStackViewDistributionFillEqually;
_stackView.alignment = UIStackViewAlignmentFill;
_stackView.spacing = 0;
}
return _stackView;
}
- (UILabel *)timeLabel {
if (!_timeLabel) {
_timeLabel = [[UILabel alloc] init];
_timeLabel.font = [UIFont systemFontOfSize:12];
_timeLabel.textColor = [UIColor whiteColor];
_timeLabel.numberOfLines = 0;
_timeLabel.textAlignment = NSTextAlignmentCenter;
}
return _timeLabel;
}
- (UILabel *)levelLabel {
if (!_levelLabel) {
_levelLabel = [[UILabel alloc] init];
_levelLabel.font = [UIFont systemFontOfSize:12];
_levelLabel.textColor = [UIColor whiteColor];
_levelLabel.textAlignment = NSTextAlignmentCenter;
}
return _levelLabel;
}
- (UILabel *)prizeLabel {
if (!_prizeLabel) {
_prizeLabel = [[UILabel alloc] init];
_prizeLabel.font = [UIFont systemFontOfSize:12];
_prizeLabel.textColor = [DJDKMIMOMColor colorWithHexString:@"#FEF8A8"];
_prizeLabel.textAlignment = NSTextAlignmentCenter;
}
return _prizeLabel;
}
@end

View File

@@ -0,0 +1,16 @@
//
// XPTreasureFairySendRecordCell.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/23.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class TreasureFairySendRecordModel;
@interface XPTreasureFairySendRecordCell : UITableViewCell
@property (nonatomic,strong) TreasureFairySendRecordModel *recordInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,142 @@
//
// XPTreasureFairySendRecordCell.m
// xplan-ios
//
// Created by on 2023/2/23.
//
#import "XPTreasureFairySendRecordCell.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "NetImageView.h"
///Model
#import "TreasureFairySendRecordModel.h"
@interface XPTreasureFairySendRecordCell ()
///
@property (nonatomic,strong) UILabel *timeLabel;
///
@property (nonatomic,strong) UIView *backView;
///
@property (nonatomic,strong) NetImageView *avatarImageView;
///
@property (nonatomic,strong) UILabel *titleLabel;
@end
@implementation XPTreasureFairySendRecordCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
self.backgroundColor = [UIColor clearColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self.contentView addSubview:self.timeLabel];
[self.contentView addSubview:self.backView];
[self.backView addSubview:self.avatarImageView];
[self.backView addSubview:self.titleLabel];
}
- (void)initSubViewConstraints {
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.contentView).offset(20);
make.top.mas_equalTo(self.contentView);
}];
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.contentView).inset(20);
make.height.mas_equalTo(58);
make.top.mas_equalTo(self.timeLabel.mas_bottom).offset(8);
}];
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(42, 42));
make.left.mas_equalTo(self.backView).offset(12);
make.centerY.mas_equalTo(self.backView);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.avatarImageView.mas_right).offset(9);
make.centerY.mas_equalTo(self.avatarImageView);
make.right.mas_lessThanOrEqualTo(self.backView).offset(-5);
}];
}
- (NSString *)getDateWithTotalTimeWith:(NSString *)time {
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterMediumStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
[formatter setDateFormat:YMLocalizedString(@"XPTreasureFairySendRecordCell0")];
NSDate* date = [NSDate dateWithTimeIntervalSince1970:[time doubleValue]/ 1000.0];
NSString* dateString = [formatter stringFromDate:date];
return dateString;
}
#pragma mark - Getters And Setters
- (void)setRecordInfo:(TreasureFairySendRecordModel *)recordInfo {
_recordInfo = recordInfo;
if (_recordInfo) {
self.timeLabel.text = [self getDateWithTotalTimeWith:_recordInfo.createTime];
self.avatarImageView.imageUrl = _recordInfo.elfPicUrl;
NSString * nick = self.recordInfo.targetNick;
if (_recordInfo.type == TreasureFairySendRecordModel_Send) {
self.titleLabel.text = [NSString stringWithFormat:YMLocalizedString(@"XPTreasureFairySendRecordCell1"),nick,self.recordInfo.elfName];
} else {
self.titleLabel.text = [NSString stringWithFormat:YMLocalizedString(@"XPTreasureFairySendRecordCell2"), nick,self.recordInfo.elfName];
}
}
}
- (UILabel *)timeLabel {
if (!_timeLabel) {
_timeLabel = [[UILabel alloc] init];
_timeLabel.font = [UIFont systemFontOfSize:12];
_timeLabel.textColor = [UIColor whiteColor];
}
return _timeLabel;
}
- (UIView *)backView {
if (!_backView) {
_backView = [[UIView alloc] init];
_backView.backgroundColor = [DJDKMIMOMColor colorWithHexString:@"#00A69D"];
_backView.layer.masksToBounds = YES;
_backView.layer.cornerRadius = 8;
}
return _backView;
}
- (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 = 4;
_avatarImageView.layer.borderColor = [DJDKMIMOMColor colorWithHexString:@"#FFE8AA"].CGColor;
_avatarImageView.layer.borderWidth = 0.5;
_avatarImageView.contentMode = UIViewContentModeScaleAspectFill;
}
return _avatarImageView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont systemFontOfSize:12];
_titleLabel.textColor = [UIColor whiteColor];
_titleLabel.numberOfLines = 0;
}
return _titleLabel;
}
@end

View File

@@ -0,0 +1,28 @@
//
// XPTreasureFairyShopingExchangeCell.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/28.
//
#import <UIKit/UIKit.h>
@class TreasureFairyFragmentModel;
NS_ASSUME_NONNULL_BEGIN
@protocol XPTreasureFairyShopingExchangeCellDelegate <NSObject>
/// 兑换事件
- (void)treasureFairyShopingExchangeAction:(TreasureFairyFragmentModel *)fragmentModel;
@end
@interface XPTreasureFairyShopingExchangeCell : UICollectionViewCell
@property (nonatomic, strong) TreasureFairyFragmentModel *fragmemtModel;
@property (nonatomic, weak) id<XPTreasureFairyShopingExchangeCellDelegate> delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,217 @@
//
// XPTreasureFairyShopingExchangeCell.m
// xplan-ios
//
// Created by on 2023/2/28.
//
#import "XPTreasureFairyShopingExchangeCell.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "NetImageView.h"
#import "UIImage+Utils.h"
///Model
#import "TreasureFairyFragmentModel.h"
@interface XPTreasureFairyShopingExchangeCell ()
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,strong) UIImageView *ballBgImageView;
///
@property (nonatomic,strong) NetImageView *ballImaegView;
///
@property (nonatomic,strong) UILabel *nameLabel;
///
@property (nonatomic,strong) UIStackView *stackView;
///便
@property (nonatomic,strong) UIImageView *pieceImageView;
///便
@property (nonatomic,strong) UILabel *pieceCountLabel;
///
@property (nonatomic,strong) UIButton *exchangeButton;
@end
@implementation XPTreasureFairyShopingExchangeCell
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.contentView.backgroundColor = UIColor.clearColor;
self.backgroundColor = UIColor.clearColor;
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
[self.contentView addSubview:self.backImageView];
[self.backImageView addSubview:self.ballImaegView];
[self.backImageView addSubview:self.nameLabel];
[self.backImageView addSubview:self.stackView];
[self.backImageView addSubview:self.exchangeButton];
[self.stackView addArrangedSubview:self.pieceImageView];
[self.stackView addArrangedSubview:self.pieceCountLabel];
}
- (void)initSubViewConstraints {
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.contentView);
}];
[self.ballImaegView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(90);
make.height.mas_equalTo(90);
make.centerX.mas_equalTo(self.backImageView);
make.top.mas_equalTo(59.0);
}];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(8);
make.right.mas_equalTo(-8);
make.bottom.mas_equalTo(self.stackView.mas_top).offset(-4);
}];
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.exchangeButton.mas_top).offset(-7);
make.centerX.mas_equalTo(self.backImageView);
make.height.mas_equalTo(20);
}];
[self.pieceImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(self.stackView.mas_height);
}];
[self.exchangeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.backImageView);
make.bottom.mas_equalTo(-26);
make.width.mas_equalTo(80);
make.height.mas_equalTo(25);
}];
}
- (void)layoutSubviews {
[super layoutSubviews];
self.ballImaegView.layer.cornerRadius = self.ballImaegView.bounds.size.width/2.0;
self.ballImaegView.clipsToBounds = YES;
}
- (void)setFragmemtModel:(TreasureFairyFragmentModel *)fragmemtModel {
_fragmemtModel = fragmemtModel;
NSString * utils = fragmemtModel.rewardUnit;
if ([fragmemtModel.rewardType isEqualToString:@"gift"]) {
utils = YMLocalizedString(@"XPTreasureFairyShopingExchangeCell0");
self.nameLabel.text = [NSString stringWithFormat:@"%@(%@%@)",fragmemtModel.rewardName, fragmemtModel.rewardShowValue, utils];
} else {
self.nameLabel.text = [NSString stringWithFormat:@"%@(%ld%@)",fragmemtModel.rewardName, fragmemtModel.rewardNum, utils];
}
[self.ballImaegView loadImageWithUrl:fragmemtModel.rewardPicUrl completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) {
self.ballImaegView.image = image;
CGFloat width = 60;
CGFloat height = 60;
if(image.size.width < image.size.height){
height = width * image.size.height / (image.size.width > 0 ? image.size.width : 1);
}else if (image.size.width > image.size.height){
width = height * image.size.width / (image.size.height > 0 ? image.size.height : 1);
}
dispatch_async(dispatch_get_main_queue(), ^{
[self.ballImaegView mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(width);
make.height.mas_equalTo(height);
}];
});
}];
self.pieceCountLabel.text = [NSString stringWithFormat:@"%ld",fragmemtModel.expendNum];
[self.exchangeButton setTitle:YMLocalizedString(@"XPTreasureFairyShopingExchangeCell1") forState:UIControlStateNormal];
}
#pragma mark - Action
- (void)exchangeBtnAction {
if (self.delegate && [self.delegate respondsToSelector:@selector(treasureFairyShopingExchangeAction:)]) {
[self.delegate treasureFairyShopingExchangeAction:self.fragmemtModel];
}
}
#pragma mark - Getters And Setters
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.image = [UIImage imageNamed:@"room_treasure_fairy_shop_exchange_bg"];
_backImageView.userInteractionEnabled = YES;
}
return _backImageView;
}
- (NetImageView *)ballImaegView {
if (!_ballImaegView) {
NetImageConfig * config = [[NetImageConfig alloc]init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
_ballImaegView = [[NetImageView alloc] initWithConfig:config];
// _ballImaegView.clipsToBounds = YES;
// _ballImaegView.contentMode = UIViewContentModeScaleAspectFill;
}
return _ballImaegView;
}
- (UILabel *)nameLabel {
if (!_nameLabel) {
_nameLabel = [[UILabel alloc] init];
_nameLabel.textColor = UIColor.whiteColor;
_nameLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
_nameLabel.textAlignment = NSTextAlignmentCenter;
}
return _nameLabel;
}
- (UIImageView *)pieceImageView {
if (!_pieceImageView) {
_pieceImageView = [[UIImageView alloc] init];
_pieceImageView.contentMode = UIViewContentModeScaleAspectFit;
_pieceImageView.image = [UIImage imageNamed:@"room_treasure_fairy_shop_fragment"];
}
return _pieceImageView;
}
- (UILabel *)pieceCountLabel {
if (!_pieceCountLabel) {
_pieceCountLabel = [[UILabel alloc] init];
_pieceCountLabel.textColor = UIColor.whiteColor;
_pieceCountLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
_pieceCountLabel.textAlignment = NSTextAlignmentCenter;
}
return _pieceCountLabel;
}
- (UIStackView *)stackView {
if (!_stackView) {
_stackView = [[UIStackView alloc] init];
_stackView.axis = UILayoutConstraintAxisHorizontal;
_stackView.alignment = UIStackViewAlignmentFill;
_stackView.distribution = UIStackViewDistributionFill;
_stackView.spacing = 4;
}
return _stackView;
}
- (UIButton *)exchangeButton {
if (!_exchangeButton) {
_exchangeButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_exchangeButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor colorWithHexString:@"#3AEAC7"], [DJDKMIMOMColor colorWithHexString:@"#FFFEBB"]] gradientType:GradientTypeTopToBottom imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
[_exchangeButton setTitleColor:[DJDKMIMOMColor colorWithHexString:@"#1F5764"] forState:UIControlStateNormal];
_exchangeButton.titleLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
_exchangeButton.layer.cornerRadius = 4;
_exchangeButton.clipsToBounds = YES;
[_exchangeButton addTarget:self action:@selector(exchangeBtnAction) forControlEvents:UIControlEventTouchUpInside];
}
return _exchangeButton;
}
@end

View File

@@ -0,0 +1,28 @@
//
// XPTreasureFairyShopingRecordCell.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/27.
//
#import <UIKit/UIKit.h>
@class TreasureFairyConvertRecordModel;
NS_ASSUME_NONNULL_BEGIN
@interface XPTreasureFairyShopingRecordCell : UITableViewCell
///是否是召唤
@property (nonatomic,assign) BOOL isSummon;
///时间
@property (nonatomic,strong, readonly) UILabel *timeLabel;
///等级
@property (nonatomic,strong, readonly) UILabel *levelLabel;
///奖励
@property (nonatomic,strong, readonly) UILabel * prizeLabel;
///记录模型
@property (nonatomic, strong) TreasureFairyConvertRecordModel *recordModel;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,158 @@
//
// XPTreasureFairyShopingRecordCell.m
// xplan-ios
//
// Created by on 2023/2/27.
//
#import "XPTreasureFairyShopingRecordCell.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "PLTimeUtil.h"
///Model
#import "TreasureFairyConvertRecordModel.h"
@interface XPTreasureFairyShopingRecordCell ()
///
@property (nonatomic,strong) UIStackView *stackView;
///
@property (nonatomic,strong) UILabel *timeLabel;
///
@property (nonatomic,strong) UILabel *levelLabel;
///
@property (nonatomic,strong) UILabel * prizeLabel;
@end
@implementation XPTreasureFairyShopingRecordCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
self.backgroundColor = [UIColor clearColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self.contentView addSubview:self.stackView];
[self.stackView addArrangedSubview:self.timeLabel];
[self.stackView addArrangedSubview:self.levelLabel];
[self.stackView addArrangedSubview:self.prizeLabel];
}
- (void)initSubViewConstraints {
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.contentView);
}];
}
- (NSString *)getDateWithHHMMSS:(NSString *)time {
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
formatter.timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
[formatter setDateStyle:NSDateFormatterMediumStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
[formatter setDateFormat:@"HH:mm:ss"];
NSDate* date = [NSDate dateWithTimeIntervalSince1970:[time doubleValue]/ 1000.0];
NSString* dateString = [formatter stringFromDate:date];
return dateString;
}
- (NSString *)getDateWithYYMM:(NSString *)time {
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
formatter.timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
[formatter setDateStyle:NSDateFormatterMediumStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
[formatter setDateFormat:@"yyyy:MM:dd"];
NSDate* date = [NSDate dateWithTimeIntervalSince1970:[time doubleValue]/ 1000.0];
NSString* dateString = [formatter stringFromDate:date];
return dateString;
}
#pragma mark - Getters And Setters
- (void)setRecordModel:(TreasureFairyConvertRecordModel *)recordModel {
_recordModel = recordModel;
if (_recordModel != nil) {
NSString * time = [NSString stringWithFormat:@"%@\n%@", [self getDateWithYYMM:recordModel.createTime], [self getDateWithHHMMSS:recordModel.createTime]];
self.timeLabel.text = time;
if (self.isSummon) {
NSString *level = @"";
if (recordModel.convertLevel == 1) {
level = YMLocalizedString(@"XPTreasureFairyShopingRecordCell0");
}else if (recordModel.convertLevel == 2) {
level = YMLocalizedString(@"XPTreasureFairyShopingRecordCell1");
}else if (recordModel.convertLevel == 3) {
level = YMLocalizedString(@"XPTreasureFairyShopingRecordCell2");
}
self.levelLabel.text = level;
self.prizeLabel.text = [NSString stringWithFormat:@"%@x%@",recordModel.rewardName, recordModel.rewardNum];
}else{
NSString *string1 = [NSString stringWithFormat:@"%@x%@\n",recordModel.rewardName, recordModel.rewardNum];
NSString *string2 = [NSString stringWithFormat:YMLocalizedString(@"XPTreasureFairyShopingRecordCell3"), recordModel.rewardShowValue];
NSString *string = [NSString stringWithFormat:@"%@%@",string1, string2];
NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:string];
NSRange range = NSMakeRange(string.length-string2.length, string2.length);
[attrStr addAttribute:NSForegroundColorAttributeName value:UIColor.whiteColor range:range];
[attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:11] range:range];
self.prizeLabel.attributedText = attrStr;
}
}
}
- (void)setIsSummon:(BOOL)isSummon {
_isSummon = isSummon;
if (_isSummon) {
self.levelLabel.hidden = NO;
} else {
self.levelLabel.hidden = YES;
}
}
- (UIStackView *)stackView {
if (!_stackView) {
_stackView = [[UIStackView alloc] init];
_stackView.axis = UILayoutConstraintAxisHorizontal;
_stackView.distribution = UIStackViewDistributionFillEqually;
_stackView.alignment = UIStackViewAlignmentFill;
_stackView.spacing = 0;
}
return _stackView;
}
- (UILabel *)timeLabel {
if (!_timeLabel) {
_timeLabel = [[UILabel alloc] init];
_timeLabel.font = [UIFont systemFontOfSize:12];
_timeLabel.textColor = [UIColor whiteColor];
_timeLabel.numberOfLines = 0;
_timeLabel.textAlignment = NSTextAlignmentCenter;
}
return _timeLabel;
}
- (UILabel *)levelLabel {
if (!_levelLabel) {
_levelLabel = [[UILabel alloc] init];
_levelLabel.font = [UIFont systemFontOfSize:12];
_levelLabel.textColor = [UIColor whiteColor];
_levelLabel.textAlignment = NSTextAlignmentCenter;
}
return _levelLabel;
}
- (UILabel *)prizeLabel {
if (!_prizeLabel) {
_prizeLabel = [[UILabel alloc] init];
_prizeLabel.font = [UIFont systemFontOfSize:12];
_prizeLabel.textColor = [DJDKMIMOMColor colorWithHexString:@"#FEF8A8"];
_prizeLabel.textAlignment = NSTextAlignmentCenter;
_prizeLabel.numberOfLines = 0;
}
return _prizeLabel;
}
@end

View File

@@ -0,0 +1,20 @@
//
// XPTreasureFairyStoreResultCell.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/20.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class TreasureFairyInfoModel, TreasureFairyBallModel;
@interface XPTreasureFairyStoreResultCell : UICollectionViewCell
///奖励信息
@property (nonatomic,strong) TreasureFairyInfoModel *prizeInfo;
///试炼精灵球信息
@property (nonatomic,strong) TreasureFairyBallModel *ballInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,114 @@
//
// XPTreasureFairyStoreResultCell.m
// xplan-ios
//
// Created by on 2023/2/20.
//
#import "XPTreasureFairyStoreResultCell.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "NetImageView.h"
#import "UIImage+Utils.h"
///Model
#import "TreasureFairyInfoModel.h"
#import "TreasureFairyBallInfoModel.h"
@interface XPTreasureFairyStoreResultCell ()
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,strong) NetImageView *giftImageView;
///
@property (nonatomic,strong) UILabel *nameLabel;
@end
@implementation XPTreasureFairyStoreResultCell
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
self.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:self.backImageView];
[self.contentView addSubview:self.nameLabel];
[self.backImageView addSubview:self.giftImageView];
}
- (void)initSubViewConstraints {
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.mas_equalTo(self);
make.height.mas_equalTo(self.backImageView.mas_width);
}];
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.backImageView).inset(10);
}];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self);
make.top.mas_equalTo(self.backImageView.mas_bottom).offset(7);
}];
}
#pragma mark - Getters And Setters
- (void)setPrizeInfo:(TreasureFairyInfoModel *)prizeInfo {
_prizeInfo = prizeInfo;
if (_prizeInfo) {
self.giftImageView.imageUrl = prizeInfo.rewardPicUrl;
self.nameLabel.text =[NSString stringWithFormat:@"%@x%ld", _prizeInfo.rewardName, _prizeInfo.rewardNum];
}
}
- (void)setBallInfo:(TreasureFairyBallModel *)ballInfo{
_ballInfo = ballInfo;
if (_ballInfo) {
self.giftImageView.imageUrl = _ballInfo.elfPicUrl;
self.nameLabel.text =[NSString stringWithFormat:@"%@", _ballInfo.elfName];
}
}
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.image = [UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor colorWithHexString:@"#00B9AF"], [DJDKMIMOMColor colorWithHexString:@"#006E7C"]] gradientType:GradientTypeTopToBottom imgSize:CGSizeMake(10, 10)];
_backImageView.layer.masksToBounds = YES;
_backImageView.layer.borderWidth = 0.5;
_backImageView.layer.cornerRadius = 45;
_backImageView.layer.borderColor = [DJDKMIMOMColor colorWithHexString:@"#F4FFC3"].CGColor;
}
return _backImageView;
}
- (NetImageView *)giftImageView {
if (!_giftImageView) {
NetImageConfig * config = [[NetImageConfig alloc]init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
_giftImageView = [[NetImageView alloc] initWithConfig:config];
_giftImageView.layer.masksToBounds = YES;
_giftImageView.contentMode = UIViewContentModeScaleAspectFill;
}
return _giftImageView;
}
- (UILabel *)nameLabel {
if (!_nameLabel) {
_nameLabel = [[UILabel alloc] init];
_nameLabel.font = [UIFont systemFontOfSize:12];
_nameLabel.textAlignment = NSTextAlignmentCenter;
_nameLabel.textColor = [UIColor whiteColor];
}
return _nameLabel;
}
@end

View File

@@ -0,0 +1,25 @@
//
// XPTreasureFairyTrialsRecordCell.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/27.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class TreasureFairyTrialsRecordModel;
@interface XPTreasureFairyTrialsRecordCell : UITableViewCell
@property (nonatomic,strong) TreasureFairyTrialsRecordModel *recordInfo;
///时间
@property (nonatomic,strong, readonly) UILabel *timeLabel;
///等级
@property (nonatomic,strong, readonly) UILabel *levelLabel;
///奖励
@property (nonatomic,strong, readonly) UILabel * prizeLabel;
///投入的
@property (nonatomic,strong, readonly) UILabel *trialsLabel;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,159 @@
//
// XPTreasureFairyTrialsRecordCell.m
// xplan-ios
//
// Created by on 2023/2/27.
//
#import "XPTreasureFairyTrialsRecordCell.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "PLTimeUtil.h"
#import "NSArray+Safe.h"
///Model
#import "TreasureFairyTrialsRecordModel.h"
@interface XPTreasureFairyTrialsRecordCell ()
///
@property (nonatomic,strong) UIStackView *stackView;
///
@property (nonatomic,strong) UILabel *timeLabel;
///
@property (nonatomic,strong) UILabel *levelLabel;
///
@property (nonatomic,strong) UILabel *trialsLabel;
///
@property (nonatomic,strong) UILabel * prizeLabel;
@end
@implementation XPTreasureFairyTrialsRecordCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
self.backgroundColor = [UIColor clearColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self.contentView addSubview:self.stackView];
[self.stackView addArrangedSubview:self.timeLabel];
[self.stackView addArrangedSubview:self.levelLabel];
[self.stackView addArrangedSubview:self.trialsLabel];
[self.stackView addArrangedSubview:self.prizeLabel];
}
- (void)initSubViewConstraints {
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.contentView);
}];
}
- (NSString *)getDateWithHHMMSS:(NSString *)time {
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
formatter.timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
[formatter setDateStyle:NSDateFormatterMediumStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
[formatter setDateFormat:@"HH:mm:ss"];
NSDate* date = [NSDate dateWithTimeIntervalSince1970:[time doubleValue]/ 1000.0];
NSString* dateString = [formatter stringFromDate:date];
return dateString;
}
- (NSString *)getDateWithYYMM:(NSString *)time {
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
formatter.timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
[formatter setDateStyle:NSDateFormatterMediumStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
[formatter setDateFormat:@"yyyy:MM:dd"];
NSDate* date = [NSDate dateWithTimeIntervalSince1970:[time doubleValue]/ 1000.0];
NSString* dateString = [formatter stringFromDate:date];
return dateString;
}
#pragma mark - Getters And Setters
- (void)setRecordInfo:(TreasureFairyTrialsRecordModel *)recordInfo {
_recordInfo = recordInfo;
if (_recordInfo) {
NSString * time = [NSString stringWithFormat:@"%@\n%@", [self getDateWithYYMM:_recordInfo.createTime], [self getDateWithHHMMSS:_recordInfo.createTime]];
self.timeLabel.text = time;
if (_recordInfo.compoundLevel == TreasureFairyStoreType_Middle) {
self.levelLabel.text = YMLocalizedString(@"XPTreasureFairyTrialsRecordCell0");
} else {
self.levelLabel.text = YMLocalizedString(@"XPTreasureFairyTrialsRecordCell1");
}
NSMutableString * trilasTitle = [[NSMutableString alloc] init];
for (int i = 0; i < _recordInfo.expendList.count; i++) {
TreasureFairyBallModel * ballInfo = [_recordInfo.expendList safeObjectAtIndex1:i];
if (ballInfo.elfName.length > 0) {
[trilasTitle appendString:[NSString stringWithFormat:@"%@x%ld", ballInfo.elfName, ballInfo.elfNum]];
}
if (i <( _recordInfo.expendList.count -1)){
[trilasTitle appendString:@"\n"];
}
}
self.trialsLabel.text = trilasTitle;
self.prizeLabel.text = _recordInfo.elfName;
}
}
- (UIStackView *)stackView {
if (!_stackView) {
_stackView = [[UIStackView alloc] init];
_stackView.axis = UILayoutConstraintAxisHorizontal;
_stackView.distribution = UIStackViewDistributionFillEqually;
_stackView.alignment = UIStackViewAlignmentFill;
_stackView.spacing = 0;
}
return _stackView;
}
- (UILabel *)timeLabel {
if (!_timeLabel) {
_timeLabel = [[UILabel alloc] init];
_timeLabel.font = [UIFont systemFontOfSize:12];
_timeLabel.textColor = [UIColor whiteColor];
_timeLabel.numberOfLines = 0;
_timeLabel.textAlignment = NSTextAlignmentCenter;
}
return _timeLabel;
}
- (UILabel *)levelLabel {
if (!_levelLabel) {
_levelLabel = [[UILabel alloc] init];
_levelLabel.font = [UIFont systemFontOfSize:12];
_levelLabel.textColor = [UIColor whiteColor];
_levelLabel.textAlignment = NSTextAlignmentCenter;
}
return _levelLabel;
}
- (UILabel *)trialsLabel {
if (!_trialsLabel) {
_trialsLabel = [[UILabel alloc] init];
_trialsLabel.font = [UIFont systemFontOfSize:12];
_trialsLabel.textColor = [UIColor whiteColor];
_trialsLabel.textAlignment = NSTextAlignmentCenter;
_trialsLabel.numberOfLines = 4;
}
return _trialsLabel;
}
- (UILabel *)prizeLabel {
if (!_prizeLabel) {
_prizeLabel = [[UILabel alloc] init];
_prizeLabel.font = [UIFont systemFontOfSize:12];
_prizeLabel.textColor = [DJDKMIMOMColor colorWithHexString:@"#FEF8A8"];
_prizeLabel.textAlignment = NSTextAlignmentCenter;
}
return _prizeLabel;
}
@end

View File

@@ -0,0 +1,16 @@
//
// XPTreasureFailrySummonBallView.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/28.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class TreasureFairyBallModel;
@interface XPTreasureFailrySummonBallView : UIView
@property (nonatomic,strong) TreasureFairyBallModel *ballInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,118 @@
//
// XPTreasureFailrySummonBallView.m
// xplan-ios
//
// Created by on 2023/2/28.
//
#import "XPTreasureFailrySummonBallView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "NetImageView.h"
///Model
#import "TreasureFairyBallInfoModel.h"
@interface XPTreasureFailrySummonBallView ()
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,strong) NetImageView *ballImageView;
///
@property (nonatomic,strong) UILabel *nameLabel;
///
@property (nonatomic,strong) UILabel *countLabel;
@end
@implementation XPTreasureFailrySummonBallView
- (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.ballImageView];
[self addSubview:self.nameLabel];
[self addSubview:self.countLabel];
}
- (void)initSubViewConstraints {
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
[self.ballImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(45, 45));
make.top.mas_equalTo(self).offset(13);
make.centerX.mas_equalTo(self);
}];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.backImageView).offset(-3);
make.left.right.mas_equalTo(self.backImageView);
}];
[self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(18, 18));
make.left.mas_equalTo(self.backImageView).offset(61);
make.top.mas_equalTo(self.backImageView).offset(51);
}];
}
#pragma mark - Getters And Setters
- (void)setBallInfo:(TreasureFairyBallModel *)ballInfo {
_ballInfo =ballInfo;
if (_ballInfo) {
self.ballImageView.imageUrl = _ballInfo.elfPicUrl;
self.nameLabel.text = _ballInfo.elfName;
self.countLabel.text = [NSString stringWithFormat:@"%ld", _ballInfo.elfNum];
}
}
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.image = [UIImage imageNamed:@"room_treasure_fairy_shoping_ball_bg"];
}
return _backImageView;
}
- (NetImageView *)ballImageView {
if (!_ballImageView) {
NetImageConfig * config = [[NetImageConfig alloc]init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
_ballImageView = [[NetImageView alloc] initWithConfig:config];
_ballImageView.contentMode = UIViewContentModeScaleAspectFill;
}
return _ballImageView;
}
- (UILabel *)nameLabel {
if (!_nameLabel) {
_nameLabel = [[UILabel alloc] init];
_nameLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
_nameLabel.textColor = [UIColor whiteColor];
_nameLabel.textAlignment = NSTextAlignmentCenter;
}
return _nameLabel;
}
- (UILabel *)countLabel {
if (!_countLabel) {
_countLabel = [[UILabel alloc] init];
_countLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
_countLabel.textColor = [DJDKMIMOMColor colorWithHexString:@"#1F5764"];
_countLabel.textAlignment = NSTextAlignmentCenter;
}
return _countLabel;
}
@end

View File

@@ -0,0 +1,17 @@
//
// XPTreasureFailyPrizeGiftView.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/15.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPTreasureFailyPrizeGiftView : UIView
///显示的内容
@property (nonatomic,copy) NSString *title;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,65 @@
//
// XPTreasureFailyPrizeGiftView.m
// xplan-ios
//
// Created by on 2023/2/15.
//
#import "XPTreasureFailyPrizeGiftView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
@interface XPTreasureFailyPrizeGiftView ()
///
@property (nonatomic,strong) UIButton *prizeButton;
@end
@implementation XPTreasureFailyPrizeGiftView
- (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.prizeButton];
}
- (void)initSubViewConstraints {
[self.prizeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.mas_equalTo(self);
make.top.mas_equalTo(self).offset(6);
}];
}
#pragma mark - Getters And Setters
- (void)setTitle:(NSString *)title {
_title = title;
if (_title.length > 0) {
[self.prizeButton setTitle:title forState:UIControlStateNormal];
}
}
- (UIButton *)prizeButton {
if (!_prizeButton) {
UIButton * newAnimaView = [UIButton buttonWithType:UIButtonTypeCustom];
newAnimaView.imageView.layer.masksToBounds = YES;
newAnimaView.imageView.contentMode = UIViewContentModeCenter;
[newAnimaView setBackgroundImage:[UIImage imageNamed:@"room_treasure_fairy_prize_bg"] forState:UIControlStateNormal];
newAnimaView.titleLabel.font = [UIFont systemFontOfSize:12];
[newAnimaView setTitleColor:[DJDKMIMOMColor colorWithHexString:@"#FFE8AA"] forState:UIControlStateNormal];
_prizeButton = newAnimaView;
}
return _prizeButton;
}
@end

View File

@@ -0,0 +1,19 @@
//
// XPTreasureFailyResultView.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/16.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPTreasureFailyResultView : UIView
///数据
@property (nonatomic,strong) NSArray *datasource;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,156 @@
//
// XPTreasureFailyResultView.m
// xplan-ios
//
// Created by on 2023/2/16.
//
#import "XPTreasureFailyResultView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "TTPopup.h"
#import "NSArray+Safe.h"
///View
#import "XPTreasureFailyResultGiftCell.h"
@interface XPTreasureFailyResultView ()<UICollectionViewDelegate, UICollectionViewDataSource>
///View
@property (nonatomic,strong) UIView *bottomView;
///
@property (nonatomic,strong) UIImageView *backImageView;
///cell
@property (nonatomic,strong) XPTreasureFailyResultGiftCell *oneGiftView;
///
@property (nonatomic,strong) UICollectionView *collectionView;
@end
@implementation XPTreasureFailyResultView
- (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.bottomView];
[self.backImageView addSubview:self.oneGiftView];
[self.backImageView addSubview:self.collectionView];
}
- (void)initSubViewConstraints {
CGFloat kscale = 364.0 / 375.0;
self.frame = CGRectMake(0, 0, KScreenWidth, KScreenWidth * kscale + 89 * kScreenScale);
[self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.mas_equalTo(self);
make.top.mas_equalTo(self.backImageView.mas_bottom);
}];
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.mas_equalTo(self);
make.height.mas_equalTo(KScreenWidth * kscale);
}];
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.backImageView).offset(87 * kScreenScale);
make.bottom.mas_equalTo(self.backImageView).offset((-182 + 89) * kScreenScale);
make.left.right.mas_equalTo(self.backImageView);
}];
[self.oneGiftView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(115);
make.width.mas_equalTo(90);
make.centerX.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.backImageView).offset(129 * kScreenScale);
}];
}
#pragma mark - Event Response
- (void)dismissView {
[TTPopup dismiss];
}
#pragma mark - UICollectionViewDelegate And UICollectionViewDataSoure
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.datasource.count;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
XPTreasureFailyResultGiftCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPTreasureFailyResultGiftCell class]) forIndexPath:indexPath];
TreasureFairyInfoModel * info = [self.datasource safeObjectAtIndex1:indexPath.row];
cell.prizeInfo = info;
return cell;
}
#pragma mark - Getters And Setters
- (void)setDatasource:(NSArray *)datasource {
_datasource = datasource;
if (_datasource.count > 1) {
self.collectionView.hidden = NO;
self.oneGiftView.hidden = YES;
[self.collectionView reloadData];
} else {
self.oneGiftView.hidden = NO;
self.collectionView.hidden = YES;
if (_datasource.count == 1) {
self.oneGiftView.prizeInfo = _datasource.firstObject;
}
}
}
- (UICollectionView *)collectionView{
if (!_collectionView) {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
CGFloat itemWidth = (KScreenWidth - 14 * 3 - 60) / 4.0;
layout.itemSize = CGSizeMake(itemWidth, itemWidth + 23);
layout.sectionInset = UIEdgeInsetsMake(0, 30, 0, 30);
layout.minimumLineSpacing = 11;
layout.minimumInteritemSpacing = 14;
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
_collectionView.dataSource = self;
_collectionView.delegate = self;
_collectionView.backgroundColor = [UIColor clearColor];
[_collectionView registerClass:[XPTreasureFailyResultGiftCell class] forCellWithReuseIdentifier:NSStringFromClass([XPTreasureFailyResultGiftCell class])];
}
return _collectionView;
}
- (UIView *)bottomView {
if (!_bottomView) {
_bottomView = [[UIView alloc] init];
_bottomView.backgroundColor = [UIColor clearColor];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissView)];
[_bottomView addGestureRecognizer:tap];
}
return _bottomView;
}
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.image = [UIImage imageNamed:@"room_treasure_fairy_result_bg"];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissView)];
[_backImageView addGestureRecognizer:tap];
}
return _backImageView;
}
- (XPTreasureFailyResultGiftCell *)oneGiftView {
if (!_oneGiftView) {
_oneGiftView = [[XPTreasureFailyResultGiftCell alloc] init];
}
return _oneGiftView;
}
@end

View File

@@ -0,0 +1,26 @@
//
// XPTreasureFairyBallContentView.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/22.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class XPTreasureFairyBallContentView, TreasureFairyBallModel;
@protocol XPTreasureFairyBallContentViewDelegate <NSObject>
///索取
- (void)xPTreasureFairyBallContentView:(XPTreasureFairyBallContentView *)view askInfo:(TreasureFairyBallModel *)askInfo;
///赠送
- (void)xPTreasureFairyBallContentView:(XPTreasureFairyBallContentView *)view sendInfo:(TreasureFairyBallModel *)sendInfo;
@end
@interface XPTreasureFairyBallContentView : UIView
///数据
@property (nonatomic,strong) NSArray *datasource;
///代理
@property (nonatomic,weak) id<XPTreasureFairyBallContentViewDelegate> delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,155 @@
//
// XPTreasureFairyBallContentView.m
// xplan-ios
//
// Created by on 2023/2/22.
//
#import "XPTreasureFairyBallContentView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "NSArray+Safe.h"
///View
#import "XPTreasureFairyBallView.h"
@interface XPTreasureFairyBallContentView ()<XPTreasureFairyBallViewDelegate>
///
@property (nonatomic,strong) XPTreasureFairyBallView *firstView;
///
@property (nonatomic,strong) XPTreasureFairyBallView *secondView;
///
@property (nonatomic,strong) XPTreasureFairyBallView *thirdView;
///
@property (nonatomic,strong) XPTreasureFairyBallView *fourthView;
///
@property (nonatomic,strong) XPTreasureFairyBallView *fifthView;
@property (nonatomic,strong) NSArray *viewList;
@end
@implementation XPTreasureFairyBallContentView
- (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.firstView];
[self addSubview:self.secondView];
[self addSubview:self.thirdView];
[self addSubview:self.fourthView];
[self addSubview:self.fifthView];
self.viewList = @[self.firstView, self.secondView, self.thirdView, self.fourthView, self.fifthView];
}
- (void)initSubViewConstraints {
[self mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.fifthView.mas_bottom);
}];
[self.secondView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(115, 162));
make.centerX.mas_equalTo(self);
make.top.mas_equalTo(self);
}];
[self.firstView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.centerY.mas_equalTo(self.secondView);
make.right.mas_equalTo(self.secondView.mas_left).offset(-4);
}];
[self.thirdView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.centerY.mas_equalTo(self.secondView);
make.left.mas_equalTo(self.secondView.mas_right).offset(4);
}];
[self.fourthView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(self.secondView);
make.top.mas_equalTo(self.firstView.mas_bottom).offset(10);
make.right.mas_equalTo(self.mas_centerX).offset(-20);
}];
[self.fifthView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.centerY.mas_equalTo(self.fourthView);
make.left.mas_equalTo(self.mas_centerX).offset(20);
}];
}
#pragma mark - XPTreasureFairyBallViewDelegate
- (void)xPTreasureFairyBallView:(XPTreasureFairyBallView *)view askBallInfo:(TreasureFairyBallModel *)info {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPTreasureFairyBallContentView:askInfo:)]) {
[self.delegate xPTreasureFairyBallContentView:self askInfo:info];
}
}
- (void)xPTreasureFairyBallView:(XPTreasureFairyBallView *)view sendBallInfo:(TreasureFairyBallModel *)info {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPTreasureFairyBallContentView:sendInfo:)]) {
[self.delegate xPTreasureFairyBallContentView:self sendInfo:info];
}
}
#pragma mark - Getters And Setters
- (void)setDatasource:(NSArray *)datasource {
_datasource = datasource;
if (_datasource.count > 0) {
for (int i = 0; i < _datasource.count; i++) {
TreasureFairyBallModel * ballInfo = [_datasource safeObjectAtIndex1:i];
if (i < self.viewList.count) {
XPTreasureFairyBallView * view = [self.viewList safeObjectAtIndex1:i];
view.ballInfo = ballInfo;
}
}
}
}
- (XPTreasureFairyBallView *)firstView {
if(!_firstView) {
_firstView = [[XPTreasureFairyBallView alloc] init];
_firstView.delegate = self;
}
return _firstView;
}
- (XPTreasureFairyBallView *)secondView {
if(!_secondView) {
_secondView = [[XPTreasureFairyBallView alloc] init];
_secondView.delegate = self;
}
return _secondView;
}
- (XPTreasureFairyBallView *)thirdView {
if(!_thirdView) {
_thirdView = [[XPTreasureFairyBallView alloc] init];
_thirdView.delegate = self;
}
return _thirdView;
}
- (XPTreasureFairyBallView *)fourthView {
if(!_fourthView) {
_fourthView = [[XPTreasureFairyBallView alloc] init];
_fourthView.delegate = self;
}
return _fourthView;
}
- (XPTreasureFairyBallView *)fifthView {
if(!_fifthView) {
_fifthView = [[XPTreasureFairyBallView alloc] init];
_fifthView.delegate = self;
}
return _fifthView;
}
@end

View File

@@ -0,0 +1,25 @@
//
// XPTreasureFairyBallView.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/22.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class TreasureFairyBallModel, XPTreasureFairyBallView;
@protocol XPTreasureFairyBallViewDelegate <NSObject>
///索要
- (void)xPTreasureFairyBallView:(XPTreasureFairyBallView *)view askBallInfo:(TreasureFairyBallModel *)info;
///赠送
- (void)xPTreasureFairyBallView:(XPTreasureFairyBallView *)view sendBallInfo:(TreasureFairyBallModel *)info;
@end
@interface XPTreasureFairyBallView : UIView
@property (nonatomic,strong) TreasureFairyBallModel *ballInfo;
///代理
@property (nonatomic,weak) id<XPTreasureFairyBallViewDelegate> delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,296 @@
//
// XPTreasureFairyBallView.m
// xplan-ios
//
// Created by on 2023/2/22.
//
#import "XPTreasureFairyBallView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "NetImageView.h"
///Model
#import "TreasureFairyBallInfoModel.h"
@interface XPTreasureFairyBallView ()
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,strong) UILabel *nameLabel;
///
@property (nonatomic,strong) UILabel *numberLabel;
///
@property (nonatomic,strong) NetImageView *ballImageView;
///
@property (nonatomic,strong) UIStackView *stackView;
///
@property (nonatomic,strong) UIButton *notGetButton;
///
@property (nonatomic,strong) UIButton *sendButton;
///
@property (nonatomic,strong) UIButton *askButton;
///
@property (nonatomic,strong) UIImageView *coverImageView;
@end
@implementation XPTreasureFairyBallView
- (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.nameLabel];
[self addSubview:self.ballImageView];
[self addSubview:self.coverImageView];
[self addSubview:self.numberLabel];
[self addSubview:self.notGetButton];
[self addSubview:self.stackView];
[self.stackView addArrangedSubview:self.sendButton];
[self.stackView addArrangedSubview:self.askButton];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(flipRecognizer)];
[self addGestureRecognizer:tap];
}
- (void)initSubViewConstraints {
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
[self.coverImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.backImageView).offset(30);
}];
[self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(8);
}];
[self.ballImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(76, 76));
make.centerX.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.backImageView).offset(74);
}];
[self.notGetButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(54, 54));
make.top.mas_equalTo(self.backImageView).offset(60);
make.centerX.mas_equalTo(self.backImageView);
}];
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.notGetButton);
make.centerX.mas_equalTo(self.backImageView);
}];
[self.askButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(54, 54));
}];
[self.sendButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(54, 54));
}];
}
- (void)delayAction {
TreasureFairyBallModel * info = self.ballInfo;
info.isFlip = !info.isFlip;
self.ballInfo = info;
}
#pragma mark - Event Response
- (void)flipRecognizer {
self.stackView.hidden = YES;
self.notGetButton.hidden = YES;
[self performSelector:@selector(delayAction) withObject:self afterDelay:0.5];
[UIView beginAnimations:@"aa" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self cache:NO];
[UIView commitAnimations];
}
- (void)sendButtonAction:(UIButton *)sener {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPTreasureFairyBallView:sendBallInfo:)]) {
[self.delegate xPTreasureFairyBallView:self sendBallInfo:self.ballInfo];
}
}
- (void)askButtonAction:(UIButton *)sender {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPTreasureFairyBallView:askBallInfo:)]) {
[self.delegate xPTreasureFairyBallView:self askBallInfo:self.ballInfo];
}
}
#pragma mark - Getters And Setters
- (void)setBallInfo:(TreasureFairyBallModel *)ballInfo {
_ballInfo = ballInfo;
if (_ballInfo) {
self.nameLabel.text = _ballInfo.elfName;
self.ballImageView.imageUrl = _ballInfo.elfPicUrl;
NSString * backImageName;
NSString * coverImageName;
if (_ballInfo.elfLevel == TreasureFairyStoreType_High) {
backImageName = @"room_treasure_fairy_my_high_ball_bg";
coverImageName = @"room_treasure_fairy_my_high_ball_cover";
self.nameLabel.textColor = [UIColor whiteColor];
self.numberLabel.textColor = [UIColor whiteColor];
} else if (_ballInfo.elfLevel == TreasureFairyStoreType_Middle) {
backImageName = @"room_treasure_fairy_my_middle_ball_bg";
coverImageName = @"room_treasure_fairy_my_middle_ball_cover";
self.nameLabel.textColor = [DJDKMIMOMColor colorWithHexString:@"#FFFED6"];
self.numberLabel.textColor = [DJDKMIMOMColor colorWithHexString:@"#59FDFF"];
} else {
backImageName = @"room_treasure_fairy_my_low_ball_bg";
coverImageName = @"room_treasure_fairy_my_low_ball_cover";
self.nameLabel.textColor = [DJDKMIMOMColor colorWithHexString:@"#A4FFFC"];
self.numberLabel.textColor = [DJDKMIMOMColor colorWithHexString:@"#FFE8AA"];
}
if (_ballInfo.elfNum <=0 || _ballInfo.isFlip) {
self.coverImageView.hidden = NO;
} else {
self.coverImageView.hidden = YES;
}
if (_ballInfo.elfNum > 0) {///
self.numberLabel.hidden = NO;
self.notGetButton.hidden = YES;
self.numberLabel.text = [NSString stringWithFormat:@"x%ld", _ballInfo.elfNum];
} else {///
self.numberLabel.hidden = YES;
if (_ballInfo.isFlip) {
self.notGetButton.hidden = YES;
} else {
self.notGetButton.hidden = NO;
}
}
if (_ballInfo.isFlip) {
self.stackView.hidden = NO;
if (_ballInfo.elfNum > 0) {
self.sendButton.hidden = NO;
} else {
self.sendButton.hidden = YES;
}
} else {
self.stackView.hidden = YES;
}
if (backImageName.length > 0) {
self.backImageView.image = [UIImage imageNamed:backImageName];
}
if (coverImageName.length > 0) {
self.coverImageView.image = [UIImage imageNamed:coverImageName];
}
}
}
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.image = [UIImage imageNamed:@"room_treasure_fairy_ball_bg"];
}
return _backImageView;
}
- (UILabel *)nameLabel {
if (!_nameLabel) {
_nameLabel = [[UILabel alloc] init];
_nameLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
_nameLabel.textColor = [DJDKMIMOMColor colorWithHexString:@"#A4FFFC"];
_nameLabel.textAlignment = NSTextAlignmentCenter;
}
return _nameLabel;
}
- (UILabel *)numberLabel {
if (!_numberLabel) {
_numberLabel = [[UILabel alloc] init];
_numberLabel.font = [UIFont systemFontOfSize:12];
_numberLabel.textColor = [DJDKMIMOMColor colorWithHexString:@"#59FDFF"];
_numberLabel.textAlignment = NSTextAlignmentCenter;
}
return _numberLabel;
}
- (UIImageView *)coverImageView {
if (!_coverImageView) {
_coverImageView = [[UIImageView alloc] init];
_coverImageView.userInteractionEnabled = YES;
}
return _coverImageView;
}
- (NetImageView *)ballImageView {
if (!_ballImageView) {
NetImageConfig * config = [[NetImageConfig alloc]init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
_ballImageView = [[NetImageView alloc] initWithConfig:config];
_ballImageView.layer.masksToBounds = YES;
_ballImageView.contentMode = UIViewContentModeScaleAspectFill;
}
return _ballImageView;
}
- (UIStackView *)stackView {
if (!_stackView) {
_stackView = [[UIStackView alloc] init];
_stackView.axis = UILayoutConstraintAxisVertical;
_stackView.distribution = UIStackViewDistributionFill;
_stackView.alignment = UIStackViewAlignmentFill;
_stackView.spacing = 10;
_stackView.hidden = YES;
}
return _stackView;
}
- (UIButton *)notGetButton {
if (!_notGetButton) {
_notGetButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_notGetButton setImage:[UIImage imageNamed:@"room_treasure_fairy_ball_not_get"] forState:UIControlStateNormal];
[_notGetButton setImage:[UIImage imageNamed:@"room_treasure_fairy_ball_not_get"] forState:UIControlStateSelected];
_notGetButton.hidden = YES;
_notGetButton.userInteractionEnabled = NO;
}
return _notGetButton;
}
- (UIButton *)sendButton {
if (!_sendButton) {
_sendButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_sendButton setImage:[UIImage imageNamed:@"room_treasure_fairy_ball_send"] forState:UIControlStateNormal];
[_sendButton setImage:[UIImage imageNamed:@"room_treasure_fairy_ball_send"] forState:UIControlStateSelected];
[_sendButton addTarget:self action:@selector(sendButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _sendButton;
}
- (UIButton *)askButton {
if (!_askButton) {
_askButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_askButton setImage:[UIImage imageNamed:@"room_treasure_fairy_ball_ask"] forState:UIControlStateNormal];
[_askButton setImage:[UIImage imageNamed:@"room_treasure_fairy_ball_ask"] forState:UIControlStateSelected];
[_askButton addTarget:self action:@selector(askButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _askButton;
}
@end

View File

@@ -0,0 +1,16 @@
//
// XPTreasureFairyDrawSubView.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/15.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class TreasureFairyInfoModel;
@interface XPTreasureFairyDrawSubView : UIView
@property (nonatomic,strong) TreasureFairyInfoModel *info;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,99 @@
//
// XPTreasureFairyDrawSubView.m
// xplan-ios
//
// Created by on 2023/2/15.
//
#import "XPTreasureFairyDrawSubView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "NetImageView.h"
///Model
#import "TreasureFairyInfoModel.h"
@interface XPTreasureFairyDrawSubView ()
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,strong) NetImageView *fairyView;
///
@property (nonatomic,strong) UILabel *nameLabel;
@end
@implementation XPTreasureFairyDrawSubView
- (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.fairyView];
[self addSubview:self.nameLabel];
}
- (void)initSubViewConstraints {
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
[self.fairyView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(40, 46));
make.centerX.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.backImageView).offset(8);
}];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.fairyView.mas_bottom).offset(2);
}];
}
#pragma mark - Getters And Setters
- (void)setInfo:(TreasureFairyInfoModel *)info {
_info = info;
if (_info) {
self.fairyView.imageUrl = _info.rewardPicUrl;
self.nameLabel.text = _info.rewardName;
}
}
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.image = [UIImage imageNamed:@"room_treasure_fairy_draw_bg"];
}
return _backImageView;
}
- (NetImageView *)fairyView {
if (!_fairyView) {
NetImageConfig * config = [[NetImageConfig alloc]init];
_fairyView = [[NetImageView alloc] initWithConfig:config];
_fairyView.layer.masksToBounds = YES;
_fairyView.contentMode = UIViewContentModeScaleAspectFit;
}
return _fairyView;
}
- (UILabel *)nameLabel {
if (!_nameLabel) {
_nameLabel = [[UILabel alloc] init];
_nameLabel.font = [UIFont systemFontOfSize:12];
_nameLabel.textColor = [DJDKMIMOMColor colorWithHexString:@"#FFE8AA"];
_nameLabel.textAlignment = NSTextAlignmentCenter;
_nameLabel.text = YMLocalizedString(@"XPTreasureFairyDrawSubView0");
}
return _nameLabel;
}
@end

View File

@@ -0,0 +1,27 @@
//
// XPTreasureFairyDrewView.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/15.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class TreasureFailyKeyInfoModel, TreasureFairyInfoModel;
typedef void(^AnimationCompletion)(BOOL finish);
@interface XPTreasureFairyDrawView : UIView
@property (nonatomic,strong) TreasureFailyKeyInfoModel *keyInfo;
///礼物的列表
@property (nonatomic,strong) NSArray *failyList;
- (void)startTimerCompletion:(AnimationCompletion)comletion;
///停止动画
- (void)stopAnimation;
///奖励的信息(最高奖励 动画要停止的位置)
@property (nonatomic,strong) TreasureFairyInfoModel *rewardInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,492 @@
//
// XPTreasureFairyDrewView.m
// xplan-ios
//
// Created by on 2023/2/15.
//
#import "XPTreasureFairyDrawView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "XPWeakTimer.h"
#import "NSArray+Safe.h"
///Model
#import "TreasureFairyInfoModel.h"
#import "TreasureFailyKeyInfoModel.h"
///View
#import "XPTreasureFairyDrawSubView.h"
@interface XPTreasureFairyDrawView ()
{
NSTimer * timer;
}
///
@property (nonatomic,strong) UIImageView *coverImageView;
///
@property (nonatomic,strong) XPTreasureFairyDrawSubView *firstView;
///
@property (nonatomic,strong) XPTreasureFairyDrawSubView *secondView;
///
@property (nonatomic,strong) XPTreasureFairyDrawSubView *thirdView;
///
@property (nonatomic,strong) XPTreasureFairyDrawSubView *fourthView;
///
@property (nonatomic,strong) XPTreasureFairyDrawSubView *fifView;
///
@property (nonatomic,strong) XPTreasureFairyDrawSubView *sixView;
///
@property (nonatomic,strong) XPTreasureFairyDrawSubView *sevenView;
///
@property (nonatomic,strong) XPTreasureFairyDrawSubView *eightView;
///9
@property (nonatomic,strong) XPTreasureFairyDrawSubView *nineView;
///10
@property (nonatomic,strong) XPTreasureFairyDrawSubView *tenView;
///11
@property (nonatomic,strong) XPTreasureFairyDrawSubView *elevenView;
///12
@property (nonatomic,strong) XPTreasureFairyDrawSubView *twelveView;
///view
@property (nonatomic,strong) NSArray *viewList;
///
@property (nonatomic,strong) UIButton *currentValueButton;
///
@property (nonatomic,strong) UIImageView *diamondBGView;
///
@property (nonatomic,strong) UIImageView *diamondImageView;
///
@property (nonatomic,strong) UIImageView *coverDiamondView;
///
@property (nonatomic,strong) UILabel *limitLabel;
///index
@property (nonatomic,assign) NSInteger currentIndex;
///
@property (nonatomic,assign) NSInteger cycleCount;
///
@property (nonatomic,assign) NSInteger rewardIndex;
@property (nonatomic,assign) NSInteger rewardNumber;
///
@property (nonatomic,copy) AnimationCompletion finishCompletion;
@end
@implementation XPTreasureFairyDrawView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Public Method
- (void)startTimerCompletion:(AnimationCompletion)comletion {
self.finishCompletion = comletion;
if (timer == nil) {
timer = [XPWeakTimer scheduledTimerWithTimeInterval:0.07 target:self selector:@selector(run) userInfo:nil repeats:YES];
[timer fire];
}
}
- (void)stopAnimation {
XPTreasureFairyDrawSubView * view = [self.viewList safeObjectAtIndex1:self.rewardNumber];
if (view) {
[self.coverImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(75 * kScreenScale, 81 * kScreenScale));
make.center.equalTo(view);
}];
}
[self stopTimer];
}
- (void)stopTimer {
[timer invalidate];
timer = nil;
self.cycleCount = 0;
self.finishCompletion(YES);
}
- (void)run {
self.currentIndex ++;
self.cycleCount ++;
///
if (self.cycleCount == (12 * 2 + self.rewardIndex)) {
[self stopTimer];
XPTreasureFairyDrawSubView * view = [self.viewList safeObjectAtIndex1:self.rewardNumber];
if (view) {
[self.coverImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(75 * kScreenScale, 81 * kScreenScale));
make.center.equalTo(view);
}];
}
return;
}
if (self.currentIndex >= self.viewList.count) {
self.currentIndex = 0;
}
XPTreasureFairyDrawSubView * view = [self.viewList safeObjectAtIndex1:self.currentIndex];
if (view) {
[self.coverImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(75 * kScreenScale, 81 * kScreenScale));
make.center.equalTo(view);
}];
}
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.firstView];
[self addSubview:self.secondView];
[self addSubview:self.thirdView];
[self addSubview:self.fourthView];
[self addSubview:self.fifView];
[self addSubview:self.sixView];
[self addSubview:self.sevenView];
[self addSubview:self.eightView];
[self addSubview:self.nineView];
[self addSubview:self.tenView];
[self addSubview:self.elevenView];
[self addSubview:self.twelveView];
[self addSubview:self.diamondBGView];
[self addSubview:self.coverImageView];
[self addSubview:self.currentValueButton];
[self addSubview:self.coverDiamondView];
[self addSubview:self.diamondImageView];
[self addSubview:self.limitLabel];
self.viewList = @[self.firstView, self.secondView, self.thirdView, self.fourthView, self.fifView, self.sixView, self.sevenView, self.eightView, self.nineView, self.tenView, self.elevenView, self.twelveView];
}
- (void)initSubViewConstraints {
[self mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.sevenView.mas_bottom);
}];
[self.coverImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(75 * kScreenScale, 81 * kScreenScale));
make.center.equalTo(self.firstView);
}];
[self.firstView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(75 * kScreenScale, 75 * kScreenScale));
make.left.mas_equalTo(self).offset(0);
make.top.mas_equalTo(self).offset(0);
}];
CGFloat margin = 15;
CGFloat topMargin = 11;
[self.secondView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.centerY.equalTo(self.firstView);
make.left.mas_equalTo(self.firstView.mas_right).offset(margin);
}];
[self.thirdView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.centerY.equalTo(self.firstView);
make.left.mas_equalTo(self.secondView.mas_right).offset(margin);
}];
[self.fourthView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.centerY.equalTo(self.firstView);
make.left.mas_equalTo(self.thirdView.mas_right).offset(margin);
}];
[self.fifView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.equalTo(self.firstView);
make.left.mas_equalTo(self.fourthView);
make.top.mas_equalTo(self.fourthView.mas_bottom).offset(topMargin);
}];
[self.sixView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.centerX.equalTo(self.fifView);
make.top.mas_equalTo(self.fifView.mas_bottom).offset(topMargin);
}];
[self.sevenView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.centerX.equalTo(self.fifView);
make.top.mas_equalTo(self.sixView.mas_bottom).offset(topMargin);
}];
[self.eightView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.centerY.equalTo(self.sevenView);
make.right.mas_equalTo(self.sevenView.mas_left).offset(-margin);
}];
[self.nineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.centerY.equalTo(self.sevenView);
make.right.mas_equalTo(self.eightView.mas_left).offset(-margin);
}];
[self.tenView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.centerY.equalTo(self.sevenView);
make.right.mas_equalTo(self.nineView.mas_left).offset(-margin);
}];
[self.elevenView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.centerX.equalTo(self.tenView);
make.bottom.mas_equalTo(self.tenView.mas_top).offset(-topMargin);
}];
[self.twelveView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.centerX.equalTo(self.tenView);
make.bottom.mas_equalTo(self.elevenView.mas_top).offset(-topMargin);
}];
[self.currentValueButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(106, 28));
make.centerX.mas_equalTo(self);
make.top.mas_equalTo(self.firstView.mas_bottom).offset(10);
}];
[self.diamondBGView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(120, 125));
make.centerX.mas_equalTo(self);
make.top.mas_equalTo(self.currentValueButton.mas_bottom).offset(5);
}];
[self.coverDiamondView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(120, 108));
make.centerX.centerY.mas_equalTo(self.diamondBGView);
}];
[self.diamondImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.mas_equalTo(self.coverDiamondView);
make.top.mas_equalTo(self.coverDiamondView).offset(108);
}];
[self.limitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self);
make.top.mas_equalTo(self.diamondBGView.mas_bottom).offset(2);
}];
}
- (void)createExtraGetFairyAtrribute:(NSInteger)value {
NSString * valueStr = [NSString stringWithFormat:@"%ld", value];
NSString * title = [NSString stringWithFormat:YMLocalizedString(@"XPTreasureFairyDrawView0"), valueStr];
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10], NSForegroundColorAttributeName:[DJDKMIMOMColor colorWithHexString:@"#59FDFF"]}];
[attribute addAttribute:NSForegroundColorAttributeName value:[DJDKMIMOMColor colorWithHexString:@"#FFE8AA"] range:[title rangeOfString:valueStr]];
[attribute addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12 weight:UIFontWeightMedium] range:[title rangeOfString:valueStr]];
self.limitLabel.attributedText = attribute;
self.limitLabel.textAlignment = NSTextAlignmentCenter;
}
- (void)createCurrentFairyValueAtrribute:(NSInteger)value {
NSString * valueStr = [NSString stringWithFormat:@"%ld", value];
NSString * title = [NSString stringWithFormat:YMLocalizedString(@"XPTreasureFairyDrawView1"), valueStr];
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10], NSForegroundColorAttributeName:[UIColor whiteColor]}];
[attribute addAttribute:NSForegroundColorAttributeName value:[DJDKMIMOMColor colorWithHexString:@"#FFE8AA"] range:[title rangeOfString:valueStr]];
[attribute addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12 weight:UIFontWeightMedium] range:[title rangeOfString:valueStr]];
[self.currentValueButton setAttributedTitle:attribute forState:UIControlStateNormal];
}
#pragma mark - Getters And Setters
- (void)setKeyInfo:(TreasureFailyKeyInfoModel *)keyInfo {
_keyInfo = keyInfo;
if (_keyInfo) {
[self createExtraGetFairyAtrribute:_keyInfo.needLuckyNum];
[self createCurrentFairyValueAtrribute:_keyInfo.luckyNum];
CGFloat kscale = 0;
if (_keyInfo.needLuckyNum > 0) {
kscale = (CGFloat)_keyInfo.luckyNum / (CGFloat)_keyInfo.needLuckyNum;
if (kscale > 1) {
kscale = 1;
}
}
[self.diamondImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.coverDiamondView).offset(108 *(1 - kscale));
}];
}
}
- (void)setFailyList:(NSArray *)failyList {
_failyList = failyList;
if (_failyList.count > 0) {
for (int i = 0; i < _failyList.count; i++) {
TreasureFairyInfoModel * info = [_failyList safeObjectAtIndex1:i];
if (i < self.viewList.count) {
XPTreasureFairyDrawSubView * view = [self.viewList safeObjectAtIndex1:i];
view.info = info;
}
}
}
}
- (void)setRewardInfo:(TreasureFairyInfoModel *)rewardInfo {
_rewardInfo = rewardInfo;
if (_rewardInfo) {
for (int i = 0; i < self.failyList.count; i++) {
TreasureFairyInfoModel * info = [_failyList safeObjectAtIndex1:i];
if (info.itemIndex == _rewardInfo.itemIndex) {
self.rewardNumber = i;
if (i > self.currentIndex) {
self.rewardIndex = (i - self.currentIndex);
} else {
self.rewardIndex = (12 - self.currentIndex) + i +1;
}
break;
}
}
}
}
- (XPTreasureFairyDrawSubView *)firstView {
if (!_firstView) {
_firstView = [[XPTreasureFairyDrawSubView alloc] init];
_firstView.tag = 1001;
}
return _firstView;
}
- (XPTreasureFairyDrawSubView *)secondView {
if (!_secondView) {
_secondView = [[XPTreasureFairyDrawSubView alloc] init];
_secondView.tag = 1002;
}
return _secondView;
}
- (XPTreasureFairyDrawSubView *)thirdView {
if (!_thirdView) {
_thirdView = [[XPTreasureFairyDrawSubView alloc] init];
_thirdView.tag = 1003;
}
return _thirdView;
}
- (XPTreasureFairyDrawSubView *)fourthView {
if (!_fourthView) {
_fourthView = [[XPTreasureFairyDrawSubView alloc] init];
_fourthView.tag = 1004;
}
return _fourthView;
}
- (XPTreasureFairyDrawSubView *)fifView {
if (!_fifView) {
_fifView = [[XPTreasureFairyDrawSubView alloc] init];
_fifView.tag = 1005;
}
return _fifView;
}
- (XPTreasureFairyDrawSubView *)sixView {
if (!_sixView) {
_sixView = [[XPTreasureFairyDrawSubView alloc] init];
_sixView.tag = 1006;
}
return _sixView;
}
- (XPTreasureFairyDrawSubView *)sevenView {
if (!_sevenView) {
_sevenView = [[XPTreasureFairyDrawSubView alloc] init];
_sevenView.tag = 1007;
}
return _sevenView;
}
- (XPTreasureFairyDrawSubView *)eightView {
if (!_eightView) {
_eightView = [[XPTreasureFairyDrawSubView alloc] init];
_eightView.tag = 1008;
}
return _eightView;
}
- (XPTreasureFairyDrawSubView *)nineView {
if (!_nineView) {
_nineView = [[XPTreasureFairyDrawSubView alloc] init];
_nineView.tag = 1009;
}
return _nineView;
}
- (XPTreasureFairyDrawSubView *)tenView {
if (!_tenView) {
_tenView = [[XPTreasureFairyDrawSubView alloc] init];
_tenView.tag = 1001;
}
return _tenView;
}
- (XPTreasureFairyDrawSubView *)elevenView {
if (!_elevenView) {
_elevenView = [[XPTreasureFairyDrawSubView alloc] init];
_elevenView.tag = 1011;
}
return _elevenView;
}
- (XPTreasureFairyDrawSubView *)twelveView {
if (!_twelveView) {
_twelveView = [[XPTreasureFairyDrawSubView alloc] init];
_twelveView.tag = 1001;
}
return _twelveView;
}
- (UIImageView *)coverImageView {
if (!_coverImageView) {
_coverImageView = [[UIImageView alloc] init];
_coverImageView.userInteractionEnabled = YES;
_coverImageView.image = [UIImage imageNamed:@"room_treasure_fairy_draw_cover"];
}
return _coverImageView;
}
- (UIButton *)currentValueButton {
if (!_currentValueButton) {
_currentValueButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_currentValueButton setBackgroundImage:[UIImage imageNamed:@"room_treasure_fairy_draw_lucky_bg"] forState:UIControlStateNormal];
}
return _currentValueButton;
}
- (UIImageView *)diamondImageView {
if (!_diamondImageView) {
_diamondImageView = [[UIImageView alloc] init];
_diamondImageView.userInteractionEnabled = YES;
_diamondImageView.image = [UIImage imageNamed:@"room_treasure_fairy_draw_diamond"];
_diamondImageView.layer.masksToBounds = YES;
_diamondBGView.layer.masksToBounds = YES;
_diamondImageView.contentMode = UIViewContentModeBottom;
}
return _diamondImageView;
}
- (UIImageView *)diamondBGView {
if (!_diamondBGView) {
_diamondBGView = [[UIImageView alloc] init];
_diamondBGView.userInteractionEnabled = YES;
_diamondBGView.image = [UIImage imageNamed:@"room_treasure_fairy_draw_diamond_bg"];
_diamondBGView.layer.masksToBounds = YES;
}
return _diamondBGView;
}
- (UIImageView *)coverDiamondView {
if (!_coverDiamondView) {
_coverDiamondView = [[UIImageView alloc] init];
_coverDiamondView.userInteractionEnabled = YES;
_coverDiamondView.image = [UIImage imageNamed:@"room_treasure_fairy_draw_diamond_cover"];
}
return _coverDiamondView;
}
- (UILabel *)limitLabel {
if (!_limitLabel) {
_limitLabel = [[UILabel alloc] init];
}
return _limitLabel;
}
@end

View File

@@ -0,0 +1,19 @@
//
// XPTreasureFairyExchangeView.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/27.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class TreasureFairyUserInfoModel;
@interface XPTreasureFairyExchangeView : UIView
///房主的uid
@property (nonatomic,strong) NSString *roomUid;
///用户信息
@property (nonatomic,strong) TreasureFairyUserInfoModel *userInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,300 @@
//
// XPTreasureFairyExchangeView.m
// xplan-ios
//
// Created by on 2023/2/27.
//
#import "XPTreasureFairyExchangeView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "NetImageView.h"
#import "Api+TreasureFairy.h"
#import "TTPopup.h"
///View
#import "XPTreasureFairyShopingExchangeCell.h"
#import "XPTreasureFairyStoreResultSmallView.h"
///Model
#import "TreasureFairyFragmentModel.h"
#import "TreasureFairyInfoModel.h"
#import "TreasureFairyBallInfoModel.h"
#import "TreasureFairyUserInfoModel.h"
@interface XPTreasureFairyExchangeView ()<UICollectionViewDelegate, UICollectionViewDataSource, XPTreasureFairyShopingExchangeCellDelegate>
///
@property (nonatomic,strong) UICollectionView *collectionView;
///
@property (nonatomic,strong) UIImageView *userImageView;
///
@property (nonatomic,strong) NetImageView *avatarImageView;
///
@property (nonatomic,strong) UILabel *nickLabel;
///
@property (nonatomic,strong) UILabel *fragmentTextLabel;
///
@property (nonatomic,strong) UIImageView *fragmentImageView;
///
@property (nonatomic,strong) UILabel *fragmentNumLabel;
///
@property (nonatomic,strong) NSMutableArray <TreasureFairyFragmentModel *>*fragmentArray;
@end
@implementation XPTreasureFairyExchangeView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
[self initHttpRequest];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.collectionView];
[self addSubview:self.userImageView];
[self.userImageView addSubview:self.avatarImageView];
[self.userImageView addSubview:self.nickLabel];
[self.userImageView addSubview:self.fragmentTextLabel];
[self.userImageView addSubview:self.fragmentImageView];
[self.userImageView addSubview:self.fragmentNumLabel];
}
- (void)initSubViewConstraints {
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
CGFloat kuserScale = 91.0 / 375.0;
[self.userImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(KScreenWidth, KScreenWidth * kuserScale));
make.bottom.mas_equalTo(self);
make.centerX.mas_equalTo(self);
}];
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(44, 44));
make.left.mas_equalTo(self.userImageView).offset(15);
make.top.mas_equalTo(self.userImageView).offset(15 * kScreenScale);
}];
[self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.avatarImageView.mas_right).offset(2);
make.centerY.mas_equalTo(self.avatarImageView);
}];
[self.fragmentNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(-15);
make.centerY.mas_equalTo(self.avatarImageView);
}];
[self.fragmentImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.fragmentNumLabel.mas_left).offset(-4);
make.centerY.mas_equalTo(self.avatarImageView);
make.size.mas_equalTo(CGSizeMake(24, 24));
}];
[self.fragmentTextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.fragmentImageView.mas_left).offset(-2);
make.centerY.mas_equalTo(self.avatarImageView);
}];
}
#pragma mark - Private Method
- (void)initHttpRequest {
[self getFragmentExchangeList];
[self getMyBallList];
}
- (void)getFragmentExchangeList {
//
[Api treasureFailyFragmentExchangeList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
NSArray * fragmentList = [TreasureFairyFragmentModel modelsWithArray:data.data];
[self.fragmentArray removeAllObjects];
[self.fragmentArray addObjectsFromArray:fragmentList];
[self.collectionView reloadData];
} else {
[XNDJTDDLoadingTool showErrorWithMessage:msg];
}
}];
}
- (void)extracted {
[Api treasureFairyMyBallList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
TreasureFairyBallInfoModel * info = [TreasureFairyBallInfoModel modelWithDictionary:data.data];
self.fragmentNumLabel.text = [NSString stringWithFormat:@"%ld",info.chipNum];
} else {
[XNDJTDDLoadingTool showErrorWithMessage:msg];
}
}];
}
- (void)getMyBallList {
//
[self extracted];
}
#pragma mark - UICollectionViewDelegate, UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.fragmentArray.count;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
XPTreasureFairyShopingExchangeCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPTreasureFairyShopingExchangeCell class]) forIndexPath:indexPath];
TreasureFairyFragmentModel *model = self.fragmentArray[indexPath.row];
cell.fragmemtModel = model;
cell.delegate = self;
return cell;
}
#pragma mark - XPTreasureFairyShopingExchangeCellDelegate
- (void)treasureFairyShopingExchangeAction:(TreasureFairyFragmentModel *)fragmentModel {
if (fragmentModel.itemId > 0) {
TTAlertConfig * config = [[TTAlertConfig alloc] init];
config.title = @"";
NSString * untils;
if ([fragmentModel.rewardType isEqualToString:@"gift"]) {
untils = [NSString stringWithFormat:@"%@%@", fragmentModel.rewardShowValue, YMLocalizedString(@"XPTreasureFairyExchangeView0")];
} else {
untils = [NSString stringWithFormat:@"%ld%@", fragmentModel.rewardNum, fragmentModel.rewardUnit];
}
config.title = YMLocalizedString(@"XPTreasureFairyExchangeView1");
config.confirmButtonConfig.title = YMLocalizedString(@"XPTreasureFairyExchangeView2");
config.message = [NSString stringWithFormat:YMLocalizedString(@"XPTreasureFairyExchangeView3"), fragmentModel.rewardName, untils];
[TTPopup alertWithConfig:config confirmHandler:^{
[Api treasureFailyConvert:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
[XNDJTDDLoadingTool showSuccessWithMessage:YMLocalizedString(@"XPTreasureFairyExchangeView4")];
///
[self getMyBallList];
} else {
[XNDJTDDLoadingTool showErrorWithMessage:msg];
}
} itemId:[NSString stringWithFormat:@"%ld", fragmentModel.itemId] roomUid:self.roomUid];
} cancelHandler:^{
}];
}
}
#pragma mark - Getters And Setters
- (void)setUserInfo:(TreasureFairyUserInfoModel *)userInfo {
_userInfo = userInfo;
self.avatarImageView.imageUrl = userInfo.avatar;
NSString * nick = userInfo.nick;
if (nick.length > 6) {
nick = [NSString stringWithFormat:@"%@…", [nick substringToIndex:6]];
}
self.nickLabel.text = nick;
}
- (UICollectionView *)collectionView {
if (!_collectionView) {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.scrollDirection = UICollectionViewScrollDirectionVertical;
CGFloat scale = 234.0/165.0;
CGFloat space = 15.0;
CGFloat itemWidth = (KScreenWidth - space*3)/2;
CGFloat itemHeight = scale*itemWidth;
// layout.itemSize = CGSizeMake(itemWidth, itemHeight);
layout.itemSize = CGSizeMake(165.0, 234.0);
layout.minimumInteritemSpacing = space;
layout.minimumLineSpacing = space;
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
_collectionView.backgroundColor = UIColor.clearColor;
_collectionView.delegate = self;
_collectionView.dataSource = self;
CGFloat kuserScale = 91.0 / 375.0;
CGFloat insetsBottom = KScreenWidth * kuserScale;
_collectionView.contentInset = UIEdgeInsetsMake(0, space, insetsBottom, space);
[_collectionView registerClass:[XPTreasureFairyShopingExchangeCell class] forCellWithReuseIdentifier:NSStringFromClass([XPTreasureFairyShopingExchangeCell class])];
}
return _collectionView;
}
- (UIImageView *)userImageView {
if (!_userImageView) {
_userImageView = [[UIImageView alloc] init];
_userImageView.userInteractionEnabled = YES;
_userImageView.image = [UIImage imageNamed:@"room_treasure_fairy_userinfo_bg"];
}
return _userImageView;
}
- (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 = 44/2;
_avatarImageView.layer.borderColor = [DJDKMIMOMColor appMainColor].CGColor;
}
return _avatarImageView;
}
- (UILabel *)nickLabel {
if (!_nickLabel) {
_nickLabel = [[UILabel alloc] init];
_nickLabel.font = [UIFont systemFontOfSize:13];
_nickLabel.textColor = [UIColor whiteColor];
_nickLabel.text = YMLocalizedString(@"XPTreasureFairyExchangeView5");
}
return _nickLabel;
}
- (UILabel *)fragmentTextLabel {
if (!_fragmentTextLabel) {
_fragmentTextLabel = [[UILabel alloc] init];
_fragmentTextLabel.font = [UIFont systemFontOfSize:12];
_fragmentTextLabel.textColor = [DJDKMIMOMColor colorWithHexString:@"#1F5764"];
_fragmentTextLabel.text = YMLocalizedString(@"XPTreasureFairyExchangeView6");
}
return _fragmentTextLabel;
}
- (UIImageView *)fragmentImageView {
if (!_fragmentImageView) {
_fragmentImageView = [[UIImageView alloc] init];
_fragmentImageView.image = [UIImage imageNamed:@"room_treasure_fairy_shop_fragment"];
}
return _fragmentImageView;
}
- (UILabel *)fragmentNumLabel {
if (!_fragmentNumLabel) {
_fragmentNumLabel = [[UILabel alloc] init];
_fragmentNumLabel.font = [UIFont systemFontOfSize:12];
_fragmentNumLabel.textColor = [UIColor whiteColor];
_fragmentNumLabel.text = @"0";
}
return _fragmentNumLabel;
}
- (NSMutableArray<TreasureFairyFragmentModel *> *)fragmentArray {
if (!_fragmentArray) {
_fragmentArray = [NSMutableArray array];
}
return _fragmentArray;
}
@end

View File

@@ -0,0 +1,24 @@
//
// XPTreasureFairyFriendView.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/23.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class TreasureFairyBallModel, XPTreasureFairyFriendView;
@protocol XPTreasureFairyFriendViewDelegate <NSObject>
- (void)treasureFairyFriendFinish:(XPTreasureFairyFriendView *)view;
@end
@interface XPTreasureFairyFriendView : UIView
@property (nonatomic,assign) BOOL isSend;
@property (nonatomic,strong) TreasureFairyBallModel *ballInfo;
///代理
@property (nonatomic,weak) id<XPTreasureFairyFriendViewDelegate> delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,315 @@
//
// XPTreasureFairyFriendView.m
// xplan-ios
//
// Created by on 2023/2/23.
//
#import "XPTreasureFairyFriendView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "Api+TreasureFairy.h"
#import "NSArray+Safe.h"
#import "TTPopup.h"
///Model
#import "UserInfoModel.h"
#import "TreasureFairyBallInfoModel.h"
///View
#import "XPTreasureFairyFriendCell.h"
#import "XPTreasureFairySendView.h"
@interface XPTreasureFairyFriendView ()<UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate>
///
@property (nonatomic,strong) UIButton *backButton;
///
@property (nonatomic,strong) UIView *dismissView;
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,strong) UIImageView *titleImageView;
///
@property (nonatomic,strong) UILabel *titleLabel;
///
@property (nonatomic,strong) UIView *searchView;
///
@property (nonatomic,strong) UITextField *searchTextField;
///
@property (nonatomic,strong) UITableView *tableView;
///
@property (nonatomic,strong) UIButton *actionButton;
///
@property (nonatomic,strong) NSArray *friendList;
///
@property (nonatomic,strong) NSArray *originList;
@end
@implementation XPTreasureFairyFriendView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self getMyFriendList];
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
- (void)getMyFriendList {
[Api treasureFairyFansFriendList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
NSArray * array = [UserInfoModel modelsWithArray:data.data];
self.friendList = array;
self.originList = array;
[self.tableView reloadData];
} else {
[XNDJTDDLoadingTool showErrorWithMessage:msg];
}
} nick:@""];
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.dismissView];
[self addSubview:self.backImageView];
[self addSubview:self.titleImageView];
[self addSubview:self.actionButton];
[self addSubview:self.backButton];
[self.backImageView addSubview:self.searchView];
[self.backImageView addSubview:self.tableView];
[self.searchView addSubview:self.searchTextField];
}
- (void)initSubViewConstraints {
CGFloat kscale = 580.0 / 375.0;
[self.dismissView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.mas_equalTo(self);
make.bottom.mas_equalTo(self.backImageView.mas_top);
}];
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.mas_equalTo(self);
make.height.mas_equalTo(KScreenWidth * kscale);
}];
[self.titleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(180, 18));
make.centerX.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.backImageView).offset(60* kScreenScale);
}];
[self.backButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(28, 28));
make.left.mas_equalTo(self.backImageView).offset(15);
make.top.mas_equalTo(self.backImageView).offset(40 * kScreenScale);
}];
[self.searchView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.backImageView).inset(15);
make.height.mas_equalTo(32);
make.top.mas_equalTo(self.backImageView).offset(103 * kScreenScale);
}];
[self.searchTextField mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.searchView).offset(15);
make.right.mas_equalTo(self.searchView).offset(-15);
make.top.bottom.mas_equalTo(self.searchView);
}];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.searchView.mas_bottom).offset(13);
make.bottom.mas_equalTo(self.backImageView).offset(-10);
}];
[self.actionButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.backImageView).offset(40);
make.top.right.mas_equalTo(self.backImageView);
make.bottom.mas_equalTo(self.searchView.mas_top);
}];
}
#pragma mark - UITableViewDelegate And UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.friendList.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 65;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
XPTreasureFairyFriendCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPTreasureFairyFriendCell class])];
if (cell == nil) {
cell = [[XPTreasureFairyFriendCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPTreasureFairyFriendCell class])];
}
UserInfoModel * info = [self.friendList safeObjectAtIndex1:indexPath.row];
cell.userInfo = info;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
[self.searchTextField resignFirstResponder];
if (self.friendList.count> 0) {
UserInfoModel * info = [self.friendList safeObjectAtIndex1:indexPath.row];
XPTreasureFairySendView * sendView = [[XPTreasureFairySendView alloc] init];
self.ballInfo.nick = info.nick;
self.ballInfo.uid = info.uid;
sendView.isSend = self.isSend;
sendView.ballInfo = self.ballInfo;
[TTPopup popupView:sendView style:TTPopupStyleActionSheet];
}
}
#pragma mark - Event Response
- (void)dismissRecognizer {
[self.searchTextField resignFirstResponder];
[UIView animateWithDuration:0.3 animations:^{
CGRect rect = self.frame;
rect.origin.y = KScreenHeight;
self.frame = rect;
if (self.delegate && [self.delegate respondsToSelector:@selector(treasureFairyFriendFinish:)]) {
[self.delegate treasureFairyFriendFinish:self];
}
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
}
- (void)resignFirstResponse {
self.friendList = self.originList;
[self.tableView reloadData];
[self.searchTextField resignFirstResponder];
}
- (void)textFieldDidChange:(UITextField *)textField {
if (textField.text.length == 0) {
self.friendList = self.originList;
[self.tableView reloadData];
}
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
NSString *searchStr = textField.text;
if (searchStr.length >= 0) {
[Api treasureFairyFansFriendList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
NSArray * array = [UserInfoModel modelsWithArray:data.data];
self.friendList = array;
[self.tableView reloadData];
} else {
[XNDJTDDLoadingTool showErrorWithMessage:msg];
}
} nick:searchStr];
}
return YES;
}
#pragma mark - Getters And Setters
- (UIButton *)backButton {
if (!_backButton) {
_backButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_backButton setImage:[UIImage imageNamed:@"room_treasure_fairy_back"] forState:UIControlStateNormal];
[_backButton setImage:[UIImage imageNamed:@"room_treasure_fairy_back"] forState:UIControlStateSelected];
[_backButton addTarget:self action:@selector(dismissRecognizer) forControlEvents:UIControlEventTouchUpInside];
}
return _backButton;
}
- (UIView *)dismissView {
if (!_dismissView) {
_dismissView = [[UIView alloc] init];
_dismissView.backgroundColor = [UIColor clearColor];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissRecognizer)];
[_dismissView addGestureRecognizer:tap];
}
return _dismissView;
}
- (UIImageView *)titleImageView {
if (!_titleImageView) {
_titleImageView = [[UIImageView alloc] init];
_titleImageView.userInteractionEnabled = YES;
_titleImageView.image = [UIImage imageNamed:@"room_treasure_my_friend_title"];
}
return _titleImageView;
}
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.image = [UIImage imageNamed:@"room_treasure_fairy_my_friend_bg"];
}
return _backImageView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont systemFontOfSize:17];
_titleLabel.textColor = [DJDKMIMOMColor mainTextColor];
_titleLabel.text = YMLocalizedString(@"XPTreasureFairyFriendView0");
_titleLabel.textAlignment = NSTextAlignmentCenter;
}
return _titleLabel;
}
- (UIView *)searchView {
if (!_searchView) {
_searchView = [[UIView alloc] init];
_searchView.backgroundColor = [DJDKMIMOMColor colorWithHexString:@"#066A6E"];
_searchView.layer.masksToBounds = YES;
_searchView.layer.cornerRadius = 16;
}
return _searchView;
}
- (UITextField *)searchTextField {
if (!_searchTextField) {
_searchTextField = [[UITextField alloc] init];
_searchTextField.layer.cornerRadius = 12;
_searchTextField.layer.masksToBounds = YES;
_searchTextField.tintColor = [DJDKMIMOMColor colorWithHexString:@"#59FDFF"];
_searchTextField.textColor = [DJDKMIMOMColor colorWithHexString:@"#59FDFF"];
_searchTextField.backgroundColor = [UIColor clearColor];
_searchTextField.font = [UIFont systemFontOfSize:13];
_searchTextField.delegate = self;
NSString *placeholder = YMLocalizedString(@"XPTreasureFairyFriendView1");
_searchTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placeholder attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:12], NSForegroundColorAttributeName : [DJDKMIMOMColor colorWithHexString:@"#59FDFF"]}];
_searchTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
_searchTextField.returnKeyType = UIReturnKeySearch;
_searchTextField.enablesReturnKeyAutomatically = YES;
[_searchTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
}
return _searchTextField;
}
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.tableFooterView = [UIView new];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.backgroundColor = [UIColor clearColor];
if (@available(iOS 11.0, *)) {
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
[_tableView registerClass:[XPTreasureFairyFriendCell class] forCellReuseIdentifier:NSStringFromClass([XPTreasureFairyFriendCell class])];
}
return _tableView;
}
- (UIButton *)actionButton {
if (!_actionButton) {
_actionButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_actionButton addTarget:self action:@selector(resignFirstResponse) forControlEvents:UIControlEventTouchUpInside];
}
return _actionButton;
}
@end

View File

@@ -0,0 +1,18 @@
//
// XPTreasureFairyMessageSendView.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/23.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class ContentTreasureFairyModel;
typedef void(^SendCompletion)(BOOL success,ContentTreasureFairyModel *fairyInfo);
@interface XPTreasureFairyMessageSendView : UIView
@property (nonatomic,copy) SendCompletion finish;
@property (nonatomic,strong) ContentTreasureFairyModel *fairyInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,185 @@
//
// XPTreasureFairyMessageSendView.m
// xplan-ios
//
// Created by on 2023/2/23.
//
#import "XPTreasureFairyMessageSendView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "NetImageView.h"
#import "TTPopup.h"
#import "Api+TreasureFairy.h"
///Model
#import "ContentTreasureFairyModel.h"
@interface XPTreasureFairyMessageSendView ()
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,strong) UILabel *titleLabel;
///
@property (nonatomic,strong) NetImageView *ballView;
///
@property (nonatomic,strong) UIButton *cancleButton;
///
@property (nonatomic,strong) UIButton *sureButton;
@end
@implementation XPTreasureFairyMessageSendView
- (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.backImageView addSubview:self.titleLabel];
[self.backImageView addSubview:self.ballView];
[self.backImageView addSubview:self.sureButton];
[self.backImageView addSubview:self.cancleButton];
}
- (void)initSubViewConstraints {
self.frame = CGRectMake(0, 0, 281, 285);
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(281, 285));
make.centerX.mas_equalTo(self);
make.top.mas_equalTo(self);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.backImageView).inset(30);
make.top.mas_equalTo(self.backImageView).offset(45);
}];
[self.ballView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(90, 90));
make.centerX.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(19);
}];
[self.cancleButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(104, 32));
make.top.mas_equalTo(self.ballView.mas_bottom).offset(15);
make.right.mas_equalTo(self.backImageView.mas_centerX).offset(-12);
}];
[self.sureButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.centerY.mas_equalTo(self.cancleButton);
make.left.mas_equalTo(self.backImageView.mas_centerX).offset(12);
}];
}
#pragma mark - Event Response
- (void)cancleButtonAction:(UIButton *)sender {
[TTPopup dismiss];
}
- (void)sureButtonAction:(UIButton *)sender {
[TTPopup dismiss];
if (self.fairyInfo.elfId.integerValue > 0 && self.fairyInfo.uid.integerValue > 0) {
NSString * elfId = self.fairyInfo.elfId;
NSString * uid = self.fairyInfo.uid;
[Api treasureFairySendFairyBall:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
if (self.finish) {
self.finish(YES,self.fairyInfo);
}
[XNDJTDDLoadingTool showSuccessWithMessage:YMLocalizedString(@"XPTreasureFairyMessageSendView0")];
} else {
[XNDJTDDLoadingTool showErrorWithMessage:msg];
}
} elfId:elfId targetUid:uid];
}
}
- (void)dismissRecognizer {
[TTPopup dismiss];
}
#pragma mark - Getters And Setters
- (void)setFairyInfo:(ContentTreasureFairyModel *)fairyInfo {
_fairyInfo = fairyInfo;
if (_fairyInfo) {
self.ballView.imageUrl = _fairyInfo.elfPicUrl;
NSString * nick = _fairyInfo.nick;
NSString * title = [NSString stringWithFormat:YMLocalizedString(@"XPTreasureFairyMessageSendView1"), nick, _fairyInfo.elfName];
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15], NSForegroundColorAttributeName:[UIColor whiteColor]}];
[attribute addAttribute:NSForegroundColorAttributeName value:[DJDKMIMOMColor colorWithHexString:@"#FEF8AA"] range:[title rangeOfString:nick]];
self.titleLabel.attributedText = attribute;
self.titleLabel.textAlignment = NSTextAlignmentCenter;
}
}
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.image = [UIImage imageNamed:@"room_treasure_fairy_my_send_record_bg"];
}
return _backImageView;
}
- (NetImageView *)ballView {
if (!_ballView) {
NetImageConfig * config = [[NetImageConfig alloc]init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
_ballView = [[NetImageView alloc] initWithConfig:config];
_ballView.layer.masksToBounds = YES;
_ballView.layer.cornerRadius = 45;
_ballView.layer.borderColor = [DJDKMIMOMColor appMainColor].CGColor;
_ballView.layer.borderWidth = 0.5;
}
return _ballView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.numberOfLines = 0;
}
return _titleLabel;
}
- (UIButton *)cancleButton {
if (!_cancleButton) {
_cancleButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_cancleButton setTitle:YMLocalizedString(@"XPTreasureFairyMessageSendView2") forState:UIControlStateNormal];
[_cancleButton setTitleColor:[DJDKMIMOMColor colorWithHexString:@"#008573"] forState:UIControlStateNormal];
_cancleButton.titleLabel.font = [UIFont systemFontOfSize:13];
[_cancleButton setBackgroundImage:[UIImage imageNamed:@"room_treasure_fairy_store_result_close_bg"] forState:UIControlStateNormal];
_cancleButton.layer.masksToBounds = YES;
_cancleButton.layer.cornerRadius = 10;
[_cancleButton addTarget:self action:@selector(cancleButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _cancleButton;
}
- (UIButton *)sureButton {
if (!_sureButton) {
_sureButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_sureButton setTitleColor:[DJDKMIMOMColor colorWithHexString:@"#8A4801"] forState:UIControlStateNormal];
_sureButton.titleLabel.font = [UIFont systemFontOfSize:13];
[_sureButton setTitle:YMLocalizedString(@"XPTreasureFairyMessageSendView3") forState:UIControlStateNormal];
[_sureButton setBackgroundImage:[UIImage imageNamed:@"room_treasure_fairy_sure_bg"] forState:UIControlStateNormal];
_sureButton.layer.masksToBounds = YES;
_sureButton.layer.cornerRadius = 10;
[_sureButton addTarget:self action:@selector(sureButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _sureButton;
}
@end

View File

@@ -0,0 +1,31 @@
//
// XPTreasureFairyMoreView.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/21.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, TreasureFairyMoreType) {
TreasureFairyMoreType_Rule = 1,
///记录
TreasureFairyMoreType_Record,
///达人
TreasureFairyMoreType_Expet
};
@class XPTreasureFairyMoreView;
@protocol XPTreasureFairyMoreViewDelegate <NSObject>
- (void)xPTreasureFairyMoreView:(XPTreasureFairyMoreView *)view didClickButton:(TreasureFairyMoreType)type;
@end
@interface XPTreasureFairyMoreView : UIView
///代理
@property (nonatomic,weak) id<XPTreasureFairyMoreViewDelegate> delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,133 @@
//
// XPTreasureFairyMoreView.m
// xplan-ios
//
// Created by on 2023/2/21.
//
#import "XPTreasureFairyMoreView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
@interface XPTreasureFairyMoreView ()
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,strong) UIButton *ruleButton;
///
@property (nonatomic,strong) UIButton *recordButton;
///
@property (nonatomic,strong) UIButton *expetButton;
@end
@implementation XPTreasureFairyMoreView
- (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.backImageView addSubview:self.ruleButton];
[self.backImageView addSubview:self.recordButton];
[self.backImageView addSubview:self.expetButton];
}
- (void)initSubViewConstraints {
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
[self.ruleButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.backImageView);
make.height.mas_equalTo(30);
make.top.mas_equalTo(self.backImageView).offset(25);
}];
[self.recordButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.backImageView);
make.height.mas_equalTo(self.recordButton);
make.top.mas_equalTo(self.ruleButton.mas_bottom).offset(3);
}];
[self.expetButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.backImageView);
make.height.mas_equalTo(self.recordButton);
make.top.mas_equalTo(self.recordButton.mas_bottom).offset(3);
}];
}
#pragma mark - Event Response
- (void)ruleButtonAction:(UIButton *)sender {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPTreasureFairyMoreView:didClickButton:)]) {
[self.delegate xPTreasureFairyMoreView:self didClickButton:TreasureFairyMoreType_Rule];
}
}
- (void)expetButtonAction:(UIButton *)sender {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPTreasureFairyMoreView:didClickButton:)]) {
[self.delegate xPTreasureFairyMoreView:self didClickButton:TreasureFairyMoreType_Expet];
}
}
- (void)recordButtonAction:(UIButton *)sender {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPTreasureFairyMoreView:didClickButton:)]) {
[self.delegate xPTreasureFairyMoreView:self didClickButton:TreasureFairyMoreType_Record];
}
}
#pragma mark - Getters And Setters
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.image = [UIImage imageNamed:@"room_treasure_fairy_more_title_bg"];
}
return _backImageView;
}
- (UIButton *)ruleButton {
if (!_ruleButton) {
_ruleButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_ruleButton setTitle:YMLocalizedString(@"XPTreasureFairyMoreView0") forState:UIControlStateNormal];
[_ruleButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
_ruleButton.titleLabel.font = [UIFont systemFontOfSize:13];
[_ruleButton addTarget:self action:@selector(ruleButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _ruleButton;
}
- (UIButton *)expetButton {
if (!_expetButton) {
_expetButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_expetButton setTitle:YMLocalizedString(@"XPTreasureFairyMoreView1") forState:UIControlStateNormal];
[_expetButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
_expetButton.titleLabel.font = [UIFont systemFontOfSize:13];
[_expetButton addTarget:self action:@selector(expetButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _expetButton;
}
- (UIButton *)recordButton {
if (!_recordButton) {
_recordButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_recordButton setTitle:YMLocalizedString(@"XPTreasureFairyMoreView2") forState:UIControlStateNormal];
[_recordButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
_recordButton.titleLabel.font = [UIFont systemFontOfSize:13];
[_recordButton addTarget:self action:@selector(recordButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _recordButton;
}
@end

View File

@@ -0,0 +1,17 @@
//
// XPTreasureFairyMyView.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/22.
//
#import <UIKit/UIKit.h>
#import "TreasureFailyKeyInfoModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface XPTreasureFairyMyView : UIView
///用户信息
@property (nonatomic,strong) TreasureFailyKeyInfoModel *keyInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,404 @@
//
// XPTreasureFairyMyView.m
// xplan-ios
//
// Created by on 2023/2/22.
//
#import "XPTreasureFairyMyView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "Api+TreasureFairy.h"
#import "TTPopup.h"
///Model
#import "TreasureFairyBallInfoModel.h"
///View
#import "XPTreasureFairyBallContentView.h"
#import "XPTreasureFairySendRecordView.h"
#import "XPTreasureFairyFriendView.h"
@interface XPTreasureFairyMyView ()<XPTreasureFairyBallContentViewDelegate, XPTreasureFairyFriendViewDelegate>
///
@property (nonatomic,strong) UIButton *backButton;
///
@property (nonatomic,strong) UIView *dismissView;
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,strong) UIImageView *titleImageView;
///
@property (nonatomic,strong) UIImageView *tipsImageView;
///
@property (nonatomic,strong) UIButton *recordButton;
///
@property (nonatomic,strong) UIImageView *segmentView;
///
@property (nonatomic,strong) UIButton *lowButton;
///
@property (nonatomic,strong) UIButton *middleButton;
///
@property (nonatomic,strong) UIButton *highButton;
///
@property (nonatomic,strong) XPTreasureFairyBallContentView *lowView;
///
@property (nonatomic,strong) XPTreasureFairyBallContentView *middleView;
///
@property (nonatomic,strong) XPTreasureFairyBallContentView *highView;
///
@property (nonatomic,strong) TreasureFairyBallInfoModel *ballInfo;
@end
@implementation XPTreasureFairyMyView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initHttpRequest];
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initHttpRequest {
[Api treasureFairyMyBallList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
TreasureFairyBallInfoModel * info = [TreasureFairyBallInfoModel modelWithDictionary:data.data];
self.ballInfo = info;
self.lowView.datasource = info.lowElves;
self.middleView.datasource = info.middleElves;
self.highView.datasource = info.highElves;
} else {
[XNDJTDDLoadingTool showErrorWithMessage:msg];
}
}];
}
- (void)initSubViews {
[self addSubview:self.dismissView];
[self addSubview:self.backImageView];
[self addSubview:self.backButton];
[self addSubview:self.titleImageView];
[self addSubview:self.tipsImageView];
[self addSubview:self.recordButton];
[self addSubview:self.segmentView];
[self addSubview:self.lowView];
[self addSubview:self.middleView];
[self addSubview:self.highView];
[self addSubview:self.lowButton];
[self addSubview:self.middleButton];
[self addSubview:self.highButton];
}
-(void)setKeyInfo:(TreasureFailyKeyInfoModel *)keyInfo{
_keyInfo =keyInfo;
if(_keyInfo.spriteLevel == 0){
[self lowButtonAction:self.lowButton];
}else if(_keyInfo.spriteLevel == 1){
[self middleButtonAction:self.middleButton];
}else{
[self highButtonAction:self.highButton];
}
}
- (void)initSubViewConstraints {
CGFloat kscale = 580.0 / 375.0;
[self.dismissView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.mas_equalTo(self);
make.bottom.mas_equalTo(self.backImageView.mas_top);
}];
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.mas_equalTo(self);
make.height.mas_equalTo(KScreenWidth * kscale);
}];
[self.backButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(28, 28));
make.left.mas_equalTo(self.backImageView).offset(15);
make.top.mas_equalTo(self.backImageView).offset(40 * kScreenScale);
}];
[self.titleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(153, 78));
make.centerX.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.backImageView);
}];
[self.tipsImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.backImageView).offset(95);
make.size.mas_equalTo(CGSizeMake(235, 32));
make.centerX.mas_equalTo(self.backImageView);
}];
[self.recordButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(50, 42));
make.centerY.mas_equalTo(self.tipsImageView);
make.right.mas_equalTo(self.backImageView).offset(-15);
}];
[self.segmentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(345, 41));
make.centerX.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.tipsImageView.mas_bottom).offset(16 * kScreenScale);
}];
[self.lowButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(107, 51));
make.left.mas_equalTo(self.segmentView.mas_left).offset(5);
make.centerY.mas_equalTo(self.segmentView).offset(1.5);
}];
[self.middleButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.centerY.mas_equalTo(self.lowButton);
make.left.mas_equalTo(self.lowButton.mas_right).offset(7);
}];
[self.highButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.centerY.mas_equalTo(self.lowButton);
make.left.mas_equalTo(self.middleButton.mas_right).offset(7);
}];
[self.lowView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.segmentView.mas_bottom).offset(16 * kScreenScale);
}];
[self.middleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.lowView);
}];
[self.highView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.lowView);
}];
}
#pragma mark - XPTreasureFairyFriendViewDelegate
- (void)treasureFairyFriendFinish:(XPTreasureFairyFriendView *)view {
[self initHttpRequest];
}
#pragma mark - XPTreasureFairyBallContentViewDelegate
- (void)xPTreasureFairyBallContentView:(XPTreasureFairyBallContentView *)view askInfo:(TreasureFairyBallModel *)askInfo {
XPTreasureFairyFriendView * friendView = [[XPTreasureFairyFriendView alloc] init];
friendView.isSend = NO;
friendView.delegate = self;
friendView.ballInfo = askInfo;
friendView.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight);
[self addSubview:friendView];
[UIView animateWithDuration:0.3 animations:^{
CGRect rect = friendView.frame;
rect.origin.y = 0;
friendView.frame = rect;
}];
}
- (void)xPTreasureFairyBallContentView:(XPTreasureFairyBallContentView *)view sendInfo:(TreasureFairyBallModel *)sendInfo {
XPTreasureFairyFriendView * friendView = [[XPTreasureFairyFriendView alloc] init];
friendView.delegate = self;
friendView.isSend = YES;
friendView.ballInfo = sendInfo;
friendView.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight);
[self addSubview:friendView];
[UIView animateWithDuration:0.3 animations:^{
CGRect rect = friendView.frame;
rect.origin.y = 0;
friendView.frame = rect;
}];
}
#pragma mark - Event Response
- (void)dismissRecognizer {
[UIView animateWithDuration:0.3 animations:^{
CGRect rect = self.frame;
rect.origin.y = KScreenHeight;
self.frame = rect;
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
}
- (void)lowButtonAction:(UIButton *)sender {
sender.selected = YES;
self.keyInfo.spriteLevel = 0;
self.middleButton.selected = NO;
self.highButton.selected = NO;
self.lowView.hidden = NO;
self.middleView.hidden = YES;
self.highView.hidden = YES;
NSMutableArray * array = [NSMutableArray array];
for (TreasureFairyBallModel * info in self.ballInfo.lowElves) {
info.isFlip = NO;
[array addObject:info];
}
self.lowView.datasource = array;
}
- (void)middleButtonAction:(UIButton *)sender {
sender.selected = YES;
self.keyInfo.spriteLevel = 1;
self.lowButton.selected = NO;
self.highButton.selected = NO;
self.lowView.hidden = YES;
self.middleView.hidden = NO;
self.highView.hidden = YES;
NSMutableArray * array = [NSMutableArray array];
for (TreasureFairyBallModel * info in self.ballInfo.middleElves) {
info.isFlip = NO;
[array addObject:info];
}
self.middleView.datasource = array;
}
- (void)highButtonAction:(UIButton *)sender {
sender.selected = YES;
self.keyInfo.spriteLevel = 2;
self.lowButton.selected = NO;
self.middleButton.selected = NO;
self.lowView.hidden = YES;
self.middleView.hidden = YES;
self.highView.hidden = NO;
NSMutableArray * array = [NSMutableArray array];
for (TreasureFairyBallModel * info in self.ballInfo.highElves) {
info.isFlip = NO;
[array addObject:info];
}
self.highView.datasource = array;
}
- (void)recordButtonAction:(UIButton *)sender {
XPTreasureFairySendRecordView * recordView = [[XPTreasureFairySendRecordView alloc] init];
[TTPopup popupView:recordView style:TTPopupStyleActionSheet];
}
#pragma mark - Getters And Setters
- (UIButton *)backButton {
if (!_backButton) {
_backButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_backButton setImage:[UIImage imageNamed:@"room_treasure_fairy_back"] forState:UIControlStateNormal];
[_backButton setImage:[UIImage imageNamed:@"room_treasure_fairy_back"] forState:UIControlStateSelected];
[_backButton addTarget:self action:@selector(dismissRecognizer) forControlEvents:UIControlEventTouchUpInside];
}
return _backButton;
}
- (UIView *)dismissView {
if (!_dismissView) {
_dismissView = [[UIView alloc] init];
_dismissView.backgroundColor = [UIColor clearColor];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissRecognizer)];
[_dismissView addGestureRecognizer:tap];
}
return _dismissView;
}
- (UIImageView *)titleImageView {
if (!_titleImageView) {
_titleImageView = [[UIImageView alloc] init];
_titleImageView.userInteractionEnabled = YES;
_titleImageView.image = [UIImage imageNamed:@"room_treasure_fairy_my_title"];
}
return _titleImageView;
}
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.image = [UIImage imageNamed:@"room_treasure_fairy_bg"];
}
return _backImageView;
}
- (UIImageView *)tipsImageView {
if (!_tipsImageView) {
_tipsImageView = [[UIImageView alloc] init];
_tipsImageView.userInteractionEnabled = YES;
_tipsImageView.image = [UIImage imageNamed:@"room_treasure_fairy_my_tips_bg"];
}
return _tipsImageView;
}
- (UIButton *)recordButton {
if (!_recordButton) {
_recordButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_recordButton setImage:[UIImage imageNamed:@"room_treasure_fairy_my_record_bg"] forState:UIControlStateNormal];
[_recordButton setImage:[UIImage imageNamed:@"room_treasure_fairy_my_record_bg"] forState:UIControlStateSelected];
[_recordButton addTarget:self action:@selector(recordButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _recordButton;
}
- (UIImageView *)segmentView {
if (!_segmentView) {
_segmentView = [[UIImageView alloc] init];
_segmentView.image = [UIImage imageNamed:@"room_treasure_fairy_my_segment_bg"];
_segmentView.userInteractionEnabled = YES;
}
return _segmentView;
}
- (UIButton *)lowButton {
if (!_lowButton) {
_lowButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_lowButton setImage:[UIImage imageNamed:@"room_treasure_fairy_my_low_title_normal"] forState:UIControlStateNormal];
[_lowButton setImage:[UIImage imageNamed:@"room_treasure_fairy_my_low_title_select"] forState:UIControlStateSelected];
[_lowButton addTarget:self action:@selector(lowButtonAction:) forControlEvents:UIControlEventTouchUpInside];
_lowButton.selected = YES;
}
return _lowButton;
}
- (UIButton *)middleButton {
if (!_middleButton) {
_middleButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_middleButton setImage:[UIImage imageNamed:@"room_treasure_fairy_my_middle_title_normal"] forState:UIControlStateNormal];
[_middleButton setImage:[UIImage imageNamed:@"room_treasure_fairy_my_middle_title_select"] forState:UIControlStateSelected];
[_middleButton addTarget:self action:@selector(middleButtonAction:) forControlEvents:UIControlEventTouchUpInside];
_middleButton.selected = NO;
}
return _middleButton;
}
- (UIButton *)highButton {
if (!_highButton) {
_highButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_highButton setImage:[UIImage imageNamed:@"room_treasure_fairy_my_high_title_normal"] forState:UIControlStateNormal];
[_highButton setImage:[UIImage imageNamed:@"room_treasure_fairy_my_high_title_select"] forState:UIControlStateSelected];
[_highButton addTarget:self action:@selector(highButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _highButton;
}
- (XPTreasureFairyBallContentView *)lowView {
if (!_lowView) {
_lowView = [[XPTreasureFairyBallContentView alloc] init];
_lowView.delegate = self;
}
return _lowView;
}
- (XPTreasureFairyBallContentView *)middleView {
if (!_middleView) {
_middleView = [[XPTreasureFairyBallContentView alloc] init];
_middleView.hidden= YES;
_middleView.delegate = self;
}
return _middleView;
}
- (XPTreasureFairyBallContentView *)highView {
if (!_highView) {
_highView = [[XPTreasureFairyBallContentView alloc] init];
_highView.hidden = YES;
_highView.delegate = self;
}
return _highView;
}
@end

View File

@@ -0,0 +1,18 @@
//
// XPTreasureFairyPoolRecordView.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/21.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPTreasureFairyPoolRecordView : UIView
@property (nonatomic,strong) NSArray *lowList;
@property (nonatomic,strong) NSArray *middleList;
@property (nonatomic,strong) NSArray *highList;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,179 @@
//
// XPTreasureFairyPoolRecordView.m
// xplan-ios
//
// Created by on 2023/2/21.
//
#import "XPTreasureFairyPoolRecordView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "TTPopup.h"
///View
#import "XPTreasureFairyPrizePoolView.h"
#import "XPTreasureFairyPrizeRecordView.h"
@interface XPTreasureFairyPoolRecordView ()
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,strong) UIView *bottomView;
///
@property (nonatomic,strong) UIButton *prizePoolButton;
///
@property (nonatomic,strong) UIButton *recordButton;
///
@property (nonatomic,strong) XPTreasureFairyPrizeRecordView *recordView;
///
@property (nonatomic,strong) XPTreasureFairyPrizePoolView *poolView;
@end
@implementation XPTreasureFairyPoolRecordView
- (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.bottomView];
[self.backImageView addSubview:self.prizePoolButton];
[self.backImageView addSubview:self.recordButton];
[self.backImageView addSubview:self.poolView];
[self.backImageView addSubview:self.recordView];
}
- (void)initSubViewConstraints {
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.centerX.mas_equalTo(self);
make.size.mas_equalTo(CGSizeMake(321, 386));
}];
[self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.mas_equalTo(self);
make.top.mas_equalTo(self.backImageView.mas_bottom);
}];
[self.prizePoolButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(120, 39));
make.right.mas_equalTo(self.backImageView.mas_centerX).offset(-18);
make.top.mas_equalTo(self.backImageView);
}];
[self.recordButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(120, 39));
make.left.mas_equalTo(self.backImageView.mas_centerX).offset(18);
make.top.mas_equalTo(self.backImageView);
}];
[self.recordView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.backImageView).inset(5);
make.bottom.mas_equalTo(self.backImageView).offset(-30);
make.top.mas_equalTo(self.prizePoolButton.mas_bottom).offset(24);
}];
[self.poolView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.backImageView).inset(5);
make.bottom.mas_equalTo(self.backImageView).offset(-30);
make.top.mas_equalTo(self.prizePoolButton.mas_bottom).offset(24);
}];
}
#pragma mark - Event Response
- (void)prizePoolButtonAction:(UIButton *)sender {
self.recordButton.selected = NO;
self.prizePoolButton.selected = YES;
self.recordView.hidden = YES;
self.poolView.hidden = NO;
}
- (void)recordButtonAction:(UIButton *)sender {
self.recordButton.selected = YES;
self.prizePoolButton.selected = NO;
self.recordView.hidden = NO;
self.poolView.hidden = YES;
}
- (void)dismissView {
[TTPopup dismiss];
}
#pragma mark - Getters And Setters
- (void)setLowList:(NSArray *)lowList {
self.poolView.lowList = lowList;
}
- (void)setMiddleList:(NSArray *)middleList {
self.poolView.middleList = middleList;
}
- (void)setHighList:(NSArray *)highList {
self.poolView.highList = highList;
}
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.image = [UIImage imageNamed:@"room_treasure_fairy_pool_bg"];
}
return _backImageView;
}
- (UIView *)bottomView {
if (!_bottomView) {
_bottomView = [[UIView alloc] init];
_bottomView.backgroundColor = [UIColor clearColor];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissView)];
[_bottomView addGestureRecognizer:tap];
}
return _bottomView;
}
- (UIButton *)prizePoolButton {
if (!_prizePoolButton) {
_prizePoolButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_prizePoolButton setImage:[UIImage imageNamed:@"room_treasure_fairy_pool_normal"] forState:UIControlStateNormal];
[_prizePoolButton setImage:[UIImage imageNamed:@"room_treasure_fairy_pool_select"] forState:UIControlStateSelected];
[_prizePoolButton addTarget:self action:@selector(prizePoolButtonAction:) forControlEvents:UIControlEventTouchUpInside];
_prizePoolButton.selected = YES;
}
return _prizePoolButton;
}
- (UIButton *)recordButton {
if (!_recordButton) {
_recordButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_recordButton setImage:[UIImage imageNamed:@"room_treasure_fairy_record_normal"] forState:UIControlStateNormal];
[_recordButton setImage:[UIImage imageNamed:@"room_treasure_fairy_record_select"] forState:UIControlStateSelected];
[_recordButton addTarget:self action:@selector(recordButtonAction:) forControlEvents:UIControlEventTouchUpInside];
_recordButton.selected = NO;
}
return _recordButton;
}
- (XPTreasureFairyPrizePoolView *)poolView {
if(!_poolView) {
_poolView = [[XPTreasureFairyPrizePoolView alloc] init];
}
return _poolView;
}
- (XPTreasureFairyPrizeRecordView *)recordView {
if (!_recordView) {
_recordView = [[XPTreasureFairyPrizeRecordView alloc] init];
_recordView.hidden = YES;
}
return _recordView;
}
@end

View File

@@ -0,0 +1,18 @@
//
// XPTreasureFairyPrizePoolView.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/21.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPTreasureFairyPrizePoolView : UIView
@property (nonatomic,strong) NSArray *lowList;
@property (nonatomic,strong) NSArray *middleList;
@property (nonatomic,strong) NSArray *highList;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,171 @@
//
// XPTreasureFairyPrizePoolView.m
// xplan-ios
//
// Created by on 2023/2/21.
//
#import "XPTreasureFairyPrizePoolView.h"
///Third
#import <Masonry/Masonry.h>
#import <JXCategoryView/JXCategoryView.h>
#import <JXCategoryView/JXCategoryIndicatorBackgroundView.h>
#import <JXCategoryView/JXCategoryListContainerView.h>
///Tool
#import "UIImage+Utils.h"
#import "Api+TreasureFairy.h"
///Model
#import "TreasureFairyInfoModel.h"
///View
#import "XPTreasureFairyPrizeSubView.h"
#import "XPTreasureFairyStoreView.h"
@interface XPTreasureFairyPrizePoolView ()<JXCategoryViewDelegate, JXCategoryListContainerViewDelegate>
///
@property (nonatomic, strong) NSArray<NSString *> *titles;
///
@property (nonatomic, strong) JXCategoryTitleView *titleView;
///lineView
@property (nonatomic, strong) JXCategoryListContainerView *containerView;
///
@property (nonatomic,strong) XPTreasureFairyPrizeSubView *normalView;
///
@property (nonatomic,strong) XPTreasureFairyPrizeSubView *middleView;
///
@property (nonatomic,strong) XPTreasureFairyPrizeSubView *highView;
@end
@implementation XPTreasureFairyPrizePoolView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
self.backgroundColor = [UIColor clearColor];
[self addSubview:self.titleView];
[self addSubview:self.containerView];
}
- (void)initSubViewConstraints {
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self);
make.width.mas_equalTo(60 * 3 + 24 * 2);
make.height.mas_equalTo(30);
make.top.mas_equalTo(self).offset(0);
}];
[self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.mas_equalTo(self);
make.top.mas_equalTo(self.titleView.mas_bottom).offset(13);
}];
}
#pragma mark - JXCategoryViewDelegate
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
return self.titles.count;
}
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
if (index == 0) {
return self.normalView;
} else if (index == 1) {
return self.middleView;
} else {
return self.highView;
}
}
#pragma mark - Event Response
#pragma mark - Getters And Setters
- (void)setLowList:(NSArray *)lowList {
self.normalView.datasource = lowList;
}
- (void)setMiddleList:(NSArray *)middleList {
self.middleView.datasource = middleList;
}
- (void)setHighList:(NSArray *)highList {
self.highView.datasource = highList;
}
- (JXCategoryTitleView *)titleView {
if (!_titleView) {
_titleView = [[JXCategoryTitleView alloc] init];
_titleView.delegate = self;
_titleView.titles = self.titles;
_titleView.backgroundColor = [UIColor clearColor];
_titleView.titleColor = [UIColor whiteColor];
_titleView.titleSelectedColor = [UIColor whiteColor];
_titleView.titleFont = [UIFont systemFontOfSize:15];
_titleView.titleSelectedFont = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
_titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter;
_titleView.contentScrollViewClickTransitionAnimationEnabled = NO;
_titleView.defaultSelectedIndex = 0;
_titleView.cellSpacing = 24;
_titleView.cellWidthIncrement = 0;
_titleView.contentEdgeInsetLeft = 0;
_titleView.contentEdgeInsetRight = 0;
_titleView.cellWidth = 60;
_titleView.listContainer = self.containerView;
JXCategoryIndicatorImageView *lineView = [[JXCategoryIndicatorImageView alloc] init];
lineView.indicatorImageViewSize = CGSizeMake(60, 4);
lineView.verticalMargin = 2;
lineView.indicatorCornerRadius = 2;
lineView.indicatorImageView.image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x69FFEB), UIColorFromRGB(0xEAFF89)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(60, 4)];
lineView.indicatorImageView.layer.masksToBounds = YES;
lineView.indicatorImageView.layer.cornerRadius = 2;
_titleView.indicators = @[lineView];
}
return _titleView;
}
- (JXCategoryListContainerView *)containerView {
if (!_containerView) {
_containerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
_containerView.defaultSelectedIndex = 0;
_containerView.scrollView.tag = 1009;
}
return _containerView;
}
- (NSArray<NSString *> *)titles {
if (!_titles) {
_titles = @[YMLocalizedString(@"XPTreasureFairyPrizePoolView0"), YMLocalizedString(@"XPTreasureFairyPrizePoolView1"), YMLocalizedString(@"XPTreasureFairyPrizePoolView2")];
}
return _titles;
}
- (XPTreasureFairyPrizeSubView *)normalView {
if (!_normalView) {
_normalView = [[XPTreasureFairyPrizeSubView alloc] init];
}
return _normalView;
}
- (XPTreasureFairyPrizeSubView *)middleView {
if (!_middleView) {
_middleView = [[XPTreasureFairyPrizeSubView alloc] init];
}
return _middleView;
}
- (XPTreasureFairyPrizeSubView *)highView {
if (!_highView) {
_highView = [[XPTreasureFairyPrizeSubView alloc] init];
}
return _highView;
}
@end

View File

@@ -0,0 +1,16 @@
//
// XPTreasureFairyPrizeRecordView.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/21.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPTreasureFairyPrizeRecordView : UIView
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,177 @@
//
// XPTreasureFairyPrizeRecordView.m
// xplan-ios
//
// Created by on 2023/2/21.
//
#import "XPTreasureFairyPrizeRecordView.h"
///Third
#import <Masonry/Masonry.h>
#import <MJRefresh/MJRefresh.h>
///Tool
#import "Api+TreasureFairy.h"
#import "NSArray+Safe.h"
///Model
#import "TreasureFairyInfoModel.h"
///View
#import "XPTreasureFairyPrizeRecordCell.h"
@interface XPTreasureFairyPrizeRecordView ()<UITableViewDelegate, UITableViewDataSource>
///
@property (nonatomic,strong) UITableView *tableView;
///
@property (nonatomic,strong) NSMutableArray *datasource;
///
@property (nonatomic,strong) XPTreasureFairyPrizeRecordCell *headView;
///
@property (nonatomic,strong) UILabel *emptyView;
///
@property (nonatomic,strong) UILabel *XPTreasureFairyPrizePoolView;
@property (nonatomic,assign) NSInteger page;
@end
@implementation XPTreasureFairyPrizeRecordView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initHeaderAndFooterRrfresh];
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Refresh
- (void)initHeaderAndFooterRrfresh {
MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)];
header.stateLabel.font = [UIFont systemFontOfSize:10.0];
header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:10.0];
header.stateLabel.textColor = [DJDKMIMOMColor secondTextColor];
header.lastUpdatedTimeLabel.textColor = [DJDKMIMOMColor secondTextColor];
self.tableView.mj_header = header;
MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)];
footer.stateLabel.textColor = [DJDKMIMOMColor secondTextColor];
footer.stateLabel.font = [UIFont systemFontOfSize:10.0];
self.tableView.mj_footer = footer;
[self headerRefresh];
}
- (void)headerRefresh {
self.page = 1;
[Api treasureFairyForestDrawRecord:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
[self.tableView.mj_header endRefreshing];
if (code == 200) {
[self.datasource removeAllObjects];
NSArray * array = [TreasureFairyInfoModel modelsWithArray:data.data];
[self.datasource addObjectsFromArray:array];
self.emptyView.hidden = self.datasource.count > 0;
[self.tableView reloadData];
} else {
[XNDJTDDLoadingTool showErrorWithMessage:msg];
}
} page:@"1" pageSize:@"20"];
}
- (void)footerRefresh {
self.page++;
[Api treasureFairyForestDrawRecord:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
[self.tableView.mj_footer endRefreshing];
if (code == 200) {
NSArray * array = [TreasureFairyInfoModel modelsWithArray:data.data];
if (array.count > 0) {
[self.datasource addObjectsFromArray:array];
}
self.emptyView.hidden = self.datasource.count > 0;
[self.tableView reloadData];
} else {
[XNDJTDDLoadingTool showErrorWithMessage:msg];
}
} page:[NSString stringWithFormat:@"%ld", self.page] pageSize:@"20"];
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.tableView];
self.tableView.tableHeaderView = self.headView;
[self.tableView addSubview:self.emptyView];
}
- (void)initSubViewConstraints {
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.mas_equalTo(self);
make.bottom.mas_equalTo(self).offset(-20);
}];
[self.emptyView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self.tableView);
}];
}
#pragma mark - UITableViewDelegate And UITableViewDataSource
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 44;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.datasource.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
XPTreasureFairyPrizeRecordCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPTreasureFairyPrizeRecordCell class])];
if (cell == nil) {
cell = [[XPTreasureFairyPrizeRecordCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPTreasureFairyPrizeRecordCell class])];
}
TreasureFairyInfoModel * info = [self.datasource safeObjectAtIndex1:indexPath.row];
cell.recordInfo = info;
return cell;
}
#pragma mark - Getters And Setters
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.tableFooterView = [UIView new];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.backgroundColor = [UIColor clearColor];
if (@available(iOS 11.0, *)) {
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
[_tableView registerClass:[XPTreasureFairyPrizeRecordCell class] forCellReuseIdentifier:NSStringFromClass([XPTreasureFairyPrizeRecordCell class])];
}
return _tableView;
}
- (XPTreasureFairyPrizeRecordCell *)headView {
if(!_headView) {
_headView = [[XPTreasureFairyPrizeRecordCell alloc] init];
_headView.timeLabel.text = YMLocalizedString(@"XPTreasureFairyPrizeRecordView0");
_headView.levelLabel.text = YMLocalizedString(@"XPTreasureFairyPrizeRecordView1");
_headView.prizeLabel.text = YMLocalizedString(@"XPTreasureFairyPrizeRecordView2");
_headView.timeLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium];
_headView.levelLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium];
_headView.prizeLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium];
_headView.frame = CGRectMake(0, 0, 360, 30);
}
return _headView;
}
- (NSMutableArray *)datasource {
if(!_datasource) {
_datasource = [NSMutableArray array];
}
return _datasource;
}
-(UILabel *)emptyView{
if (!_emptyView){
_emptyView = [UILabel labelInitWithText:YMLocalizedString(@"XPTreasureFairyViewController7") font:[UIFont systemFontOfSize:15 weight:UIFontWeightMedium] textColor:[UIColor whiteColor]];
_emptyView.hidden = YES;
}
return _emptyView;
}
@end

View File

@@ -0,0 +1,17 @@
//
// XPTreasureFairyPrizeSubView.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/21.
//
#import <UIKit/UIKit.h>
#import <JXCategoryView/JXCategoryListContainerView.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPTreasureFairyPrizeSubView : UIView<JXCategoryListContentViewDelegate>
///数据源
@property (nonatomic,strong) NSArray *datasource;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,93 @@
//
// XPTreasureFairyPrizeSubView.m
// xplan-ios
//
// Created by on 2023/2/21.
//
#import "XPTreasureFairyPrizeSubView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "NSArray+Safe.h"
///View
#import "XPTreasureFairyPrizePoolCell.h"
@interface XPTreasureFairyPrizeSubView ()<UICollectionViewDelegate, UICollectionViewDataSource>
///
@property (nonatomic,strong) UICollectionView *collectionView;
///
@property (nonatomic,strong) UILabel *emptyView;
@end
@implementation XPTreasureFairyPrizeSubView
- (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.collectionView];
[self.collectionView addSubview:self.emptyView];
}
-(void)setDatasource:(NSArray *)datasource{
_datasource = datasource;
_emptyView.hidden = _datasource.count > 0;
}
- (void)initSubViewConstraints {
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
[self.emptyView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self.collectionView);
}];
}
#pragma mark - UICollectionViewDelegate, UICollectionViewDataSource>
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.datasource.count;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
XPTreasureFairyPrizePoolCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPTreasureFairyPrizePoolCell class]) forIndexPath:indexPath];
TreasureFairyInfoModel * info = [self.datasource safeObjectAtIndex1:indexPath.row];
cell.info = info;
return cell;
}
#pragma mark - JXCategoryListContentViewDelegate
- (UIView *)listView {
return self;
}
#pragma mark - Getters And Setters
- (UICollectionView *)collectionView{
if (!_collectionView) {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.itemSize = CGSizeMake(90, 110);
layout.minimumLineSpacing = 10;
layout.minimumInteritemSpacing = 10;
layout.sectionInset = UIEdgeInsetsMake(0, 10, 0, 10);
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
_collectionView.dataSource = self;
_collectionView.delegate = self;
_collectionView.backgroundColor = [UIColor clearColor];
[_collectionView registerClass:[XPTreasureFairyPrizePoolCell class] forCellWithReuseIdentifier:NSStringFromClass([XPTreasureFairyPrizePoolCell class])];
}
return _collectionView;
}
-(UILabel *)emptyView{
if (!_emptyView){
_emptyView = [UILabel labelInitWithText:YMLocalizedString(@"XPTreasureFairyViewController7") font:[UIFont systemFontOfSize:15 weight:UIFontWeightMedium] textColor:[UIColor whiteColor]];
_emptyView.hidden = YES;
}
return _emptyView;
}
@end

View File

@@ -0,0 +1,16 @@
//
// XPTreasureFairySendRecordView.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/23.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPTreasureFairySendRecordView : UIView
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,224 @@
//
// XPTreasureFairySendRecordView.m
// xplan-ios
//
// Created by on 2023/2/23.
//
#import "XPTreasureFairySendRecordView.h"
///Third
#import <Masonry/Masonry.h>
#import <MJRefresh/MJRefresh.h>
///Tool
#import "Api+TreasureFairy.h"
#import "NSArray+Safe.h"
#import "TTPopup.h"
///Model
#import "TreasureFairySendRecordModel.h"
///View
#import "XPTreasureFairySendRecordCell.h"
@interface XPTreasureFairySendRecordView ()<UITableViewDelegate, UITableViewDataSource>
///View
@property (nonatomic,strong) UIView *bottomView;
///
@property (nonatomic,strong) UILabel *titleLabel;
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,strong) UITableView *tableView;
@property (nonatomic,strong) NSMutableArray *datasource;
@property (nonatomic,assign) NSInteger page;
///
@property (nonatomic,strong) UILabel *emptyView;
@end
@implementation XPTreasureFairySendRecordView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initHeaderAndFooterRrfresh];
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Refresh
- (void)initHeaderAndFooterRrfresh {
MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)];
header.stateLabel.font = [UIFont systemFontOfSize:10.0];
header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:10.0];
header.stateLabel.textColor = [DJDKMIMOMColor secondTextColor];
header.lastUpdatedTimeLabel.textColor = [DJDKMIMOMColor secondTextColor];
self.tableView.mj_header = header;
MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)];
footer.stateLabel.textColor = [DJDKMIMOMColor secondTextColor];
footer.stateLabel.font = [UIFont systemFontOfSize:10.0];
self.tableView.mj_footer = footer;
[self headerRefresh];
}
- (void)headerRefresh {
self.page = 1;
[Api treasureFailySendAndAskRecordList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
[self.tableView.mj_header endRefreshing];
if (code == 200) {
[self.datasource removeAllObjects];
NSArray * array = [TreasureFairySendRecordModel modelsWithArray:data.data];
[self.datasource addObjectsFromArray:array];
self.emptyView.hidden = self.datasource.count > 0;
[self.tableView reloadData];
} else {
[XNDJTDDLoadingTool showErrorWithMessage:msg];
}
} page:@"1" pageSize:@"20"];
}
- (void)footerRefresh {
self.page++;
[Api treasureFailySendAndAskRecordList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
[self.tableView.mj_footer endRefreshing];
if (code == 200) {
NSArray * array = [TreasureFairySendRecordModel modelsWithArray:data.data];
if (array.count > 0) {
[self.datasource addObjectsFromArray:array];
}
self.emptyView.hidden = self.datasource.count > 0;
[self.tableView reloadData];
} else {
[XNDJTDDLoadingTool showErrorWithMessage:msg];
}
} page:[NSString stringWithFormat:@"%ld", self.page] pageSize:@"20"];
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.backImageView];
[self addSubview:self.bottomView];
[self.backImageView addSubview:self.titleLabel];
[self.backImageView addSubview:self.tableView];
[self.tableView addSubview:self.emptyView];
}
- (void)initSubViewConstraints {
CGFloat kscale = 388.0 / 318.0;
self.frame = CGRectMake(0, 0, KScreenWidth, KScreenWidth * kscale + 134 * kScreenScale);
[self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.mas_equalTo(self);
make.top.mas_equalTo(self.backImageView.mas_bottom);
}];
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.top.mas_equalTo(self);
make.height.mas_equalTo(388);
make.width.mas_equalTo(318);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.backImageView).offset(52);
}];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.backImageView).inset(3);
make.top.mas_equalTo(self.backImageView).offset(82);
make.bottom.mas_equalTo(self.backImageView).offset(-42);
}];
[self.emptyView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self.tableView);
}];
}
#pragma mark - UITableViewDelegate And UITableViewDataSource
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 86;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.datasource.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
XPTreasureFairySendRecordCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPTreasureFairySendRecordCell class])];
if (cell == nil) {
cell = [[XPTreasureFairySendRecordCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPTreasureFairySendRecordCell class])];
}
TreasureFairySendRecordModel * record = [self.datasource safeObjectAtIndex1:indexPath.row];
cell.recordInfo = record;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
#pragma mark - Event Response
- (void)dismissView {
[TTPopup dismiss];
}
#pragma mark - Getters And Setters
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.tableFooterView = [UIView new];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.backgroundColor = [UIColor clearColor];
if (@available(iOS 11.0, *)) {
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
[_tableView registerClass:[XPTreasureFairySendRecordCell class] forCellReuseIdentifier:NSStringFromClass([XPTreasureFairySendRecordCell class])];
}
return _tableView;
}
- (UIView *)bottomView {
if (!_bottomView) {
_bottomView = [[UIView alloc] init];
_bottomView.backgroundColor = [UIColor clearColor];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissView)];
[_bottomView addGestureRecognizer:tap];
}
return _bottomView;
}
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.image = [UIImage imageNamed:@"room_treasure_fairy_my_send_record_back"];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissView)];
[_backImageView addGestureRecognizer:tap];
}
return _backImageView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
_titleLabel.textColor = [UIColor whiteColor];
_titleLabel.text = YMLocalizedString(@"XPTreasureFairySendRecordView0");
_titleLabel.textAlignment = NSTextAlignmentCenter;
}
return _titleLabel;
}
- (NSMutableArray *)datasource {
if(!_datasource) {
_datasource = [NSMutableArray array];
}
return _datasource;
}
-(UILabel *)emptyView{
if (!_emptyView){
_emptyView = [UILabel labelInitWithText:YMLocalizedString(@"XPTreasureFairyViewController7") font:[UIFont systemFontOfSize:15 weight:UIFontWeightMedium] textColor:[UIColor whiteColor]];
_emptyView.hidden = YES;
}
return _emptyView;
}
@end

View File

@@ -0,0 +1,19 @@
//
// XPTreasureFairySendView.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/23.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class TreasureFairyBallModel;
@interface XPTreasureFairySendView : UIView
///是否是赠送
@property (nonatomic,assign) BOOL isSend;
///精灵球信息
@property (nonatomic,strong) TreasureFairyBallModel *ballInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,226 @@
//
// XPTreasureFairySendView.m
// xplan-ios
//
// Created by on 2023/2/23.
//
#import "XPTreasureFairySendView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "NetImageView.h"
#import "TTPopup.h"
#import "Api+TreasureFairy.h"
///Model
#import "TreasureFairyBallInfoModel.h"
@interface XPTreasureFairySendView ()
///
@property (nonatomic,strong) UIView *dismissView;
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,strong) UILabel *titleLabel;
///
@property (nonatomic,strong) NetImageView *ballView;
///
@property (nonatomic,strong) UIButton *cancleButton;
///
@property (nonatomic,strong) UIButton *sureButton;
@end
@implementation XPTreasureFairySendView
- (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.dismissView];
[self.backImageView addSubview:self.titleLabel];
[self.backImageView addSubview:self.ballView];
[self.backImageView addSubview:self.sureButton];
[self.backImageView addSubview:self.cancleButton];
}
- (void)initSubViewConstraints {
self.frame = CGRectMake(0, 0, KScreenWidth, 285 + 183);
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(281, 285));
make.centerX.mas_equalTo(self);
make.top.mas_equalTo(self);
}];
[self.dismissView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.mas_equalTo(self);
make.top.mas_equalTo(self.backImageView.mas_bottom);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.backImageView).inset(30);
make.top.mas_equalTo(self.backImageView).offset(45);
}];
[self.ballView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(90, 90));
make.centerX.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(19);
}];
[self.cancleButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(104, 32));
make.top.mas_equalTo(self.ballView.mas_bottom).offset(15);
make.right.mas_equalTo(self.backImageView.mas_centerX).offset(-12);
}];
[self.sureButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.centerY.mas_equalTo(self.cancleButton);
make.left.mas_equalTo(self.backImageView.mas_centerX).offset(12);
}];
}
#pragma mark - Event Response
- (void)cancleButtonAction:(UIButton *)sender {
[TTPopup dismiss];
}
- (void)sureButtonAction:(UIButton *)sender {
[TTPopup dismiss];
if (self.ballInfo.elfId > 0 && self.ballInfo.uid > 0) {
NSString * elfId = [NSString stringWithFormat:@"%ld", self.ballInfo.elfId];
NSString * uid = [NSString stringWithFormat:@"%ld", self.ballInfo.uid];
if (self.isSend) {
[Api treasureFairySendFairyBall:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
[XNDJTDDLoadingTool showSuccessWithMessage:YMLocalizedString(@"XPTreasureFairySendView0")];
} else {
[XNDJTDDLoadingTool showErrorWithMessage:msg];
}
} elfId:elfId targetUid:uid];
} else {
[Api treasureFairyAskForFairyBall:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
[XNDJTDDLoadingTool showSuccessWithMessage:YMLocalizedString(@"XPTreasureFairySendView1")];
} else {
[XNDJTDDLoadingTool showErrorWithMessage:msg];
}
} elfId:elfId targetUid:uid];
}
}
}
- (void)dismissRecognizer {
[TTPopup dismiss];
}
#pragma mark - Getters And Setters
- (void)setBallInfo:(TreasureFairyBallModel *)ballInfo {
_ballInfo = ballInfo;
if (_ballInfo) {
self.ballView.imageUrl = _ballInfo.elfPicUrl;
NSString * nick = _ballInfo.nick;
NSString * title;
if (self.isSend) {
title = [NSString stringWithFormat:YMLocalizedString(@"XPTreasureFairySendView2"), nick, _ballInfo.elfName];
} else {
title = [NSString stringWithFormat:YMLocalizedString(@"XPTreasureFairySendView3"), nick, _ballInfo.elfName];
}
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15], NSForegroundColorAttributeName:[UIColor whiteColor]}];
[attribute addAttribute:NSForegroundColorAttributeName value:[DJDKMIMOMColor colorWithHexString:@"#FEF8AA"] range:[title rangeOfString:nick]];
self.titleLabel.attributedText = attribute;
self.titleLabel.textAlignment = NSTextAlignmentCenter;
}
}
- (void)setIsSend:(BOOL)isSend {
_isSend = isSend;
if (_isSend) {
[self.sureButton setTitle:YMLocalizedString(@"XPTreasureFairySendView4") forState:UIControlStateNormal];
} else {
[self.sureButton setTitle:YMLocalizedString(@"XPTreasureFairySendView5") forState:UIControlStateNormal];
}
}
- (UIView *)dismissView {
if (!_dismissView) {
_dismissView = [[UIView alloc] init];
_dismissView.backgroundColor = [UIColor clearColor];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissRecognizer)];
[_dismissView addGestureRecognizer:tap];
}
return _dismissView;
}
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.image = [UIImage imageNamed:@"room_treasure_fairy_my_send_record_bg"];
}
return _backImageView;
}
- (NetImageView *)ballView {
if (!_ballView) {
NetImageConfig * config = [[NetImageConfig alloc]init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
_ballView = [[NetImageView alloc] initWithConfig:config];
_ballView.layer.masksToBounds = YES;
_ballView.layer.cornerRadius = 45;
_ballView.layer.borderColor = [DJDKMIMOMColor appMainColor].CGColor;
_ballView.layer.borderWidth = 0.5;
}
return _ballView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.numberOfLines = 0;
}
return _titleLabel;
}
- (UIButton *)cancleButton {
if (!_cancleButton) {
_cancleButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_cancleButton setTitle:YMLocalizedString(@"XPTreasureFairySendView6") forState:UIControlStateNormal];
[_cancleButton setTitleColor:[DJDKMIMOMColor colorWithHexString:@"#008573"] forState:UIControlStateNormal];
_cancleButton.titleLabel.font = [UIFont systemFontOfSize:13];
[_cancleButton setBackgroundImage:[UIImage imageNamed:@"room_treasure_fairy_store_result_close_bg"] forState:UIControlStateNormal];
_cancleButton.layer.masksToBounds = YES;
_cancleButton.layer.cornerRadius = 10;
[_cancleButton addTarget:self action:@selector(cancleButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _cancleButton;
}
- (UIButton *)sureButton {
if (!_sureButton) {
_sureButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_sureButton setTitleColor:[DJDKMIMOMColor colorWithHexString:@"#8A4801"] forState:UIControlStateNormal];
_sureButton.titleLabel.font = [UIFont systemFontOfSize:13];
[_sureButton setBackgroundImage:[UIImage imageNamed:@"room_treasure_fairy_sure_bg"] forState:UIControlStateNormal];
_sureButton.layer.masksToBounds = YES;
_sureButton.layer.cornerRadius = 10;
_sureButton.yn_acceptEventInterval = 1;
[_sureButton addTarget:self action:@selector(sureButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _sureButton;
}
@end

View File

@@ -0,0 +1,19 @@
//
// XPTreasureFairyShopingRecordSubView.h
// xplan-ios
//
// Created by 冯硕 on 2023/2/27.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPTreasureFairyShopingRecordSubView : UIView
///是否是召唤
@property (nonatomic,assign) BOOL isSummond;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,188 @@
//
// XPTreasureFairyShopingRecordSubView.m
// xplan-ios
//
// Created by on 2023/2/27.
//
#import "XPTreasureFairyShopingRecordSubView.h"
///Third
#import <Masonry/Masonry.h>
#import <MJRefresh/MJRefresh.h>
///Tool
#import "Api+TreasureFairy.h"
#import "NSArray+Safe.h"
///Model
#import "TreasureFairyConvertRecordModel.h"
///View
#import "XPTreasureFairyShopingRecordCell.h"
@interface XPTreasureFairyShopingRecordSubView ()<UITableViewDelegate, UITableViewDataSource>
///
@property (nonatomic,strong) UITableView *tableView;
///
@property (nonatomic,strong) NSMutableArray *datasource;
///
@property (nonatomic,strong) UILabel *emptyView;
///
@property (nonatomic,strong) XPTreasureFairyShopingRecordCell *headView;
@property (nonatomic,assign) NSInteger page;
@end
@implementation XPTreasureFairyShopingRecordSubView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initHeaderAndFooterRrfresh];
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Refresh
- (void)initHeaderAndFooterRrfresh {
MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)];
header.stateLabel.font = [UIFont systemFontOfSize:10.0];
header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:10.0];
header.stateLabel.textColor = [DJDKMIMOMColor secondTextColor];
header.lastUpdatedTimeLabel.textColor = [DJDKMIMOMColor secondTextColor];
self.tableView.mj_header = header;
MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)];
footer.stateLabel.textColor = [DJDKMIMOMColor secondTextColor];
footer.stateLabel.font = [UIFont systemFontOfSize:10.0];
self.tableView.mj_footer = footer;
}
- (void)headerRefresh {
self.page = 1;
[Api treasureFairyConvertRecord:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
[self.tableView.mj_header endRefreshing];
if (code == 200) {
[self.datasource removeAllObjects];
NSArray * array = [TreasureFairyConvertRecordModel modelsWithArray:data.data];
[self.datasource addObjectsFromArray:array];
self.emptyView.hidden = self.datasource.count > 0;
[self.tableView reloadData];
} else {
[XNDJTDDLoadingTool showErrorWithMessage:msg];
}
} convertType:self.isSummond? @"1":@"2" page:@"1" pageSize:@"20"];
}
- (void)footerRefresh {
self.page++;
[Api treasureFairyConvertRecord:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
[self.tableView.mj_footer endRefreshing];
if (code == 200) {
NSArray * array = [TreasureFairyConvertRecordModel modelsWithArray:data.data];
if (array.count > 0) {
[self.datasource addObjectsFromArray:array];
}
self.emptyView.hidden = self.datasource.count > 0;
[self.tableView reloadData];
} else {
[XNDJTDDLoadingTool showErrorWithMessage:msg];
}
} convertType:self.isSummond?@"1":@"2" page:[NSString stringWithFormat:@"%ld", self.page] pageSize:@"20"];
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.tableView];
self.tableView.tableHeaderView = self.headView;
[self.tableView addSubview:self.emptyView];
}
- (void)initSubViewConstraints {
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.mas_equalTo(self);
make.bottom.mas_equalTo(self).offset(-20);
}];
[self.emptyView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self.tableView);
}];
}
#pragma mark - UITableViewDelegate And UITableViewDataSource
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 44;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.datasource.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
XPTreasureFairyShopingRecordCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPTreasureFairyShopingRecordCell class])];
if (cell == nil) {
cell = [[XPTreasureFairyShopingRecordCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPTreasureFairyShopingRecordCell class])];
}
TreasureFairyConvertRecordModel *recordModel = [self.datasource safeObjectAtIndex1:indexPath.row];
cell.isSummon = self.isSummond;
cell.recordModel = recordModel;
return cell;
}
#pragma mark - Getters And Setters
- (void)setIsSummond:(BOOL)isSummond {
_isSummond = isSummond;
self.headView.isSummon = _isSummond;
if (_isSummond) {
_headView.timeLabel.text = YMLocalizedString(@"XPTreasureFairyShopingRecordSubView0");
_headView.levelLabel.text = YMLocalizedString(@"XPTreasureFairyShopingRecordSubView1");
_headView.prizeLabel.text = YMLocalizedString(@"XPTreasureFairyShopingRecordSubView2");
_headView.prizeLabel.textColor = UIColor.whiteColor;
} else {
_headView.timeLabel.text = YMLocalizedString(@"XPTreasureFairyShopingRecordSubView3");
_headView.prizeLabel.text = YMLocalizedString(@"XPTreasureFairyShopingRecordSubView4");
_headView.prizeLabel.textColor = UIColor.whiteColor;
}
[self headerRefresh];
}
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.tableFooterView = [UIView new];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.backgroundColor = [UIColor clearColor];
if (@available(iOS 11.0, *)) {
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
[_tableView registerClass:[XPTreasureFairyShopingRecordCell class] forCellReuseIdentifier:NSStringFromClass([XPTreasureFairyShopingRecordCell class])];
}
return _tableView;
}
- (XPTreasureFairyShopingRecordCell *)headView {
if(!_headView) {
_headView = [[XPTreasureFairyShopingRecordCell alloc] init];
_headView.timeLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium];
_headView.levelLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium];
_headView.prizeLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium];
_headView.frame = CGRectMake(0, 0, KScreenWidth, 30);
}
return _headView;
}
- (NSMutableArray *)datasource {
if(!_datasource) {
_datasource = [NSMutableArray array];
}
return _datasource;
}
-(UILabel *)emptyView{
if (!_emptyView){
_emptyView = [UILabel labelInitWithText:YMLocalizedString(@"XPTreasureFairyViewController7") font:[UIFont systemFontOfSize:15 weight:UIFontWeightMedium] textColor:[UIColor whiteColor]];
_emptyView.hidden = YES;
}
return _emptyView;
}
@end

Some files were not shown because too many files have changed in this diff Show More