Commit 9155725f by suolong

完善主播端的礼物互动

parent d9e1a5b9
Showing with 250 additions and 1 deletions
......@@ -115,6 +115,7 @@
#define ROOM_CID_LINKMIC_CHANGE 30012 // 麦位列表存在变化
#define USER_ACCOUNT_CHANGE 12000 // 推送用户账户发生变化
#define ROOM_CID_GIFT_INTERACT_TASK_CHANGED 12002 // 礼物互动任务达成变化
#define ROOM_CID_REALTIME_ACTIVITY_INFO 10091 // 直播间实时活动
#define ROOM_CID_LIVE_ALERT 10090 // 接收到直播弹窗通知
......@@ -133,4 +134,3 @@
......@@ -1667,6 +1667,7 @@
BED65A782C5B745F00668116 /* FUSLiveFunctionLayerView.m in Sources */ = {isa = PBXBuildFile; fileRef = BED657A32C5B745D00668116 /* FUSLiveFunctionLayerView.m */; };
BED65A792C5B745F00668116 /* FUSLiveFunctionView.h in Headers */ = {isa = PBXBuildFile; fileRef = BED657A42C5B745D00668116 /* FUSLiveFunctionView.h */; };
BED65A7A2C5B745F00668116 /* FUSLiveFunctionView.m in Sources */ = {isa = PBXBuildFile; fileRef = BED657A52C5B745D00668116 /* FUSLiveFunctionView.m */; };
C0A1B2C32F6A000100AAAA03 /* FUSLiveGiftInteractTaskPanelView.m in Sources */ = {isa = PBXBuildFile; fileRef = C0A1B2C32F6A000100AAAA02 /* FUSLiveGiftInteractTaskPanelView.m */; };
BED65A7B2C5B745F00668116 /* FUSLiveLoadingView.h in Headers */ = {isa = PBXBuildFile; fileRef = BED657A72C5B745D00668116 /* FUSLiveLoadingView.h */; };
BED65A7C2C5B745F00668116 /* FUSLiveLoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = BED657A82C5B745D00668116 /* FUSLiveLoadingView.m */; };
BED65A7E2C5B745F00668116 /* FUSLiveMinimizeView.h in Headers */ = {isa = PBXBuildFile; fileRef = BED657AB2C5B745D00668116 /* FUSLiveMinimizeView.h */; };
......@@ -4090,6 +4091,8 @@
BED657A32C5B745D00668116 /* FUSLiveFunctionLayerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSLiveFunctionLayerView.m; sourceTree = "<group>"; };
BED657A42C5B745D00668116 /* FUSLiveFunctionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSLiveFunctionView.h; sourceTree = "<group>"; };
BED657A52C5B745D00668116 /* FUSLiveFunctionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSLiveFunctionView.m; sourceTree = "<group>"; };
C0A1B2C32F6A000100AAAA01 /* FUSLiveGiftInteractTaskPanelView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSLiveGiftInteractTaskPanelView.h; sourceTree = "<group>"; };
C0A1B2C32F6A000100AAAA02 /* FUSLiveGiftInteractTaskPanelView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSLiveGiftInteractTaskPanelView.m; sourceTree = "<group>"; };
BED657A72C5B745D00668116 /* FUSLiveLoadingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSLiveLoadingView.h; sourceTree = "<group>"; };
BED657A82C5B745D00668116 /* FUSLiveLoadingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSLiveLoadingView.m; sourceTree = "<group>"; };
BED657A92C5B745D00668116 /* FUSLiveLoadingView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = FUSLiveLoadingView.xib; sourceTree = "<group>"; };
......@@ -7392,6 +7395,7 @@
BEEAB2502D337F87008CD059 /* AnchorReward */,
00F0A0102F5F0A1B00C0FFEE /* PayRoom */,
BEB504712D2E8FD100EA6E6F /* LiveThemeView */,
C0A1B2C32F6A000100AAAA00 /* GiftInteract */,
BED655C12C5B745D00668116 /* Activity */,
BED655DC2C5B745D00668116 /* AudienceListView */,
BED656122C5B745D00668116 /* ChatInputView */,
......@@ -7419,6 +7423,15 @@
path = FunctionView;
sourceTree = "<group>";
};
C0A1B2C32F6A000100AAAA00 /* GiftInteract */ = {
isa = PBXGroup;
children = (
C0A1B2C32F6A000100AAAA01 /* FUSLiveGiftInteractTaskPanelView.h */,
C0A1B2C32F6A000100AAAA02 /* FUSLiveGiftInteractTaskPanelView.m */,
);
path = GiftInteract;
sourceTree = "<group>";
};
BED657AA2C5B745D00668116 /* LoadingView */ = {
isa = PBXGroup;
children = (
......@@ -10760,6 +10773,7 @@
BED659E42C5B745F00668116 /* FUSPKHttpHelper.m in Sources */,
BED658BA2C5B745E00668116 /* FUSHalfWebViewCollectionViewCell.m in Sources */,
BED65A7A2C5B745F00668116 /* FUSLiveFunctionView.m in Sources */,
C0A1B2C32F6A000100AAAA03 /* FUSLiveGiftInteractTaskPanelView.m in Sources */,
004773412F5EBADE00E46A79 /* FUSNewUserSevenDayCheckInControl.swift in Sources */,
BED658FF2C5B745E00668116 /* FUSLiveChatInputBulletsListCell.m in Sources */,
BED6599A2C5B745E00668116 /* FUSAgoraHelper.m in Sources */,
{
"images" : [
{
"filename" : "Live_bottom_actIcon.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Live_bottom_actIcon@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Live_bottom_actIcon@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "Live_bottom_actYes.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Live_bottom_actYes@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Live_bottom_actYes@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -97,6 +97,7 @@ static NSInteger const FUSLiveGiftInteractMaxItemCount = 6;
if (roomInfo.stateSwitch) {
roomInfo.stateSwitch.giftinteractionstate = switchState;
}
[[NSNotificationCenter defaultCenter] postNotificationName:@"FUSGiftInteractSwitchDidChangeNotification" object:nil userInfo:@{@"switchState": @(switchState)}];
[weakCell fus_setupWithEnabled:switchState];
[weakCell fus_setSwitchUserInteractionEnabled:YES];
} failure:^(NSString *msg, NSInteger code) {
......
......@@ -9,6 +9,15 @@ NS_ASSUME_NONNULL_BEGIN
/// 互动描述
@property (nonatomic, copy) NSString *name;
/// 任务ID(任务列表接口返回)
@property (nonatomic, copy) NSString *taskId;
/// 用户ID(任务列表接口返回)
@property (nonatomic, copy) NSString *userId;
/// 用户头像(任务列表接口返回)
@property (nonatomic, copy) NSString *userFace;
/// 用户昵称(任务列表接口返回)
@property (nonatomic, copy) NSString *userNickname;
/// 礼物ID
@property (nonatomic, copy) NSString *giftId;
/// 礼物图标URL
......
......@@ -2,4 +2,14 @@
@implementation FUSLiveGiftInteractSettingItemModel
+ (NSDictionary *)modelCustomPropertyMapper {
return @{
@"name": @[@"name", @"action"],
@"taskId": @[@"taskId", @"taskid"],
@"userId": @[@"userId", @"userid"],
@"userFace": @[@"userFace", @"userface"],
@"userNickname": @[@"userNickname", @"usernickname"]
};
}
@end
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface FUSLiveGiftInteractTaskPanelView : UIView
/// 点击“消失”回调,index 对应 taskTexts 的下标
@property (nonatomic, copy, nullable) void (^doneHandler)(NSInteger index);
/// 刷新展示文本(最多展示调用方传入的数量)
- (void)fus_updateWithTaskTexts:(NSArray<NSString *> *)taskTexts;
@end
NS_ASSUME_NONNULL_END
#import "FUSLiveGiftInteractTaskPanelView.h"
@interface FUSLiveGiftInteractTaskPanelView ()
/// 顶部标题栏
@property (nonatomic, strong) UIView *headerView;
/// 顶部icon
@property (nonatomic, strong) UIImageView *headerIconView;
/// 顶部标题
@property (nonatomic, strong) UILabel *headerTitleLabel;
/// 空态文案(当 taskTexts 为空时显示)
@property (nonatomic, strong) UILabel *emptyLabel;
/// 当前展示的文本数组
@property (nonatomic, copy) NSArray<NSString *> *taskTexts;
/// 左侧文本 label 列表(按 taskTexts 数量动态增减)
@property (nonatomic, strong) NSMutableArray<UILabel *> *textLabels;
/// 右侧“消失”按钮列表(按 taskTexts 数量动态增减)
@property (nonatomic, strong) NSMutableArray<UIButton *> *doneButtons;
@end
@implementation FUSLiveGiftInteractTaskPanelView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (!self) {
return nil;
}
self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.35];
self.layer.cornerRadius = 8;
self.clipsToBounds = YES;
self.userInteractionEnabled = YES;
self.headerView = [[UIView alloc] initWithFrame:CGRectZero];
self.headerView.backgroundColor = [UIColor colorWithHex:@"36E6ED" alpha:1];
[self addSubview:self.headerView];
self.headerIconView = [[UIImageView alloc] initWithFrame:CGRectZero];
self.headerIconView.contentMode = UIViewContentModeScaleAspectFit;
self.headerIconView.image = [FUSShowRoomCenterBunble imageNamed:@"Live_bottom_actIcon"];
[self.headerView addSubview:self.headerIconView];
self.headerTitleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
self.headerTitleLabel.text = [NSString fus_localString:@"互动"];
self.headerTitleLabel.font = [UIFont fus_themeFont:15];
self.headerTitleLabel.textColor = UIColor.blackColor;
[self.headerView addSubview:self.headerTitleLabel];
self.textLabels = [NSMutableArray array];
self.doneButtons = [NSMutableArray array];
self.emptyLabel = [[UILabel alloc] initWithFrame:CGRectZero];
self.emptyLabel.text = [NSString fus_localString:@"暂无"];
self.emptyLabel.textAlignment = NSTextAlignmentCenter;
self.emptyLabel.font = [UIFont fus_themeFont:12];
self.emptyLabel.textColor = UIColor.whiteColor;
[self addSubview:self.emptyLabel];
[self fus_updateWithTaskTexts:@[]];
return self;
}
/// 刷新内容并驱动视图子控件数量与布局更新
- (void)fus_updateWithTaskTexts:(NSArray<NSString *> *)taskTexts {
self.taskTexts = taskTexts ?: @[];
NSInteger targetCount = self.taskTexts.count;
while (self.textLabels.count > targetCount) {
UILabel *label = self.textLabels.lastObject;
[label removeFromSuperview];
[self.textLabels removeLastObject];
}
while (self.doneButtons.count > targetCount) {
UIButton *btn = self.doneButtons.lastObject;
[btn removeFromSuperview];
[self.doneButtons removeLastObject];
}
while (self.textLabels.count < targetCount) {
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
label.font = [UIFont fus_themeFont:12];
label.textColor = UIColor.whiteColor;
label.numberOfLines = 1;
[self addSubview:label];
[self.textLabels addObject:label];
}
while (self.doneButtons.count < targetCount) {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *img = [FUSShowRoomCenterBunble imageNamed:@"Live_bottom_actYes"];
[btn setImage:img forState:UIControlStateNormal];
[btn addTarget:self action:@selector(fus_onClickDone:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:btn];
[self.doneButtons addObject:btn];
}
for (NSInteger i = 0; i < targetCount; i++) {
UILabel *label = self.textLabels[i];
label.text = self.taskTexts[i] ?: @"";
UIButton *btn = self.doneButtons[i];
btn.tag = i;
}
self.emptyLabel.hidden = (targetCount > 0);
[self setNeedsLayout];
}
- (void)layoutSubviews {
[super layoutSubviews];
CGFloat headerH = 30;
CGFloat padding = 8;
CGFloat buttonSize = 18;
self.headerView.frame = CGRectMake(0, 0, CGRectGetWidth(self.bounds), headerH);
CGFloat iconSize = 16;
CGFloat spacing = 4;
CGSize titleSize = [self.headerTitleLabel sizeThatFits:CGSizeMake(CGFLOAT_MAX, headerH)];
CGFloat groupW = iconSize + spacing + titleSize.width;
CGFloat groupX = (CGRectGetWidth(self.headerView.bounds) - groupW) * 0.5;
if (groupX < 0) {
groupX = 0;
}
self.headerIconView.frame = CGRectMake(groupX, (headerH - iconSize) * 0.5, iconSize, iconSize);
self.headerTitleLabel.frame = CGRectMake(CGRectGetMaxX(self.headerIconView.frame) + spacing, 0, titleSize.width, headerH);
CGFloat contentTop = CGRectGetMaxY(self.headerView.frame);
if (self.taskTexts.count == 0) {
self.emptyLabel.frame = CGRectMake(0, contentTop, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds) - contentTop);
return;
}
self.emptyLabel.frame = CGRectZero;
CGFloat labelX = padding;
CGFloat buttonX = CGRectGetWidth(self.bounds) - padding - buttonSize;
CGFloat labelW = buttonX - labelX - 8;
CGFloat availableH = CGRectGetHeight(self.bounds) - contentTop - padding * 2;
CGFloat rowHeight = (availableH > 0 ? (availableH / self.taskTexts.count) : 0);
for (NSInteger i = 0; i < self.taskTexts.count; i++) {
CGFloat y = contentTop + padding + i * rowHeight;
UILabel *label = self.textLabels[i];
label.frame = CGRectMake(labelX, y, labelW, rowHeight);
UIButton *btn = self.doneButtons[i];
btn.frame = CGRectMake(buttonX, y + (rowHeight - buttonSize) * 0.5, buttonSize, buttonSize);
}
}
/// 点击“消失”
- (void)fus_onClickDone:(UIButton *)sender {
if (self.doneHandler) {
self.doneHandler(sender.tag);
}
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment