跨房PK面板的UI

This commit is contained in:
fengshuo
2022-01-11 20:01:58 +08:00
committed by chenguilong
parent 93d6be3989
commit 0d6975c8c3
41 changed files with 1465 additions and 1 deletions

View File

@@ -517,6 +517,9 @@
E8CEA03D26EA3DE500644B44 /* LoginPasswordPresent.m in Sources */ = {isa = PBXBuildFile; fileRef = E8CEA03C26EA3DE500644B44 /* LoginPasswordPresent.m */; };
E8D4824A278D1F73003C1D08 /* XPAcrossRoomPKInviteView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8D48249278D1F73003C1D08 /* XPAcrossRoomPKInviteView.m */; };
E8D4824D278D2CE4003C1D08 /* XPAcrossRoomPKInviteResultView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8D4824C278D2CE4003C1D08 /* XPAcrossRoomPKInviteResultView.m */; };
E8D48250278D68BA003C1D08 /* XPAcrpssRoomPKPanelView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8D4824F278D68BA003C1D08 /* XPAcrpssRoomPKPanelView.m */; };
E8D48253278D8228003C1D08 /* AcrossRoomPKPanelModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8D48252278D8228003C1D08 /* AcrossRoomPKPanelModel.m */; };
E8D48256278D83AE003C1D08 /* XPAcrossRoomPKPanelUserView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8D48255278D83AE003C1D08 /* XPAcrossRoomPKPanelUserView.m */; };
E8DACCFB2766EDC60052092C /* MicroGiftValueView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DACCFA2766EDC60052092C /* MicroGiftValueView.m */; };
E8DACCFE27673F870052092C /* GiftValueInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DACCFD27673F870052092C /* GiftValueInfoModel.m */; };
E8DEC98B27637EA50078CB70 /* candyTree_open.svga in Resources */ = {isa = PBXBuildFile; fileRef = E8DEC98927637EA50078CB70 /* candyTree_open.svga */; };
@@ -1590,6 +1593,12 @@
E8D48249278D1F73003C1D08 /* XPAcrossRoomPKInviteView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPAcrossRoomPKInviteView.m; sourceTree = "<group>"; };
E8D4824B278D2CE4003C1D08 /* XPAcrossRoomPKInviteResultView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPAcrossRoomPKInviteResultView.h; sourceTree = "<group>"; };
E8D4824C278D2CE4003C1D08 /* XPAcrossRoomPKInviteResultView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPAcrossRoomPKInviteResultView.m; sourceTree = "<group>"; };
E8D4824E278D68BA003C1D08 /* XPAcrpssRoomPKPanelView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPAcrpssRoomPKPanelView.h; sourceTree = "<group>"; };
E8D4824F278D68BA003C1D08 /* XPAcrpssRoomPKPanelView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPAcrpssRoomPKPanelView.m; sourceTree = "<group>"; };
E8D48251278D8228003C1D08 /* AcrossRoomPKPanelModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AcrossRoomPKPanelModel.h; sourceTree = "<group>"; };
E8D48252278D8228003C1D08 /* AcrossRoomPKPanelModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AcrossRoomPKPanelModel.m; sourceTree = "<group>"; };
E8D48254278D83AE003C1D08 /* XPAcrossRoomPKPanelUserView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPAcrossRoomPKPanelUserView.h; sourceTree = "<group>"; };
E8D48255278D83AE003C1D08 /* XPAcrossRoomPKPanelUserView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPAcrossRoomPKPanelUserView.m; sourceTree = "<group>"; };
E8DACCF92766EDC60052092C /* MicroGiftValueView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MicroGiftValueView.h; sourceTree = "<group>"; };
E8DACCFA2766EDC60052092C /* MicroGiftValueView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MicroGiftValueView.m; sourceTree = "<group>"; };
E8DACCFC27673F870052092C /* GiftValueInfoModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiftValueInfoModel.h; sourceTree = "<group>"; };
@@ -3731,6 +3740,8 @@
children = (
E880B3A7278BD82300A83B0D /* AcrossRoomPKInfoModel.h */,
E880B3A8278BD82300A83B0D /* AcrossRoomPKInfoModel.m */,
E8D48251278D8228003C1D08 /* AcrossRoomPKPanelModel.h */,
E8D48252278D8228003C1D08 /* AcrossRoomPKPanelModel.m */,
);
path = Model;
sourceTree = "<group>";
@@ -3755,6 +3766,10 @@
E8D48249278D1F73003C1D08 /* XPAcrossRoomPKInviteView.m */,
E8D4824B278D2CE4003C1D08 /* XPAcrossRoomPKInviteResultView.h */,
E8D4824C278D2CE4003C1D08 /* XPAcrossRoomPKInviteResultView.m */,
E8D4824E278D68BA003C1D08 /* XPAcrpssRoomPKPanelView.h */,
E8D4824F278D68BA003C1D08 /* XPAcrpssRoomPKPanelView.m */,
E8D48254278D83AE003C1D08 /* XPAcrossRoomPKPanelUserView.h */,
E8D48255278D83AE003C1D08 /* XPAcrossRoomPKPanelUserView.m */,
);
path = SubViews;
sourceTree = "<group>";
@@ -4917,6 +4932,7 @@
E824543A26F5880E00BE8163 /* XPLoginVerifBindPhoneProtocol.h in Sources */,
E824543826F5820A00BE8163 /* XPLoginVerifBindPhonePresenter.m in Sources */,
E8B846BF26FD827900A777FE /* XPMineUserInfoAlbumViewController.m in Sources */,
E8D48253278D8228003C1D08 /* AcrossRoomPKPanelModel.m in Sources */,
E824545C26F5EEBA00BE8163 /* XPMineVerifIdentityPresenter.m in Sources */,
9B92A3562798096000AD168F /* XPSkillCardPresenter.m in Sources */,
E8A1E44E2761F98600B294CA /* XPCandyTreeViewController.m in Sources */,
@@ -5128,6 +5144,7 @@
9BCF58532798FDA1008401A4 /* XPSkillCardModel.m in Sources */,
18E7B1B726E8B2D10064BC9B /* Api+Main.m in Sources */,
E8B846D326FDDBE600A777FE /* XPMineRechargeTableViewCell.m in Sources */,
E8D48256278D83AE003C1D08 /* XPAcrossRoomPKPanelUserView.m in Sources */,
E824546126F5F4E400BE8163 /* XPMineResetPayPwdViewController.m in Sources */,
E81D58822720082A003063FE /* MicroWaveView.m in Sources */,
E8B825C226EA00DF009E8E9F /* LoginVerifCodePresent.m in Sources */,
@@ -5176,6 +5193,7 @@
E82D5C70276AE60000858D6D /* HeadwearModel.m in Sources */,
E8A03DEC276301EF0098D9EA /* XPCandyTreeRankView.m in Sources */,
E880B3A1278BD60C00A83B0D /* XPAcrossRoomPKSelectRoomView.m in Sources */,
E8D48250278D68BA003C1D08 /* XPAcrpssRoomPKPanelView.m in Sources */,
18F404C3276098F100A6C548 /* Api+Message.m in Sources */,
E8C6FFED27550CC2004DC9F0 /* HomeSearchResultModel.m in Sources */,
9BB549592782E6A30090CD26 /* XPNobleCenterPresenter.m in Sources */,

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_across_pk_panel_bg@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_across_pk_panel_bg@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_across_pk_panel_charm_avatar@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_across_pk_panel_charm_avatar@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_across_pk_panel_charm_bg@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_across_pk_panel_charm_bg@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1015 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_across_pk_panel_charm_head@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_across_pk_panel_charm_head@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_across_pk_panel_contribute_avatar@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_across_pk_panel_contribute_avatar@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_across_pk_panel_contribute_bg@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_across_pk_panel_contribute_bg@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_across_pk_panel_contribute_head@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_across_pk_panel_contribute_head@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_across_pk_panel_fold@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_across_pk_panel_fold@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 504 B

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_across_pk_panel_help@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_across_pk_panel_help@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 547 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_across_pk_panel_rule_bg@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_across_pk_panel_rule_bg@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@@ -130,6 +130,12 @@ NS_ASSUME_NONNULL_BEGIN
roomUid:(NSString *)roomUid
roundId:(NSString *)roundId
isAccept:(NSString *)isAccept;
/// 获取跨房PK详情
/// @param completion 完成
/// @param roomUid 房主的ui
+ (void)getAcrossRoomPKDetail:(HttpRequestHelperCompletion)completion
roomUid:(NSString *)roomUid;
@end
NS_ASSUME_NONNULL_END

