Commit c4be54a1 by suolong

添加限时表演弹窗

parent 7f1f2d50
Showing with 489 additions and 2 deletions
...@@ -1433,6 +1433,8 @@ ...@@ -1433,6 +1433,8 @@
BED658F22C5B745E00668116 /* FUSLiveBottomToolManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BED655EF2C5B745D00668116 /* FUSLiveBottomToolManager.m */; }; BED658F22C5B745E00668116 /* FUSLiveBottomToolManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BED655EF2C5B745D00668116 /* FUSLiveBottomToolManager.m */; };
BED658F32C5B745E00668116 /* FUSLiveBottomToolSubView.h in Headers */ = {isa = PBXBuildFile; fileRef = BED655F02C5B745D00668116 /* FUSLiveBottomToolSubView.h */; }; BED658F32C5B745E00668116 /* FUSLiveBottomToolSubView.h in Headers */ = {isa = PBXBuildFile; fileRef = BED655F02C5B745D00668116 /* FUSLiveBottomToolSubView.h */; };
BED658F42C5B745E00668116 /* FUSLiveBottomToolSubView.m in Sources */ = {isa = PBXBuildFile; fileRef = BED655F12C5B745D00668116 /* FUSLiveBottomToolSubView.m */; }; BED658F42C5B745E00668116 /* FUSLiveBottomToolSubView.m in Sources */ = {isa = PBXBuildFile; fileRef = BED655F12C5B745D00668116 /* FUSLiveBottomToolSubView.m */; };
BEF6C0A72F0A1B2C0033D4E5 /* FUSLiveShowTimePopView.h in Headers */ = {isa = PBXBuildFile; fileRef = BEF6C0A52F0A1B2C0033D4E5 /* FUSLiveShowTimePopView.h */; };
BEF6C0A82F0A1B2C0033D4E5 /* FUSLiveShowTimePopView.m in Sources */ = {isa = PBXBuildFile; fileRef = BEF6C0A62F0A1B2C0033D4E5 /* FUSLiveShowTimePopView.m */; };
BED658F52C5B745E00668116 /* FUSLiveBottomToolView.h in Headers */ = {isa = PBXBuildFile; fileRef = BED655F22C5B745D00668116 /* FUSLiveBottomToolView.h */; }; BED658F52C5B745E00668116 /* FUSLiveBottomToolView.h in Headers */ = {isa = PBXBuildFile; fileRef = BED655F22C5B745D00668116 /* FUSLiveBottomToolView.h */; };
BED658F62C5B745E00668116 /* FUSLiveBottomToolView.m in Sources */ = {isa = PBXBuildFile; fileRef = BED655F32C5B745D00668116 /* FUSLiveBottomToolView.m */; }; BED658F62C5B745E00668116 /* FUSLiveBottomToolView.m in Sources */ = {isa = PBXBuildFile; fileRef = BED655F32C5B745D00668116 /* FUSLiveBottomToolView.m */; };
BED658F72C5B745E00668116 /* FUSLiveChatFastInputCell.h in Headers */ = {isa = PBXBuildFile; fileRef = BED655F42C5B745D00668116 /* FUSLiveChatFastInputCell.h */; }; BED658F72C5B745E00668116 /* FUSLiveChatFastInputCell.h in Headers */ = {isa = PBXBuildFile; fileRef = BED655F42C5B745D00668116 /* FUSLiveChatFastInputCell.h */; };
...@@ -3814,6 +3816,8 @@ ...@@ -3814,6 +3816,8 @@
BED655EF2C5B745D00668116 /* FUSLiveBottomToolManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSLiveBottomToolManager.m; sourceTree = "<group>"; }; BED655EF2C5B745D00668116 /* FUSLiveBottomToolManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSLiveBottomToolManager.m; sourceTree = "<group>"; };
BED655F02C5B745D00668116 /* FUSLiveBottomToolSubView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSLiveBottomToolSubView.h; sourceTree = "<group>"; }; BED655F02C5B745D00668116 /* FUSLiveBottomToolSubView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSLiveBottomToolSubView.h; sourceTree = "<group>"; };
BED655F12C5B745D00668116 /* FUSLiveBottomToolSubView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSLiveBottomToolSubView.m; sourceTree = "<group>"; }; BED655F12C5B745D00668116 /* FUSLiveBottomToolSubView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSLiveBottomToolSubView.m; sourceTree = "<group>"; };
BEF6C0A52F0A1B2C0033D4E5 /* FUSLiveShowTimePopView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSLiveShowTimePopView.h; sourceTree = "<group>"; };
BEF6C0A62F0A1B2C0033D4E5 /* FUSLiveShowTimePopView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSLiveShowTimePopView.m; sourceTree = "<group>"; };
BED655F22C5B745D00668116 /* FUSLiveBottomToolView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSLiveBottomToolView.h; sourceTree = "<group>"; }; BED655F22C5B745D00668116 /* FUSLiveBottomToolView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSLiveBottomToolView.h; sourceTree = "<group>"; };
BED655F32C5B745D00668116 /* FUSLiveBottomToolView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSLiveBottomToolView.m; sourceTree = "<group>"; }; BED655F32C5B745D00668116 /* FUSLiveBottomToolView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUSLiveBottomToolView.m; sourceTree = "<group>"; };
BED655F42C5B745D00668116 /* FUSLiveChatFastInputCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSLiveChatFastInputCell.h; sourceTree = "<group>"; }; BED655F42C5B745D00668116 /* FUSLiveChatFastInputCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUSLiveChatFastInputCell.h; sourceTree = "<group>"; };
...@@ -6762,6 +6766,8 @@ ...@@ -6762,6 +6766,8 @@
BED655EF2C5B745D00668116 /* FUSLiveBottomToolManager.m */, BED655EF2C5B745D00668116 /* FUSLiveBottomToolManager.m */,
BED655F02C5B745D00668116 /* FUSLiveBottomToolSubView.h */, BED655F02C5B745D00668116 /* FUSLiveBottomToolSubView.h */,
BED655F12C5B745D00668116 /* FUSLiveBottomToolSubView.m */, BED655F12C5B745D00668116 /* FUSLiveBottomToolSubView.m */,
BEF6C0A52F0A1B2C0033D4E5 /* FUSLiveShowTimePopView.h */,
BEF6C0A62F0A1B2C0033D4E5 /* FUSLiveShowTimePopView.m */,
BED655F22C5B745D00668116 /* FUSLiveBottomToolView.h */, BED655F22C5B745D00668116 /* FUSLiveBottomToolView.h */,
BED655F32C5B745D00668116 /* FUSLiveBottomToolView.m */, BED655F32C5B745D00668116 /* FUSLiveBottomToolView.m */,
BED655F42C5B745D00668116 /* FUSLiveChatFastInputCell.h */, BED655F42C5B745D00668116 /* FUSLiveChatFastInputCell.h */,
...@@ -8606,6 +8612,7 @@ ...@@ -8606,6 +8612,7 @@
files = ( files = (
BED65B0A2C5B746000668116 /* FUSOpenScreenPushHelp.h in Headers */, BED65B0A2C5B746000668116 /* FUSOpenScreenPushHelp.h in Headers */,
BED658F32C5B745E00668116 /* FUSLiveBottomToolSubView.h in Headers */, BED658F32C5B745E00668116 /* FUSLiveBottomToolSubView.h in Headers */,
BEF6C0A72F0A1B2C0033D4E5 /* FUSLiveShowTimePopView.h in Headers */,
00B28CBA2D2FC4E10008476B /* FUSLiveEndLiveAssesModel.h in Headers */, 00B28CBA2D2FC4E10008476B /* FUSLiveEndLiveAssesModel.h in Headers */,
BE189DDF2C733B460008418B /* FSRRoomManagerViewController.h in Headers */, BE189DDF2C733B460008418B /* FSRRoomManagerViewController.h in Headers */,
BED65A442C5B745F00668116 /* FUSLiveBoxDetailSettingView.h in Headers */, BED65A442C5B745F00668116 /* FUSLiveBoxDetailSettingView.h in Headers */,
...@@ -10673,6 +10680,7 @@ ...@@ -10673,6 +10680,7 @@
BED659C02C5B745F00668116 /* FUSEmitterView.m in Sources */, BED659C02C5B745F00668116 /* FUSEmitterView.m in Sources */,
BE189DBC2C733B460008418B /* FSRSettingRoomGuarderOnlineModel.m in Sources */, BE189DBC2C733B460008418B /* FSRSettingRoomGuarderOnlineModel.m in Sources */,
BED658F42C5B745E00668116 /* FUSLiveBottomToolSubView.m in Sources */, BED658F42C5B745E00668116 /* FUSLiveBottomToolSubView.m in Sources */,
BEF6C0A82F0A1B2C0033D4E5 /* FUSLiveShowTimePopView.m in Sources */,
BED6599E2C5B745F00668116 /* FUSLinkMicItemView.m in Sources */, BED6599E2C5B745F00668116 /* FUSLinkMicItemView.m in Sources */,
BED658802C5B745E00668116 /* FUSLivePropsModel.m in Sources */, BED658802C5B745E00668116 /* FUSLivePropsModel.m in Sources */,
BE189DB82C733B460008418B /* FSRRoomManagerShowRoomModel.m in Sources */, BE189DB82C733B460008418B /* FSRRoomManagerShowRoomModel.m in Sources */,
{
"images" : [
{
"filename" : "Live_bottom_add.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Live_bottom_add@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Live_bottom_add@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "Live_bottom_sub.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Live_bottom_sub@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Live_bottom_sub@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
...@@ -40,6 +40,8 @@ typedef enum : NSInteger { ...@@ -40,6 +40,8 @@ typedef enum : NSInteger {
// FUSLiveBottomToolTypeNovaBuild, // FUSLiveBottomToolTypeNovaBuild,
/// 直播管理 /// 直播管理
FUSLiveBottomToolTypeLiveManage, FUSLiveBottomToolTypeLiveManage,
/// 限时表演:仅公开房在「房间设置」弹窗展示(第 3 个),图标 Live_bottom_showTime
FUSLiveBottomToolTypeShowTime,
} FUSLiveBottomToolType; } FUSLiveBottomToolType;
......
...@@ -186,6 +186,11 @@ ...@@ -186,6 +186,11 @@
image = [FUSShowRoomCenterBunble imageNamed:@"live_chat_icon_live_setting"]; image = [FUSShowRoomCenterBunble imageNamed:@"live_chat_icon_live_setting"];
break; break;
} }
case FUSLiveBottomToolTypeShowTime:
{
image = [FUSShowRoomCenterBunble imageNamed:@"Live_bottom_showTime"];
break;
}
// case FUSLiveBottomToolTypeNovaBuild: // case FUSLiveBottomToolTypeNovaBuild:
// if (isSelect) { // if (isSelect) {
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#import "FUSShowRoomModule/FUSShowRoomModule-Swift.h" #import "FUSShowRoomModule/FUSShowRoomModule-Swift.h"
#import "FUSLiveShowTimePopView.h"
//#import "UIImageView+FUSTestImgeView.h" //#import "UIImageView+FUSTestImgeView.h"
@interface FUSLiveBottomToolSubView () <FUSLiveChatInputTextViewDelegate> @interface FUSLiveBottomToolSubView () <FUSLiveChatInputTextViewDelegate>
...@@ -168,6 +170,11 @@ ...@@ -168,6 +170,11 @@
[self onClickCameraBtn]; [self onClickCameraBtn];
} }
break; break;
case FUSLiveBottomToolTypeShowTime:
{
[FUSLiveShowTimePopView fus_showOnView:bgView];
}
break;
case FUSLiveBottomToolTypeExchange: case FUSLiveBottomToolTypeExchange:
{ {
[self onClickExchangeBtn]; [self onClickExchangeBtn];
...@@ -583,7 +590,11 @@ ...@@ -583,7 +590,11 @@
[toolTypesList appendObjects:@[@(FUSLiveBottomToolTypeLiveSetting),@(FUSLiveBottomToolTypeRoomSetting), /*@(FUSLiveBottomToolTypeRoomScope),@(FUSLiveBottomToolTypePK), @(FUSLiveBottomToolTypeNovaBuild)*/]]; [toolTypesList appendObjects:@[@(FUSLiveBottomToolTypeLiveSetting),@(FUSLiveBottomToolTypeRoomSetting), /*@(FUSLiveBottomToolTypeRoomScope),@(FUSLiveBottomToolTypePK), @(FUSLiveBottomToolTypeNovaBuild)*/]];
} }
else { else {
[toolTypesList appendObjects:@[@(FUSLiveBottomToolTypeLiveSetting),@(FUSLiveBottomToolTypeRoomSetting), /*@(FUSLiveBottomToolTypeRoomScope),*/@(FUSLiveBottomToolTypePK)/*, @(FUSLiveBottomToolTypeNovaBuild)*/]]; if (FUSLiveHelper.shareInstance.roomScopeType == FUSLiveRoomScopeTypeOpen) {
[toolTypesList appendObjects:@[@(FUSLiveBottomToolTypeLiveSetting),@(FUSLiveBottomToolTypeRoomSetting),@(FUSLiveBottomToolTypeShowTime), /*@(FUSLiveBottomToolTypeRoomScope),*/@(FUSLiveBottomToolTypePK)/*, @(FUSLiveBottomToolTypeNovaBuild)*/]];
} else {
[toolTypesList appendObjects:@[@(FUSLiveBottomToolTypeLiveSetting),@(FUSLiveBottomToolTypeRoomSetting), /*@(FUSLiveBottomToolTypeRoomScope),*/@(FUSLiveBottomToolTypePK)/*, @(FUSLiveBottomToolTypeNovaBuild)*/]];
}
} }
// [toolTypesList appendObjects:@[@(FFLiveBottomToolTypeLiveSetting),@(FFLiveBottomToolTypeRoomSetting), @(FFLiveBottomToolTypeRoomScope),@(FFLiveBottomToolTypeBeautySticker), @(FFLiveBottomToolTypeNovaBuild)]]; // [toolTypesList appendObjects:@[@(FFLiveBottomToolTypeLiveSetting),@(FFLiveBottomToolTypeRoomSetting), @(FFLiveBottomToolTypeRoomScope),@(FFLiveBottomToolTypeBeautySticker), @(FFLiveBottomToolTypeNovaBuild)]];
} }
......
...@@ -574,6 +574,8 @@ ...@@ -574,6 +574,8 @@
image = [FUSShowRoomCenterBunble imageNamed:@"live_RoomScope_normal"]; image = [FUSShowRoomCenterBunble imageNamed:@"live_RoomScope_normal"];
} }
[self.roomScopeBtn setImage:image forState:UIControlStateNormal]; [self.roomScopeBtn setImage:image forState:UIControlStateNormal];
// 房间私密度切换后,同步刷新「房间设置」弹窗的功能列表(例如:公开屋才显示“限时表演”)
[self.bottomSubView fus_updateToolView2Types];
} else { } else {
[self fus_insertBtnWithType:FUSLiveBottomToolTypeShare index:self.divisionBtnType]; [self fus_insertBtnWithType:FUSLiveBottomToolTypeShare index:self.divisionBtnType];
......
...@@ -37,7 +37,7 @@ import RxCocoa ...@@ -37,7 +37,7 @@ import RxCocoa
case .liveFunction: case .liveFunction:
return [FUSLiveBottomToolTypeTask, FUSLiveBottomToolTypeExchange, FUSLiveBottomToolTypeScreenShot, FUSLiveBottomToolTypeMessageBox, FUSLiveBottomToolTypeMessage, FUSLiveBottomToolTypeAudienceMessage] return [FUSLiveBottomToolTypeTask, FUSLiveBottomToolTypeExchange, FUSLiveBottomToolTypeScreenShot, FUSLiveBottomToolTypeMessageBox, FUSLiveBottomToolTypeMessage, FUSLiveBottomToolTypeAudienceMessage]
case .roomSetting: case .roomSetting:
return [FUSLiveBottomToolTypeLiveSetting, FUSLiveBottomToolTypeRoomSetting, FUSLiveBottomToolTypeLiveManage/*, .novaBuild*/, FUSLiveBottomToolTypeStartPictureInPicture, FUSLiveBottomToolTypePK] return [FUSLiveBottomToolTypeLiveSetting, FUSLiveBottomToolTypeRoomSetting, FUSLiveBottomToolTypeShowTime, FUSLiveBottomToolTypeLiveManage/*, .novaBuild*/, FUSLiveBottomToolTypeStartPictureInPicture, FUSLiveBottomToolTypePK]
case .broadcastFunction: case .broadcastFunction:
// return [.RoomScope, .PK] // return [.RoomScope, .PK]
return [FUSLiveBottomToolTypeRoomScope, FUSLiveBottomToolTypeBeautySticker] return [FUSLiveBottomToolTypeRoomScope, FUSLiveBottomToolTypeBeautySticker]
...@@ -414,6 +414,8 @@ extension FUSLiveBottomToolType{ ...@@ -414,6 +414,8 @@ extension FUSLiveBottomToolType{
return .fus_versionLocalString("聊天") return .fus_versionLocalString("聊天")
case FUSLiveBottomToolTypePK: case FUSLiveBottomToolTypePK:
return .fus_versionLocalString("PK") return .fus_versionLocalString("PK")
case FUSLiveBottomToolTypeShowTime:
return .fus_versionLocalString("限时表演")
// case FUSLiveBottomToolTypeLuckWheel: // case FUSLiveBottomToolTypeLuckWheel:
// return .fus_versionLocalString("转盘") // return .fus_versionLocalString("转盘")
// case FUSLiveBottomToolTypeOpenRoom: // case FUSLiveBottomToolTypeOpenRoom:
...@@ -444,6 +446,8 @@ extension FUSLiveBottomToolType{ ...@@ -444,6 +446,8 @@ extension FUSLiveBottomToolType{
return FUSShowRoomCenterBunble.imageNamed(isSelect ? "live_chat_tool_msgBox_highlight" : "live_chat_tool_msgBox_normal") return FUSShowRoomCenterBunble.imageNamed(isSelect ? "live_chat_tool_msgBox_highlight" : "live_chat_tool_msgBox_normal")
case FUSLiveBottomToolTypePK: case FUSLiveBottomToolTypePK:
return FUSShowRoomCenterBunble.versionImageNamed(isSelect ? "Live_bottom_PK_Preesed" : "Live_bottom_PK_Normal") return FUSShowRoomCenterBunble.versionImageNamed(isSelect ? "Live_bottom_PK_Preesed" : "Live_bottom_PK_Normal")
case FUSLiveBottomToolTypeShowTime:
return FUSShowRoomCenterBunble.versionImageNamed("Live_bottom_showTime")
case FUSLiveBottomToolTypeGameEntrance: case FUSLiveBottomToolTypeGameEntrance:
return FUSShowRoomCenterBunble.versionImageNamed(isSelect ? "live_game_entrance_preesed" : "live_game_entrance_normal") return FUSShowRoomCenterBunble.versionImageNamed(isSelect ? "live_game_entrance_preesed" : "live_game_entrance_normal")
case FUSLiveBottomToolTypeTask: case FUSLiveBottomToolTypeTask:
......
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/// “限时表演”底部弹窗(集票数量配置)
@interface FUSLiveShowTimePopView : UIView
/// 在指定容器上展示弹窗
/// - Parameter onView: 承载弹窗的父视图
+ (instancetype)fus_showOnView:(UIView *)onView;
@end
NS_ASSUME_NONNULL_END
#import "FUSLiveShowTimePopView.h"
#import <FUSCommon/FUSCommon.h>
#import <FUSFoundation/FUSFoundation.h>
#import "FUSShowRoomCenterBunble.h"
static const NSInteger kFUSShowTimeTicketMin = 5;
static const NSInteger kFUSShowTimeTicketMax = 50;
@interface FUSLiveShowTimePopView ()
/// 点击背景关闭按钮
@property (nonatomic, strong) UIButton *bgBtn;
/// 弹窗内容容器(从底部滑出)
@property (nonatomic, strong) UIView *contentView;
/// 顶部拖拽灰色横杠
@property (nonatomic, strong) UIView *grabberView;
/// 标题
@property (nonatomic, strong) UILabel *titleLabel;
/// 主题输入背景(灰底圆角)
@property (nonatomic, strong) UIView *themeBgView;
/// 主题输入框(可编辑)
@property (nonatomic, strong) UITextField *themeTextField;
/// “集票数量”标题
@property (nonatomic, strong) UILabel *ticketTitleLabel;
/// 减号按钮
@property (nonatomic, strong) UIButton *subBtn;
/// 数量展示
@property (nonatomic, strong) UILabel *countLabel;
/// 加号按钮
@property (nonatomic, strong) UIButton *addBtn;
/// 提示文案
@property (nonatomic, strong) UILabel *tipLabel;
/// 底部主操作按钮
@property (nonatomic, strong) UIButton *startBtn;
/// 当前集票数量
@property (nonatomic, assign) NSInteger ticketCount;
/// 长按连发计时器(每 1 秒触发一次)
@property (nonatomic, strong) dispatch_source_t longPressTimer;
/// 长按连发方向(+10 / -10)
@property (nonatomic, assign) NSInteger longPressDelta;
@end
@implementation FUSLiveShowTimePopView
/// 创建并展示弹窗
+ (instancetype)fus_showOnView:(UIView *)onView {
FUSLiveShowTimePopView *view = [[FUSLiveShowTimePopView alloc] initWithFrame:onView.bounds];
[onView addSubview:view];
[view fus_show];
return view;
}
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.ticketCount = kFUSShowTimeTicketMin;
self.bgBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.bgBtn.frame = self.bounds;
self.bgBtn.backgroundColor = [UIColor colorWithWhite:0 alpha:0.35];
[self.bgBtn addTarget:self action:@selector(fus_dismiss) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:self.bgBtn];
CGFloat safeBottom = UIView.fus_SafeBottom;
CGFloat contentH = 314 + safeBottom;
self.contentView = [[UIView alloc] initWithFrame:CGRectMake(0, UIView.fus_screenH, UIView.fus_screenW, contentH)];
self.contentView.backgroundColor = UIColor.whiteColor;
[self.contentView addRoundedCorners:UIRectCornerTopLeft|UIRectCornerTopRight withRadii:CGSizeMake(16, 16)];
[self addSubview:self.contentView];
self.grabberView = [[UIView alloc] initWithFrame:CGRectMake(0, 8, 40, 4)];
self.grabberView.centerX = self.contentView.width / 2.0;
self.grabberView.backgroundColor = [UIColor colorWithHex:@"#DADDE1"];
self.grabberView.layer.cornerRadius = 2;
self.grabberView.layer.masksToBounds = YES;
[self.contentView addSubview:self.grabberView];
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.grabberView.bottom + 10, self.contentView.width, 22)];
self.titleLabel.textAlignment = NSTextAlignmentCenter;
self.titleLabel.font = [UIFont fus_themeBoldFont:16];
self.titleLabel.textColor = [UIColor colorWithHex:@"#333333"];
self.titleLabel.text = [NSString fus_localString:@"限时表演"];
[self.contentView addSubview:self.titleLabel];
self.themeBgView = [[UIView alloc] initWithFrame:CGRectMake(25, self.titleLabel.bottom + 10, self.contentView.width - 50, 35)];
self.themeBgView.backgroundColor = [UIColor colorWithHex:@"#F2F3F5"];
self.themeBgView.layer.cornerRadius = 8;
self.themeBgView.layer.masksToBounds = YES;
[self.contentView addSubview:self.themeBgView];
self.themeTextField = [[UITextField alloc] initWithFrame:CGRectMake(12, 0, self.themeBgView.width - 24, self.themeBgView.height)];
self.themeTextField.font = [UIFont fus_themeFont:12];
self.themeTextField.textColor = [UIColor colorWithHex:@"#666666"];
self.themeTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:[NSString fus_localString:@"每日16:00,来找我一起玩吧。"]
attributes:@{NSForegroundColorAttributeName:[UIColor colorWithHex:@"#9AA0A6"]}];
self.themeTextField.userInteractionEnabled = NO;
[self.themeBgView addSubview:self.themeTextField];
UITapGestureRecognizer *tapTheme = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(fus_onTapTheme)];
[self.themeBgView addGestureRecognizer:tapTheme];
UIView *separator = [[UIView alloc] initWithFrame:CGRectMake(0, self.themeBgView.bottom + 14, self.contentView.width, 1)];
separator.backgroundColor = [UIColor colorWithHex:@"#F2F3F5"];
[self.contentView addSubview:separator];
self.ticketTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, separator.bottom + 18, self.contentView.width, 20)];
self.ticketTitleLabel.textAlignment = NSTextAlignmentCenter;
self.ticketTitleLabel.font = [UIFont fus_themeFont:14];
self.ticketTitleLabel.textColor = [UIColor colorWithHex:@"#333333"];
self.ticketTitleLabel.text = [NSString fus_localString:@"集票数量"];
[self.contentView addSubview:self.ticketTitleLabel];
CGFloat controlH = 34;
CGFloat controlY = self.ticketTitleLabel.bottom + 12;
CGFloat btnSize = 30;
CGFloat countW = 80;
CGFloat space = 16;
CGFloat totalW = btnSize + space + countW + space + btnSize;
CGFloat startX = (self.contentView.width - totalW) / 2.0;
self.subBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.subBtn.frame = CGRectMake(startX, 0, btnSize, btnSize);
self.subBtn.centerY = controlY + controlH / 2.0;
[self.subBtn setImage:[FUSShowRoomCenterBunble imageNamed:@"Live_bottom_sub"] forState:UIControlStateNormal];
[self.subBtn addTarget:self action:@selector(fus_onClickSub) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:self.subBtn];
self.countLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.subBtn.right + space, 0, countW, controlH)];
self.countLabel.textAlignment = NSTextAlignmentCenter;
self.countLabel.font = [UIFont fus_themeBoldFont:16];
self.countLabel.textColor = [UIColor colorWithHex:@"#333333"];
self.countLabel.centerY = self.subBtn.centerY;
self.countLabel.userInteractionEnabled = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(fus_onTapCount)];
[self.countLabel addGestureRecognizer:tap];
[self.contentView addSubview:self.countLabel];
[self fus_refreshCountUI];
self.addBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.addBtn.frame = CGRectMake(self.countLabel.right + space, 0, btnSize, btnSize);
self.addBtn.centerY = self.subBtn.centerY;
[self.addBtn setImage:[FUSShowRoomCenterBunble imageNamed:@"Live_bottom_add"] forState:UIControlStateNormal];
[self.addBtn addTarget:self action:@selector(fus_onClickAdd) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:self.addBtn];
self.tipLabel = [[UILabel alloc] initWithFrame:CGRectMake(24, self.countLabel.bottom + 12, self.contentView.width - 48, 18)];
self.tipLabel.textAlignment = NSTextAlignmentCenter;
self.tipLabel.font = [UIFont fus_themeFont:12];
self.tipLabel.textColor = [UIColor colorWithHex:@"#9AA0A6"];
self.tipLabel.text = [NSString fus_localString:@"集得足够票数,可开启限时表演(10分钟)"];
[self.contentView addSubview:self.tipLabel];
CGFloat btnH = 44;
self.startBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.startBtn.frame = CGRectMake(24, self.contentView.height - safeBottom - 14 - btnH, self.contentView.width - 48, btnH);
self.startBtn.layer.cornerRadius = btnH / 2.0;
self.startBtn.layer.masksToBounds = YES;
self.startBtn.backgroundColor = [UIColor fus_appMainColor];
[self.startBtn setTitle:[NSString fus_localString:@"开启集票"] forState:UIControlStateNormal];
[self.startBtn setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
self.startBtn.titleLabel.font = [UIFont fus_themeBoldFont:15];
[self.startBtn addTarget:self action:@selector(fus_onClickStart) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:self.startBtn];
UILongPressGestureRecognizer *longPressAdd = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(fus_onLongPressAdd:)];
longPressAdd.minimumPressDuration = 0.4;
[self.addBtn addGestureRecognizer:longPressAdd];
UILongPressGestureRecognizer *longPressSub = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(fus_onLongPressSub:)];
longPressSub.minimumPressDuration = 0.4;
[self.subBtn addGestureRecognizer:longPressSub];
}
return self;
}
/// 执行动画:弹窗从底部滑入
- (void)fus_show {
[UIView animateWithDuration:0.3 animations:^{
self.contentView.bottom = UIView.fus_screenH;
}];
}
/// 执行动画:弹窗滑出并移除
- (void)fus_dismiss {
[self fus_stopLongPressTimer];
[UIView animateWithDuration:0.25 animations:^{
self.contentView.top = UIView.fus_screenH;
self.bgBtn.alpha = 0;
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
}
/// 视图移除前确保定时器释放
- (void)dealloc {
[self fus_stopLongPressTimer];
}
/// 点击减号:下调集票数量
- (void)fus_onClickSub {
[self fus_tryChangeTicketCountBy:-1];
}
/// 点击加号:上调集票数量
- (void)fus_onClickAdd {
[self fus_tryChangeTicketCountBy:1];
}
/// 刷新数量与按钮可用态
- (void)fus_refreshCountUI {
self.countLabel.text = [NSString stringWithFormat:@"%zd", self.ticketCount];
self.subBtn.enabled = YES;
}
/// 点击主按钮:后续接入真实“开始集票/开启表演”逻辑
- (void)fus_onClickStart {
// 跟服务器相关逻辑先保留入口:后续接入接口时在这里提交 themeTextField/ticketCount
[FUSDialogView fus_showDialog:[NSString fus_localString:@"功能开发中"]];
[self fus_dismiss];
}
- (void)fus_onLongPressAdd:(UILongPressGestureRecognizer *)gesture {
if (gesture.state == UIGestureRecognizerStateBegan) {
[self fus_startLongPressTimerWithDelta:10];
} else if (gesture.state == UIGestureRecognizerStateEnded ||
gesture.state == UIGestureRecognizerStateCancelled ||
gesture.state == UIGestureRecognizerStateFailed) {
[self fus_stopLongPressTimer];
}
}
- (void)fus_onLongPressSub:(UILongPressGestureRecognizer *)gesture {
if (gesture.state == UIGestureRecognizerStateBegan) {
[self fus_startLongPressTimerWithDelta:-10];
} else if (gesture.state == UIGestureRecognizerStateEnded ||
gesture.state == UIGestureRecognizerStateCancelled ||
gesture.state == UIGestureRecognizerStateFailed) {
[self fus_stopLongPressTimer];
}
}
/// 点击主题输入区域:弹出输入框填写主题,避免键盘遮挡
- (void)fus_onTapTheme {
UIViewController *topVC = [UIViewController fus_topViewController];
if (!topVC) {
return;
}
UIAlertController *alert = [UIAlertController alertControllerWithTitle:[NSString fus_localString:@"设置主题"]
message:nil
preferredStyle:UIAlertControllerStyleAlert];
__weak typeof(self) weakSelf = self;
[alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.text = weakSelf.themeTextField.text ?: @"";
textField.placeholder = [NSString fus_localString:@"每日16:00,来找我一起玩吧。"];
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
textField.returnKeyType = UIReturnKeyDone;
}];
[alert addAction:[UIAlertAction actionWithTitle:[NSString fus_localString:@"取消"]
style:UIAlertActionStyleCancel
handler:nil]];
[alert addAction:[UIAlertAction actionWithTitle:[NSString fus_localString:@"确定"]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
NSString *text = alert.textFields.firstObject.text ?: @"";
weakSelf.themeTextField.text = text;
}]];
[topVC presentViewController:alert animated:YES completion:nil];
}
/// 点击中间数字:弹出输入框填写具体票数
- (void)fus_onTapCount {
UIViewController *topVC = [UIViewController fus_topViewController];
if (!topVC) {
return;
}
UIAlertController *alert = [UIAlertController alertControllerWithTitle:[NSString fus_localString:@"填写票数"]
message:nil
preferredStyle:UIAlertControllerStyleAlert];
__weak typeof(self) weakSelf = self;
[alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.keyboardType = UIKeyboardTypeNumberPad;
textField.text = [NSString stringWithFormat:@"%zd", weakSelf.ticketCount];
}];
[alert addAction:[UIAlertAction actionWithTitle:[NSString fus_localString:@"取消"]
style:UIAlertActionStyleCancel
handler:nil]];
[alert addAction:[UIAlertAction actionWithTitle:[NSString fus_localString:@"确定"]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
NSString *text = alert.textFields.firstObject.text ?: @"";
NSInteger value = text.integerValue;
[weakSelf fus_setTicketCount:value showTipIfOutOfRange:YES];
}]];
[topVC presentViewController:alert animated:YES completion:nil];
}
/// 尝试按步长调整票数,超过边界时提示并保持在边界值
- (void)fus_tryChangeTicketCountBy:(NSInteger)delta {
NSInteger target = self.ticketCount + delta;
[self fus_setTicketCount:target showTipIfOutOfRange:YES];
}
/// 设置票数并刷新 UI
- (void)fus_setTicketCount:(NSInteger)ticketCount showTipIfOutOfRange:(BOOL)showTipIfOutOfRange {
NSInteger newValue = ticketCount;
if (newValue < kFUSShowTimeTicketMin) {
newValue = kFUSShowTimeTicketMin;
if (showTipIfOutOfRange) {
[FUSDialogView fus_showDialog:[NSString fus_localString:@"最低5张"]];
}
} else if (newValue > kFUSShowTimeTicketMax) {
newValue = kFUSShowTimeTicketMax;
if (showTipIfOutOfRange) {
[FUSDialogView fus_showDialog:[NSString fus_localString:@"最高50张"]];
}
}
self.ticketCount = newValue;
[self fus_refreshCountUI];
}
/// 启动长按连发(首次立即触发,之后每 1 秒触发一次)
- (void)fus_startLongPressTimerWithDelta:(NSInteger)delta {
if (delta < 0 && self.ticketCount <= kFUSShowTimeTicketMin) {
[FUSDialogView fus_showDialog:[NSString fus_localString:@"最低5张"]];
return;
}
if (delta > 0 && self.ticketCount >= kFUSShowTimeTicketMax) {
[FUSDialogView fus_showDialog:[NSString fus_localString:@"最高50张"]];
return;
}
[self fus_stopLongPressTimer];
self.longPressDelta = delta;
__weak typeof(self) weakSelf = self;
dispatch_queue_t queue = dispatch_get_main_queue();
dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
self.longPressTimer = timer;
dispatch_source_set_timer(timer, DISPATCH_TIME_NOW, (uint64_t)(1.0 * NSEC_PER_SEC), (uint64_t)(0.05 * NSEC_PER_SEC));
dispatch_source_set_event_handler(timer, ^{
[weakSelf fus_onLongPressTick];
});
dispatch_resume(timer);
[self fus_onLongPressTick];
}
/// 停止长按连发
- (void)fus_stopLongPressTimer {
if (self.longPressTimer) {
dispatch_source_cancel(self.longPressTimer);
self.longPressTimer = nil;
}
}
/// 长按连发触发:每次步进 10,触到边界就停止
- (void)fus_onLongPressTick {
if (self.longPressDelta < 0) {
if (self.ticketCount <= kFUSShowTimeTicketMin) {
[self fus_stopLongPressTimer];
return;
}
NSInteger target = self.ticketCount + self.longPressDelta;
if (target <= kFUSShowTimeTicketMin) {
[self fus_setTicketCount:kFUSShowTimeTicketMin showTipIfOutOfRange:YES];
[self fus_stopLongPressTimer];
return;
}
[self fus_setTicketCount:target showTipIfOutOfRange:NO];
return;
}
if (self.longPressDelta > 0) {
if (self.ticketCount >= kFUSShowTimeTicketMax) {
[self fus_stopLongPressTimer];
return;
}
NSInteger target = self.ticketCount + self.longPressDelta;
if (target >= kFUSShowTimeTicketMax) {
[self fus_setTicketCount:kFUSShowTimeTicketMax showTipIfOutOfRange:YES];
[self fus_stopLongPressTimer];
return;
}
[self fus_setTicketCount:target showTipIfOutOfRange:NO];
}
}
@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