Files
peko-ios/YuMi/Modules/YMRoom/View/SendGiftView/GiftComboManager.h

139 lines
4.1 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// GiftComboManager.h
// YuMi
//
// Created by P on 2024/9/5.
//
#import <Foundation/Foundation.h>
#import "GiftInfoModel.h"
#import "GiftComboView.h"
@class GiftReceiveInfoModel, UserInfoModel, GiftReceiveInfoModel, XPGiftCountModel;
typedef enum : NSUInteger {
ComboAction_ShowPanel,
ComboAction_RemovePanel,
ComboAction_Error,
ComboAction_Combo_Count_Update,
ComboAction_Update_After_Send_Success,
ComboAction_SendGift_Gold_Update
} ComboActionType;
typedef enum : NSUInteger {
ComboFlagAction_,
// ComboAction_RemovePanel,
// ComboAction_Combo_Count_Update,
} ComboFlagActionType;
// 通知常量定义
UIKIT_EXTERN NSString * _Nonnull const kBoomStateForceResetNotification;
NS_ASSUME_NONNULL_BEGIN
@interface GiftComboManager : NSObject
@property (nonatomic, assign, readonly) BOOL enableCombo;
//@property(nonatomic, strong, nullable) GiftComboView *comboView;
@property (nonatomic, strong) GiftReceiveInfoModel *sendGiftReceiveInfo;
@property(nonatomic, copy) void(^handleComboSuccess)(GiftReceiveInfoModel *receiveModel, NSMutableDictionary *originDic);
@property(nonatomic, copy) void(^handleRoomUIChanged)(BOOL comboViewDisplay);
// 单例方法
+ (instancetype)sharedManager;
- (void)registerActions:(void(^ _Nullable)(ComboActionType type))action;
#pragma mark - 新的简化接口
// 状态管理
- (void)activate; // 激活连击功能
- (void)deactivate; // 停用连击功能
- (BOOL)isActive; // 检查是否激活
// 计数管理
- (NSInteger)currentCount; // 获取当前连击计数
- (void)incrementCount; // 增加连击计数
- (void)reset; // 重置连击状态
// 操作控制
- (void)clear; // 清除连击状态
- (void)send; // 发送连击礼物
// 状态查询
- (NSDictionary * _Nonnull)stateInfo; // 获取完整状态信息
- (BOOL)canStartCombo; // 检查是否可以开始连击
- (void)validateState; // 验证并修复状态
// 错误处理
- (void)handleError:(NSError * _Nonnull)error;
- (NSString * _Nonnull)lastErrorMessage;
- (void)clearError;
- (void)sendGift;
- (void)forceBoomStateReset;
- (BOOL)loadEnable;
- (NSInteger)loadTotalGiftNum;
// 统一配置方法替代多个save方法
- (void)configureWithGiftInfo:(GiftInfoModel * _Nonnull)giftInfo
targetUIDs:(NSArray * _Nonnull)UIDs
roomUID:(NSString * _Nonnull)roomUID
sessionID:(NSString * _Nonnull)sessionID
userInfo:(UserInfoModel * _Nonnull)userInfo
countModel:(XPGiftCountModel * _Nonnull)countModel
sourceType:(GiftSourceType)sourceType
sendType:(RoomSendGiftType)sendType
giftNum:(NSString * _Nonnull)giftNum;
// 新增:连击状态检查方法
- (BOOL)isComboStateValid;
- (NSDictionary * _Nonnull)getComboStateInfo;
// 🔧 新增:状态通知方法
- (void)setUserComboState:(BOOL)isCombo forUser:(NSString *)uid;
- (void)clearUserComboState:(NSString *)uid;
#pragma mark - 使用示例
/*
新的简化接口使用示例:
// 1. 激活连击功能
[[GiftComboManager sharedManager] activate];
// 2. 重置连击状态
[[GiftComboManager sharedManager] reset];
// 3. 增加连击计数
[[GiftComboManager sharedManager] incrementCount];
// 4. 获取当前状态
NSDictionary *state = [[GiftComboManager sharedManager] stateInfo];
// 5. 清除连击状态
[[GiftComboManager sharedManager] clear];
迁移建议:
- enableToCombo:YES -> activate
- enableToCombo:NO -> deactivate
- resetCombo -> reset
- forceRemove -> clear
- loadComboCount -> currentCount
- loadComboCountFromSendGiftView -> incrementCount
- isGiftCombing -> isActive
*/
- (NSString * _Nonnull)loadErrorMessage;
- (void)receiveGiftInfoForDisplayComboFlags:(GiftReceiveInfoModel * _Nonnull)receiveInfo
container:(UIView * _Nonnull)container;
- (void)removeComboFlag;
@end
NS_ASSUME_NONNULL_END