View File

@@ -144,4 +144,11 @@
[self makeRequest:@"crossroompkround/replyChallenge" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, roomUid, roundId, isAccept, nil];
}
/// PK
/// @param completion
/// @param roomUid ui
+ (void)getAcrossRoomPKDetail:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid {
[self makeRequest:@"crossroompkround/getCrossPkData" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, roomUid, nil];
}
@end

View File

@@ -0,0 +1,67 @@
//
// AcrossRoomPKPanelModel.h
// xplan-ios
//
// Created by 冯硕 on 2022/1/11.
//
#import <Foundation/Foundation.h>
#import "XPEnum.h"
NS_ASSUME_NONNULL_BEGIN
@class AcrossRoomPkRankModel;
@interface AcrossRoomPKPanelModel : NSObject
///当前时间
@property (nonatomic, assign) long now;
///对方流水
@property (nonatomic, assign) long long aAmount;
///对方头像
@property (nonatomic, copy) NSString *aAvatar;
/// 所有流水
@property (nonatomic, assign) long long allAmount;
///对方进度条比例
@property (nonatomic, assign) float aPercent;
///对方魅力榜
@property (nonatomic, strong) NSArray<AcrossRoomPkRankModel *> *arRank;
///对方贡献榜
@property (nonatomic, strong) NSArray<AcrossRoomPkRankModel *> *asRank;
///对方标题
@property (nonatomic, copy) NSString *aTitle;
///对方UID
@property (nonatomic, copy) NSString *aUid;
///我方流水
@property (nonatomic, assign) long long cAmount;
///我方头像
@property (nonatomic, copy) NSString *cAvatar;
///我方进度条比例
@property (nonatomic, assign) float cPercent;
///我方魅力榜
@property (nonatomic, strong) NSArray<AcrossRoomPkRankModel *> *crRank;
///我方贡献榜
@property (nonatomic, strong) NSArray<AcrossRoomPkRankModel *> *csRank;
///我方标题
@property (nonatomic, copy) NSString *cTitle;
///我方UID
@property (nonatomic, copy) NSString * cUid;
///结束时间戳
@property (nonatomic, assign) long long endTime;
/// 赢家uid
@property (nonatomic, copy) NSString * winUid;
///是否异常结束
@property (nonatomic, assign) BOOL isForce;
@end
@interface AcrossRoomPkRankModel : NSObject
///金币
@property (nonatomic, copy) NSString *amount;
///性别
@property (nonatomic, assign) GenderType gender;
///昵称
@property (nonatomic, copy) NSString *nick;
///头像
@property (nonatomic, copy) NSString *avatar;
///Uid
@property (nonatomic, copy) NSString * uid;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,29 @@
//
// AcrossRoomPKPanelModel.m
// xplan-ios
//
// Created by on 2022/1/11.
//
#import "AcrossRoomPKPanelModel.h"
@implementation AcrossRoomPKPanelModel
///
///
+ (NSDictionary *)objectClassInArray {
return @{@"arRank" : [AcrossRoomPkRankModel class],
@"asRank" : [AcrossRoomPkRankModel class],
@"crRank" : [AcrossRoomPkRankModel class],
@"csRank" : [AcrossRoomPkRankModel class]
};
}
@end
@implementation AcrossRoomPkRankModel
@end

View File

