Commit 2e3afab2 by suolong

添加buyuser刷新磨砂层

parent cebed0a8
...@@ -1496,6 +1496,8 @@ ...@@ -1496,6 +1496,8 @@
BED6590B2C5B745E00668116 /* FUSLiveChatInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = BED656082C5B745D00668116 /* FUSLiveChatInputView.m */; }; BED6590B2C5B745E00668116 /* FUSLiveChatInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = BED656082C5B745D00668116 /* FUSLiveChatInputView.m */; };
00F7AA012FA1234500AA0001 /* FUSLiveShowTimeAudienceEntryMainView.h in Headers */ = {isa = PBXBuildFile; fileRef = 00F7AA032FA1234500AA0001 /* FUSLiveShowTimeAudienceEntryMainView.h */; }; 00F7AA012FA1234500AA0001 /* FUSLiveShowTimeAudienceEntryMainView.h in Headers */ = {isa = PBXBuildFile; fileRef = 00F7AA032FA1234500AA0001 /* FUSLiveShowTimeAudienceEntryMainView.h */; };
00F7AA022FA1234500AA0001 /* FUSLiveShowTimeAudienceEntryMainView.m in Sources */ = {isa = PBXBuildFile; fileRef = 00F7AA042FA1234500AA0001 /* FUSLiveShowTimeAudienceEntryMainView.m */; }; 00F7AA022FA1234500AA0001 /* FUSLiveShowTimeAudienceEntryMainView.m in Sources */ = {isa = PBXBuildFile; fileRef = 00F7AA042FA1234500AA0001 /* FUSLiveShowTimeAudienceEntryMainView.m */; };
00F7AA082FA1234500AA0002 /* FUSLiveShowTimeAudienceEntryNoticeView.h in Headers */ = {isa = PBXBuildFile; fileRef = 00F7AA062FA1234500AA0002 /* FUSLiveShowTimeAudienceEntryNoticeView.h */; };
00F7AA092FA1234500AA0002 /* FUSLiveShowTimeAudienceEntryNoticeView.m in Sources */ = {isa = PBXBuildFile; fileRef = 00F7AA072FA1234500AA0002 /* FUSLiveShowTimeAudienceEntryNoticeView.m */; };
BED6590C2C5B745E00668116 /* FUSLiveChatToolGiftTipView.h in Headers */ = {isa = PBXBuildFile; fileRef = BED656092C5B745D00668116 /* FUSLiveChatToolGiftTipView.h */; }; BED6590C2C5B745E00668116 /* FUSLiveChatToolGiftTipView.h in Headers */ = {isa = PBXBuildFile; fileRef = BED656092C5B745D00668116 /* FUSLiveChatToolGiftTipView.h */; };
BED6590D2C5B745E00668116 /* FUSLiveChatToolGiftTipView.m in Sources */ = {isa = PBXBuildFile; fileRef = BED6560A2C5B745D00668116 /* FUSLiveChatToolGiftTipView.m */; }; BED6590D2C5B745E00668116 /* FUSLiveChatToolGiftTipView.m in Sources */ = {isa = PBXBuildFile; fileRef = BED6560A2C5B745D00668116 /* FUSLiveChatToolGiftTipView.m */; };
BED6590E2C5B745E00668116 /* FUSLiveShareView.h in Headers */ = {isa = PBXBuildFile; fileRef = BED6560B2C5B745D00668116 /* FUSLiveShareView.h */; }; BED6590E2C5B745E00668116 /* FUSLiveShareView.h in Headers */ = {isa = PBXBuildFile; fileRef = BED6560B2C5B745D00668116 /* FUSLiveShareView.h */; };
...@@ -3922,6 +3924,8 @@ ...@@ -3922,6 +3924,8 @@
BED656082C5B745D00668116 /* FUSLiveChatInputView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSLiveChatInputView.m; sourceTree = "<group>"; }; BED656082C5B745D00668116 /* FUSLiveChatInputView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSLiveChatInputView.m; sourceTree = "<group>"; };
00F7AA032FA1234500AA0001 /* FUSLiveShowTimeAudienceEntryMainView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSLiveShowTimeAudienceEntryMainView.h; sourceTree = "<group>"; }; 00F7AA032FA1234500AA0001 /* FUSLiveShowTimeAudienceEntryMainView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSLiveShowTimeAudienceEntryMainView.h; sourceTree = "<group>"; };
00F7AA042FA1234500AA0001 /* FUSLiveShowTimeAudienceEntryMainView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSLiveShowTimeAudienceEntryMainView.m; sourceTree = "<group>"; }; 00F7AA042FA1234500AA0001 /* FUSLiveShowTimeAudienceEntryMainView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSLiveShowTimeAudienceEntryMainView.m; sourceTree = "<group>"; };
00F7AA062FA1234500AA0002 /* FUSLiveShowTimeAudienceEntryNoticeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSLiveShowTimeAudienceEntryNoticeView.h; sourceTree = "<group>"; };
00F7AA072FA1234500AA0002 /* FUSLiveShowTimeAudienceEntryNoticeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSLiveShowTimeAudienceEntryNoticeView.m; sourceTree = "<group>"; };
BED656092C5B745D00668116 /* FUSLiveChatToolGiftTipView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSLiveChatToolGiftTipView.h; sourceTree = "<group>"; }; BED656092C5B745D00668116 /* FUSLiveChatToolGiftTipView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSLiveChatToolGiftTipView.h; sourceTree = "<group>"; };
BED6560A2C5B745D00668116 /* FUSLiveChatToolGiftTipView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSLiveChatToolGiftTipView.m; sourceTree = "<group>"; }; BED6560A2C5B745D00668116 /* FUSLiveChatToolGiftTipView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSLiveChatToolGiftTipView.m; sourceTree = "<group>"; };
BED6560B2C5B745D00668116 /* FUSLiveShareView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSLiveShareView.h; sourceTree = "<group>"; }; BED6560B2C5B745D00668116 /* FUSLiveShareView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSLiveShareView.h; sourceTree = "<group>"; };
...@@ -6949,6 +6953,8 @@ ...@@ -6949,6 +6953,8 @@
children = ( children = (
00F7AA032FA1234500AA0001 /* FUSLiveShowTimeAudienceEntryMainView.h */, 00F7AA032FA1234500AA0001 /* FUSLiveShowTimeAudienceEntryMainView.h */,
00F7AA042FA1234500AA0001 /* FUSLiveShowTimeAudienceEntryMainView.m */, 00F7AA042FA1234500AA0001 /* FUSLiveShowTimeAudienceEntryMainView.m */,
00F7AA062FA1234500AA0002 /* FUSLiveShowTimeAudienceEntryNoticeView.h */,
00F7AA072FA1234500AA0002 /* FUSLiveShowTimeAudienceEntryNoticeView.m */,
); );
path = ShowTimeAudienceEntry; path = ShowTimeAudienceEntry;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -9182,6 +9188,7 @@ ...@@ -9182,6 +9188,7 @@
BED658A92C5B745E00668116 /* FUSVideoEndedView.h in Headers */, BED658A92C5B745E00668116 /* FUSVideoEndedView.h in Headers */,
BED6590A2C5B745E00668116 /* FUSLiveChatInputView.h in Headers */, BED6590A2C5B745E00668116 /* FUSLiveChatInputView.h in Headers */,
00F7AA012FA1234500AA0001 /* FUSLiveShowTimeAudienceEntryMainView.h in Headers */, 00F7AA012FA1234500AA0001 /* FUSLiveShowTimeAudienceEntryMainView.h in Headers */,
00F7AA082FA1234500AA0002 /* FUSLiveShowTimeAudienceEntryNoticeView.h in Headers */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -10984,6 +10991,7 @@ ...@@ -10984,6 +10991,7 @@
BED65A992C5B745F00668116 /* FUSLiveManagerCell.m in Sources */, BED65A992C5B745F00668116 /* FUSLiveManagerCell.m in Sources */,
BED6590B2C5B745E00668116 /* FUSLiveChatInputView.m in Sources */, BED6590B2C5B745E00668116 /* FUSLiveChatInputView.m in Sources */,
00F7AA022FA1234500AA0001 /* FUSLiveShowTimeAudienceEntryMainView.m in Sources */, 00F7AA022FA1234500AA0001 /* FUSLiveShowTimeAudienceEntryMainView.m in Sources */,
00F7AA092FA1234500AA0002 /* FUSLiveShowTimeAudienceEntryNoticeView.m in Sources */,
00E6CB272F4E9AB800B63797 /* FUSLiveReleasePunishmentView.m in Sources */, 00E6CB272F4E9AB800B63797 /* FUSLiveReleasePunishmentView.m in Sources */,
00E6CB282F4E9AB800B63797 /* FUSLiveGlobalSpecialEffectView.m in Sources */, 00E6CB282F4E9AB800B63797 /* FUSLiveGlobalSpecialEffectView.m in Sources */,
00E6CB292F4E9AB800B63797 /* FUSLivePunishListCell.m in Sources */, 00E6CB292F4E9AB800B63797 /* FUSLivePunishListCell.m in Sources */,
...@@ -1013,14 +1013,34 @@ static NSString *const KLiveDataCenter_store_liveRTCData = @"LiveDataCenter_stor ...@@ -1013,14 +1013,34 @@ static NSString *const KLiveDataCenter_store_liveRTCData = @"LiveDataCenter_stor
[self.liveVC destroyPlayPictureInPicture]; [self.liveVC destroyPlayPictureInPicture];
} }
UIView *rootView = self.liveVC.view ?: [UIViewController fus_topViewController].view; UIView *rootView = self.liveVC.view ?: [UIViewController fus_topViewController].view;
__weak typeof(self) weakSelf = self;
__block FUSTicketShowCollectTicketToggleResultModel *buyGetDataModel = nil;
NSString *channelId = [[errorDict[@"channelId"] description] ?: @"" copy];
NSString *roundId = [[errorDict[@"roundId"] description] ?: @"" copy];
__block __weak FUSLiveShowTimeAudienceEntryMainView *weakEntryView = nil;
FUSLiveShowTimeAudienceEntryMainView *entry = [FUSLiveShowTimeAudienceEntryMainView fus_showOnView:rootView actionHandler:^(FUSLiveShowTimeAudienceEntryMainViewAction action, NSInteger selectedOptionIndex) { FUSLiveShowTimeAudienceEntryMainView *entry = [FUSLiveShowTimeAudienceEntryMainView fus_showOnView:rootView actionHandler:^(FUSLiveShowTimeAudienceEntryMainViewAction action, NSInteger selectedOptionIndex) {
__strong typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf) {
return;
}
if (action == FUSLiveShowTimeAudienceEntryMainViewActionDismiss) { if (action == FUSLiveShowTimeAudienceEntryMainViewActionDismiss) {
[FUSLiveHelper fus_quitLiveWithCompletion:nil]; [FUSLiveHelper fus_quitLiveWithCompletion:nil];
return;
}
if (action == FUSLiveShowTimeAudienceEntryMainViewActionEnter) {
if (!buyGetDataModel) {
[FUSDialogView fus_showDialog:[NSString fus_localString:@"数据加载中,请稍后"]];
return;
}
NSInteger buyNum = [strongSelf fus_ticketShowBuyNumWithBuyGetDataModel:buyGetDataModel selectedOptionIndex:selectedOptionIndex];
[strongSelf fus_requestTicketShowUserBuyAndEnterRoomWithRoomId:currentRoomId channelId:channelId roundId:roundId buyNum:buyNum entryView:weakEntryView password:password behaviorSrc:behaviorSrc otherInfo:otherInfo];
return;
} }
}]; }];
NSString *channelId = [[errorDict[@"channelId"] description] ?: @"" copy]; weakEntryView = entry;
NSString *roundId = [[errorDict[@"roundId"] description] ?: @"" copy]; [self fus_requestTicketShowBuyGetDataAndFillEntry:entry roomId:currentRoomId channelId:channelId roundId:roundId completion:^(FUSTicketShowCollectTicketToggleResultModel * _Nullable model) {
[self fus_requestTicketShowBuyGetDataAndFillEntry:entry roomId:currentRoomId channelId:channelId roundId:roundId]; buyGetDataModel = model;
}];
}); });
return; return;
} else { } else {
...@@ -1046,6 +1066,15 @@ static NSString *const KLiveDataCenter_store_liveRTCData = @"LiveDataCenter_stor ...@@ -1046,6 +1066,15 @@ static NSString *const KLiveDataCenter_store_liveRTCData = @"LiveDataCenter_stor
channelId:(NSString *)channelId channelId:(NSString *)channelId
roundId:(NSString *)roundId roundId:(NSString *)roundId
{ {
[self fus_requestTicketShowBuyGetDataAndFillEntry:entry roomId:roomId channelId:channelId roundId:roundId completion:nil];
}
- (void)fus_requestTicketShowBuyGetDataAndFillEntry:(FUSLiveShowTimeAudienceEntryMainView *)entry
roomId:(NSString *)roomId
channelId:(NSString *)channelId
roundId:(NSString *)roundId
completion:(void (^ _Nullable)(FUSTicketShowCollectTicketToggleResultModel * _Nullable model))completion
{
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
[FUSLiveHttpHelper fus_ticketShowBuyGetDataWithRoomId:(roomId ?: @"") [FUSLiveHttpHelper fus_ticketShowBuyGetDataWithRoomId:(roomId ?: @"")
channelId:([NSString isNull:channelId] ? @"" : channelId) channelId:([NSString isNull:channelId] ? @"" : channelId)
...@@ -1054,10 +1083,75 @@ static NSString *const KLiveDataCenter_store_liveRTCData = @"LiveDataCenter_stor ...@@ -1054,10 +1083,75 @@ static NSString *const KLiveDataCenter_store_liveRTCData = @"LiveDataCenter_stor
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
NSString *anchorFace = [[weakSelf.roomInfoModel.face description] length] > 0 ? [weakSelf.roomInfoModel.face description] : @""; NSString *anchorFace = [[weakSelf.roomInfoModel.face description] length] > 0 ? [weakSelf.roomInfoModel.face description] : @"";
[entry fus_updateWithBuyGetDataModel:model anchorFacePath:anchorFace]; [entry fus_updateWithBuyGetDataModel:model anchorFacePath:anchorFace];
if (completion) {
completion(model);
}
}); });
} failure:^(NSString *msg, NSInteger code) { } failure:^(NSString *msg, NSInteger code) {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[FUSDialogView fus_showDialog:(msg ?: @"")]; [FUSDialogView fus_showDialog:(msg ?: @"")];
if (completion) {
completion(nil);
}
});
}];
}
- (NSInteger)fus_ticketShowBuyNumWithBuyGetDataModel:(FUSTicketShowCollectTicketToggleResultModel *)model
selectedOptionIndex:(NSInteger)selectedOptionIndex
{
if (!model) {
return 0;
}
NSInteger option = MAX(0, selectedOptionIndex);
if (option == 0) {
return MAX(1, model.directBuyNum);
}
if (option == 1) {
return MAX(1, model.showStrengthNum);
}
if (option == 2) {
return MAX(1, model.mvpBuyNum);
}
return MAX(1, model.directBuyNum);
}
- (void)fus_requestTicketShowUserBuyAndEnterRoomWithRoomId:(NSString *)roomId
channelId:(NSString *)channelId
roundId:(NSString *)roundId
buyNum:(NSInteger)buyNum
entryView:(FUSLiveShowTimeAudienceEntryMainView *)entryView
password:(NSString *)password
behaviorSrc:(NSString *)behaviorSrc
otherInfo:(NSDictionary * __nullable)otherInfo
{
if ([NSString isNull:roomId] || [NSString isNull:channelId] || [NSString isNull:roundId] || buyNum <= 0) {
[FUSDialogView fus_showDialog:[NSString fus_localString:@"当前房间信息异常"]];
return;
}
[FUSLoadingView fus_showProgressViewWithMessage:@""];
__weak typeof(self) weakSelf = self;
__weak FUSLiveShowTimeAudienceEntryMainView *weakEntryView = entryView;
[FUSLiveHttpHelper fus_ticketShowUserBuyWithRoomId:(roomId ?: @"")
channelId:(channelId ?: @"")
roundId:(roundId ?: @"")
num:buyNum
succeed:^(FUSTicketShowUserBuyResultModel *model) {
dispatch_async(dispatch_get_main_queue(), ^{
[FUSLoadingView fus_dismissProgressView];
[weakEntryView fus_dismissAnimated:YES];
[weakSelf fus_audienceJoinRoomWithRoomId:(roomId ?: @"") password:(password ?: @"") behaviorSrc:(behaviorSrc ?: @"") otherInfo:otherInfo];
});
} failure:^(NSString *msg, NSInteger code) {
dispatch_async(dispatch_get_main_queue(), ^{
[FUSLoadingView fus_dismissProgressView];
if (![NSString isNull:msg]) {
[FUSDialogView fus_showDialog:msg];
} else {
[FUSDialogView fus_showDialog:[NSString fus_localString:@"请求失败"]];
}
}); });
}]; }];
} }
......
...@@ -3208,7 +3208,19 @@ ...@@ -3208,7 +3208,19 @@
}; };
[FUSHttpHelper postRequestBinaryWithUrl:FUSShowRoomURLs.fus_URL_TicketShow_Progress_GetInfo params:params success:^(NSDictionary * _Nullable dataDict, int code) { [FUSHttpHelper postRequestBinaryWithUrl:FUSShowRoomURLs.fus_URL_TicketShow_Progress_GetInfo params:params success:^(NSDictionary * _Nullable dataDict, int code) {
FUSTicketShowCollectTicketToggleResultModel *model = [FUSTicketShowCollectTicketToggleResultModel fus_modelWithDict:dataDict]; NSDictionary *payload = ([dataDict[@"data"] isKindOfClass:NSDictionary.class] ? dataDict[@"data"] : dataDict);
FUSTicketShowCollectTicketToggleResultModel *model = [FUSTicketShowCollectTicketToggleResultModel fus_modelWithDict:(payload ?: @{})];
NSDictionary *lastInfo = ([payload[@"lastInfo"] isKindOfClass:NSDictionary.class] ? payload[@"lastInfo"] : ( [dataDict[@"lastInfo"] isKindOfClass:NSDictionary.class] ? dataDict[@"lastInfo"] : nil ));
if (lastInfo) {
id buyNumObj = lastInfo[@"buyNum"];
if ([buyNumObj respondsToSelector:@selector(integerValue)]) {
model.buyNum = [buyNumObj integerValue];
}
NSDictionary *buyUserDict = ([lastInfo[@"buyUser"] isKindOfClass:NSDictionary.class] ? lastInfo[@"buyUser"] : nil);
if (buyUserDict) {
model.buyUser = [FUSOnlineUserModel fus_modelWithDict:buyUserDict];
}
}
if (succeed) succeed(model); if (succeed) succeed(model);
} failure:^(NSDictionary * _Nullable dataDict, int code) { } failure:^(NSDictionary * _Nullable dataDict, int code) {
if (failure) failure(dataDict[@"msg"], code); if (failure) failure(dataDict[@"msg"], code);
......
...@@ -1777,8 +1777,10 @@ ...@@ -1777,8 +1777,10 @@
countdownTotalSeconds:totalSeconds countdownTotalSeconds:totalSeconds
countdownRemainingSeconds:remainSeconds countdownRemainingSeconds:remainSeconds
newTicketCount:0 newTicketCount:0
giftUserModel:model.buyUser giftUserModel:nil
mvpUserModel:model.mvpInfo.mvpUserInfo]; mvpUserModel:model.mvpInfo.mvpUserInfo];
[currentBar fus_updateTopTicketInfoWithGiftUserModel:model.buyUser newTicketCount:MAX(0, model.buyNum)];
}); });
} failure:^(NSString * _Nonnull msg, NSInteger code) { } failure:^(NSString * _Nonnull msg, NSInteger code) {
}]; }];
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#import "FUSShowRoomCenterBunble.h" #import "FUSShowRoomCenterBunble.h"
#import "FUSTicketShowCollectTicketToggleResultModel.h" #import "FUSTicketShowCollectTicketToggleResultModel.h"
#import "CBAutoScrollLabel.h" #import "CBAutoScrollLabel.h"
#import "FUSLiveShowTimeAudienceEntryNoticeView.h"
/// 复用同类弹窗实例,避免重复叠加遮罩导致触摸穿透/层级错乱 /// 复用同类弹窗实例,避免重复叠加遮罩导致触摸穿透/层级错乱
static NSInteger const kFUSLiveShowTimeAudienceEntryMainViewTag = 90917002; static NSInteger const kFUSLiveShowTimeAudienceEntryMainViewTag = 90917002;
...@@ -655,9 +656,8 @@ NSString * const FUSLiveShowTimeAudienceEntryTicketOptionTagTextKey = @"tagText" ...@@ -655,9 +656,8 @@ NSString * const FUSLiveShowTimeAudienceEntryTicketOptionTagTextKey = @"tagText"
} }
- (void)fus_onTapNotice { - (void)fus_onTapNotice {
if (self.actionHandler) { [FUSLiveShowTimeAudienceEntryNoticeView showOnView:self];
self.actionHandler(FUSLiveShowTimeAudienceEntryMainViewActionNotice, self.selectedOptionIndex); if (self.actionHandler) self.actionHandler(FUSLiveShowTimeAudienceEntryMainViewActionNotice, self.selectedOptionIndex);
}
} }
@end @end
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface FUSLiveShowTimeAudienceEntryNoticeView : UIView
+ (instancetype)showOnView:(UIView *)rootView;
- (void)dismissAnimated:(BOOL)animated;
@end
NS_ASSUME_NONNULL_END
#import "FUSLiveShowTimeAudienceEntryNoticeView.h"
#import <Masonry/Masonry.h>
#import <FUSFoundation/FUSFoundation.h>
#import "FUSShowRoomCenterBunble.h"
static NSInteger const kFUSLiveShowTimeAudienceEntryNoticeViewTag = 90917003;
@interface FUSLiveShowTimeAudienceEntryNoticeView ()
@property (nonatomic, strong) UIButton *bgBtn;
@property (nonatomic, strong) UIView *cardView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *contentLabel;
@property (nonatomic, strong) UIButton *confirmButton;
@end
@implementation FUSLiveShowTimeAudienceEntryNoticeView
+ (instancetype)showOnView:(UIView *)rootView {
if (!rootView) return nil;
FUSLiveShowTimeAudienceEntryNoticeView *exist = [rootView viewWithTag:kFUSLiveShowTimeAudienceEntryNoticeViewTag];
if ([exist isKindOfClass:FUSLiveShowTimeAudienceEntryNoticeView.class]) {
[rootView bringSubviewToFront:exist];
[exist showAnimated:YES];
return exist;
}
FUSLiveShowTimeAudienceEntryNoticeView *view = [[FUSLiveShowTimeAudienceEntryNoticeView alloc] initWithFrame:CGRectZero];
view.tag = kFUSLiveShowTimeAudienceEntryNoticeViewTag;
[rootView addSubview:view];
[view mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(rootView);
}];
[view showAnimated:YES];
return view;
}
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (!self) return nil;
[self buildUI];
return self;
}
- (void)buildUI {
self.alpha = 0;
self.backgroundColor = UIColor.clearColor;
self.bgBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.bgBtn.backgroundColor = [UIColor colorWithWhite:0 alpha:0.55];
[self.bgBtn addTarget:self action:@selector(onTapBackground) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:self.bgBtn];
self.cardView = [[UIView alloc] initWithFrame:CGRectZero];
self.cardView.backgroundColor = UIColor.whiteColor;
self.cardView.layer.cornerRadius = 16;
self.cardView.layer.masksToBounds = YES;
[self addSubview:self.cardView];
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
self.titleLabel.font = [UIFont fus_themeMediumFont:17];
self.titleLabel.textColor = [UIColor colorWithHex:@"#2A2A2A"];
self.titleLabel.textAlignment = NSTextAlignmentCenter;
self.titleLabel.text = [NSString fus_localString:@"活動須知"];
[self.cardView addSubview:self.titleLabel];
self.contentLabel = [[UILabel alloc] initWithFrame:CGRectZero];
self.contentLabel.font = [UIFont fus_themeFont:14];
self.contentLabel.textColor = [UIColor colorWithHex:@"#2A2A2A"];
self.contentLabel.numberOfLines = 0;
self.contentLabel.textAlignment = NSTextAlignmentLeft;
NSString *text = @"本活動由主播個人主辦,詳細活動辦法與內容請洽詢主播。集票達成或未達成主播自願表演,本活動才算成立;若集票未達成且主播不願意表演,則活動取消,並退回寶石。若活動已經開始表演,請注意剩餘時間,確保你不會錯過精彩表演時刻。本平台保有活動說明的權利,可隨時修改、變更及解釋活動之權利。";
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
style.lineSpacing = 4;
style.alignment = NSTextAlignmentLeft;
NSAttributedString *attr = [[NSAttributedString alloc] initWithString:text attributes:@{
NSFontAttributeName: self.contentLabel.font,
NSForegroundColorAttributeName: self.contentLabel.textColor,
NSParagraphStyleAttributeName: style
}];
self.contentLabel.attributedText = attr;
[self.cardView addSubview:self.contentLabel];
self.confirmButton = [UIButton buttonWithType:UIButtonTypeCustom];
self.confirmButton.titleLabel.font = [UIFont fus_themeMediumFont:15];
[self.confirmButton setTitle:[NSString fus_localString:@"確認"] forState:UIControlStateNormal];
[self.confirmButton setTitleColor:[UIColor colorWithHex:@"#003333"] forState:UIControlStateNormal];
self.confirmButton.backgroundColor = [UIColor colorWithRed:(45.0 / 255.0) green:(226.0 / 255.0) blue:(224.0 / 255.0) alpha:1.0];
self.confirmButton.layer.cornerRadius = 22;
self.confirmButton.layer.masksToBounds = YES;
[self.confirmButton addTarget:self action:@selector(onTapConfirm) forControlEvents:UIControlEventTouchUpInside];
[self.cardView addSubview:self.confirmButton];
[self.bgBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
[self.cardView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self);
make.width.mas_equalTo(285);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.cardView).offset(18);
make.left.equalTo(self.cardView).offset(20);
make.right.equalTo(self.cardView).offset(-20);
make.height.mas_equalTo(22);
}];
[self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.titleLabel.mas_bottom).offset(12);
make.left.equalTo(self.cardView).offset(20);
make.right.equalTo(self.cardView).offset(-20);
}];
[self.confirmButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentLabel.mas_bottom).offset(18);
make.left.equalTo(self.cardView).offset(20);
make.right.equalTo(self.cardView).offset(-20);
make.height.mas_equalTo(44);
make.bottom.equalTo(self.cardView).offset(-14);
}];
}
- (void)showAnimated:(BOOL)animated {
if (!animated) {
self.alpha = 1;
self.cardView.transform = CGAffineTransformIdentity;
return;
}
self.alpha = 0;
self.cardView.transform = CGAffineTransformMakeScale(0.98, 0.98);
__weak typeof(self) weakSelf = self;
[UIView animateWithDuration:0.25 animations:^{
weakSelf.alpha = 1;
weakSelf.cardView.transform = CGAffineTransformIdentity;
}];
}
- (void)onTapBackground {
[self dismissAnimated:YES];
}
- (void)onTapConfirm {
[self dismissAnimated:YES];
}
- (void)dismissAnimated:(BOOL)animated {
if (!self.superview) return;
if (!animated) {
[self removeFromSuperview];
return;
}
__weak typeof(self) weakSelf = self;
[UIView animateWithDuration:0.25 animations:^{
weakSelf.alpha = 0;
weakSelf.cardView.transform = CGAffineTransformMakeScale(0.98, 0.98);
} completion:^(BOOL finished) {
[weakSelf removeFromSuperview];
}];
}
@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