礼物值模式的UI

This commit is contained in:
fengshuo
2021-12-13 16:08:24 +08:00
parent 7a41eee1d6
commit 260cec82be
20 changed files with 340 additions and 11 deletions

View File

@@ -304,6 +304,8 @@
E8DEC98C27637EA50078CB70 /* candyTree_transform.svga in Resources */ = {isa = PBXBuildFile; fileRef = E8DEC98A27637EA50078CB70 /* candyTree_transform.svga */; };
E8DEC98F27643EB30078CB70 /* XPCandyTreeAnimationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC98E27643EB30078CB70 /* XPCandyTreeAnimationManager.m */; };
E8DEC992276441AA0078CB70 /* XPCandyTreeAnimationModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC991276441AA0078CB70 /* XPCandyTreeAnimationModel.m */; };
E8DACCFB2766EDC60052092C /* MicroGiftValueView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DACCFA2766EDC60052092C /* MicroGiftValueView.m */; };
E8DACCFE27673F870052092C /* MicroGiftValueModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DACCFD27673F870052092C /* MicroGiftValueModel.m */; };
E8DEC99527648FA50078CB70 /* ClientConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC99427648FA50078CB70 /* ClientConfig.m */; };
E8DEC99E2764A5B60078CB70 /* XPRoomMoreMenuViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC99D2764A5B60078CB70 /* XPRoomMoreMenuViewController.m */; };
E8DEC9A12764A5D20078CB70 /* XPRoomMoreItemModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC9A02764A5D20078CB70 /* XPRoomMoreItemModel.m */; };
@@ -927,6 +929,10 @@
E8DEC98E27643EB30078CB70 /* XPCandyTreeAnimationManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPCandyTreeAnimationManager.m; sourceTree = "<group>"; };
E8DEC990276441AA0078CB70 /* XPCandyTreeAnimationModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPCandyTreeAnimationModel.h; sourceTree = "<group>"; };
E8DEC991276441AA0078CB70 /* XPCandyTreeAnimationModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPCandyTreeAnimationModel.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 /* MicroGiftValueModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MicroGiftValueModel.h; sourceTree = "<group>"; };
E8DACCFD27673F870052092C /* MicroGiftValueModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MicroGiftValueModel.m; sourceTree = "<group>"; };
E8DEC99327648FA50078CB70 /* ClientConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ClientConfig.h; sourceTree = "<group>"; };
E8DEC99427648FA50078CB70 /* ClientConfig.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ClientConfig.m; sourceTree = "<group>"; };
E8DEC99C2764A5B60078CB70 /* XPRoomMoreMenuViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMoreMenuViewController.h; sourceTree = "<group>"; };
@@ -1951,6 +1957,8 @@
E8680717271967B00024F48F /* MicroView.m */,
E81D58802720082A003063FE /* MicroWaveView.h */,
E81D58812720082A003063FE /* MicroWaveView.m */,
E8DACCF92766EDC60052092C /* MicroGiftValueView.h */,
E8DACCFA2766EDC60052092C /* MicroGiftValueView.m */,
);
path = MicroView;
sourceTree = "<group>";
@@ -1979,6 +1987,8 @@
E874B88727215D39003954B9 /* MicroStateModel.m */,
E874B88927215EAF003954B9 /* MicroQueueModel.h */,
E874B88A27215EAF003954B9 /* MicroQueueModel.m */,
E8DACCFC27673F870052092C /* MicroGiftValueModel.h */,
E8DACCFD27673F870052092C /* MicroGiftValueModel.m */,
);
path = Model;
sourceTree = "<group>";
@@ -3063,6 +3073,7 @@
E8AEAED6271412EC0017FCE0 /* XPRoomViewController.m in Sources */,
E8E70D9226F2F60C00F03460 /* XPMineItemModel.m in Sources */,
189DD74A26E21D8400AB55B1 /* SSKeychain.m in Sources */,
E8DACCFE27673F870052092C /* MicroGiftValueModel.m in Sources */,
E8B846CF26FDD96100A777FE /* XPMineRechageHeadView.m in Sources */,
186A534926FC6ED900D67B2C /* TTAlertMessageAttributedConfig.m in Sources */,
E81C27AE26EF39AB0031E639 /* AppDelegate+ThirdConfig.m in Sources */,
@@ -3147,6 +3158,7 @@
E8AE427327153A3500BEEBB2 /* XPRoomActivityContainerView.m in Sources */,
E86596432701611A00846EBD /* UIImage+ImageEffects.m in Sources */,
18486217271EAB8C005FC5DC /* BaseRtcImpl.m in Sources */,
E8DACCFB2766EDC60052092C /* MicroGiftValueView.m in Sources */,
E8CEA03D26EA3DE500644B44 /* LoginPasswordPresent.m in Sources */,
E8E70D7726F2F15100F03460 /* XPMineViewController.m in Sources */,
E8E7DAEB2745158500C631CC /* XPGiftUserInfoModel.m in Sources */,

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 904 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 B

View File

@@ -61,6 +61,25 @@ NS_ASSUME_NONNULL_BEGIN
roomId:(NSString *)roomId
position:(NSString *)position
ticket:(NSString *)ticket;
/// 获取麦序礼物值
/// @param completion 完成
/// @param roomUid 房间的uid
/// @param uid 用户的uid
+ (void)roomMicroGiftValue:(HttpRequestHelperCompletion)completion
roomUid:(NSString *)roomUid
uid:(NSString *)uid;
/// 开启礼物值的情况下 上麦
/// @param completion 完成
/// @param roomUid 房间的uid
/// @param micUid 上麦的uid
/// @param position 几号麦序
/// @param uid 操作者的uid
+ (void)roomGiftValueUpMic:(HttpRequestHelperCompletion)completion
roomUid:(NSString *)roomUid
micUid:(NSString *)micUid
position:(NSString *)position
uid:(NSString *)uid;
@end
NS_ASSUME_NONNULL_END

View File

@@ -68,4 +68,25 @@
[Api makeRequest:@"room/mic/downmic" method:HttpRequestHelperMethodPOST completion:complection, __FUNCTION__, micUid, roomId, position, ticket, nil];
}
///
/// @param completion
/// @param roomUid uid
/// @param uid uid
+ (void)roomMicroGiftValue:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid uid:(NSString *)uid {
[self makeRequest:@"room/gift/value/get" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, roomUid, uid, nil];
}
///
/// @param completion
/// @param roomUid uid
/// @param micUid uid
/// @param position
/// @param uid uid
+ (void)roomGiftValueUpMic:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid micUid:(NSString *)micUid position:(NSString *)position uid:(NSString *)uid {
[self makeRequest:@"room/gift/value/up/mic" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, roomUid, micUid, position, uid, nil];
}
@end

View File

@@ -177,6 +177,10 @@
self.micButton.hidden = YES;
}
}
- (void)onRoomUpdate {
self.moreButton.hidden = self.delegate.getRoomInfo.uid == [AccountInfoStorage instance].getUid.integerValue ? NO : YES;
}
#pragma mark - Getters And Setters
- (UIButton *)inputButton {
if (!_inputButton) {

View File

@@ -0,0 +1,17 @@
//
// MicroGiftValueView.h
// xplan-ios
//
// Created by 冯硕 on 2021/12/13.
//
#import "MicroView.h"
NS_ASSUME_NONNULL_BEGIN
@interface MicroGiftValueView : UIView
///当前的礼物值
@property (nonatomic,assign) long long giftValue;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,97 @@
//
// MicroGiftValueView.m
// xplan-ios
//
// Created by on 2021/12/13.
//
#import "MicroGiftValueView.h"
///Third
#import <Masonry/Masonry.h>
@interface MicroGiftValueView ()
///
@property (nonatomic, strong) UIImageView *bgImageView;
///
@property (nonatomic, strong) UIImageView *iconImageView;
///
@property (nonatomic, strong) UILabel *valueLabel;
@end
@implementation MicroGiftValueView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.bgImageView];
[self.bgImageView addSubview:self.iconImageView];
[self.bgImageView addSubview:self.valueLabel];
}
- (void)initSubViewConstraints {
[self mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.valueLabel.mas_right).offset(3);
}];
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
[self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.bgImageView).offset(3);
make.centerY.mas_equalTo(self.bgImageView);
make.width.height.mas_equalTo(8);
}];
[self.valueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.iconImageView.mas_right).offset(2);
make.centerY.mas_equalTo(self.bgImageView);
}];
}
#pragma mark - Getters And Setters
- (void)setGiftValue:(long long)giftValue {
NSString *value;
if (giftValue < 1000000) {
value = @(giftValue).stringValue;
} else if (giftValue >= 100000000) {
value = @"9999万+";
} else {
value = [NSString stringWithFormat:@"%lld万", giftValue/10000];
}
self.valueLabel.text = value;
}
- (UIImageView *)bgImageView {
if (_bgImageView == nil) {
_bgImageView = [[UIImageView alloc] init];
_bgImageView.image = [[UIImage imageNamed:@"room_position_giftValue_bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 20, 0, 50) resizingMode:UIImageResizingModeTile];
}
return _bgImageView;
}
- (UIImageView *)iconImageView {
if (_iconImageView == nil) {
_iconImageView = [[UIImageView alloc] init];
_iconImageView.image = [UIImage imageNamed:@"room_position_giftValue_heart"];
}
return _iconImageView;
}
- (UILabel *)valueLabel {
if (_valueLabel == nil) {
_valueLabel = [[UILabel alloc] init];
_valueLabel.textColor = UIColor.whiteColor;
_valueLabel.font = [UIFont systemFontOfSize:9];
_valueLabel.text = @"0";
}
return _valueLabel;
}
@end

View File

@@ -10,6 +10,7 @@
#import <Masonry/Masonry.h>
///View
#import "MicroWaveView.h"
#import "MicroGiftValueView.h"
#import "NetImageView.h"
#import "ThemeColor+Room.h"
@@ -33,6 +34,8 @@
@property (nonatomic,strong) MicroWaveView *animationView;
///
@property (nonatomic,strong) UILabel *leaveLabel;
///
@property (nonatomic,strong) MicroGiftValueView *giftValueView;
@end
@implementation MicroView
@@ -55,6 +58,7 @@
[self addSubview:self.animationView];
[self addSubview:self.avatarImageView];
[self addSubview:self.micStateImageView];
[self addSubview:self.giftValueView];
[self addSubview:self.stackView];
[self.stackView addArrangedSubview:self.postionLabel];
@@ -83,6 +87,12 @@
[self.postionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(14);
}];
[self.giftValueView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.avatarImageView.mas_right).offset(-5);
make.height.mas_equalTo(15);
make.top.mas_equalTo(self.avatarImageView);
}];
}
#pragma mark - MicroViewProtocol
@@ -148,6 +158,18 @@
}
}
- (void)configGiftValue:(long long)giftValue {
self.giftValueView.giftValue = giftValue;
}
- (void)showGiftValueMode:(BOOL)isGiftValue {
self.giftValueView.hidden = !isGiftValue;
}
- (void)resetGiftValue {
self.giftValueView.giftValue = 0;
}
#pragma mark - Getters And Setters
- (NetImageView *)avatarImageView {
if (!_avatarImageView) {
@@ -224,5 +246,12 @@
return _leaveLabel ;
}
- (MicroGiftValueView *)giftValueView {
if (!_giftValueView) {
_giftValueView = [[MicroGiftValueView alloc] init];
}
return _giftValueView;
}
@end

View File

@@ -40,6 +40,21 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)userSpeaking;
/**
* 礼物值。
*/
- (void)configGiftValue:(long long)giftValue;
/**
* 礼物值模式
*/
- (void)showGiftValueMode:(BOOL)isGiftValue;
/**
* 礼物值清零
*/
- (void)resetGiftValue;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,25 @@
//
// MicroGiftValueModel.h
// xplan-ios
//
// Created by 冯硕 on 2021/12/13.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class MicroGiftValueDetailModel;
@interface MicroGiftValueModel : NSObject
@property (nonatomic, copy) NSString *currentTime;//系统时间戳
@property (nonatomic, strong) NSArray<MicroGiftValueDetailModel *> *giftValueVos;
@end
@interface MicroGiftValueDetailModel : NSObject
///用户的uid
@property (nonatomic, copy) NSString * uid;
///礼物值
@property (nonatomic, assign) long long giftValue;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,23 @@
//
// MicroGiftValueModel.m
// xplan-ios
//
// Created by on 2021/12/13.
//
#import "MicroGiftValueModel.h"
@implementation MicroGiftValueModel
+ (NSDictionary *)objectClassInArray {
return @{@"giftValueVos":MicroGiftValueDetailModel.class};
}
@end
@implementation MicroGiftValueDetailModel
@end

View File

@@ -7,8 +7,9 @@
#import "SocialStageView.h"
#import "MicroView.h"
#import "MicroGiftValueView.h"
#import "XPMacro.h"
#import "RoomInfoModel.h"
// 58 + 5
#define ownerWidth (58 + 5)
// 12 6

View File

@@ -42,7 +42,7 @@ NS_ASSUME_NONNULL_BEGIN
@end
@interface StageView : UIView<StageViewDelegate, RoomGuestDelegate>
@property (nonatomic, weak, readonly) id<RoomHostDelegate> hostDelegate;
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate;
@end

View File

@@ -9,24 +9,28 @@
#import <Masonry/Masonry.h>
#import <NIMSDK/NIMSDK.h>
#import <ReactiveObjC/ReactiveObjC.h>
///Tool
#import "RtcManager.h"
#import "RtcDelegate.h"
#import "RoomInfoModel.h"
#import "UserInfoModel.h"
#import "MicroStateModel.h"
#import "MicroQueueModel.h"
#import "NSObject+MJExtension.h"
#import "TTPopup.h"
#import "XPMacro.h"
#import "XPGiftStorage.h"
#import "XCHudTool.h"
#import "Api.h"
#import "Api+Room.h"
#import "AccountInfoStorage.h"
#import "XPRoomMiniManager.h"
///Model
#import "RoomInfoModel.h"
#import "UserInfoModel.h"
#import "MicroStateModel.h"
#import "MicroQueueModel.h"
#import "AttachmentModel.h"
#import "GiftReceiveInfoModel.h"
#import "MicroGiftValueModel.h"
///View
#import "NetImageView.h"
#import "XPUserCardViewController.h"
#import "XPRoomMiniManager.h"
@interface StageView()<RtcDelegate>
@@ -139,6 +143,12 @@
sequence.userInfo = userInfo;
}
[self microQueueUpdated];
[Api roomMicroGiftValue:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
[self giftValueUpdate:data.data];
}
} roomUid:[NSString stringWithFormat:@"%ld", roomInfo.uid] uid:[AccountInfoStorage instance].getUid];
//
[self.hostDelegate onMicroQueueUpdate:self.micQueue];
}];
@@ -160,7 +170,7 @@
UIView<MicroViewProtocol> * view = [self findMicroViewByIndex:i];
[view configMicroView:model];
[view showLeaveMode:i == 0 && leaveMode];
if (model.userInfo == nil) [view resetGiftValue];
if (self.hostDelegate.getUserInfo.uid && model.userInfo.uid == self.hostDelegate.getUserInfo.uid) {
selfNeedBroadcast = model.microState.micState == MicroMicStateType_Open;
}
@@ -179,6 +189,17 @@
[[RtcManager instance] broadcast:selfNeedBroadcast];
}
- (void)giftValueUpdate:(NSDictionary *)dic {
MicroGiftValueModel * model = [MicroGiftValueModel modelWithDictionary:dic];
for (int i = 0; i < model.giftValueVos.count; i++) {
MicroGiftValueDetailModel * giftValueModel = [model.giftValueVos objectAtIndex:i];
UIView<MicroViewProtocol> * view = [self findMicroViewByUid:giftValueModel.uid];
if (view == nil) continue;
[view configGiftValue:giftValueModel.giftValue];
}
}
#pragma mark - RoomGuestDelegate
- (void)onRoomEntered {
[self initRtcRoom];

View File

@@ -172,6 +172,7 @@
} else {
[self.roomHeaderView onRoomUpdate];
[self.activityContainerView onRoomUpdate];
[self.menuContainerView onRoomUpdate];
if ([XPRoomMiniManager shareManager].getRoomInfo.uid != self.roomUid.integerValue) {// 退
[self.presenter enterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] user:self.userInfo];
} else {