@@ -0,0 +1,30 @@
//
// XPAcrossRoomPKPanelUserView.h
// xplan-ios
//
// Created by 冯硕 on 2022/1/11.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class AcrossRoomPkRankModel;
typedef NS_ENUM(NSInteger, AcrossRoomPKPanelUserType) {
///红队贡献
AcrossRoomPKPanelUserType_Red_Contribute = 1,
///红队魅力榜
AcrossRoomPKPanelUserType_Red_Charm,
///蓝队魅力
AcrossRoomPKPanelUserType_Blue_Contribute,
///蓝队贡献
AcrossRoomPKPanelUserType_Blue_Charm,
};
@interface XPAcrossRoomPKPanelUserView : UIView
///类型
@property (nonatomic,assign) AcrossRoomPKPanelUserType type;
@property (nonatomic,strong) AcrossRoomPkRankModel * panelInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,148 @@
//
// XPAcrossRoomPKPanelUserView.m
// xplan-ios
//
// Created by on 2022/1/11.
//
#import "XPAcrossRoomPKPanelUserView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "NetImageView.h"
#import "ThemeColor.h"
#import "UIImage+Utils.h"
///Model
#import "AcrossRoomPKPanelModel.h"
@interface XPAcrossRoomPKPanelUserView ()
///
@property (nonatomic, strong) UIImageView *headwearImageView;
///
@property (nonatomic, strong) NetImageView *avatarImageView;
///
@property (nonatomic,strong) UIButton *coinButton;
@end
@implementation XPAcrossRoomPKPanelUserView
#pragma mark - Life Style
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.headwearImageView];
[self addSubview:self.avatarImageView];
[self addSubview:self.coinButton];
}
- (void)initSubViewConstraints {
[self mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(32);
make.height.mas_equalTo(38);
}];
[self.headwearImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.mas_equalTo(self);
make.height.mas_equalTo(38);
}];
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.mas_equalTo(self);
make.height.mas_equalTo(self.avatarImageView.mas_width);
}];
[self.coinButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(32);
make.height.mas_equalTo(10);
make.bottom.centerX.mas_equalTo(self);
}];
}
#pragma mark - getters and setters
- (void)setType:(AcrossRoomPKPanelUserType)type {
_type = type;
NSString * headwearName;
NSString * avatarPlaceName;
UIColor * coinColorStart;
UIColor * coinColorEnd;
switch (type) {
case AcrossRoomPKPanelUserType_Red_Contribute:
case AcrossRoomPKPanelUserType_Blue_Contribute:
headwearName = @"room_across_pk_panel_contribute_head";
coinColorStart = UIColorFromRGB(0xFF9813);
coinColorEnd = UIColorFromRGB(0xFFB22B);
avatarPlaceName = @"room_across_pk_panel_contribute_avatar";
break;
case AcrossRoomPKPanelUserType_Red_Charm:
case AcrossRoomPKPanelUserType_Blue_Charm:
headwearName = @"room_across_pk_panel_charm_head";
coinColorStart = UIColorFromRGB(0xFF5FC1);
coinColorEnd = UIColorFromRGB(0xFA81FF);
avatarPlaceName = @"room_across_pk_panel_charm_avatar";
break;
default:
break;
}
self.headwearImageView.image = [UIImage imageNamed:headwearName];
self.avatarImageView.image = [UIImage imageNamed:avatarPlaceName];
[self.coinButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[coinColorStart, coinColorEnd] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
CGFloat width = 32;
if (self.tag == 1000) {
self.headwearImageView.hidden = NO;
} else {
self.headwearImageView.hidden = YES;
}
}
- (void)setPanelInfo:(AcrossRoomPkRankModel *)panelInfo {
_panelInfo = panelInfo;
if (_panelInfo) {
self.avatarImageView.imageUrl = _panelInfo.avatar;
NSString * amount = _panelInfo.amount.length > 0 ? _panelInfo.amount : @"";
[self.coinButton setTitle:amount forState:UIControlStateNormal];
self.coinButton.hidden = !amount;
}
}
- (UIImageView *)headwearImageView {
if (!_headwearImageView) {
_headwearImageView = [[UIImageView alloc] init];
_headwearImageView.userInteractionEnabled = YES;
}
return _headwearImageView;
}
- (NetImageView *)avatarImageView {
if (!_avatarImageView) {
NetImageConfig * config = [[NetImageConfig alloc]init];
config.imageType = ImageTypeUserIcon;
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
_avatarImageView = [[NetImageView alloc] initWithConfig:config];
}
return _avatarImageView;
}
- (UIButton *)coinButton {
if (!_coinButton) {
_coinButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_coinButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
_coinButton.titleLabel.font = [UIFont systemFontOfSize:9 weight:UIFontWeightMedium];
_coinButton.layer.masksToBounds = YES;
_coinButton.layer.cornerRadius = 5;
_coinButton.hidden = YES;
}
return _coinButton;
}
@end

View File

@@ -0,0 +1,19 @@
//
// XPAcrpssRoomPKPanelView.h
// xplan-ios
//
// Created by 冯硕 on 2022/1/11.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class AcrossRoomPKPanelModel;
@interface XPAcrpssRoomPKPanelView : UIView
///开启pk
- (void)openCountdownWithTime:(long)time;
///pk 信息
@property (nonatomic,strong) AcrossRoomPKPanelModel *pkPanelInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,873 @@
//
// XPAcrpssRoomPKPanelView.m
// xplan-ios
//
// Created by on 2022/1/11.
//
#import "XPAcrpssRoomPKPanelView.h"
///Third
#import <Masonry/Masonry.h>
#import <SVGA.h>
///Tool
#import "ThemeColor.h"
#import "NetImageView.h"
#import "XPMacro.h"
#import "UIImage+Utils.h"
///Model
#import "UserInfoModel.h"
#import "AcrossRoomPKPanelModel.h"
///View
#import "XPAcrossRoomPKPanelUserView.h"
@interface XPAcrpssRoomPKPanelView ()
///
@property (nonatomic, strong) UIImageView *backImageView;
#pragma mark - view
///
@property (nonatomic, strong) UIButton *helpButton;
///
@property (nonatomic, strong) UIImageView *ruleBgImageView;
///
@property (nonatomic, strong) UITextView *ruleTextView;
///
@property (nonatomic, strong) UILabel *timeLabel;
///
@property (nonatomic,strong) UIStackView *stackView;
#pragma mark - view
///
@property (nonatomic,strong) UIView * teamContainerView;
///
@property (nonatomic, strong) UILabel *redTitleLabel;
///
@property (nonatomic, strong) NetImageView *redAvatarImageView;
///
@property (nonatomic, strong) UIButton *assistButton;
///
@property (nonatomic, strong) UILabel *blueTitleLabel;
///
@property (nonatomic, strong) NetImageView *blueAvatarImageView;
///
@property (nonatomic, strong) UIButton *onlookButton;
#pragma mark -
///PK
@property (nonatomic, strong) UIView *progressContentView;
///
@property (nonatomic, strong) UIImageView *redCountImageView;
///
@property (nonatomic, strong) UILabel *redCountLabel;
///
@property (strong, nonatomic) SVGAParser *parser;
///
@property (nonatomic, strong) SVGAImageView *svgDisplayView;
///
@property (nonatomic, strong) UIImageView *buleCountImageView;
///
@property (nonatomic, strong) UILabel *buleCountLabel;
#pragma mark -
///
@property (nonatomic,strong) UIButton *foldButton;
#pragma mark - view
///
@property (nonatomic,strong) UIStackView *userStackView;
///
@property (nonatomic,strong) UIStackView *contributeStackView;
///
@property (nonatomic,strong) UIStackView *redContributeStackView;
///
@property (nonatomic,strong) UIStackView *blueContributeStackView;
///logo
@property (nonatomic,strong) UIButton *contributeButton;
///
@property (nonatomic,strong) UIStackView *charmStackView;
///
@property (nonatomic,strong) UIStackView *redCharmStackView;
///
@property (nonatomic,strong) UIStackView *blueCharmStackView;
///logo
@property (nonatomic,strong) UIButton *charmButton;
///
@property (strong, nonatomic) dispatch_source_t timer;
@end
@implementation XPAcrpssRoomPKPanelView
#pragma mark - life cycle
- (void)dealloc {
NSLog(@"销毁了");
}
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.userInteractionEnabled = YES;
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(changeLocation:)];
// delaysTouchesBegantouchBegin,
// YES,touchesBegan ;
// NO,touchesBegan ;
pan.delaysTouchesBegan = YES;
[self addGestureRecognizer:pan];
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.backImageView];
[self.backImageView addSubview:self.stackView];
[self.backImageView addSubview:self.helpButton];
[self.backImageView addSubview:self.timeLabel];
[self.backImageView addSubview:self.ruleBgImageView];
///
[self.ruleBgImageView addSubview:self.ruleTextView];
///
[self.stackView addArrangedSubview:self.teamContainerView];
[self.stackView addArrangedSubview:self.foldButton];
[self.stackView addArrangedSubview:self.userStackView];
///pk
[self.teamContainerView addSubview:self.redTitleLabel];
[self.teamContainerView addSubview:self.redAvatarImageView];
[self.teamContainerView addSubview:self.assistButton];
[self.teamContainerView addSubview:self.blueTitleLabel];
[self.teamContainerView addSubview:self.blueAvatarImageView];
[self.teamContainerView addSubview:self.onlookButton];
[self.teamContainerView addSubview:self.progressContentView];
///
[self.progressContentView addSubview:self.redCountImageView];
[self.progressContentView addSubview:self.buleCountImageView];
[self.progressContentView addSubview:self.redCountLabel];
[self.progressContentView addSubview:self.buleCountLabel];
[self.progressContentView addSubview:self.svgDisplayView];
///PKView
[self.userStackView addArrangedSubview:self.contributeStackView];
[self.userStackView addArrangedSubview:self.charmStackView];
///
[self.contributeStackView addArrangedSubview:self.redContributeStackView];
[self.contributeStackView addArrangedSubview:self.contributeButton];
[self.contributeStackView addArrangedSubview:self.blueContributeStackView];
///
[self.charmStackView addArrangedSubview:self.redCharmStackView];
[self.charmStackView addArrangedSubview:self.charmButton];
[self.charmStackView addArrangedSubview:self.blueCharmStackView];
[self initUserSubViews];
[self.parser parseWithNamed:@"crossRoomPk_progress" inBundle:[NSBundle mainBundle] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
self.svgDisplayView.loops = INT_MAX;
self.svgDisplayView.clearsAfterStop = NO;
self.svgDisplayView.videoItem = videoItem;
[self.svgDisplayView startAnimation];
} failureBlock:^(NSError * _Nonnull error) {
}];
}
- (void)initUserSubViews {
for (int i = 0; i < 3; i++) {
XPAcrossRoomPKPanelUserView * userView = [[XPAcrossRoomPKPanelUserView alloc] init];
userView.tag = (1000 + i);
userView.type = AcrossRoomPKPanelUserType_Red_Contribute;
[self.redContributeStackView addArrangedSubview:userView];
}
for (int i = 0; i < 3; i++) {
XPAcrossRoomPKPanelUserView * userView = [[XPAcrossRoomPKPanelUserView alloc] init];
userView.tag = (1000 + i);
userView.type = AcrossRoomPKPanelUserType_Blue_Contribute;
[self.blueContributeStackView addArrangedSubview:userView];
}
for (int i = 0; i < 3; i++) {
XPAcrossRoomPKPanelUserView * userView = [[XPAcrossRoomPKPanelUserView alloc] init];
userView.tag = (1000 + i);
userView.type = AcrossRoomPKPanelUserType_Red_Charm;
[self.redCharmStackView addArrangedSubview:userView];
}
for (int i = 0; i < 3; i++) {
XPAcrossRoomPKPanelUserView * userView = [[XPAcrossRoomPKPanelUserView alloc] init];
userView.tag = (1000 + i);
userView.type = AcrossRoomPKPanelUserType_Blue_Charm;
[self.blueCharmStackView addArrangedSubview:userView];
}
}
- (void)initSubViewConstraints {
[self mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(339);
make.bottom.mas_equalTo(self.backImageView);
}];
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.mas_equalTo(self);
make.bottom.mas_equalTo(self.stackView).offset(17);
}];
[self.helpButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(145);
make.top.mas_equalTo(8);
make.width.height.mas_equalTo(16);
}];
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.helpButton);
make.centerX.mas_equalTo(self.helpButton.mas_right).mas_offset(66);
}];
[self.ruleBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(71);
make.top.mas_equalTo(33);
make.width.mas_equalTo(244);
make.height.mas_equalTo(177);
}];
[self.ruleTextView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(10);
make.right.mas_equalTo(-14);
make.top.mas_equalTo(24);
make.bottom.mas_equalTo(-15);
}];
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.backImageView).offset(28);
make.left.right.mas_equalTo(self.backImageView);
}];
[self.teamContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(88);
make.width.mas_equalTo(self.backImageView);
}];
[self.foldButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(16, 8));
}];
///
[self.userStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(38 * 2 + 8);
make.left.right.mas_equalTo(self.stackView).inset(12);
}];
[self.redTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.teamContainerView).offset(12);
make.top.mas_equalTo(self.teamContainerView).offset(12);
make.right.mas_lessThanOrEqualTo(self.teamContainerView.mas_centerX);
}];
[self.redAvatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.teamContainerView).offset(30);
make.top.mas_equalTo(self.redTitleLabel.mas_bottom).mas_offset(11);
make.width.height.mas_equalTo(44);
}];
[self.assistButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.redAvatarImageView.mas_right).mas_offset(8);
make.top.mas_equalTo(self.redAvatarImageView);
make.width.mas_equalTo(50);
make.height.mas_equalTo(18);
}];
[self.blueTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.redTitleLabel);
make.right.mas_equalTo(-12);
make.left.mas_lessThanOrEqualTo(self.teamContainerView.mas_centerX);
}];
[self.blueAvatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(-30);
make.centerY.mas_equalTo(self.redAvatarImageView);
make.width.height.mas_equalTo(44);
}];
[self.onlookButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.blueAvatarImageView.mas_left).mas_offset(-8);
make.centerY.mas_equalTo(self.assistButton);
make.width.mas_equalTo(50);
make.height.mas_equalTo(18);
}];
///
[self.progressContentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.assistButton);
make.right.mas_equalTo(self.onlookButton);
make.height.mas_equalTo(12);
make.top.mas_equalTo(self.assistButton.mas_bottom).offset(8);
}];
[self.redCountImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(0);
make.height.mas_equalTo(12);
make.centerY.mas_equalTo(0);
make.right.mas_equalTo(self.buleCountImageView.mas_left);
}];
[self.redCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.redCountImageView.mas_left).mas_offset(6);
make.right.mas_lessThanOrEqualTo(self.redCountImageView);
make.centerY.mas_equalTo(self.redCountImageView);
}];
[self.svgDisplayView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.redCountImageView);
make.bottom.mas_equalTo(self.progressContentView.mas_bottom).mas_offset(-5);
make.height.mas_equalTo(27);
make.width.mas_equalTo(18);
}];
[self.buleCountImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.progressContentView).offset(-6);
make.height.mas_equalTo(12);
make.centerY.mas_equalTo(self.progressContentView);
make.width.mas_equalTo(self.progressContentView.mas_width).multipliedBy(0.5);
}];
[self.buleCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.buleCountImageView.mas_right).mas_offset((-6));
make.left.mas_lessThanOrEqualTo(self.buleCountImageView);
make.centerY.mas_equalTo(self.buleCountImageView);
}];
[self.contributeStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(38);
}];
[self.charmStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(38);
}];
[self.contributeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(53, 22));
}];
[self.charmButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(53, 22));
}];
[self.redContributeStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(self.blueContributeStackView);
}];
[self.redCharmStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(self.blueCharmStackView);
}];
}
#pragma mark -
- (void)openCountdownWithTime:(long)time {
__block long tempTime = time; //
if (self.timer != nil) {
dispatch_source_cancel(self.timer);
}
@kWeakify(self);
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
self.timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
dispatch_source_set_timer(self.timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //
dispatch_source_set_event_handler(self.timer, ^{
@kStrongify(self);
if(tempTime <= 0){ //
dispatch_source_cancel(self.timer);
self.timer = nil;
dispatch_async(dispatch_get_main_queue(), ^{
self.timeLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightBold];
self.timeLabel.text = @"PK结果计算中";
});
} else {
dispatch_async(dispatch_get_main_queue(), ^{
//
[self acrossRoomPKCutdownOpen:tempTime];
});
tempTime--;
}
});
dispatch_resume(self.timer);
}
///pk,
- (void)acrossRoomPKCutdownOpen:(NSInteger)time {
NSInteger minute = time / 60;
NSInteger second = (time % 60);
NSInteger hour = time/3600;
NSString *timeStr;
if (hour > 0) {
minute = minute % 60;
timeStr = [NSString stringWithFormat:@"%02zd:%02zd:%02zd", hour, minute, second];
} else {
timeStr = [NSString stringWithFormat:@"%02zd:%02zd", minute, second];
}
self.timeLabel.text = timeStr;
if (time <= 30) {
self.timeLabel.textColor = UIColorFromRGB(0xFF87A1);
} else {
self.timeLabel.textColor = UIColorFromRGB(0xFFF600);
}
}
#pragma mark - Event Response
- (void)foldButtonAction:(UIButton *)sender {
sender.selected = !sender.selected;
if (sender.isSelected) {
self.userStackView.hidden = NO;
[UIView animateWithDuration:0.5 animations:^{
self.foldButton.transform = CGAffineTransformIdentity;
}];
} else {
self.userStackView.hidden = YES;
[UIView animateWithDuration:0.5 animations:^{
self.foldButton.transform = CGAffineTransformMakeRotation(M_PI);
}];
}
}
- (void)helpButtonAction:(UIButton *)sender {
sender.selected = !sender.selected;
self.ruleBgImageView.hidden = !sender.selected;
}
- (void)tapRedAvatarRecognizer:(UITapGestureRecognizer *)ges {
//TODO:
}
- (void)tapBlueAvatarRecognizer:(UITapGestureRecognizer *)ges {
//TODO:
}
- (void)assistButtonAction:(UIButton *)sender {
//TODO:
}
- (void)onlookButtonAction:(UIButton *)sender {
//TODO:
}
- (void)changeLocation:(UIPanGestureRecognizer*)p {
// window,APPdelegetewindow
// Window,http://www.jianshu.com/p/d23763e60e94
UIWindow *appWindow = [UIApplication sharedApplication].delegate.window;
CGPoint panPoint = [p locationInView:appWindow];
if (p.state == UIGestureRecognizerStateBegan) {
self.alpha = 1;
} else if(p.state == UIGestureRecognizerStateChanged) {
self.center = CGPointMake(panPoint.x, panPoint.y);
} else if(p.state == UIGestureRecognizerStateEnded
|| p.state == UIGestureRecognizerStateCancelled) {
self.alpha = 1;
CGFloat touchWidth = self.frame.size.width;
CGFloat touchHeight = self.frame.size.height;
CGFloat screenWidth = [[UIScreen mainScreen] bounds].size.width;
CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height;
// fabs
CGFloat left = fabs(panPoint.x);
CGFloat right = fabs(screenWidth - left);
CGFloat top = fabs(panPoint.y);
CGFloat bottom = fabs(screenHeight - top);
CGFloat minSpace = 0;
minSpace = MIN(MIN(MIN(top, left), bottom), right);
CGPoint newCenter;
CGFloat targetY = 0;
//Y
if (panPoint.y < 15 + touchHeight / 2.0) {
targetY = 15 + touchHeight / 2.0;
}else if (panPoint.y > (screenHeight - touchHeight / 2.0 - 15)) {
targetY = screenHeight - touchHeight / 2.0 - 15;
}else{
targetY = panPoint.y;
}
if (minSpace == left) {
newCenter = CGPointMake(15+touchWidth/2.0, targetY);
}else if (minSpace == right) {
newCenter = CGPointMake(screenWidth - touchWidth/2.0 - 15, targetY);
}else if (minSpace == top) {
newCenter = CGPointMake(panPoint.x, touchWidth / 3);
}else {
newCenter = CGPointMake(panPoint.x, screenHeight - touchWidth / 3);
}
[UIView animateWithDuration:0.25 animations:^{
if (newCenter.y + self.frame.size.height / 2 > KScreenHeight - kSafeAreaBottomHeight - 44) {
[self mas_updateConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(CGPointMake(newCenter.x, KScreenHeight - self.frame.size.height / 2 - kSafeAreaBottomHeight - 44));
}];
}else {
[self mas_updateConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(newCenter);
}];
}
}];
}
}
#pragma mark - getters and setters
- (void)setPkPanelInfo:(AcrossRoomPKPanelModel *)pkPanelInfo {
_pkPanelInfo = pkPanelInfo;
if (_pkPanelInfo) {
self.redTitleLabel.text = _pkPanelInfo.cTitle;
self.redAvatarImageView.imageUrl = _pkPanelInfo.cAvatar;
self.redCountLabel.text = [NSString stringWithFormat:@"%lld", _pkPanelInfo.cAmount];
self.blueTitleLabel.text = _pkPanelInfo.aTitle;
self.blueAvatarImageView.imageUrl = _pkPanelInfo.aAvatar;
self.buleCountLabel.text = [NSString stringWithFormat:@"%lld", _pkPanelInfo.aAmount];
for (int i = 0; i<_pkPanelInfo.csRank.count; i++) {
AcrossRoomPkRankModel * rankModel = [_pkPanelInfo.csRank objectAtIndex:i];
if (i < self.redContributeStackView.subviews.count) {
break;
}
XPAcrossRoomPKPanelUserView *userView = self.redContributeStackView.subviews[i];
userView.panelInfo = rankModel;
}
for (int i = 0; i<_pkPanelInfo.crRank.count; i++) {
AcrossRoomPkRankModel * rankModel = [_pkPanelInfo.crRank objectAtIndex:i];
if (i < self.redCharmStackView.subviews.count) {
break;
}
XPAcrossRoomPKPanelUserView *userView = self.redCharmStackView.subviews[i];
userView.panelInfo = rankModel;
}
for (int i = 0; i<_pkPanelInfo.asRank.count; i++) {
AcrossRoomPkRankModel * rankModel = [_pkPanelInfo.asRank objectAtIndex:i];
if (i < self.blueContributeStackView.subviews.count) {
break;
}
XPAcrossRoomPKPanelUserView *userView = self.blueContributeStackView.subviews[i];
userView.panelInfo = rankModel;
}
for (int i = 0; i<_pkPanelInfo.arRank.count; i++) {
AcrossRoomPkRankModel * rankModel = [_pkPanelInfo.arRank objectAtIndex:i];
if (i < self.blueCharmStackView.subviews.count) {
break;
}
XPAcrossRoomPKPanelUserView *userView = self.blueCharmStackView.subviews[i];
userView.panelInfo = rankModel;
}
if (_pkPanelInfo.aPercent > 1) {
_pkPanelInfo.aPercent = 1;
}
[self.buleCountImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(self.progressContentView.mas_width).multipliedBy(_pkPanelInfo.aPercent);
}];
}
}
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.image = [UIImage imageNamed:@"room_across_pk_panel_bg"];
}
return _backImageView;
}
- (UIButton *)helpButton {
if (!_helpButton) {
_helpButton = [[UIButton alloc] init];
[_helpButton setImage:[UIImage imageNamed:@"room_across_pk_panel_help"] forState:UIControlStateNormal];
[_helpButton addTarget:self action:@selector(helpButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _helpButton;
}
- (UILabel *)timeLabel {
if (!_timeLabel) {
_timeLabel = [[UILabel alloc] init];
_timeLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightBold];
_timeLabel.textColor = UIColorFromRGB(0xFFF600);
_timeLabel.text = @"00:00";
}
return _timeLabel;
}
- (UIImageView *)ruleBgImageView {
if (!_ruleBgImageView) {
_ruleBgImageView = [[UIImageView alloc] init];
_ruleBgImageView.image = [UIImage imageNamed:@"room_across_pk_panel_rule_bg"];
_ruleBgImageView.hidden = YES;
}
return _ruleBgImageView;
}
- (UITextView *)ruleTextView {
if (!_ruleTextView) {
_ruleTextView = [[UITextView alloc] init];
_ruleTextView.backgroundColor = [UIColor clearColor];
_ruleTextView.textColor = [UIColor whiteColor];
_ruleTextView.font = [UIFont systemFontOfSize:12];
_ruleTextView.text = @"1按收到的礼物价值积分1钻石=1分礼物值高的一方获胜。\n2PK结束后若比分差距≥1314或双方分数总值≥15000平局除外将在与获胜方相同类型的房间公示PK结果若比分差距≥5200或双方分数总值≥30000平局除外将在全服所有房间公示PK结果。";
}
return _ruleTextView;
}
- (UIStackView *)stackView {
if (!_stackView) {
_stackView = [[UIStackView alloc] init];
_stackView.axis = UILayoutConstraintAxisVertical;
_stackView.distribution = UIStackViewDistributionFill;
_stackView.alignment = UIStackViewAlignmentCenter;
_stackView.spacing = 10;
}
return _stackView;
}
- (UIView *)teamContainerView {
if (!_teamContainerView) {
_teamContainerView = [[UIView alloc] init];
_teamContainerView.backgroundColor = [UIColor clearColor];
}
return _teamContainerView;
}
- (UIView *)progressContentView {
if (!_progressContentView) {
_progressContentView = [[UIView alloc] init];
_progressContentView.backgroundColor = [UIColor whiteColor];
_progressContentView.layer.cornerRadius = 6;
_progressContentView.layer.masksToBounds = YES;
}
return _progressContentView;
}
- (UIImageView *)redCountImageView {
if (!_redCountImageView) {
_redCountImageView = [[UIImageView alloc] init];
_redCountImageView.backgroundColor = UIColorFromRGB(0xFF4D73);
}
return _redCountImageView;
}
- (UILabel *)redCountLabel {
if (!_redCountLabel) {
_redCountLabel = [[UILabel alloc] init];
_redCountLabel.font = [UIFont systemFontOfSize:12];
_redCountLabel.textColor = [UIColor whiteColor];
_redCountLabel.text = @"0";
_redCountLabel.textAlignment = NSTextAlignmentLeft;
}
return _redCountLabel;
}
- (UIImageView *)buleCountImageView {
if (!_buleCountImageView) {
_buleCountImageView = [[UIImageView alloc] init];
_buleCountImageView.backgroundColor = UIColorFromRGB(0x45C0FF);
}
return _buleCountImageView;
}
- (UILabel *)buleCountLabel {
if (!_buleCountLabel) {
_buleCountLabel = [[UILabel alloc] init];
_buleCountLabel.font = [UIFont systemFontOfSize:12];
_buleCountLabel.textColor = [UIColor whiteColor];
_buleCountLabel.text = @"0";
_buleCountLabel.textAlignment = NSTextAlignmentRight;
}
return _buleCountLabel;
}
- (UILabel *)redTitleLabel {
if (!_redTitleLabel) {
_redTitleLabel = [[UILabel alloc] init];
_redTitleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightBold];
_redTitleLabel.textColor = [UIColor whiteColor];
}
return _redTitleLabel;
}
- (NetImageView *)redAvatarImageView {
if (!_redAvatarImageView) {
NetImageConfig * config = [[NetImageConfig alloc]init];
config.imageType = ImageTypeUserIcon;
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
_redAvatarImageView = [[NetImageView alloc] initWithConfig:config];
_redAvatarImageView.layer.masksToBounds = YES;
_redAvatarImageView.layer.cornerRadius = 22;
_redAvatarImageView.layer.borderWidth = 1;
_redAvatarImageView.layer.borderColor = UIColorFromRGB(0xFF6574).CGColor;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRedAvatarRecognizer:)];
[_redAvatarImageView addGestureRecognizer:tap];
}
return _redAvatarImageView;
}
- (UILabel *)blueTitleLabel {
if (!_blueTitleLabel) {
_blueTitleLabel = [[UILabel alloc] init];
_blueTitleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightBold];
_blueTitleLabel.textColor = [UIColor whiteColor];
_blueTitleLabel.textAlignment = NSTextAlignmentRight;
}
return _blueTitleLabel;
}
- (NetImageView *)blueAvatarImageView {
if (!_blueAvatarImageView) {
NetImageConfig * config = [[NetImageConfig alloc]init];
config.imageType = ImageTypeUserIcon;
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
_blueAvatarImageView = [[NetImageView alloc] initWithConfig:config];
_blueAvatarImageView.layer.masksToBounds = YES;
_blueAvatarImageView.layer.cornerRadius = 22;
_blueAvatarImageView.layer.borderWidth = 1;
_blueAvatarImageView.layer.borderColor = UIColorFromRGB(0x45C0FF).CGColor;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapBlueAvatarRecognizer:)];
[_blueAvatarImageView addGestureRecognizer:tap];
}
return _blueAvatarImageView;
}
- (UIButton *)assistButton {
if (!_assistButton) {
_assistButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_assistButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor], [ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
[_assistButton setTitle:@"助攻" forState:UIControlStateNormal];
_assistButton.titleLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
[_assistButton setTitleColor:[ThemeColor confirmButtonTextColor] forState:UIControlStateNormal];
[_assistButton addTarget:self action:@selector(assistButtonAction:) forControlEvents:UIControlEventTouchUpInside];
_assistButton.layer.masksToBounds = YES;
_assistButton.layer.cornerRadius = 9;
_assistButton.layer.borderWidth = 1;
_assistButton.layer.borderColor = [UIColor whiteColor].CGColor;
}
return _assistButton;
}
- (UIButton *)onlookButton {
if (!_onlookButton) {
_onlookButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_onlookButton setBackgroundImage:[UIImage imageWithColor:[ThemeColor disableButtonColor]] forState:UIControlStateNormal];
[_onlookButton setTitle:@"去围观" forState:UIControlStateNormal];
_onlookButton.titleLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
[_onlookButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[_onlookButton addTarget:self action:@selector(onlookButtonAction:) forControlEvents:UIControlEventTouchUpInside];
_onlookButton.layer.masksToBounds = YES;
_onlookButton.layer.cornerRadius = 9;
_onlookButton.layer.borderWidth = 1;
_onlookButton.layer.borderColor = [UIColor whiteColor].CGColor;
}
return _onlookButton;
}
- (UIButton *)foldButton {
if (!_foldButton) {
_foldButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_foldButton setImage:[UIImage imageNamed:@"room_across_pk_panel_fold"] forState:UIControlStateNormal];
[_foldButton addTarget:self action:@selector(foldButtonAction:) forControlEvents:UIControlEventTouchUpInside];
_foldButton.transform = CGAffineTransformMakeRotation(M_PI);
}
return _foldButton;
}
- (UIStackView *)userStackView {
if (!_userStackView) {
_userStackView = [[UIStackView alloc] init];
_userStackView.axis = UILayoutConstraintAxisVertical;
_userStackView.distribution = UIStackViewDistributionFill;
_userStackView.alignment = UIStackViewAlignmentFill;
_userStackView.spacing = 8;
}
return _userStackView;
}
- (UIStackView *)contributeStackView {
if (!_contributeStackView) {
_contributeStackView = [[UIStackView alloc] init];
_contributeStackView.axis = UILayoutConstraintAxisHorizontal;
_contributeStackView.distribution = UIStackViewDistributionFill;
_contributeStackView.alignment = UIStackViewAlignmentCenter;
_contributeStackView.spacing = 12;
}
return _contributeStackView;
}
- (UIStackView *)charmStackView {
if (!_charmStackView) {
_charmStackView = [[UIStackView alloc] init];
_charmStackView.axis = UILayoutConstraintAxisHorizontal;
_charmStackView.distribution = UIStackViewDistributionFill;
_charmStackView.alignment = UIStackViewAlignmentCenter;
_charmStackView.spacing = 12;
}
return _charmStackView;
}
- (UIStackView *)redContributeStackView {
if (!_redContributeStackView) {
_redContributeStackView = [[UIStackView alloc] init];
_redContributeStackView.axis = UILayoutConstraintAxisHorizontal;
_redContributeStackView.distribution = UIStackViewDistributionEqualSpacing;
_redContributeStackView.alignment = UIStackViewAlignmentFill;
}
return _redContributeStackView;
}
- (UIStackView *)blueContributeStackView {
if (!_blueContributeStackView) {
_blueContributeStackView = [[UIStackView alloc] init];
_blueContributeStackView.axis = UILayoutConstraintAxisHorizontal;
_blueContributeStackView.distribution = UIStackViewDistributionEqualSpacing;
_blueContributeStackView.alignment = UIStackViewAlignmentFill;
}
return _blueContributeStackView;
}
- (UIStackView *)redCharmStackView {
if (!_redCharmStackView) {
_redCharmStackView = [[UIStackView alloc] init];
_redCharmStackView.axis = UILayoutConstraintAxisHorizontal;
_redCharmStackView.distribution = UIStackViewDistributionEqualSpacing;
_redCharmStackView.alignment = UIStackViewAlignmentFill;
}
return _redCharmStackView;
}
- (UIStackView *)blueCharmStackView {
if (!_blueCharmStackView) {
_blueCharmStackView = [[UIStackView alloc] init];
_blueCharmStackView.axis = UILayoutConstraintAxisHorizontal;
_blueCharmStackView.distribution = UIStackViewDistributionEqualSpacing;
_blueCharmStackView.alignment = UIStackViewAlignmentFill;
}
return _blueCharmStackView;
}
- (UIButton *)contributeButton {
if (!_contributeButton) {
_contributeButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_contributeButton setBackgroundImage:[UIImage imageNamed:@"room_across_pk_panel_contribute_bg"] forState:UIControlStateNormal];
[_contributeButton setTitle:@"神豪" forState:UIControlStateNormal];
_contributeButton.titleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
[_contributeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
}
return _contributeButton;
}
- (UIButton *)charmButton {
if (!_charmButton) {
_charmButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_charmButton setBackgroundImage:[UIImage imageNamed:@"room_across_pk_panel_charm_bg"] forState:UIControlStateNormal];
[_charmButton setTitle:@"魅力" forState:UIControlStateNormal];
_charmButton.titleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
[_charmButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
}
return _charmButton;
}
- (SVGAImageView *)svgDisplayView {
if (_svgDisplayView == nil) {
_svgDisplayView = [[SVGAImageView alloc]init];
_svgDisplayView.contentMode = UIViewContentModeScaleToFill;
_svgDisplayView.userInteractionEnabled = NO;
_svgDisplayView.backgroundColor = [UIColor clearColor];
}
return _svgDisplayView;
}
- (SVGAParser *)parser {
if (!_parser) {
_parser = [[SVGAParser alloc]init];
}
return _parser;
}
@end

View File

@@ -27,6 +27,7 @@
#import "UserInfoModel.h"
#import "AttachmentModel.h"
#import "GiftValueInfoModel.h"
#import "AcrossRoomPKPanelModel.h"
///View
#import "XPRoomHalfWebView.h"
#import "XPAnchorAudienceUpMicView.h"
@@ -36,6 +37,7 @@
#import "XPRoomTopicAlertView.h"
#import "XPAcrossRoomPKInviteView.h"
#import "XPAcrossRoomPKInviteResultView.h"
#import "XPAcrpssRoomPKPanelView.h"
@interface XPRoomFunctionContainerView ()
///host
@property (nonatomic,weak) id<RoomHostDelegate>delegate;
@@ -53,7 +55,8 @@
@property (nonatomic,strong) UILabel *topicLabel;
///
@property (nonatomic,strong) UIButton *editButton;
///pk
@property (nonatomic,strong) XPAcrpssRoomPKPanelView *acrossPKPanelView;
@end
@implementation XPRoomFunctionContainerView
@@ -171,6 +174,26 @@
} uid:uid isLikeUid:roomUid];
}
}
if (roomInfo.roomModeType == RoomModeType_Open_AcrossRoomPK_mode) {
[Api getAcrossRoomPKDetail:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
AcrossRoomPKPanelModel * acrossPKPanelInfo = [AcrossRoomPKPanelModel modelWithJSON:data.data];
if (acrossPKPanelInfo.aUid.integerValue > 0) {
if (!self.acrossPKPanelView.superview) {
[self addSubview:self.acrossPKPanelView];
[self.acrossPKPanelView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self);
}];
}
self.acrossPKPanelView.pkPanelInfo = acrossPKPanelInfo;
}
} else {
[XCHUDTool showErrorWithMessage:msg];
}
} roomUid:roomUid];
}
[self updateRoomTopic];
}
@@ -178,6 +201,7 @@
[self handleAnchorGiftValue:data];
}
- (void)handleNIMCustomMessage:(NIMMessage *)message {
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
@@ -264,6 +288,22 @@
}];
}
break;
case Custom_Message_Sub_AcrossRoomPK_Panel:
{
if (!self.acrossPKPanelView.superview) {
[self addSubview:self.acrossPKPanelView];
[self.acrossPKPanelView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self);
}];
}
AcrossRoomPKPanelModel * acrossPKPanelInfo = [AcrossRoomPKPanelModel modelWithJSON:attachment.data];
self.acrossPKPanelView.pkPanelInfo = acrossPKPanelInfo;
}
break;
case Custom_Message_Sub_AcrossRoomPK_End:
{
}
default:
break;
}
@@ -565,4 +605,11 @@
return _editButton;
}
- (XPAcrpssRoomPKPanelView *)acrossPKPanelView {
if (!_acrossPKPanelView) {
_acrossPKPanelView = [[XPAcrpssRoomPKPanelView alloc] init];
}
return _acrossPKPanelView;
}
@end

Binary file not shown.