增加换肤功能
This commit is contained in:
18
QXLive/Tabbar/QXTabbarController.h
Normal file
18
QXLive/Tabbar/QXTabbarController.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// QXTabbarController.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/4/24.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXTabbarController : UITabBarController
|
||||
@property (nonatomic,assign)UInt64 unReadNumber;
|
||||
@property (nonatomic,assign)UInt64 messageUnReadNumber;
|
||||
@property (nonatomic,assign)UInt64 systemUnreadNumber;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
279
QXLive/Tabbar/QXTabbarController.m
Normal file
279
QXLive/Tabbar/QXTabbarController.m
Normal file
@@ -0,0 +1,279 @@
|
||||
//
|
||||
// QXTabbarController.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/4/24.
|
||||
//
|
||||
|
||||
#import "QXTabbarController.h"
|
||||
#import "QXDynamicViewController.h"
|
||||
#import "QXHomeViewController.h"
|
||||
#import "QXLoginViewController.h"
|
||||
#import "QXMessageViewController.h"
|
||||
#import "QXMineViewController.h"
|
||||
#import "QXPartyViewController.h"
|
||||
#import "QXBaseNavigationController.h"
|
||||
#import "QXLoginViewController.h"
|
||||
#import "QXTabbarConfig.h"
|
||||
#import "QXTabBar.h"
|
||||
#import "QXChirldViewController.h"
|
||||
#import "QXManagerMqtt.h"
|
||||
#import "QXGiftScrollView.h"
|
||||
|
||||
//弹窗
|
||||
#import "QXChirldPopView.h" // 青少年
|
||||
#import "QXNiceGiftPopView.h" // 天降好礼
|
||||
#import "QXFirstRechargePopView.h" // 首充
|
||||
#import "QXInvitePopView.h" // 邀请
|
||||
#import "QXGiftDriftView.h" // 礼物飘屏
|
||||
#import <ImSDK_Plus/ImSDK_Plus.h>
|
||||
#import "QXMessageServices.h"
|
||||
|
||||
@interface QXTabbarController ()<UITabBarControllerDelegate,QXTabBarDelegate,UINavigationControllerDelegate,MQTTClientModelDelegate,V2TIMConversationListener>
|
||||
@property(nonatomic,strong) QXTabBar *customTabBar;
|
||||
@property(nonatomic,strong) QXHomeViewController *homeVC;
|
||||
@property(nonatomic,assign) BOOL isAlreadyShowChirld;
|
||||
@end
|
||||
|
||||
@implementation QXTabbarController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
self.delegate = self;
|
||||
[self setupTabbar];
|
||||
[self configChildVC];
|
||||
|
||||
// [self performSelector:@selector(giftAction) afterDelay:7];
|
||||
}
|
||||
-(void)viewWillAppear:(BOOL)animated{
|
||||
[super viewWillAppear:animated];
|
||||
if (self.isAlreadyShowChirld) {
|
||||
return;
|
||||
}
|
||||
if (QXGlobal.shareGlobal.isLogin) {
|
||||
[self performSelector:@selector(popChirldView) afterDelay:1];
|
||||
}
|
||||
QXLOG(@"视图即将展示");
|
||||
}
|
||||
#pragma mark - 青少年模式
|
||||
-(void)popChirldView{
|
||||
self.isAlreadyShowChirld = YES;
|
||||
MJWeakSelf
|
||||
QXChirldPopView *view = [[QXChirldPopView alloc] init];
|
||||
view.closeActionBlock = ^{
|
||||
[[QXGlobal shareGlobal].alertViewController hideViewFinishBlock:^{
|
||||
QXLOG(@"页面关闭");
|
||||
// [weakSelf popNiceGiftView];
|
||||
}];
|
||||
};
|
||||
view.gotoActionBlock = ^{
|
||||
[[QXGlobal shareGlobal].alertViewController hideViewFinishBlock:^{
|
||||
QXLOG(@"页面关闭");
|
||||
[weakSelf pushToChirld];
|
||||
}];
|
||||
};
|
||||
view.setActionBlock = ^{
|
||||
[[QXGlobal shareGlobal].alertViewController hideViewFinishBlock:^{
|
||||
QXLOG(@"页面关闭");
|
||||
|
||||
}];
|
||||
};
|
||||
[[QXGlobal shareGlobal] showView:view controller:self.homeVC popType:(PopViewTypeTopToCenter) tapDismiss:NO finishBlock:^{
|
||||
|
||||
}];
|
||||
}
|
||||
-(void)pushToChirld{
|
||||
QXChirldViewController *vc = [[QXChirldViewController alloc] init];
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
-(void)popFirstRechargeView{
|
||||
MJWeakSelf
|
||||
// QXFirstRechargePopView *view = [[QXFirstRechargePopView alloc] init];
|
||||
// view.giftArray = @[@"",@"",@"",@"",@"",@""];
|
||||
// view.closeActionBlock = ^{
|
||||
// [[QXGlobal shareGlobal].alertViewController hideViewFinishBlock:^{
|
||||
// QXLOG(@"页面关闭");
|
||||
// [weakSelf popInvitePopView];
|
||||
// }];
|
||||
// };
|
||||
// view.rechargeActionBlock = ^{
|
||||
// [[QXGlobal shareGlobal].alertViewController hideViewFinishBlock:^{
|
||||
// QXLOG(@"页面关闭");
|
||||
// }];
|
||||
// };
|
||||
// [[QXGlobal shareGlobal] showView:view popType:(PopViewTypeTopToCenter) tapDismiss:NO finishBlock:^{
|
||||
//
|
||||
// }];
|
||||
}
|
||||
-(void)popNiceGiftView{
|
||||
MJWeakSelf
|
||||
QXNiceGiftPopView *view = [[QXNiceGiftPopView alloc] init];
|
||||
view.closeActionBlock = ^{
|
||||
[[QXGlobal shareGlobal].alertViewController hideViewFinishBlock:^{
|
||||
QXLOG(@"页面关闭");
|
||||
[weakSelf popFirstRechargeView];
|
||||
}];
|
||||
};
|
||||
view.getActionBlock = ^{
|
||||
[[QXGlobal shareGlobal].alertViewController hideViewFinishBlock:^{
|
||||
QXLOG(@"页面关闭");
|
||||
}];
|
||||
};
|
||||
view.ruleActionBlock = ^{
|
||||
[[QXGlobal shareGlobal].alertViewController hideViewFinishBlock:^{
|
||||
QXLOG(@"页面关闭");
|
||||
}];
|
||||
};
|
||||
view.giftArray = @[@"",@"",@"",@"",@"",@""];
|
||||
[[QXGlobal shareGlobal] showView:view popType:(PopViewTypeTopToCenter) tapDismiss:NO finishBlock:^{
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)popInvitePopView{
|
||||
QXInvitePopView *view = [[QXInvitePopView alloc] init];
|
||||
view.closeActionBlock = ^{
|
||||
[[QXGlobal shareGlobal].alertViewController hideViewFinishBlock:^{
|
||||
QXLOG(@"页面关闭");
|
||||
|
||||
}];
|
||||
};
|
||||
view.agreeActionBlock = ^{
|
||||
|
||||
};
|
||||
|
||||
[[QXGlobal shareGlobal] showView:view popType:(PopViewTypeTopToCenter) tapDismiss:NO finishBlock:^{
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
//解决tabbar被原生tabbar覆盖问题
|
||||
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animate{
|
||||
if (navigationController.viewControllers.count == 1) {
|
||||
for (UIView *child in self.tabBar.subviews){
|
||||
if ([child isKindOfClass:NSClassFromString(@"UITabBarButton")]){
|
||||
[child removeFromSuperview];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
- (void)setupTabbar {
|
||||
[self.tabBar removeAllSubviews];
|
||||
self.tabBar.shadowImage = [UIImage new];
|
||||
self.tabBar.backgroundImage = [UIImage new];
|
||||
|
||||
self.tabBar.backgroundColor = [UIColor clearColor];
|
||||
// self.tabBarController.tabBar.standardAppearance = tabBar;
|
||||
// if (@available(iOS 15.0,*)) {
|
||||
// self.tabBarController.tabBar.scrollEdgeAppearance = tabBar;
|
||||
// }
|
||||
QXTabbarConfig *config = [QXTabbarConfig shareInstance];
|
||||
config.imageOffset = -5;
|
||||
QXTabBar *customTabBar = [[QXTabBar alloc] initWithFrame:CGRectMake(15, 0, SCREEN_WIDTH-30, 50) centerCustom:NO config:config];
|
||||
customTabBar.backgroundColor = [UIColor whiteColor];
|
||||
customTabBar.layer.shadowColor = [UIColor grayColor].CGColor;
|
||||
customTabBar.layer.shadowOpacity = 0.5;
|
||||
customTabBar.layer.shadowOffset = CGSizeMake(0, 2);
|
||||
customTabBar.layer.shadowRadius = 25.0;
|
||||
customTabBar.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:customTabBar.bounds cornerRadius:customTabBar.layer.cornerRadius].CGPath;
|
||||
customTabBar.delegate = self;
|
||||
customTabBar.layer.cornerRadius = 25.0;
|
||||
customTabBar.layer.masksToBounds = NO;
|
||||
self.selectedIndex = 0;
|
||||
// [self.view addSubview:customTabBar];
|
||||
self.customTabBar = customTabBar;
|
||||
[self.tabBar addSubview:self.customTabBar];
|
||||
[self.tabBar bringSubviewToFront:self.customTabBar];
|
||||
}
|
||||
-(void)setMessageUnReadNumber:(UInt64)messageUnReadNumber{
|
||||
_messageUnReadNumber = messageUnReadNumber;
|
||||
QXLOG(@"会话未读消息--%ld",_messageUnReadNumber);
|
||||
[self setUnReadNumber:self.messageUnReadNumber+self.systemUnreadNumber];
|
||||
}
|
||||
-(void)setSystemUnreadNumber:(UInt64)systemUnreadNumber{
|
||||
_systemUnreadNumber = systemUnreadNumber;
|
||||
QXLOG(@"系统未读消息--%ld",_systemUnreadNumber);
|
||||
[self setUnReadNumber:self.messageUnReadNumber+self.systemUnreadNumber];
|
||||
}
|
||||
-(void)setUnReadNumber:(UInt64)unReadNumber{
|
||||
_unReadNumber = unReadNumber;
|
||||
QXLOG(@"总计未读消息--%ld",_unReadNumber);
|
||||
self.customTabBar.unReadNumber = unReadNumber;
|
||||
}
|
||||
|
||||
-(void)QXTabBar:(QXTabBar *)tabBar didSelectedButtonFrom:(NSInteger)from to:(NSInteger)to{
|
||||
if (![QXGlobal shareGlobal].isLogin && to==QXConfig.tabbarArray.count-1) {
|
||||
QXLoginViewController *vc = [[QXLoginViewController alloc] init];
|
||||
QXBaseNavigationController *na = [[QXBaseNavigationController alloc] initWithRootViewController:vc];
|
||||
na.modalPresentationStyle = UIModalPresentationFullScreen;
|
||||
[self presentViewController:na animated:YES completion:nil];
|
||||
return;
|
||||
}
|
||||
self.selectedIndex = to;
|
||||
}
|
||||
|
||||
-(void)configChildVC{
|
||||
[QXManagerMqtt sharedInstance].delegate = self;
|
||||
QXHomeViewController *homeVC = [[QXHomeViewController alloc] init];
|
||||
self.homeVC = homeVC;
|
||||
// [self addChildVCWithTitle:@"首页" normalImage:[UIImage imageNamed:@"qx_tabbar_home_nor"] selectedImage:[UIImage imageNamed:@"qx_tabbar_home_sel"] controller:homeVC];
|
||||
QXDynamicViewController *dynamicVC = [[QXDynamicViewController alloc] init];
|
||||
// [self addChildVCWithTitle:@"动态" normalImage:[UIImage imageNamed:@"qx_tabbar_find_nor"] selectedImage:[UIImage imageNamed:@"qx_tabbar_find_sel"] controller:dynamicVC];
|
||||
// QXPartyViewController *partyVC = [[QXPartyViewController alloc] init];
|
||||
// [self addChildVCWithTitle:@"" normalImage:[UIImage imageNamed:@"qx_tabbar_party"] selectedImage:[UIImage imageNamed:@"qx_tabbar_party"] controller:partyVC];
|
||||
QXMessageViewController *messageVC = [[QXMessageViewController alloc] init];
|
||||
// [self addChildVCWithTitle:@"消息" normalImage:[UIImage imageNamed:@"qx_tabbar_message_nor"] selectedImage:[UIImage imageNamed:@"qx_tabbar_message_sel"] controller:messageVC];
|
||||
QXMineViewController *mineVC = [[QXMineViewController alloc] init];
|
||||
// [self addChildVCWithTitle:@"我的" normalImage:[UIImage imageNamed:@"qx_tabbar_me_nor"] selectedImage:[UIImage imageNamed:@"qx_tabbar_me_sel"] controller:mineVC];
|
||||
NSArray *tabbarArray = QXConfig.tabbarArray;
|
||||
NSArray *controller = @[homeVC,dynamicVC,messageVC,mineVC];
|
||||
for (int i =0; i < tabbarArray.count ;i++) {
|
||||
QXTabbarModel *model = tabbarArray[i];
|
||||
UIViewController *vc = controller[i];
|
||||
[self addChildVCWithTitle:model.title normalImage:model.normalImage selectedImage:model.selectedImage controller:vc];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)addChildVCWithTitle:(NSString*)title
|
||||
normalImage:(NSString*)normalImage
|
||||
selectedImage:(NSString*)selectedImage
|
||||
controller:(UIViewController*)controller{
|
||||
QXBaseNavigationController *na = [[QXBaseNavigationController alloc] initWithRootViewController:controller];
|
||||
na.delegate = self;
|
||||
// UITabBarItem *item = [[UITabBarItem alloc] init];
|
||||
// item.title = title;
|
||||
// item.image = [normalImage imageWithRenderingMode:(UIImageRenderingModeAlwaysOriginal)];
|
||||
// item.selectedImage = [selectedImage imageWithRenderingMode:(UIImageRenderingModeAlwaysOriginal)];
|
||||
// na.tabBarItem = item;
|
||||
[self addChildViewController:na];
|
||||
[self.customTabBar addTabBarButtonNorImageUrl:normalImage
|
||||
selImageUrl:selectedImage
|
||||
title:title];
|
||||
}
|
||||
|
||||
-(void)socketManager:(NSString *)socketManager receivedMessage:(NSDictionary *)message topic:(NSString *)topic{
|
||||
QXGiftScrollModel *model = [QXGiftScrollModel yy_modelWithJSON:message[@"msg"][@"list"]];
|
||||
[self.homeVC giftScrollViewShowWithModel:model];
|
||||
[[QXGiftDriftView shareView] addGiftModel:model];
|
||||
}
|
||||
|
||||
//-(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{
|
||||
// NSInteger index = [self.viewControllers indexOfObject:viewController];
|
||||
// if (index == 4) {
|
||||
// //判断是否登录
|
||||
// if (![QXGlobal shareGlobal].isLogin) {
|
||||
// QXLoginViewController *vc = [[QXLoginViewController alloc] init];
|
||||
//// vc.hidesBottomBarWhenPushed = YES;
|
||||
//// [(QXBaseNavigationController*)tabBarController.selectedViewController pushViewController:vc animated:YES];
|
||||
// QXBaseNavigationController *na = [[QXBaseNavigationController alloc] initWithRootViewController:vc];
|
||||
// na.modalPresentationStyle = UIModalPresentationFullScreen;
|
||||
// [(QXBaseNavigationController*)tabBarController.selectedViewController presentViewController:na animated:YES completion:nil];
|
||||
// return NO;
|
||||
// }
|
||||
// return YES;
|
||||
// }
|
||||
// return YES;
|
||||
//}
|
||||
@end
|
||||
17
QXLive/Tabbar/TabbarCustomView/CustomVersionUpdateView.h
Executable file
17
QXLive/Tabbar/TabbarCustomView/CustomVersionUpdateView.h
Executable file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// CustomVersionUpdateView.h
|
||||
// SoundRiver
|
||||
//
|
||||
// Created by y1758946235 on 2020/2/17.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface CustomVersionUpdateView : UIView
|
||||
|
||||
-(void)getDownloadUrl:(NSString *)downloadUrl isForceUpdate:(NSString *)ForceUpdate;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
87
QXLive/Tabbar/TabbarCustomView/CustomVersionUpdateView.m
Executable file
87
QXLive/Tabbar/TabbarCustomView/CustomVersionUpdateView.m
Executable file
@@ -0,0 +1,87 @@
|
||||
//
|
||||
// CustomVersionUpdateView.m
|
||||
// SoundRiver
|
||||
//
|
||||
// Created by y1758946235 on 2020/2/17.
|
||||
//
|
||||
|
||||
#import "CustomVersionUpdateView.h"
|
||||
@interface CustomVersionUpdateView ()
|
||||
@property (nonatomic, strong) UIButton *centerBgBtn;
|
||||
@property (nonatomic, copy) NSString *downloadUrl;
|
||||
@end
|
||||
@implementation CustomVersionUpdateView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
self.backgroundColor = RGBA(0, 0, 0, 0.5);
|
||||
[self centerBgBtn];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)tapClick {
|
||||
[self removeFromSuperview];
|
||||
}
|
||||
|
||||
- (void)getDownloadUrl:(NSString *)downloadUrl isForceUpdate:(NSString *)ForceUpdate {
|
||||
self.downloadUrl = downloadUrl;
|
||||
if ([ForceUpdate intValue] != 1) {
|
||||
self.userInteractionEnabled = YES;
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick)];
|
||||
[self addGestureRecognizer:tap];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Getter
|
||||
|
||||
- (NSString *)downloadUrl
|
||||
{
|
||||
if (!_downloadUrl) {
|
||||
_downloadUrl = [[NSString alloc] init];
|
||||
}
|
||||
return _downloadUrl;
|
||||
}
|
||||
|
||||
- (UIButton *)centerBgBtn
|
||||
{
|
||||
if (!_centerBgBtn) {
|
||||
_centerBgBtn = [[UIButton alloc] initWithFrame:CGRectZero];
|
||||
[_centerBgBtn setBackgroundImage:[UIImage imageNamed:@"sr_update_version"] forState:UIControlStateNormal];
|
||||
[_centerBgBtn setBackgroundImage:[UIImage imageNamed:@"sr_update_version"] forState:UIControlStateHighlighted];
|
||||
[_centerBgBtn addTarget:self action:@selector(updateClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
// UIView *view = [QuickCreatUI creatUIViewWithSuperView:_centerBgBtn andFrame:CGRectZero color:UIColor.redColor];
|
||||
[self addSubview:_centerBgBtn];
|
||||
[_centerBgBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(0);
|
||||
make.centerY.mas_equalTo(0);
|
||||
make.size.mas_equalTo(CGSizeMake(ScaleWidth(305), ScaleWidth(345)));
|
||||
}];
|
||||
// [view mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.centerX.mas_equalTo(0);
|
||||
// make.centerY.mas_equalTo(0);
|
||||
// make.size.mas_equalTo(CGSizeMake(AUTO_CEIL_WIETH(305), AUTO_CEIL_WIETH(40)));
|
||||
// }];
|
||||
}
|
||||
return _centerBgBtn;
|
||||
}
|
||||
|
||||
- (void)updateClick {
|
||||
if (@available(iOS 10.0, *)) {
|
||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.downloadUrl] options:@{} completionHandler:nil];
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// Only override drawRect: if you perform custom drawing.
|
||||
// An empty implementation adversely affects performance during animation.
|
||||
- (void)drawRect:(CGRect)rect {
|
||||
// Drawing code
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
24
QXLive/Tabbar/TabbarCustomView/DrayView.h
Executable file
24
QXLive/Tabbar/TabbarCustomView/DrayView.h
Executable file
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// DrayView.h
|
||||
// SoundRiver
|
||||
//
|
||||
// Created by apple on 2020/1/18.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "FLImageView.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DrayView : UIView
|
||||
@property (nonatomic, strong) FLImageView *animationView;
|
||||
|
||||
@property (nonatomic,copy) dispatch_block_t onGotoRoomBtnCallBack;
|
||||
@property (nonatomic,copy) dispatch_block_t onLeaveRoomBtnCallBack;
|
||||
|
||||
// 靠右边
|
||||
- (void)keepRightViewStatus;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
205
QXLive/Tabbar/TabbarCustomView/DrayView.m
Executable file
205
QXLive/Tabbar/TabbarCustomView/DrayView.m
Executable file
@@ -0,0 +1,205 @@
|
||||
//
|
||||
// DrayView.m
|
||||
// SoundRiver
|
||||
//
|
||||
// Created by apple on 2020/1/18.
|
||||
//
|
||||
|
||||
#import "DrayView.h"
|
||||
|
||||
@interface DrayView ()
|
||||
@property (nonatomic, strong) UIImageView *bgImgView;
|
||||
@property (nonatomic, strong) UIButton *tapBtn;
|
||||
@property (nonatomic, strong) UIButton *closeBtn;
|
||||
@property (nonatomic, strong) UIView *lineView;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation DrayView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
//添加拖拽手势-改变控件的位置
|
||||
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(changePostion:)];
|
||||
[self addGestureRecognizer:pan];
|
||||
[self setHidden:YES];
|
||||
|
||||
[self addSubview:self.bgImgView];
|
||||
[self addSubview:self.animationView];
|
||||
[self addSubview:self.tapBtn];
|
||||
[self addSubview:self.closeBtn];
|
||||
[self addSubview:self.lineView];
|
||||
|
||||
[self.bgImgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self);
|
||||
}];
|
||||
[self.animationView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(2);
|
||||
make.centerY.equalTo(self);
|
||||
make.width.height.mas_equalTo(46);
|
||||
}];
|
||||
[self.tapBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self.animationView);
|
||||
}];
|
||||
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(70);
|
||||
make.centerY.equalTo(self);
|
||||
make.width.height.mas_equalTo(25);
|
||||
}];
|
||||
[self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.bottom.equalTo(self).inset(15);
|
||||
make.left.mas_equalTo(60);
|
||||
make.width.mas_offset(1);
|
||||
}];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Btn Click
|
||||
- (void)onTapBtnClick:(UIButton *)btn {
|
||||
if (self.onGotoRoomBtnCallBack) {
|
||||
self.onGotoRoomBtnCallBack();
|
||||
}
|
||||
}
|
||||
- (void)onLeaveRoomBtnClick:(UIButton *)btn {
|
||||
if (self.onLeaveRoomBtnCallBack) {
|
||||
self.onLeaveRoomBtnCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Getter
|
||||
- (UIImageView *)bgImgView {
|
||||
if (!_bgImgView) {
|
||||
_bgImgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tabbar_live_room_play_bg_tip"]];
|
||||
}
|
||||
return _bgImgView;
|
||||
}
|
||||
- (FLImageView *)animationView {
|
||||
if (!_animationView) {
|
||||
_animationView = [[FLImageView alloc] init];
|
||||
_animationView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
_animationView.layer.masksToBounds = YES;
|
||||
_animationView.layer.cornerRadius = 23;
|
||||
}
|
||||
return _animationView;
|
||||
}
|
||||
- (UIButton *)tapBtn {
|
||||
if (!_tapBtn) {
|
||||
_tapBtn = [[UIButton alloc] init];
|
||||
// _tapBtn.needEventInterval = 0.5;
|
||||
// [_tapBtn hx_setEnlargeEdgeWithTop:5 right:5 bottom:5 left:5];
|
||||
[_tapBtn addTarget:self action:@selector(onTapBtnClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _tapBtn;
|
||||
}
|
||||
- (UIButton *)closeBtn {
|
||||
if (!_closeBtn) {
|
||||
_closeBtn = [[UIButton alloc] init];
|
||||
[_closeBtn setImage:[UIImage imageNamed:@"tabbar_live_close_btn"] forState:UIControlStateNormal];
|
||||
// _closeBtn.needEventInterval = 0.5;
|
||||
// [_closeBtn hx_setEnlargeEdgeWithTop:5 right:5 bottom:5 left:5];
|
||||
[_closeBtn addTarget:self action:@selector(onLeaveRoomBtnClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _closeBtn;
|
||||
}
|
||||
|
||||
- (UIView *)lineView {
|
||||
if (!_lineView) {
|
||||
_lineView = [[UIView alloc] init];
|
||||
_lineView.backgroundColor = UIColor.whiteColor;
|
||||
}
|
||||
return _lineView;
|
||||
}
|
||||
|
||||
#pragma mark - Other
|
||||
// 靠右边
|
||||
- (void)keepRightViewStatus {
|
||||
self.bgImgView.transform = CGAffineTransformIdentity;
|
||||
|
||||
[self.animationView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(2);
|
||||
make.centerY.equalTo(self);
|
||||
make.width.height.mas_equalTo(46);
|
||||
}];
|
||||
[self.closeBtn mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(70);
|
||||
}];
|
||||
[self.lineView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(60);
|
||||
}];
|
||||
}
|
||||
// 靠左边
|
||||
- (void)keepLeftViewStatus {
|
||||
self.bgImgView.transform = CGAffineTransformMakeRotation(M_PI);
|
||||
|
||||
[self.animationView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(-2);
|
||||
make.centerY.equalTo(self);
|
||||
make.width.height.mas_equalTo(46);
|
||||
}];
|
||||
[self.closeBtn mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(5);
|
||||
}];
|
||||
[self.lineView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(35);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - UIPanGestureRecognizer
|
||||
- (void)changePostion:(UIPanGestureRecognizer *)pan{
|
||||
CGPoint point = [pan translationInView:self];
|
||||
CGRect originalFrame = self.frame;
|
||||
originalFrame = [self changeXWithFrame:originalFrame point:point];
|
||||
originalFrame = [self changeYWithFrame:originalFrame point:point];
|
||||
self.frame = originalFrame;
|
||||
[pan setTranslation:CGPointZero inView:self];
|
||||
|
||||
UIButton *button = (UIButton *)pan.view;
|
||||
if (pan.state == UIGestureRecognizerStateBegan) {
|
||||
button.enabled = NO;
|
||||
}else if (pan.state == UIGestureRecognizerStateChanged){
|
||||
} else {
|
||||
CGRect frame = self.frame;
|
||||
if (self.center.x <= SCREEN_WIDTH / 2.0){
|
||||
frame.origin.x = 0;
|
||||
[self keepLeftViewStatus];
|
||||
}else {
|
||||
frame.origin.x = SCREEN_WIDTH - frame.size.width;
|
||||
[self keepRightViewStatus];
|
||||
}
|
||||
if (frame.origin.y < NavContentHeight) {
|
||||
frame.origin.y = NavContentHeight;
|
||||
} else if (frame.origin.y + frame.size.height > SCREEN_HEIGHT - NavContentHeight - TabbarHeight) {
|
||||
frame.origin.y = SCREEN_WIDTH - NavContentHeight - TabbarHeight - frame.size.height;
|
||||
}
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.frame = frame;
|
||||
}];
|
||||
button.enabled = YES;
|
||||
}
|
||||
}
|
||||
|
||||
//拖动改变控件的水平方向x值
|
||||
- (CGRect)changeXWithFrame:(CGRect)originalFrame point:(CGPoint)point{
|
||||
BOOL q1 = originalFrame.origin.x >= 0;
|
||||
BOOL q2 = originalFrame.origin.x + originalFrame.size.width <= SCREEN_WIDTH;
|
||||
if (q1 && q2) {
|
||||
originalFrame.origin.x += point.x;
|
||||
}
|
||||
return originalFrame;
|
||||
}
|
||||
|
||||
//拖动改变控件的竖直方向y值
|
||||
- (CGRect)changeYWithFrame:(CGRect)originalFrame point:(CGPoint)point{
|
||||
BOOL q1 = originalFrame.origin.y >= 20;
|
||||
BOOL q2 = originalFrame.origin.y + originalFrame.size.height <= SCREEN_HEIGHT;
|
||||
if (q1 && q2) {
|
||||
originalFrame.origin.y += point.y;
|
||||
}
|
||||
return originalFrame;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
21
QXLive/Tabbar/TabbarCustomView/FLImageView.h
Executable file
21
QXLive/Tabbar/TabbarCustomView/FLImageView.h
Executable file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// FLImageView.h
|
||||
// SoundRiver
|
||||
//
|
||||
// Created by ln007 on 2019/4/27.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FLImageView : UIImageView {
|
||||
CABasicAnimation *_rotateAnimation;
|
||||
}
|
||||
|
||||
- (void)startRotating;
|
||||
- (void)stopRotating;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
29
QXLive/Tabbar/TabbarCustomView/FLImageView.m
Executable file
29
QXLive/Tabbar/TabbarCustomView/FLImageView.m
Executable file
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// FLImageView.m
|
||||
// SoundRiver
|
||||
//
|
||||
// Created by ln007 on 2019/4/27.
|
||||
//
|
||||
|
||||
#import "FLImageView.h"
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
@implementation FLImageView
|
||||
- (void)startRotating {
|
||||
if (!_rotateAnimation) {
|
||||
CABasicAnimation *rotateAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
|
||||
rotateAnimation.fromValue = [NSNumber numberWithFloat:0.0];
|
||||
rotateAnimation.toValue = [NSNumber numberWithFloat:M_PI * 2]; //旋转一周
|
||||
rotateAnimation.duration = 20.0; //旋转时间 20秒
|
||||
rotateAnimation.repeatCount = MAXFLOAT; //重复次数,这里使用最大次数
|
||||
_rotateAnimation = rotateAnimation;
|
||||
rotateAnimation.removedOnCompletion = NO;
|
||||
}
|
||||
[self.layer addAnimation:_rotateAnimation forKey:nil];
|
||||
}
|
||||
|
||||
- (void)stopRotating {
|
||||
[self.layer removeAllAnimations];
|
||||
}
|
||||
|
||||
@end
|
||||
39
QXLive/Tabbar/TabbarCustomView/QXTabBar.h
Normal file
39
QXLive/Tabbar/TabbarCustomView/QXTabBar.h
Normal file
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// QXTabBar.h
|
||||
// FreeTabbar_JoeJin
|
||||
//
|
||||
// Created by J-Mac on 2024/5/24.
|
||||
// Copyright © 2024 JoeJin-QQ:853105953. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <Masonry/Masonry.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class QXTabBar,QXTabbarConfig;
|
||||
|
||||
@protocol QXTabBarDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
- (void)QXTabBar:(QXTabBar *)tabBar didSelectedButtonFrom:(NSInteger)from to:(NSInteger)to;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface QXTabBar : UIView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame centerCustom:(BOOL)centerCustom config:(QXTabbarConfig *)config;
|
||||
|
||||
|
||||
- (void)addTabBarButtonNorImageUrl:(NSString *)norImageUrl
|
||||
selImageUrl:(NSString *)selImageUrl
|
||||
title:(NSString *)title;
|
||||
|
||||
|
||||
@property (nonatomic, weak) id<QXTabBarDelegate> delegate;
|
||||
@property (nonatomic,assign)UInt64 unReadNumber;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
186
QXLive/Tabbar/TabbarCustomView/QXTabBar.m
Normal file
186
QXLive/Tabbar/TabbarCustomView/QXTabBar.m
Normal file
@@ -0,0 +1,186 @@
|
||||
//
|
||||
// QXTabBar.m
|
||||
// FreeTabbar_JoeJin
|
||||
//
|
||||
// Created by J-Mac on 2024/5/24.
|
||||
// Copyright © 2024 JoeJin-QQ:853105953. All rights reserved.
|
||||
//
|
||||
|
||||
#import "QXTabBar.h"
|
||||
#import <Masonry/Masonry.h>
|
||||
#import "QXTabbarConfig.h"
|
||||
#import "QXTabBarButton.h"
|
||||
|
||||
@interface QXTabBar()<QXTabBarButtonDelegate>
|
||||
/// 当前选中的按钮
|
||||
@property (nonatomic, weak) QXTabBarButton *selectedButton;
|
||||
/// UITabBarItem对象数组
|
||||
@property(nonatomic, strong)NSMutableArray *tabbarBtnArray;
|
||||
/// norImage
|
||||
@property (nonatomic, strong) NSMutableArray *norImageArrM;
|
||||
/// SelImage
|
||||
@property (nonatomic, strong) NSMutableArray *selImageArrM;
|
||||
/// 背景图片
|
||||
@property (nonatomic, strong) UIImageView *bgImageView;
|
||||
@property (nonatomic, assign) BOOL centerCustom;
|
||||
|
||||
@property (nonatomic, weak) QXTabBarButton *messageBtn;
|
||||
@end
|
||||
|
||||
@implementation QXTabBar
|
||||
|
||||
- (NSMutableArray *)tabbarBtnArray {
|
||||
if (!_tabbarBtnArray) {
|
||||
_tabbarBtnArray = [NSMutableArray array];
|
||||
}
|
||||
return _tabbarBtnArray;
|
||||
}
|
||||
|
||||
- (NSMutableArray *)norImageArrM {
|
||||
if (!_norImageArrM) {
|
||||
_norImageArrM = [NSMutableArray array];
|
||||
}
|
||||
return _norImageArrM;
|
||||
}
|
||||
|
||||
- (NSMutableArray *)selImageArrM {
|
||||
if (!_selImageArrM) {
|
||||
_selImageArrM = [NSMutableArray array];
|
||||
}
|
||||
return _selImageArrM;
|
||||
}
|
||||
|
||||
- (UIImageView *)bgImageView {
|
||||
if (!_bgImageView) {
|
||||
_bgImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"tabbar背景"]];
|
||||
_bgImageView.userInteractionEnabled = YES;
|
||||
}
|
||||
return _bgImageView;
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame centerCustom:(BOOL)centerCustom config:(QXTabbarConfig *)config{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
self.centerCustom = self.centerCustom;
|
||||
[self addSubview:self.bgImageView];
|
||||
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self).offset(0);//[[QXTabbarConfig shareInstance]bgImageOffset]
|
||||
make.left.right.equalTo(self);
|
||||
make.bottom.equalTo(self);
|
||||
}];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void)addTabBarButtonNorImageUrl:(NSString *)norImageUrl
|
||||
selImageUrl:(NSString *)selImageUrl
|
||||
title:(NSString *)title {
|
||||
|
||||
// 1.创建按钮
|
||||
QXTabBarButton *tabBarBtn = [[QXTabBarButton alloc] init];
|
||||
tabBarBtn.delegate = self;
|
||||
[self addSubview:tabBarBtn];
|
||||
// 2.设置数据
|
||||
[tabBarBtn setTabBarImageUrl:norImageUrl selectedImg:selImageUrl title:title];
|
||||
// 3.监听按钮点击
|
||||
[tabBarBtn addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchDown];
|
||||
// 4.将自定义的YBTabBarButton对象
|
||||
[self.tabbarBtnArray addObject:tabBarBtn];
|
||||
[self.norImageArrM addObject:norImageUrl];
|
||||
// 5.默认选中第0个按钮
|
||||
if (self.tabbarBtnArray.count == 1) {
|
||||
[self buttonClick:tabBarBtn];
|
||||
[tabBarBtn.iconBtn setSelected:YES];
|
||||
}
|
||||
|
||||
if ([title isEqualToString:QXText(@"消息")]) {
|
||||
self.messageBtn = tabBarBtn;
|
||||
}
|
||||
}
|
||||
|
||||
-(void)setUnReadNumber:(UInt64)unReadNumber{
|
||||
_unReadNumber = unReadNumber;
|
||||
[self.messageBtn.unreadView setNum:unReadNumber];
|
||||
}
|
||||
|
||||
/// 当前点击的按钮置为选中样式
|
||||
#pragma mark - 设置选中的ybButton
|
||||
- (void)JJDealSelectButton:(QXTabBarButton *)ybButton {
|
||||
for (int i = 0; i < self.tabbarBtnArray.count; i++) {
|
||||
QXTabBarButton *currentButton = self.tabbarBtnArray[i];
|
||||
if (currentButton == ybButton) {
|
||||
[currentButton.iconBtn setSelected:YES];
|
||||
currentButton.titleLbl.textColor = QXConfig.themeColor;
|
||||
} else {
|
||||
[currentButton.iconBtn setSelected:NO];
|
||||
currentButton.titleLbl.textColor = [[QXTabbarConfig shareInstance] norTitleColor];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - <QXTabBarButtonDelegate>
|
||||
- (void)QXTabbarIconButtonClick:(QXTabBarButton *)button {
|
||||
[self buttonClick:button];
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听按钮点击
|
||||
*/
|
||||
- (void)buttonClick:(QXTabBarButton *)button {
|
||||
// 1.通知代理
|
||||
if ([self.delegate respondsToSelector:@selector(QXTabBar:didSelectedButtonFrom:to:)]) {
|
||||
[self.delegate QXTabBar:self didSelectedButtonFrom:self.selectedButton.tag to:button.tag];
|
||||
}
|
||||
if (![QXGlobal shareGlobal].isLogin && button.tag == QXConfig.tabbarArray.count-1) {
|
||||
return;
|
||||
}
|
||||
// 2.设置按钮的状态
|
||||
self.selectedButton.selected = NO;
|
||||
button.selected = YES;
|
||||
self.selectedButton = button;
|
||||
[self JJDealSelectButton:self.selectedButton];
|
||||
|
||||
}
|
||||
|
||||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
|
||||
// 按钮的frame数据
|
||||
CGFloat buttonH = self.frame.size.height;
|
||||
CGFloat buttonW = self.frame.size.width / self.tabbarBtnArray.count;
|
||||
CGFloat buttonY = 0;
|
||||
for (int index = 0; index<self.tabbarBtnArray.count; index++) {
|
||||
// 1.取出按钮
|
||||
QXTabBarButton *button = self.tabbarBtnArray[index];
|
||||
// 2.设置按钮的frame
|
||||
CGFloat buttonX = index * buttonW;
|
||||
|
||||
if(index==2 && self.centerCustom){
|
||||
[button.titleLbl mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(self);
|
||||
make.top.equalTo(button.iconBtn.mas_bottom).offset([[QXTabbarConfig shareInstance] titleOffset]);
|
||||
make.left.right.equalTo(self);
|
||||
make.height.mas_equalTo([[QXTabbarConfig shareInstance]titleHeight]);
|
||||
}];
|
||||
button.frame = CGRectMake(buttonX, -18, buttonW, buttonH);
|
||||
[button.iconBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(button.mas_centerX);
|
||||
make.top.equalTo(button.mas_top);
|
||||
make.height.width.mas_equalTo(65);
|
||||
}];
|
||||
}else{
|
||||
|
||||
button.frame = CGRectMake(buttonX, buttonY, buttonW, buttonH);
|
||||
}
|
||||
|
||||
// 3.绑定tag
|
||||
button.tag = index;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
40
QXLive/Tabbar/TabbarCustomView/QXTabBarButton.h
Normal file
40
QXLive/Tabbar/TabbarCustomView/QXTabBarButton.h
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// QXTabBarButton.h
|
||||
// FreeTabbar_JoeJin
|
||||
//
|
||||
// Created by J-Mac on 2024/5/24.
|
||||
// Copyright © 2024 JoeJin-QQ:853105953. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <Masonry/Masonry.h>
|
||||
#import "QXTabbarConfig.h"
|
||||
#import "TIMCommonModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class QXTabBarButton;
|
||||
|
||||
@protocol QXTabBarButtonDelegate <NSObject>
|
||||
|
||||
- (void)QXTabbarIconButtonClick:(QXTabBarButton *)button;
|
||||
|
||||
@end
|
||||
|
||||
@interface QXTabBarButton : UIControl
|
||||
@property (nonatomic, weak) id<QXTabBarButtonDelegate> delegate;
|
||||
|
||||
/// 背景图片按钮
|
||||
@property (nonatomic, strong) UIButton *iconBtn;
|
||||
/// 文字
|
||||
@property (nonatomic, strong) UILabel *titleLbl;
|
||||
|
||||
@property (nonatomic,strong)TUIUnReadView *unreadView;
|
||||
/// 设置自定义tabbar的图片和文字
|
||||
/// @param imageUrl 图片URL路径
|
||||
/// @param title 标题文字
|
||||
- (void)setTabBarImageUrl:(NSString *)imageUrl selectedImg:(NSString*)imageName title:(NSString *)title;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
122
QXLive/Tabbar/TabbarCustomView/QXTabBarButton.m
Normal file
122
QXLive/Tabbar/TabbarCustomView/QXTabBarButton.m
Normal file
@@ -0,0 +1,122 @@
|
||||
//
|
||||
// QXTabBarButton.m
|
||||
// FreeTabbar_JoeJin
|
||||
//
|
||||
// Created by J-Mac on 2024/5/24.
|
||||
// Copyright © 2024 JoeJin-QQ:853105953. All rights reserved.
|
||||
//
|
||||
|
||||
#import "QXTabBarButton.h"
|
||||
|
||||
@implementation QXTabBarButton
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self addSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void)addSubviews {
|
||||
|
||||
[self addSubview:self.iconBtn];
|
||||
[self addSubview:self.titleLbl];
|
||||
[self.iconBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(self);
|
||||
make.top.equalTo(self.mas_top).offset(-1);
|
||||
make.height.width.mas_equalTo(32);
|
||||
}];
|
||||
|
||||
|
||||
[self.titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(self);
|
||||
make.top.equalTo(self.iconBtn.mas_bottom).offset(0);
|
||||
make.left.right.equalTo(self);
|
||||
make.height.mas_equalTo(12);
|
||||
}];
|
||||
[self addTarget:self action:@selector(iconButtonClick:) forControlEvents:(UIControlEventTouchDown)];
|
||||
|
||||
self.unreadView = [[TUIUnReadView alloc] init];
|
||||
[self.unreadView setNum:0];
|
||||
[self addSubview:self.unreadView];
|
||||
[self.unreadView.unReadLabel sizeToFit];
|
||||
[self.unreadView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self);
|
||||
make.left.equalTo(self.iconBtn.mas_right).offset(-10);
|
||||
make.width.mas_equalTo(kScale375(20));
|
||||
make.height.mas_equalTo(kScale375(20));
|
||||
}];
|
||||
|
||||
|
||||
[self.unreadView.unReadLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.center.mas_equalTo(self.unreadView);
|
||||
make.size.mas_equalTo(self.unreadView.unReadLabel);
|
||||
}];
|
||||
self.unreadView.layer.cornerRadius = kScale375(10);
|
||||
[self.unreadView.layer masksToBounds];
|
||||
}
|
||||
|
||||
#pragma mark -- 点击
|
||||
- (void)iconButtonClick:(QXTabBarButton *)ybButton {
|
||||
// if (ybButton.titleLbl.text.length == 0) {
|
||||
[self heartAnimationWithView:ybButton.iconBtn];
|
||||
// }
|
||||
if ([self.delegate respondsToSelector:@selector(QXTabbarIconButtonClick:)]) {
|
||||
[self.delegate QXTabbarIconButtonClick:self];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -- lazy load
|
||||
|
||||
- (UIButton *)iconBtn {
|
||||
if (!_iconBtn) {
|
||||
_iconBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
//_iconBtn.backgroundColor = [UIColor cyanColor];
|
||||
_iconBtn.contentMode = UIViewContentModeScaleAspectFill;
|
||||
_iconBtn.userInteractionEnabled = NO;
|
||||
}
|
||||
return _iconBtn;
|
||||
}
|
||||
|
||||
- (UILabel *)titleLbl {
|
||||
if (!_titleLbl) {
|
||||
_titleLbl = [[UILabel alloc] init];
|
||||
_titleLbl.font = [UIFont systemFontOfSize:[[QXTabbarConfig shareInstance] titleFont]];
|
||||
//_titleLbl.textColor = KColorFromRGB(0x916d55);
|
||||
_titleLbl.textColor = [[QXTabbarConfig shareInstance] norTitleColor];
|
||||
_titleLbl.textAlignment = NSTextAlignmentCenter;
|
||||
}
|
||||
return _titleLbl;
|
||||
}
|
||||
|
||||
/// 设置自定义tabbar的图片和文字
|
||||
/// @param title 标题文字
|
||||
- (void)setTabBarImageUrl:(NSString *)imageUrl selectedImg:(nonnull NSString *)imageName title:(nonnull NSString *)title {
|
||||
self.titleLbl.text = title;
|
||||
if ([imageUrl hasPrefix:@"http"] || [imageUrl hasPrefix:@"https"]) {
|
||||
[self.iconBtn sd_setBackgroundImageWithURL:[NSURL URLWithString:imageUrl] forState:UIControlStateNormal placeholderImage:nil];
|
||||
}else{
|
||||
[self.iconBtn setBackgroundImage:[UIImage imageNamed:imageUrl] forState:UIControlStateNormal];
|
||||
}
|
||||
if ([imageName hasPrefix:@"http"] || [imageName hasPrefix:@"https"]) {
|
||||
[self.iconBtn sd_setBackgroundImageWithURL:[NSURL URLWithString:imageName] forState:UIControlStateSelected placeholderImage:nil];
|
||||
}else{
|
||||
[self.iconBtn setBackgroundImage:[UIImage imageNamed:imageName] forState:UIControlStateSelected];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)heartAnimationWithView:(UIView*)view{
|
||||
CABasicAnimation *anima = [CABasicAnimation animation];
|
||||
anima.keyPath = @"transform.scale";
|
||||
anima.fromValue = @1.2;
|
||||
anima.toValue = @0.5;
|
||||
anima.repeatCount = 1;
|
||||
anima.duration = 0.1;
|
||||
anima.autoreverses = YES;
|
||||
anima.removedOnCompletion = YES;
|
||||
[view.layer addAnimation:anima forKey:nil];
|
||||
}
|
||||
@end
|
||||
44
QXLive/Tabbar/TabbarCustomView/QXTabbarConfig.h
Normal file
44
QXLive/Tabbar/TabbarCustomView/QXTabbarConfig.h
Normal file
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// QXTabbarConfig.h
|
||||
// FreeTabbar_JoeJin
|
||||
//
|
||||
// Created by J-Mac on 2024/5/24.
|
||||
// Copyright © 2024 JoeJin-QQ:853105953. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Masonry/Masonry.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXTabbarConfig : NSObject
|
||||
|
||||
/**
|
||||
单例模式
|
||||
*/
|
||||
+ (instancetype)shareInstance;
|
||||
|
||||
/**
|
||||
* 默认配置/恢复默认配置(有需调用)
|
||||
*/
|
||||
- (void)configNormal;
|
||||
|
||||
/** 标题的默认颜色 (默认为 #808080) */
|
||||
@property (nonatomic, strong) UIColor *norTitleColor;
|
||||
/** 标题的选中颜色 (默认为 #d81e06)*/
|
||||
@property (nonatomic, strong) UIColor *selTitleColor;
|
||||
/** 图片的size (默认 50*50) */
|
||||
@property (nonatomic, assign) CGSize imageSize;
|
||||
/** 标签的高度 (默认 12) */
|
||||
@property (nonatomic, assign) CGFloat titleHeight;
|
||||
/** 标题文字大小 (默认 12.f) */
|
||||
@property (nonatomic, assign) CGFloat titleFont;
|
||||
/** 标题的偏移值 (标题距离底部的距离 默认 5.f) */
|
||||
@property (nonatomic, assign) CGFloat titleOffset;
|
||||
/** 图片的偏移值 (图片距离顶部的距离 默认 5.f) */
|
||||
@property (nonatomic, assign) CGFloat imageOffset;
|
||||
/** 背景图片的偏移值 (图片距离顶部的距离 默认 20.f) */
|
||||
@property (nonatomic, assign) CGFloat bgImageOffset;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
46
QXLive/Tabbar/TabbarCustomView/QXTabbarConfig.m
Normal file
46
QXLive/Tabbar/TabbarCustomView/QXTabbarConfig.m
Normal file
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// QXTabbarConfig.m
|
||||
// FreeTabbar_JoeJin
|
||||
//
|
||||
// Created by J-Mac on 2024/5/24.
|
||||
// Copyright © 2024 JoeJin-QQ:853105953. All rights reserved.
|
||||
//
|
||||
|
||||
#import "QXTabbarConfig.h"
|
||||
|
||||
@implementation QXTabbarConfig
|
||||
|
||||
static id _instance = nil;
|
||||
|
||||
+ (instancetype)shareInstance {
|
||||
return [[self alloc] init];
|
||||
}
|
||||
|
||||
+ (instancetype)allocWithZone:(struct _NSZone *)zone {
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
_instance = [super allocWithZone:zone];
|
||||
});
|
||||
return _instance;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
_instance = [super init];
|
||||
[self configNormal];
|
||||
});
|
||||
return _instance;
|
||||
}
|
||||
|
||||
- (void)configNormal {
|
||||
_norTitleColor = RGB16(0x999999);//[UIColor colorWithHexString:@"#808080"];
|
||||
_selTitleColor = RGB16(0x333333);//[UIColor colorWithHexString:@"#d81e06"];
|
||||
_imageSize = CGSizeMake(24, 24);
|
||||
_titleFont = 12.f;
|
||||
_titleOffset = 5.f;
|
||||
_imageOffset = 5.f;
|
||||
_titleHeight = 12.f;
|
||||
_bgImageOffset = 20.f;
|
||||
}
|
||||
@end
|
||||
31
QXLive/Tabbar/弹窗/QXAlertView.h
Normal file
31
QXLive/Tabbar/弹窗/QXAlertView.h
Normal file
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// QXAlertView.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/6/3.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
typedef NS_ENUM(NSInteger) {
|
||||
/// 删除动态
|
||||
QXAlertViewTypeDeleteDynamic = 0,
|
||||
/// 删除评论
|
||||
QXAlertViewTypeDeleteComment,
|
||||
/// 发起点歌
|
||||
QXAlertViewTypeApplySong,
|
||||
/// 同意点歌
|
||||
QXAlertViewTypeAgreeSong,
|
||||
/// pk弹窗
|
||||
QXAlertViewTypeAgreePK,
|
||||
}QXAlertViewType;
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXAlertView : UIView
|
||||
@property (nonatomic,assign)QXAlertViewType type;
|
||||
@property (nonatomic,assign)NSString *message;
|
||||
@property (nonatomic,assign)NSString *title;
|
||||
@property (nonatomic,copy)void(^commitBlock)(void);
|
||||
@property (nonatomic,copy)void(^cancelBlock)(void);
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
152
QXLive/Tabbar/弹窗/QXAlertView.m
Normal file
152
QXLive/Tabbar/弹窗/QXAlertView.m
Normal file
@@ -0,0 +1,152 @@
|
||||
//
|
||||
// QXAlertView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/6/3.
|
||||
//
|
||||
|
||||
#import "QXAlertView.h"
|
||||
#import "QXTimer.h"
|
||||
|
||||
@interface QXAlertView()
|
||||
@property (nonatomic,strong)UILabel *titleLabel;
|
||||
@property (nonatomic,strong)UILabel *messageLabel;
|
||||
@property (nonatomic,strong)UIButton *cancelBtn;
|
||||
@property (nonatomic,strong)UIButton *commitBtn;
|
||||
@property (nonatomic,strong)QXTimer *timer;
|
||||
@end
|
||||
@implementation QXAlertView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)initSubviews{
|
||||
self.backgroundColor = [UIColor whiteColor];
|
||||
[self addRoundedCornersWithRadius:16];
|
||||
self.titleLabel = [[UILabel alloc] init];
|
||||
self.titleLabel.font = [UIFont boldSystemFontOfSize:16];
|
||||
self.titleLabel.text = QXText(@"提示");
|
||||
self.titleLabel.textColor = RGB16(0x333333);
|
||||
[self addSubview:self.titleLabel];
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(self);
|
||||
make.top.equalTo(self).offset(16);
|
||||
make.height.mas_equalTo(24);
|
||||
}];
|
||||
|
||||
self.messageLabel = [[UILabel alloc] init];
|
||||
self.messageLabel.font = [UIFont boldSystemFontOfSize:16];
|
||||
self.messageLabel.text = QXText(@"确定要删除此评论吗?");
|
||||
self.messageLabel.textColor = RGB16(0x000000);
|
||||
self.messageLabel.numberOfLines = 0;
|
||||
[self addSubview:self.messageLabel];
|
||||
[self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(self);
|
||||
make.left.equalTo(self).offset(16);
|
||||
make.right.equalTo(self).offset(-16);
|
||||
make.centerY.equalTo(self);
|
||||
}];
|
||||
|
||||
|
||||
self.commitBtn = [[UIButton alloc] init];
|
||||
[self.commitBtn addRoundedCornersWithRadius:21];
|
||||
self.commitBtn.backgroundColor = QXConfig.themeColor;
|
||||
[self.commitBtn setTitle:QXText(@"确认") forState:(UIControlStateNormal)];
|
||||
[self.commitBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
||||
self.commitBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.commitBtn addTarget:self action:@selector(commitAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.commitBtn];
|
||||
[self.commitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.equalTo(self).offset(-12);
|
||||
make.height.mas_equalTo(42);
|
||||
make.width.mas_equalTo(ScaleWidth(110));
|
||||
make.right.mas_equalTo(-20);
|
||||
}];
|
||||
|
||||
|
||||
self.cancelBtn = [[UIButton alloc] init];
|
||||
[self.cancelBtn addRoundedCornersWithRadius:21];
|
||||
self.cancelBtn.backgroundColor = RGB16(0xF3F3F3);
|
||||
[self.cancelBtn setTitle:QXText(@"取消") forState:(UIControlStateNormal)];
|
||||
[self.cancelBtn setTitleColor:RGB16(0x999999) forState:(UIControlStateNormal)];
|
||||
self.cancelBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.cancelBtn addTarget:self action:@selector(cancelAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.cancelBtn];
|
||||
[self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.equalTo(self).offset(-12);
|
||||
make.height.mas_equalTo(42);
|
||||
make.width.mas_equalTo(ScaleWidth(110));
|
||||
make.left.mas_equalTo(20);
|
||||
}];
|
||||
}
|
||||
-(void)setType:(QXAlertViewType)type{
|
||||
_type = type;
|
||||
switch (type) {
|
||||
case QXAlertViewTypeDeleteDynamic:
|
||||
self.messageLabel.text = QXText(@"确定要删除此动态吗?");
|
||||
break;
|
||||
case QXAlertViewTypeDeleteComment:
|
||||
self.messageLabel.text = QXText(@"确定要删除此评论吗?");
|
||||
break;
|
||||
case QXAlertViewTypeApplySong:
|
||||
self.messageLabel.text = QXText(@"您将要发起点歌申请");
|
||||
break;
|
||||
case QXAlertViewTypeAgreeSong:
|
||||
case QXAlertViewTypeAgreePK:{
|
||||
MJWeakSelf
|
||||
[self.cancelBtn setTitle:QXText(@"拒绝") forState:(UIControlStateNormal)];
|
||||
[self.commitBtn setTitle:QXText(@"同意") forState:(UIControlStateNormal)];
|
||||
__block int timeCount = 10;
|
||||
_timer = [QXTimer scheduledTimerWithTimeInterval:1 repeats:YES queue:dispatch_get_main_queue() block:^{
|
||||
timeCount--;
|
||||
if (timeCount<=0) {
|
||||
[self->_timer invalidate];
|
||||
[weakSelf cancelAction];
|
||||
}else{
|
||||
[self->_cancelBtn setTitle:[NSString stringWithFormat:@"%@(%d)",QXText(@"拒绝"),timeCount] forState:(UIControlStateNormal)];
|
||||
}
|
||||
}];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
-(void)setMessage:(NSString *)message{
|
||||
self.messageLabel.text = message;
|
||||
}
|
||||
-(void)setTitle:(NSString *)title{
|
||||
_title = title;
|
||||
self.titleLabel.text = title;
|
||||
}
|
||||
-(void)cancelAction{
|
||||
if (_timer) {
|
||||
[self->_timer invalidate];
|
||||
_timer = nil;
|
||||
}
|
||||
MJWeakSelf
|
||||
[[QXGlobal shareGlobal] hideViewBlock:^{
|
||||
if (weakSelf.cancelBlock) {
|
||||
weakSelf.cancelBlock();
|
||||
}
|
||||
}];
|
||||
}
|
||||
-(void)commitAction{
|
||||
if (_timer) {
|
||||
[self->_timer invalidate];
|
||||
_timer = nil;
|
||||
}
|
||||
MJWeakSelf
|
||||
[[QXGlobal shareGlobal] hideViewBlock:^{
|
||||
if (weakSelf.commitBlock) {
|
||||
weakSelf.commitBlock();
|
||||
}
|
||||
}];
|
||||
}
|
||||
@end
|
||||
18
QXLive/Tabbar/弹窗/QXChirldPopView.h
Normal file
18
QXLive/Tabbar/弹窗/QXChirldPopView.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// QXChirldPopView.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/8.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXChirldPopView : UIView
|
||||
@property (nonatomic,copy)void(^closeActionBlock)(void);
|
||||
@property (nonatomic,copy)void(^gotoActionBlock)(void);
|
||||
@property (nonatomic,copy)void(^setActionBlock)(void);
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
128
QXLive/Tabbar/弹窗/QXChirldPopView.m
Normal file
128
QXLive/Tabbar/弹窗/QXChirldPopView.m
Normal file
@@ -0,0 +1,128 @@
|
||||
//
|
||||
// QXChirldPopView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/8.
|
||||
//
|
||||
|
||||
#import "QXChirldPopView.h"
|
||||
@interface QXChirldPopView()
|
||||
@property (nonatomic,strong)UIImageView*bgImageView;
|
||||
@property (nonatomic,strong)UILabel*titleLabel;
|
||||
@property (nonatomic,strong)UILabel*contentLabel;
|
||||
@property (nonatomic,strong)UIButton*goBtn;
|
||||
@property (nonatomic,strong)UIButton*closeBtn;
|
||||
@property (nonatomic,strong)UIButton *setBtn;
|
||||
@end
|
||||
|
||||
@implementation QXChirldPopView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.frame = CGRectMake(0, 0, ScaleWidth(275), ScaleWidth(365+48));
|
||||
[self initSubViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)initSubViews{
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"a_pop_chirld_mode"]];
|
||||
[self addSubview:self.bgImageView];
|
||||
|
||||
self.titleLabel = [[UILabel alloc] init];
|
||||
self.titleLabel.font = [UIFont boldSystemFontOfSize:16];
|
||||
self.titleLabel.textColor = QXConfig.textColor;
|
||||
self.titleLabel.text = QXText(@"青少年模式");
|
||||
self.titleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
[self addSubview:self.titleLabel];
|
||||
|
||||
self.contentLabel = [[UILabel alloc] init];
|
||||
self.contentLabel.numberOfLines = 0;
|
||||
self.contentLabel.font = [UIFont boldSystemFontOfSize:14];
|
||||
self.contentLabel.textColor = RGB16(0x666666);
|
||||
self.contentLabel.text = QXText(@"为了呵护未成年人健康成长,蜜耳语音特别推出青少年模式,该模式下部分功能无法正常使用,请监护人主动选择并设置监护密码");
|
||||
[self addSubview:self.contentLabel];
|
||||
|
||||
self.goBtn = [[UIButton alloc] init];
|
||||
[self.goBtn setTitleColor:RGB16(0xF4DF39) forState:(UIControlStateNormal)];
|
||||
[self.goBtn setTitle:[NSString stringWithFormat:@"%@>",QXText(@"进入青少年模式")] forState:(UIControlStateNormal)];
|
||||
self.goBtn.titleLabel.font = [UIFont systemFontOfSize:12];
|
||||
[self.goBtn addTarget:self action:@selector(gotoChirld) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.goBtn];
|
||||
|
||||
self.closeBtn = [[UIButton alloc] init];
|
||||
[self.closeBtn setBackgroundImage:[UIImage imageNamed:@"home_white_close"] forState:(UIControlStateNormal)];
|
||||
[self.closeBtn addTarget:self action:@selector(closeAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.closeBtn];
|
||||
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.centerX.equalTo(self);
|
||||
make.size.mas_equalTo(CGSizeMake(ScaleWidth(275), ScaleWidth(365)));
|
||||
}];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.equalTo(self);
|
||||
make.top.mas_equalTo(ScaleWidth(163));
|
||||
make.height.mas_equalTo(24);
|
||||
}];
|
||||
|
||||
[self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self).offset(13);
|
||||
make.right.equalTo(self).offset(-13);
|
||||
make.top.equalTo(self.titleLabel.mas_bottom).offset(10);
|
||||
}];
|
||||
|
||||
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(self);
|
||||
make.top.equalTo(self.bgImageView.mas_bottom).offset(8);
|
||||
make.height.width.mas_equalTo(30);
|
||||
}];
|
||||
//
|
||||
[self.goBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(self);
|
||||
make.height.mas_equalTo(30);
|
||||
make.bottom.equalTo(self.bgImageView.mas_bottom).offset(-55);
|
||||
}];
|
||||
|
||||
self.setBtn = [[UIButton alloc] init];
|
||||
[self.setBtn addRoundedCornersWithRadius:21];
|
||||
self.setBtn.backgroundColor = QXConfig.themeColor;
|
||||
[self.setBtn setTitle:QXText(@"设置青少年模式") forState:(UIControlStateNormal)];
|
||||
[self.setBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
||||
self.setBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.setBtn addTarget:self action:@selector(setAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.setBtn];
|
||||
[self.setBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.equalTo(self.bgImageView).offset(-12);
|
||||
make.height.mas_equalTo(42);
|
||||
make.right.equalTo(self.bgImageView).offset(-48);
|
||||
make.left.equalTo(self.bgImageView).offset(48);
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)gotoChirld{
|
||||
if (self.gotoActionBlock) {
|
||||
self.gotoActionBlock();
|
||||
}
|
||||
}
|
||||
-(void)closeAction{
|
||||
if (self.closeActionBlock) {
|
||||
self.closeActionBlock();
|
||||
}
|
||||
}
|
||||
|
||||
-(void)setAction{
|
||||
if (self.setActionBlock) {
|
||||
self.setActionBlock();
|
||||
}
|
||||
}
|
||||
@end
|
||||
19
QXLive/Tabbar/弹窗/QXFirstRechargePopView.h
Normal file
19
QXLive/Tabbar/弹窗/QXFirstRechargePopView.h
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// QXFirstRechargePopView.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/13.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXFirstRechargePopView : UIView
|
||||
@property (nonatomic,copy)void(^closeActionBlock)(void);
|
||||
@property (nonatomic,copy)void(^rechargeActionBlock)(NSString*money);
|
||||
@property (nonatomic,strong)NSArray *giftArray;
|
||||
-(void)reloadData;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
310
QXLive/Tabbar/弹窗/QXFirstRechargePopView.m
Normal file
310
QXLive/Tabbar/弹窗/QXFirstRechargePopView.m
Normal file
@@ -0,0 +1,310 @@
|
||||
//
|
||||
// QXFirstRechargePopView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/13.
|
||||
//
|
||||
|
||||
#import "QXFirstRechargePopView.h"
|
||||
#import "GKPageControl.h"
|
||||
#import <NSAttributedString+YYText.h>
|
||||
#import "QXGiftCell.h"
|
||||
#import "QXHomePageNetwork.h"
|
||||
|
||||
@interface QXFirstRechargePopView()<UICollectionViewDelegate,UICollectionViewDataSource>
|
||||
@property (nonatomic,strong)UIImageView *lightBgImageView;
|
||||
@property (nonatomic,strong)UIImageView *bgImageView;
|
||||
@property (nonatomic,strong)UILabel *priceLabel;
|
||||
|
||||
@property (nonatomic,strong)UIButton *firstBtn;
|
||||
@property (nonatomic,strong)UIButton *secondBtn;
|
||||
@property (nonatomic,strong)UIButton *thirdBtn;
|
||||
@property (nonatomic,strong)UIButton *selectedBtn;
|
||||
|
||||
@property (nonatomic,strong)UIView *giftBgView;
|
||||
@property (nonatomic,strong)UICollectionView *collectionView;
|
||||
@property (nonatomic,strong)GKPageControl *pageControl;
|
||||
@property (nonatomic,strong)UIButton *getBtn;
|
||||
@property (nonatomic,strong)UIButton *closeBtn;
|
||||
@property (nonatomic,strong)QXFirstRechargeModel *md1;
|
||||
@property (nonatomic,strong)QXFirstRechargeModel *md2;
|
||||
@property (nonatomic,strong)QXFirstRechargeModel *md3;
|
||||
@property (nonatomic,strong)QXFirstRechargeModel *smd;
|
||||
@end
|
||||
|
||||
@implementation QXFirstRechargePopView
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(582));
|
||||
[self initSubViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)initSubViews{
|
||||
self.lightBgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"a_pop_bg"]];
|
||||
[self addSubview:self.lightBgImageView];
|
||||
[self.lightBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.top.bottom.equalTo(self);
|
||||
}];
|
||||
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"a_pop_first_recharge"]];
|
||||
[self addSubview:self.bgImageView];
|
||||
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.centerY.equalTo(self);
|
||||
make.size.mas_equalTo(CGSizeMake(ScaleWidth(275), ScaleWidth(338)));
|
||||
}];
|
||||
|
||||
self.priceLabel = [[UILabel alloc] init];
|
||||
// self.priceLabel.attributedText =
|
||||
[self addSubview:self.priceLabel];
|
||||
[self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.bgImageView).offset(ScaleWidth(98));
|
||||
make.left.equalTo(self.bgImageView).offset(ScaleWidth(119));
|
||||
make.height.mas_equalTo(ScaleWidth(20));
|
||||
make.right.equalTo(self.bgImageView).offset(-5);
|
||||
}];
|
||||
|
||||
self.firstBtn = [[UIButton alloc] init];
|
||||
self.firstBtn.hidden = YES;
|
||||
UIImage *firstNorImage = [UIImage imageWithColor:RGB16(0xFFFFFF)];
|
||||
UIImage *firstSelImage = [UIImage imageWithColor:RGB16(0xF4DF39)];
|
||||
[self.firstBtn setBackgroundImage:firstNorImage forState:(UIControlStateNormal)];
|
||||
[self.firstBtn setBackgroundImage:firstSelImage forState:(UIControlStateSelected)];
|
||||
self.firstBtn.selected = YES;
|
||||
// [self.firstBtn setTitle:@"9元" forState:(UIControlStateNormal)];
|
||||
[self.firstBtn setTitleColor:RGB16(0x333333) forState:(UIControlStateNormal)];
|
||||
[self.firstBtn addRoundedCornersWithRadius:ScaleWidth(13)];
|
||||
self.firstBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.firstBtn addTarget:self action:@selector(rechargeSelectedAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
self.selectedBtn = self.firstBtn;
|
||||
[self addSubview:self.firstBtn];
|
||||
[self.firstBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.bgImageView).offset(ScaleWidth(24));
|
||||
make.top.equalTo(self.priceLabel.mas_bottom).offset(ScaleWidth(11));
|
||||
make.height.mas_equalTo(ScaleWidth(26));
|
||||
make.width.mas_equalTo(ScaleWidth(42));
|
||||
}];
|
||||
|
||||
self.secondBtn = [[UIButton alloc] init];
|
||||
self.secondBtn.hidden = YES;
|
||||
UIImage *secondNorImage = [UIImage imageWithColor:RGB16(0xFFFFFF)];
|
||||
UIImage *secondSelImage = [UIImage imageWithColor:RGB16(0xF4DF39)];
|
||||
[self.secondBtn setBackgroundImage:secondNorImage forState:(UIControlStateNormal)];
|
||||
[self.secondBtn setBackgroundImage:secondSelImage forState:(UIControlStateSelected)];
|
||||
// [self.secondBtn setTitle:@"30元" forState:(UIControlStateNormal)];
|
||||
[self.secondBtn setTitleColor:RGB16(0x333333) forState:(UIControlStateNormal)];
|
||||
[self.secondBtn addRoundedCornersWithRadius:ScaleWidth(13)];
|
||||
self.secondBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.secondBtn addTarget:self action:@selector(rechargeSelectedAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.secondBtn];
|
||||
[self.secondBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.firstBtn.mas_right).offset(12);
|
||||
make.top.equalTo(self.firstBtn);
|
||||
make.height.mas_equalTo(ScaleWidth(26));
|
||||
make.width.mas_equalTo(ScaleWidth(42));
|
||||
}];
|
||||
|
||||
|
||||
self.thirdBtn = [[UIButton alloc] init];
|
||||
self.thirdBtn.hidden = YES;
|
||||
UIImage *thirdNorImage = [UIImage imageWithColor:RGB16(0xFFFFFF)];
|
||||
UIImage *thirdSelImage = [UIImage imageWithColor:RGB16(0xF4DF39)];
|
||||
[self.thirdBtn setBackgroundImage:thirdNorImage forState:(UIControlStateNormal)];
|
||||
[self.thirdBtn setBackgroundImage:thirdSelImage forState:(UIControlStateSelected)];
|
||||
// [self.thirdBtn setTitle:@"60元" forState:(UIControlStateNormal)];
|
||||
[self.thirdBtn setTitleColor:RGB16(0x333333) forState:(UIControlStateNormal)];
|
||||
[self.thirdBtn addRoundedCornersWithRadius:ScaleWidth(13)];
|
||||
self.thirdBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.thirdBtn addTarget:self action:@selector(rechargeSelectedAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.thirdBtn];
|
||||
[self.thirdBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.secondBtn.mas_right).offset(12);
|
||||
make.top.equalTo(self.firstBtn);
|
||||
make.height.mas_equalTo(ScaleWidth(26));
|
||||
make.width.mas_equalTo(ScaleWidth(42));
|
||||
}];
|
||||
|
||||
self.giftBgView = [[UIView alloc] init];
|
||||
self.giftBgView.backgroundColor = [UIColor whiteColor];
|
||||
[self.giftBgView addRoundedCornersWithRadius:13];
|
||||
[self addSubview:self.giftBgView];
|
||||
[self.giftBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.firstBtn.mas_bottom).offset(ScaleWidth(12));
|
||||
make.left.equalTo(self.bgImageView).offset(24);
|
||||
make.right.equalTo(self.bgImageView).offset(-24);
|
||||
make.height.mas_equalTo(108);
|
||||
}];
|
||||
|
||||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||||
layout.itemSize = CGSizeMake((ScaleWidth(275)-24*2-3*8-12*2)/4, ScaleWidth(76));
|
||||
layout.minimumLineSpacing = 8;
|
||||
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
||||
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
||||
[self.collectionView registerNib:[UINib nibWithNibName:@"QXGiftCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"QXGiftCell"];
|
||||
self.collectionView.delegate = self;
|
||||
self.collectionView.dataSource = self;
|
||||
self.collectionView.showsHorizontalScrollIndicator = NO;
|
||||
self.collectionView.bounces = NO;
|
||||
// self.collectionView.pagingEnabled = YES;
|
||||
[self.giftBgView addSubview:self.collectionView];
|
||||
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(12);
|
||||
make.top.mas_equalTo(12);
|
||||
make.height.mas_equalTo(ScaleWidth(76));
|
||||
make.right.mas_equalTo(-12);
|
||||
}];
|
||||
|
||||
_pageControl = [[GKPageControl alloc] init];
|
||||
_pageControl.style = GKPageControlStyleRectangle;
|
||||
_pageControl.dotWidth = 15;
|
||||
_pageControl.dotHeight = 5;
|
||||
_pageControl.dotMargin = 2;
|
||||
_pageControl.hidden = YES;
|
||||
_pageControl.pageIndicatorTintColor = RGB16(0xEBEBEB);
|
||||
_pageControl.currentPageIndicatorTintColor = QXConfig.textColor;
|
||||
[self.giftBgView addSubview:self.pageControl];
|
||||
[self.pageControl mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.collectionView.mas_bottom).offset(3);
|
||||
make.height.mas_equalTo(5);
|
||||
make.right.mas_equalTo(-48);
|
||||
make.left.mas_equalTo(48);
|
||||
}];
|
||||
|
||||
self.getBtn = [[UIButton alloc] init];
|
||||
[self.getBtn addRoundedCornersWithRadius:21];
|
||||
self.getBtn.backgroundColor = QXConfig.themeColor;
|
||||
[self.getBtn setTitle:QXText(@"立即充值") forState:(UIControlStateNormal)];
|
||||
[self.getBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
||||
self.getBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.getBtn addTarget:self action:@selector(rechargeAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.getBtn];
|
||||
[self.getBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.equalTo(self.bgImageView).offset(-12);
|
||||
make.height.mas_equalTo(42);
|
||||
make.right.equalTo(self.bgImageView).offset(-48);
|
||||
make.left.equalTo(self.bgImageView).offset(48);
|
||||
}];
|
||||
|
||||
self.closeBtn = [[UIButton alloc] init];
|
||||
[self.closeBtn setBackgroundImage:[UIImage imageNamed:@"home_white_close"] forState:(UIControlStateNormal)];
|
||||
[self.closeBtn addTarget:self action:@selector(closeAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.closeBtn];
|
||||
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(self);
|
||||
make.top.equalTo(self.bgImageView.mas_bottom).offset(8);
|
||||
make.height.width.mas_equalTo(30);
|
||||
}];
|
||||
[self getFirstRechargeGiftList];
|
||||
}
|
||||
-(void)reloadData{
|
||||
[self getFirstRechargeGiftList];
|
||||
}
|
||||
-(void)getFirstRechargeGiftList{
|
||||
MJWeakSelf
|
||||
[QXHomePageNetwork getFirstRechargeGiftListSuccessBlock:^(NSArray<QXFirstRechargeModel *> * _Nonnull list) {
|
||||
for (int i = 0; i<list.count; i++) {
|
||||
if (i == 0) {
|
||||
weakSelf.md1 = list[i];
|
||||
weakSelf.firstBtn.hidden = NO;
|
||||
[weakSelf.firstBtn setTitle:weakSelf.md1.name forState:(UIControlStateNormal)];
|
||||
continue;
|
||||
}
|
||||
if (i == 1) {
|
||||
weakSelf.md2 = list[i];
|
||||
weakSelf.secondBtn.hidden = NO;
|
||||
[weakSelf.secondBtn setTitle:weakSelf.md2.name forState:(UIControlStateNormal)];
|
||||
continue;
|
||||
}
|
||||
if (i == 2) {
|
||||
weakSelf.md3 = list[i];
|
||||
weakSelf.thirdBtn.hidden = NO;
|
||||
[weakSelf.thirdBtn setTitle:weakSelf.md3.name forState:(UIControlStateNormal)];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
[weakSelf rechargeSelectedAction:weakSelf.firstBtn];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
showToast(msg);
|
||||
}];
|
||||
}
|
||||
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
|
||||
if ([scrollView isKindOfClass:[UICollectionView class]]) {
|
||||
long offsetX = (long)scrollView.contentOffset.x;
|
||||
int width = ScaleWidth(275-15*2-12*2-3*8);
|
||||
int remainder = offsetX % width;
|
||||
NSInteger index;
|
||||
if (remainder>(width)/2) {
|
||||
index = offsetX/width+1;
|
||||
}else{
|
||||
index = offsetX/width;
|
||||
}
|
||||
self.pageControl.currentPage = index;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-(void)setGiftArray:(NSArray *)giftArray{
|
||||
// _giftArray = giftArray;
|
||||
// self.pageControl.numberOfPages = giftArray.count/4+1;
|
||||
// self.pageControl.currentPage = 0;
|
||||
// [self.collectionView reloadData];
|
||||
//}
|
||||
|
||||
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||||
return self.giftArray.count;
|
||||
}
|
||||
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXGiftCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXGiftCell" forIndexPath:indexPath];
|
||||
cell.roomGiftModel = self.giftArray[indexPath.row];
|
||||
cell.cellType = QXGiftCellTypeNiceGift;
|
||||
return cell;
|
||||
}
|
||||
-(void)rechargeSelectedAction:(UIButton*)sender{
|
||||
self.selectedBtn.selected = !self.selectedBtn.selected;
|
||||
sender.selected = !sender.selected;
|
||||
self.selectedBtn = sender;
|
||||
QXFirstRechargeModel *md = nil;
|
||||
if (sender == self.firstBtn) {
|
||||
md = self.md1;
|
||||
self.giftArray = self.md1.gift_list;
|
||||
}else if (sender == self.secondBtn){
|
||||
self.giftArray = self.md2.gift_list;
|
||||
md = self.md2;
|
||||
}else if (sender == self.thirdBtn){
|
||||
self.giftArray = self.md3.gift_list;
|
||||
md = self.md3;
|
||||
}
|
||||
self.smd = md;
|
||||
if (md == nil) {
|
||||
return;
|
||||
}
|
||||
NSAttributedString *attr = [self changePrice:md.title1 giftPrice:md.title2];
|
||||
self.priceLabel.attributedText = attr;
|
||||
self.pageControl.numberOfPages = self.giftArray.count/4+1;
|
||||
self.pageControl.currentPage = 0;
|
||||
[self.collectionView reloadData];
|
||||
}
|
||||
|
||||
-(NSAttributedString *)changePrice:(NSString*)price giftPrice:(NSString*)giftPrice{
|
||||
NSString *str = [NSString stringWithFormat:@"%@ %@",price,giftPrice];
|
||||
NSAttributedString *attr = [str deleteLineWithTextColor:RGB16(0x999999) lineColor:RGB16(0x999999) range:[str rangeOfString:giftPrice]];
|
||||
NSMutableAttributedString *att = [[NSMutableAttributedString alloc] initWithAttributedString:attr];
|
||||
[att yy_setFont:[UIFont systemFontOfSize:14] range:[str rangeOfString:price]];
|
||||
[att yy_setFont:[UIFont systemFontOfSize:12] range:[str rangeOfString:giftPrice]];
|
||||
[att yy_setColor:RGB16(0x333333) range:[price rangeOfString:str]];
|
||||
return att;
|
||||
}
|
||||
-(void)rechargeAction{
|
||||
if (self.rechargeActionBlock) {
|
||||
self.rechargeActionBlock(self.smd.money);
|
||||
}
|
||||
}
|
||||
-(void)closeAction{
|
||||
if (self.closeActionBlock) {
|
||||
self.closeActionBlock();
|
||||
}
|
||||
}
|
||||
@end
|
||||
42
QXLive/Tabbar/弹窗/QXGiftCell.h
Normal file
42
QXLive/Tabbar/弹窗/QXGiftCell.h
Normal file
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// QXGiftCell.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/13.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "QXGiftModel.h"
|
||||
#import "QXUserModel.h"
|
||||
typedef NS_ENUM(NSInteger) {
|
||||
/// 天降好礼
|
||||
QXGiftCellTypeNiceGift = 0,
|
||||
/// 背包
|
||||
QXGiftCellTypeBackpack,
|
||||
/// 直播间
|
||||
QXGiftCellTypeLive,
|
||||
/// 礼物墙
|
||||
QXGiftCellTypeGiftWall,
|
||||
}QXGiftCellType;
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXGiftCell : UICollectionViewCell
|
||||
@property (weak, nonatomic) IBOutlet UILabel *numberLabel;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *gitfImageView;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *giftNameLabel;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *cornBtn;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *numberHeightConstraint;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *selecteBtn;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *nameLabelHeight;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *cornHeight;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *numberWidthConstraint;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *userHeaderView;
|
||||
@property (weak, nonatomic) IBOutlet UIView *numberBgView;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *grayCoverView;
|
||||
|
||||
@property (strong, nonatomic) QXGiftModel *roomGiftModel;
|
||||
@property (strong, nonatomic) QXUserGiftWallModel *giftWall;
|
||||
@property (assign, nonatomic) QXGiftCellType cellType;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
110
QXLive/Tabbar/弹窗/QXGiftCell.m
Normal file
110
QXLive/Tabbar/弹窗/QXGiftCell.m
Normal file
@@ -0,0 +1,110 @@
|
||||
//
|
||||
// QXGiftCell.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/13.
|
||||
//
|
||||
|
||||
#import "QXGiftCell.h"
|
||||
|
||||
@implementation QXGiftCell
|
||||
|
||||
- (void)awakeFromNib {
|
||||
[super awakeFromNib];
|
||||
// Initialization code
|
||||
[self.selecteBtn setBackgroundImage:[UIImage imageWithColor:RGB16(0xEFF2F8)] forState:(UIControlStateNormal)];
|
||||
[self.selecteBtn setBackgroundImage:[UIImage imageNamed:@"mine_dress_bg"] forState:(UIControlStateSelected)];
|
||||
}
|
||||
|
||||
-(void)setCellType:(QXGiftCellType)cellType{
|
||||
_cellType = cellType;
|
||||
switch (cellType) {
|
||||
case QXGiftCellTypeNiceGift:{
|
||||
self.numberWidthConstraint.constant = 23;
|
||||
self.numberHeightConstraint.constant = 9;
|
||||
self.cornHeight.constant = 10;
|
||||
self.nameLabelHeight.constant = 10;
|
||||
self.giftNameLabel.font = [UIFont systemFontOfSize:8];
|
||||
self.cornBtn.titleLabel.font = [UIFont systemFontOfSize:8];
|
||||
self.userHeaderView.hidden = YES;
|
||||
}
|
||||
break;
|
||||
case QXGiftCellTypeBackpack:{
|
||||
self.numberWidthConstraint.constant = 35;
|
||||
self.numberHeightConstraint.constant = 13;
|
||||
self.cornHeight.constant = 18;
|
||||
self.nameLabelHeight.constant = 18;
|
||||
self.giftNameLabel.font = [UIFont systemFontOfSize:14];
|
||||
self.numberLabel.font = [UIFont systemFontOfSize:10];
|
||||
self.cornBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
self.selecteBtn.selected = YES;
|
||||
[self.cornBtn setImage:[UIImage imageNamed:@"mine_live_gift_corn"] forState:(UIControlStateNormal)];
|
||||
self.userHeaderView.hidden = YES;
|
||||
}
|
||||
break;
|
||||
case QXGiftCellTypeLive:{
|
||||
self.numberWidthConstraint.constant = 35;
|
||||
self.numberHeightConstraint.constant = 13;
|
||||
self.cornHeight.constant = 18;
|
||||
self.nameLabelHeight.constant = 18;
|
||||
self.giftNameLabel.font = [UIFont systemFontOfSize:14];
|
||||
self.cornBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.cornBtn setImage:[UIImage imageNamed:@"mine_live_gift_corn"] forState:(UIControlStateNormal)];
|
||||
self.userHeaderView.hidden = YES;
|
||||
self.numberBgView.hidden = YES;
|
||||
[self.selecteBtn setBackgroundImage:[UIImage imageWithColor:RGB16A(0xE9E9E9, 0.2)] forState:(UIControlStateNormal)];
|
||||
[self.selecteBtn setBackgroundImage:[UIImage imageNamed:@"room_sound_sel"] forState:(UIControlStateSelected)];
|
||||
}
|
||||
break;
|
||||
|
||||
case QXGiftCellTypeGiftWall:{
|
||||
self.numberWidthConstraint.constant = 35;
|
||||
self.numberHeightConstraint.constant = 13;
|
||||
self.cornHeight.constant = 18;
|
||||
self.nameLabelHeight.constant = 18;
|
||||
self.giftNameLabel.font = [UIFont systemFontOfSize:14];
|
||||
self.cornBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.cornBtn setImage:[UIImage imageNamed:@"mine_live_gift_corn"] forState:(UIControlStateNormal)];
|
||||
self.userHeaderView.hidden = NO;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
-(void)setRoomGiftModel:(QXGiftModel *)roomGiftModel{
|
||||
_roomGiftModel = roomGiftModel;
|
||||
self.giftNameLabel.text = roomGiftModel.gift_name;
|
||||
[self.gitfImageView sd_setImageWithURL:[NSURL URLWithString:roomGiftModel.base_image]];
|
||||
[self.cornBtn setTitle:[NSString stringWithFormat:@" %@",roomGiftModel.gift_price] forState:(UIControlStateNormal)];
|
||||
if (roomGiftModel.num.intValue > 0) {
|
||||
self.numberBgView.hidden = NO;
|
||||
self.numberLabel.text = [NSString stringWithFormat:@"x%@",roomGiftModel.num];
|
||||
}else{
|
||||
self.numberBgView.hidden = YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setGiftWall:(QXUserGiftWallModel *)giftWall{
|
||||
_giftWall = giftWall;
|
||||
self.giftNameLabel.text = giftWall.gift_name;
|
||||
[self.gitfImageView sd_setImageWithURL:[NSURL URLWithString:giftWall.base_image]];
|
||||
self.numberLabel.text = [NSString stringWithFormat:@"x%@",giftWall.total_count];
|
||||
self.grayCoverView.backgroundColor = RGB16A(0xE9E9E9, 0.8);
|
||||
if (giftWall.total_count.longLongValue == 0) {
|
||||
self.numberBgView.hidden = YES;
|
||||
self.grayCoverView.hidden = NO;
|
||||
}else{
|
||||
self.numberBgView.hidden = NO;
|
||||
self.grayCoverView.hidden = YES;
|
||||
}
|
||||
[self.cornBtn setTitle:[NSString stringWithFormat:@" %@",giftWall.gift_price] forState:(UIControlStateNormal)];
|
||||
QXUserHomeModel*user = giftWall.top_users.firstObject;
|
||||
if (user) {
|
||||
self.userHeaderView.hidden = NO;
|
||||
[self.userHeaderView sd_setImageWithURL:[NSURL URLWithString:user.avatar]];
|
||||
}else{
|
||||
self.userHeaderView.hidden = YES;
|
||||
}
|
||||
}
|
||||
@end
|
||||
156
QXLive/Tabbar/弹窗/QXGiftCell.xib
Normal file
156
QXLive/Tabbar/弹窗/QXGiftCell.xib
Normal file
@@ -0,0 +1,156 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<device id="retina6_12" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23506"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="QXGiftCell">
|
||||
<rect key="frame" x="0.0" y="0.0" width="253" height="303"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="253" height="303"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="QMu-c3-HcP">
|
||||
<rect key="frame" x="0.0" y="0.0" width="253" height="303"/>
|
||||
<subviews>
|
||||
<button opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="YN0-v8-SAo">
|
||||
<rect key="frame" x="0.0" y="0.0" width="253" height="303"/>
|
||||
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
|
||||
</button>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="anN-iX-rGm">
|
||||
<rect key="frame" x="230" y="0.0" width="23" height="9"/>
|
||||
<subviews>
|
||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="gift_number_bg" translatesAutoresizingMaskIntoConstraints="NO" id="Yu7-xk-6PI">
|
||||
<rect key="frame" x="0.0" y="0.0" width="23" height="9"/>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="x99" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="NY9-Jo-6BD">
|
||||
<rect key="frame" x="0.0" y="0.0" width="23" height="9"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="7"/>
|
||||
<color key="textColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="NY9-Jo-6BD" firstAttribute="top" secondItem="anN-iX-rGm" secondAttribute="top" id="EEs-zk-dKx"/>
|
||||
<constraint firstItem="NY9-Jo-6BD" firstAttribute="leading" secondItem="anN-iX-rGm" secondAttribute="leading" id="Ptd-SE-gCD"/>
|
||||
<constraint firstAttribute="bottom" secondItem="NY9-Jo-6BD" secondAttribute="bottom" id="Q6n-eP-v2P"/>
|
||||
<constraint firstAttribute="width" constant="23" id="TKe-Nq-00R"/>
|
||||
<constraint firstAttribute="bottom" secondItem="Yu7-xk-6PI" secondAttribute="bottom" id="U0K-XR-YH3"/>
|
||||
<constraint firstItem="Yu7-xk-6PI" firstAttribute="leading" secondItem="anN-iX-rGm" secondAttribute="leading" id="aW4-7r-fQ0"/>
|
||||
<constraint firstItem="Yu7-xk-6PI" firstAttribute="top" secondItem="anN-iX-rGm" secondAttribute="top" id="iAx-xJ-Oil"/>
|
||||
<constraint firstAttribute="height" constant="9" id="kap-xl-Ydf"/>
|
||||
<constraint firstAttribute="trailing" secondItem="Yu7-xk-6PI" secondAttribute="trailing" id="lmx-7S-0Gr"/>
|
||||
<constraint firstAttribute="trailing" secondItem="NY9-Jo-6BD" secondAttribute="trailing" id="z9T-dt-Qob"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="1oa-XB-z2H">
|
||||
<rect key="frame" x="5" y="7" width="243" height="250"/>
|
||||
</imageView>
|
||||
<imageView hidden="YES" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="niZ-Xc-95T">
|
||||
<rect key="frame" x="0.0" y="0.0" width="253" height="303"/>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="爱的抱抱" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rHb-Od-M4a">
|
||||
<rect key="frame" x="5" y="257" width="243" height="18"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="18" id="yY1-Fd-GTO"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="8"/>
|
||||
<color key="textColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3d1-U7-04n">
|
||||
<rect key="frame" x="5" y="278" width="243" height="18"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="18" id="svX-z8-2v4"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="8"/>
|
||||
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
|
||||
<state key="normal" title=" 9999" image="gift_corn">
|
||||
<color key="titleColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="calibratedRGB"/>
|
||||
</state>
|
||||
</button>
|
||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="user_header_placehoulder" translatesAutoresizingMaskIntoConstraints="NO" id="fxQ-G1-4U5">
|
||||
<rect key="frame" x="4" y="4" width="15" height="15"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="15" id="1Di-mL-Ufh"/>
|
||||
<constraint firstAttribute="height" constant="15" id="sDK-xi-9FI"/>
|
||||
</constraints>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="boolean" keyPath="layer.masksToBounds" value="YES"/>
|
||||
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
|
||||
<real key="value" value="7.5"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</imageView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="bottom" secondItem="YN0-v8-SAo" secondAttribute="bottom" id="0UV-vT-lSa"/>
|
||||
<constraint firstItem="niZ-Xc-95T" firstAttribute="leading" secondItem="QMu-c3-HcP" secondAttribute="leading" id="4eE-QY-8iw"/>
|
||||
<constraint firstAttribute="trailing" secondItem="niZ-Xc-95T" secondAttribute="trailing" id="88r-oD-p4E"/>
|
||||
<constraint firstItem="3d1-U7-04n" firstAttribute="leading" secondItem="1oa-XB-z2H" secondAttribute="leading" id="8De-gE-33I"/>
|
||||
<constraint firstItem="rHb-Od-M4a" firstAttribute="top" secondItem="1oa-XB-z2H" secondAttribute="bottom" id="8dO-90-EcR"/>
|
||||
<constraint firstItem="fxQ-G1-4U5" firstAttribute="top" secondItem="QMu-c3-HcP" secondAttribute="top" constant="4" id="AaP-Bh-HJO"/>
|
||||
<constraint firstAttribute="bottom" secondItem="niZ-Xc-95T" secondAttribute="bottom" id="Hcq-Ev-Yt1"/>
|
||||
<constraint firstAttribute="trailing" secondItem="1oa-XB-z2H" secondAttribute="trailing" constant="5" id="IeP-It-gIz"/>
|
||||
<constraint firstItem="YN0-v8-SAo" firstAttribute="top" secondItem="QMu-c3-HcP" secondAttribute="top" id="MM9-lD-eb5"/>
|
||||
<constraint firstItem="1oa-XB-z2H" firstAttribute="leading" secondItem="QMu-c3-HcP" secondAttribute="leading" constant="5" id="MYb-BM-fhX"/>
|
||||
<constraint firstItem="anN-iX-rGm" firstAttribute="top" secondItem="QMu-c3-HcP" secondAttribute="top" id="QVB-1T-j7f"/>
|
||||
<constraint firstAttribute="trailing" secondItem="YN0-v8-SAo" secondAttribute="trailing" id="TM5-gQ-Sjd"/>
|
||||
<constraint firstItem="niZ-Xc-95T" firstAttribute="top" secondItem="QMu-c3-HcP" secondAttribute="top" id="Vx1-do-zNx"/>
|
||||
<constraint firstAttribute="trailing" secondItem="anN-iX-rGm" secondAttribute="trailing" id="gMa-Ee-Va2"/>
|
||||
<constraint firstItem="YN0-v8-SAo" firstAttribute="leading" secondItem="QMu-c3-HcP" secondAttribute="leading" id="gwM-TL-16q"/>
|
||||
<constraint firstItem="rHb-Od-M4a" firstAttribute="trailing" secondItem="1oa-XB-z2H" secondAttribute="trailing" id="j58-9C-4jp"/>
|
||||
<constraint firstItem="rHb-Od-M4a" firstAttribute="leading" secondItem="1oa-XB-z2H" secondAttribute="leading" id="lZC-mt-8rI"/>
|
||||
<constraint firstItem="fxQ-G1-4U5" firstAttribute="leading" secondItem="QMu-c3-HcP" secondAttribute="leading" constant="4" id="sEi-oU-MFz"/>
|
||||
<constraint firstItem="3d1-U7-04n" firstAttribute="trailing" secondItem="1oa-XB-z2H" secondAttribute="trailing" id="su7-47-d1q"/>
|
||||
<constraint firstItem="3d1-U7-04n" firstAttribute="top" secondItem="rHb-Od-M4a" secondAttribute="bottom" constant="3" id="tsv-TX-kEv"/>
|
||||
<constraint firstAttribute="bottom" secondItem="3d1-U7-04n" secondAttribute="bottom" constant="7" id="vHo-v2-n7q"/>
|
||||
<constraint firstItem="1oa-XB-z2H" firstAttribute="top" secondItem="anN-iX-rGm" secondAttribute="bottom" constant="-2" id="wzY-ud-btV"/>
|
||||
</constraints>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="boolean" keyPath="layer.masksToBounds" value="YES"/>
|
||||
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
|
||||
<integer key="value" value="5"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</view>
|
||||
</subviews>
|
||||
</view>
|
||||
<viewLayoutGuide key="safeArea" id="SEy-5g-ep8"/>
|
||||
<constraints>
|
||||
<constraint firstItem="QMu-c3-HcP" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="1mN-Um-ETK"/>
|
||||
<constraint firstAttribute="trailing" secondItem="QMu-c3-HcP" secondAttribute="trailing" id="QHz-IM-RT8"/>
|
||||
<constraint firstAttribute="bottom" secondItem="QMu-c3-HcP" secondAttribute="bottom" id="amE-gn-beF"/>
|
||||
<constraint firstItem="QMu-c3-HcP" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="y9f-l6-oun"/>
|
||||
</constraints>
|
||||
<size key="customSize" width="253" height="303"/>
|
||||
<connections>
|
||||
<outlet property="cornBtn" destination="3d1-U7-04n" id="PLQ-JR-U9b"/>
|
||||
<outlet property="cornHeight" destination="svX-z8-2v4" id="ocG-gq-4Wo"/>
|
||||
<outlet property="giftNameLabel" destination="rHb-Od-M4a" id="nik-Bp-Ce4"/>
|
||||
<outlet property="gitfImageView" destination="1oa-XB-z2H" id="1bo-km-q0H"/>
|
||||
<outlet property="grayCoverView" destination="niZ-Xc-95T" id="vbK-Sr-GkT"/>
|
||||
<outlet property="nameLabelHeight" destination="yY1-Fd-GTO" id="ewH-OC-DXC"/>
|
||||
<outlet property="numberBgView" destination="anN-iX-rGm" id="6VQ-ZT-vQ2"/>
|
||||
<outlet property="numberHeightConstraint" destination="kap-xl-Ydf" id="SBZ-42-8wP"/>
|
||||
<outlet property="numberLabel" destination="NY9-Jo-6BD" id="2ua-Kf-Wue"/>
|
||||
<outlet property="numberWidthConstraint" destination="TKe-Nq-00R" id="yDl-AX-pmQ"/>
|
||||
<outlet property="selecteBtn" destination="YN0-v8-SAo" id="xcO-aq-DzN"/>
|
||||
<outlet property="userHeaderView" destination="fxQ-G1-4U5" id="857-MT-DQR"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="293.89312977099235" y="108.80281690140846"/>
|
||||
</collectionViewCell>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="gift_corn" width="6" height="6"/>
|
||||
<image name="gift_number_bg" width="22.666666030883789" height="8.6666669845581055"/>
|
||||
<image name="user_header_placehoulder" width="40" height="40"/>
|
||||
</resources>
|
||||
</document>
|
||||
20
QXLive/Tabbar/弹窗/QXGiftDriftView.h
Normal file
20
QXLive/Tabbar/弹窗/QXGiftDriftView.h
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// QXGiftDriftView.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/21.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "QXGiftScrollView.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXGiftDriftView : UIView
|
||||
|
||||
@property (nonatomic,strong)NSMutableArray *dataArray;
|
||||
@property (nonatomic,strong)QXGiftScrollModel *model;
|
||||
-(void)addGiftModel:(QXGiftScrollModel*)model;
|
||||
+(instancetype)shareView;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
116
QXLive/Tabbar/弹窗/QXGiftDriftView.m
Normal file
116
QXLive/Tabbar/弹窗/QXGiftDriftView.m
Normal file
@@ -0,0 +1,116 @@
|
||||
//
|
||||
// QXGiftDriftView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/21.
|
||||
//
|
||||
|
||||
#import "QXGiftDriftView.h"
|
||||
@interface QXGiftDriftView()
|
||||
@property (nonatomic,strong)UIImageView *bgImageView;
|
||||
|
||||
@property (nonatomic,strong)UILabel *titleLabel;
|
||||
@property (nonatomic,strong)UIImageView *giftImageView;
|
||||
@property (nonatomic,strong)UILabel *countLabel;
|
||||
@property (nonatomic,assign)BOOL isPlaying;
|
||||
@end
|
||||
@implementation QXGiftDriftView
|
||||
+(instancetype)shareView{
|
||||
static QXGiftDriftView *manager = nil;
|
||||
static dispatch_once_t predicate;
|
||||
dispatch_once(&predicate, ^{
|
||||
manager = [[QXGiftDriftView alloc] init];
|
||||
});
|
||||
return manager;
|
||||
}
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.frame = CGRectMake(SCREEN_WIDTH, 150, ScaleWidth(316), ScaleWidth(50));
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)initSubviews{
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pop_gift_bg"]];
|
||||
self.bgImageView.frame = self.bounds;
|
||||
[self addSubview:self.bgImageView];
|
||||
|
||||
self.titleLabel = [[UILabel alloc] init];
|
||||
self.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
self.titleLabel.textColor = UIColor.whiteColor;
|
||||
[self addSubview:self.titleLabel];
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(self).offset(-ScaleWidth(30));
|
||||
make.height.mas_equalTo(30);
|
||||
make.centerY.equalTo(self).offset(2);
|
||||
}];
|
||||
|
||||
self.giftImageView = [[UIImageView alloc] init];
|
||||
self.giftImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
[self addSubview:self.giftImageView];
|
||||
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.titleLabel.mas_right).offset(5);
|
||||
make.height.width.mas_equalTo(20);
|
||||
make.centerY.equalTo(self).offset(2);
|
||||
}];
|
||||
|
||||
self.countLabel = [[UILabel alloc] init];
|
||||
self.countLabel.font = [UIFont systemFontOfSize:14];
|
||||
self.countLabel.textColor = UIColor.whiteColor;
|
||||
[self addSubview:self.countLabel];
|
||||
[self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.giftImageView.mas_right);
|
||||
make.height.mas_equalTo(30);
|
||||
make.centerY.equalTo(self).offset(2);
|
||||
}];
|
||||
}
|
||||
-(void)addGiftModel:(QXGiftScrollModel *)model{
|
||||
[self.dataArray addObject:model];
|
||||
[self giftAction];
|
||||
}
|
||||
|
||||
|
||||
-(void)giftAction{
|
||||
if (self.isPlaying) {
|
||||
return;
|
||||
}
|
||||
[QXGiftDriftView shareView].isPlaying = YES;
|
||||
[QXGiftDriftView shareView].model = [QXGiftDriftView shareView].dataArray.firstObject;
|
||||
[KEYWINDOW addSubview:[QXGiftDriftView shareView]];
|
||||
[UIView animateWithDuration:1.5 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
|
||||
[QXGiftDriftView shareView].x = (SCREEN_WIDTH-ScaleWidth(316))/2;
|
||||
} completion:^(BOOL finished) {
|
||||
[UIView animateWithDuration:2 delay:1 options:UIViewAnimationOptionCurveEaseIn animations:^{
|
||||
[QXGiftDriftView shareView].x = -SCREEN_WIDTH;
|
||||
} completion:^(BOOL finished) {
|
||||
[QXGiftDriftView shareView].x = SCREEN_WIDTH;
|
||||
[[QXGiftDriftView shareView] removeFromSuperview];
|
||||
[[QXGiftDriftView shareView].dataArray removeFirstObject];
|
||||
[QXGiftDriftView shareView].isPlaying = NO;
|
||||
if ([QXGiftDriftView shareView].dataArray.count>0) {
|
||||
[[QXGiftDriftView shareView] giftAction];
|
||||
}
|
||||
}];
|
||||
}];
|
||||
}
|
||||
-(void)setModel:(QXGiftScrollModel *)model{
|
||||
_model = model;
|
||||
NSString *str = [NSString stringWithFormat:@"%@送给%@",model.fromUserName,model.toUserName];
|
||||
NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:str];
|
||||
[attr yy_setColor:RGB16(0xFFDE77) range:[str rangeOfString:model.fromUserName]];
|
||||
[attr yy_setColor:RGB16(0xFFDE77) range:[str rangeOfString:model.toUserName]];
|
||||
self.titleLabel.attributedText = attr;
|
||||
|
||||
[self.giftImageView sd_setImageWithURL:[NSURL URLWithString:model.gift_picture]];
|
||||
self.countLabel.text = [NSString stringWithFormat:@"X%@",model.number];
|
||||
}
|
||||
|
||||
-(NSMutableArray *)dataArray{
|
||||
if (!_dataArray) {
|
||||
_dataArray = [NSMutableArray array];
|
||||
}
|
||||
return _dataArray;
|
||||
}
|
||||
@end
|
||||
17
QXLive/Tabbar/弹窗/QXInvitePopView.h
Normal file
17
QXLive/Tabbar/弹窗/QXInvitePopView.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// QXInvitePopView.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/13.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXInvitePopView : UIView
|
||||
@property (nonatomic,copy)void(^closeActionBlock)(void);
|
||||
@property (nonatomic,copy)void(^agreeActionBlock)(void);
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
117
QXLive/Tabbar/弹窗/QXInvitePopView.m
Normal file
117
QXLive/Tabbar/弹窗/QXInvitePopView.m
Normal file
@@ -0,0 +1,117 @@
|
||||
//
|
||||
// QXInvitePopView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/13.
|
||||
//
|
||||
|
||||
#import "QXInvitePopView.h"
|
||||
#import "QXSeatHeaderView.h"
|
||||
#import "QXTimer.h"
|
||||
|
||||
@interface QXInvitePopView()
|
||||
@property (nonatomic,strong)UIImageView *bgImageView;
|
||||
@property (nonatomic,strong)QXSeatHeaderView *headerView;
|
||||
@property (nonatomic,strong)UILabel *inviteLabel;
|
||||
@property (nonatomic,strong)UIButton *agreeBtn;
|
||||
@property (nonatomic,strong)QXTimer *timer;
|
||||
@property (nonatomic,strong)UIButton *closeBtn;
|
||||
@end
|
||||
@implementation QXInvitePopView
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.frame = CGRectMake(0, 0, ScaleWidth(275), ScaleWidth(200+48));
|
||||
[self initSubViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)initSubViews{
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"a_pop_invite"]];
|
||||
[self addSubview:self.bgImageView];
|
||||
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.left.right.equalTo(self);
|
||||
make.height.mas_equalTo(ScaleWidth(200));
|
||||
}];
|
||||
|
||||
self.headerView = [[QXSeatHeaderView alloc] init];
|
||||
[self addSubview:self.headerView];
|
||||
[self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(70, 70));
|
||||
make.centerX.equalTo(self);
|
||||
make.top.equalTo(self).offset(12);
|
||||
}];
|
||||
|
||||
self.inviteLabel = [[UILabel alloc] init];
|
||||
self.inviteLabel.font = [UIFont boldSystemFontOfSize:16];
|
||||
self.inviteLabel.text = QXText(@"邀请你进房陪她聊天");
|
||||
self.inviteLabel.textColor = RGB16(0x333333);
|
||||
[self addSubview:self.inviteLabel];
|
||||
[self.inviteLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(self);
|
||||
make.top.equalTo(self.headerView.mas_bottom).offset(12);
|
||||
make.height.mas_equalTo(24);
|
||||
}];
|
||||
|
||||
|
||||
self.agreeBtn = [[UIButton alloc] init];
|
||||
[self.agreeBtn addRoundedCornersWithRadius:21];
|
||||
self.agreeBtn.backgroundColor = QXConfig.themeColor;
|
||||
[self.agreeBtn setTitle:QXText(@"接收邀请") forState:(UIControlStateNormal)];
|
||||
[self.agreeBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
||||
self.agreeBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.agreeBtn addTarget:self action:@selector(agreeAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.agreeBtn];
|
||||
[self.agreeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.equalTo(self.bgImageView).offset(-12);
|
||||
make.height.mas_equalTo(42);
|
||||
make.width.mas_equalTo(178);
|
||||
make.centerX.equalTo(self.bgImageView);
|
||||
}];
|
||||
|
||||
self.closeBtn = [[UIButton alloc] init];
|
||||
[self.closeBtn setBackgroundImage:[UIImage imageNamed:@"home_white_close"] forState:(UIControlStateNormal)];
|
||||
[self.closeBtn addTarget:self action:@selector(closeAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.closeBtn];
|
||||
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(self);
|
||||
make.top.equalTo(self.bgImageView.mas_bottom).offset(8);
|
||||
make.height.width.mas_equalTo(30);
|
||||
}];
|
||||
|
||||
__block int timeCount = 10;
|
||||
MJWeakSelf
|
||||
_timer = [QXTimer scheduledTimerWithTimeInterval:1 repeats:YES queue:dispatch_get_main_queue() block:^{
|
||||
timeCount--;
|
||||
if (timeCount<=0) {
|
||||
[weakSelf noAgree];
|
||||
[self->_agreeBtn setTitle:[NSString stringWithFormat:@"%@(0)",QXText(@"接收邀请")] forState:(UIControlStateNormal)];
|
||||
[[QXGlobal shareGlobal] hideViewBlock:^{
|
||||
|
||||
}];
|
||||
}
|
||||
[self->_agreeBtn setTitle:[NSString stringWithFormat:@"%@(%d)",QXText(@"接收邀请"),timeCount] forState:(UIControlStateNormal)];
|
||||
}];
|
||||
}
|
||||
-(void)noAgree{
|
||||
[self->_timer invalidate];
|
||||
}
|
||||
|
||||
-(void)agreeAction{
|
||||
MJWeakSelf
|
||||
[[QXGlobal shareGlobal] hideViewBlock:^{
|
||||
if (weakSelf.agreeActionBlock) {
|
||||
weakSelf.agreeActionBlock();
|
||||
}
|
||||
}];
|
||||
|
||||
}
|
||||
-(void)closeAction{
|
||||
[self noAgree];
|
||||
if (self.closeActionBlock) {
|
||||
self.closeActionBlock();
|
||||
}
|
||||
}
|
||||
@end
|
||||
19
QXLive/Tabbar/弹窗/QXNiceGiftPopView.h
Normal file
19
QXLive/Tabbar/弹窗/QXNiceGiftPopView.h
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// QXNiceGiftPopView.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/13.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXNiceGiftPopView : UIView
|
||||
@property (nonatomic,copy)void(^closeActionBlock)(void);
|
||||
@property (nonatomic,copy)void(^getActionBlock)(void);
|
||||
@property (nonatomic,copy)void(^ruleActionBlock)(void);
|
||||
@property (nonatomic,strong)NSArray *giftArray;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
217
QXLive/Tabbar/弹窗/QXNiceGiftPopView.m
Normal file
217
QXLive/Tabbar/弹窗/QXNiceGiftPopView.m
Normal file
@@ -0,0 +1,217 @@
|
||||
//
|
||||
// QXNiceGiftPopView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/13.
|
||||
//
|
||||
|
||||
#import "QXNiceGiftPopView.h"
|
||||
#import "GKPageControl.h"
|
||||
#import "QXGiftCell.h"
|
||||
|
||||
@interface QXNiceGiftPopView()<UICollectionViewDelegate,UICollectionViewDataSource>
|
||||
@property (nonatomic,strong)UIImageView *lightBgImageView;
|
||||
@property (nonatomic,strong)UIImageView *bgImageView;
|
||||
@property (nonatomic,strong)UIImageView *timeDownbgView;
|
||||
@property (nonatomic,strong)UILabel *timeDownLabel;
|
||||
@property (nonatomic,strong)UIView *giftBgView;
|
||||
@property (nonatomic,strong)UIButton *ruleBtn;
|
||||
@property (nonatomic,strong)UICollectionView *collectionView;
|
||||
@property (nonatomic,strong)GKPageControl *pageControl;
|
||||
@property (nonatomic,strong)UILabel *messageLabel;
|
||||
@property (nonatomic,strong)UIButton *getBtn;
|
||||
@property (nonatomic,strong)UIButton *closeBtn;
|
||||
@end
|
||||
@implementation QXNiceGiftPopView
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(582));
|
||||
[self initSubViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)initSubViews{
|
||||
self.lightBgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"a_pop_bg"]];
|
||||
[self addSubview:self.lightBgImageView];
|
||||
[self.lightBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.top.bottom.equalTo(self);
|
||||
}];
|
||||
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"a_pop_nice_gift"]];
|
||||
[self addSubview:self.bgImageView];
|
||||
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.centerY.equalTo(self);
|
||||
make.size.mas_equalTo(CGSizeMake(ScaleWidth(275), ScaleWidth(338)));
|
||||
}];
|
||||
|
||||
self.timeDownbgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gift_time_bg"]];
|
||||
[self addSubview:self.timeDownbgView];
|
||||
[self.timeDownbgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.bgImageView).offset(ScaleWidth(117));
|
||||
make.left.equalTo(self.bgImageView).offset(9);
|
||||
make.size.mas_equalTo(CGSizeMake(ScaleWidth(179), ScaleWidth(20)));
|
||||
}];
|
||||
|
||||
self.timeDownLabel = [[UILabel alloc] init];
|
||||
self.timeDownLabel.textColor = RGB16(0x666666);
|
||||
self.timeDownLabel.text = QXText(@"剩余时间");
|
||||
self.timeDownLabel.font = [UIFont systemFontOfSize:12];
|
||||
[self addSubview:self.timeDownLabel];
|
||||
[self.timeDownLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.bottom.equalTo(self.timeDownbgView);
|
||||
make.left.equalTo(self.timeDownbgView).offset(19);
|
||||
make.right.equalTo(self.timeDownbgView).offset(-19);
|
||||
}];
|
||||
|
||||
self.ruleBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 54, 20)];
|
||||
self.ruleBtn.backgroundColor = QXConfig.themeColor;
|
||||
[self.ruleBtn addTarget:self action:@selector(ruleAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.ruleBtn setTitle:QXText(@"规则") forState:(UIControlStateNormal)];
|
||||
self.ruleBtn.titleLabel.font = [UIFont systemFontOfSize:12];
|
||||
[self.ruleBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
||||
[self.ruleBtn addRoundedCornersWithRadius:10 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerBottomLeft)];
|
||||
[self addSubview:self.ruleBtn];
|
||||
[self.ruleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(self.bgImageView);
|
||||
make.centerY.equalTo(self.timeDownbgView);
|
||||
make.size.mas_equalTo(CGSizeMake(ScaleWidth(54), ScaleWidth(20)));
|
||||
}];
|
||||
|
||||
self.giftBgView = [[UIView alloc] init];
|
||||
// self.giftBgView.backgroundColor = [UIColor whiteColor];
|
||||
[self.giftBgView addRoundedCornersWithRadius:13];
|
||||
[self addSubview:self.giftBgView];
|
||||
[self.giftBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.timeDownbgView.mas_bottom).offset(ScaleWidth(3));
|
||||
make.left.equalTo(self.bgImageView).offset(15);
|
||||
make.right.equalTo(self.bgImageView).offset(-15);
|
||||
make.bottom.equalTo(self.bgImageView).offset(-ScaleWidth(51));
|
||||
}];
|
||||
|
||||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||||
layout.itemSize = CGSizeMake((ScaleWidth(275-15*2-12*2-3*8))/4, ScaleWidth(76));
|
||||
layout.minimumLineSpacing = 8;
|
||||
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
||||
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
||||
[self.collectionView registerNib:[UINib nibWithNibName:@"QXGiftCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"QXGiftCell"];
|
||||
self.collectionView.delegate = self;
|
||||
self.collectionView.dataSource = self;
|
||||
self.collectionView.showsHorizontalScrollIndicator = NO;
|
||||
self.collectionView.bounces = NO;
|
||||
self.collectionView.pagingEnabled = YES;
|
||||
[self.giftBgView addSubview:self.collectionView];
|
||||
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(12);
|
||||
make.top.mas_equalTo(ScaleWidth(16));
|
||||
make.height.mas_equalTo(ScaleWidth(76));
|
||||
make.right.mas_equalTo(-12);
|
||||
}];
|
||||
|
||||
_pageControl = [[GKPageControl alloc] init];
|
||||
_pageControl.style = GKPageControlStyleRectangle;
|
||||
_pageControl.dotWidth = 15;
|
||||
_pageControl.dotHeight = 5;
|
||||
_pageControl.dotMargin = 2;
|
||||
_pageControl.pageIndicatorTintColor = RGB16(0xEBEBEB);
|
||||
_pageControl.currentPageIndicatorTintColor = QXConfig.textColor;
|
||||
[self.giftBgView addSubview:self.pageControl];
|
||||
[self.pageControl mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.collectionView.mas_bottom).offset(9);
|
||||
make.height.mas_equalTo(5);
|
||||
make.right.mas_equalTo(-48);
|
||||
make.left.mas_equalTo(48);
|
||||
}];
|
||||
|
||||
self.messageLabel = [[UILabel alloc] init];
|
||||
self.messageLabel.font = [UIFont systemFontOfSize:12];
|
||||
self.messageLabel.numberOfLines = 0;
|
||||
self.messageLabel.text = QXText(@"充值6元即可获得总价值888金币的道具或装扮");
|
||||
self.messageLabel.textColor = QXConfig.textColor;
|
||||
[self.giftBgView addSubview:self.messageLabel];
|
||||
[self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(12);
|
||||
make.right.mas_equalTo(-12);
|
||||
make.top.equalTo(self.pageControl.mas_bottom).offset(2);
|
||||
make.bottom.equalTo(self.giftBgView).offset(-5);
|
||||
}];
|
||||
|
||||
|
||||
self.getBtn = [[UIButton alloc] init];
|
||||
[self.getBtn addRoundedCornersWithRadius:21];
|
||||
self.getBtn.backgroundColor = QXConfig.themeColor;
|
||||
[self.getBtn setTitle:QXText(@"立即领取") forState:(UIControlStateNormal)];
|
||||
[self.getBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
||||
self.getBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.getBtn addTarget:self action:@selector(getAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.getBtn];
|
||||
[self.getBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.equalTo(self.bgImageView).offset(-ScaleWidth(16));
|
||||
make.height.mas_equalTo(42);
|
||||
make.right.equalTo(self.bgImageView).offset(-48);
|
||||
make.left.equalTo(self.bgImageView).offset(48);
|
||||
}];
|
||||
|
||||
self.closeBtn = [[UIButton alloc] init];
|
||||
[self.closeBtn setBackgroundImage:[UIImage imageNamed:@"home_white_close"] forState:(UIControlStateNormal)];
|
||||
[self.closeBtn addTarget:self action:@selector(closeAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.closeBtn];
|
||||
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(self);
|
||||
make.top.equalTo(self.bgImageView.mas_bottom).offset(8);
|
||||
make.height.width.mas_equalTo(30);
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
|
||||
if ([scrollView isKindOfClass:[UICollectionView class]]) {
|
||||
long offsetX = (long)scrollView.contentOffset.x;
|
||||
int width = ScaleWidth(275-15*2-12*2-3*8);
|
||||
int remainder = offsetX % width;
|
||||
NSInteger index;
|
||||
if (remainder>(width)/2) {
|
||||
index = offsetX/width+1;
|
||||
}else{
|
||||
index = offsetX/width;
|
||||
}
|
||||
self.pageControl.currentPage = index;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-(void)setGiftArray:(NSArray *)giftArray{
|
||||
_giftArray = giftArray;
|
||||
self.pageControl.numberOfPages = giftArray.count/4+1;
|
||||
self.pageControl.currentPage = 0;
|
||||
[self.collectionView reloadData];
|
||||
}
|
||||
|
||||
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||||
return self.giftArray.count;
|
||||
}
|
||||
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXGiftCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXGiftCell" forIndexPath:indexPath];
|
||||
cell.cellType = QXGiftCellTypeNiceGift;
|
||||
return cell;
|
||||
}
|
||||
|
||||
// 规则
|
||||
-(void)ruleAction{
|
||||
if (self.ruleActionBlock) {
|
||||
self.ruleActionBlock();
|
||||
}
|
||||
}
|
||||
// 立即领取
|
||||
-(void)getAction{
|
||||
if (self.getActionBlock) {
|
||||
self.getActionBlock();
|
||||
}
|
||||
}
|
||||
-(void)closeAction{
|
||||
if (self.closeActionBlock) {
|
||||
self.closeActionBlock();
|
||||
}
|
||||
}
|
||||
@end
|
||||
17
QXLive/Tabbar/弹窗/QXRealNamePopView.h
Normal file
17
QXLive/Tabbar/弹窗/QXRealNamePopView.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// QXRealNamePopView.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/14.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXRealNamePopView : UIView
|
||||
@property (nonatomic,copy)void(^closeActionBlock)(void);
|
||||
@property (nonatomic,copy)void(^authActionBlock)(void);
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
93
QXLive/Tabbar/弹窗/QXRealNamePopView.m
Normal file
93
QXLive/Tabbar/弹窗/QXRealNamePopView.m
Normal file
@@ -0,0 +1,93 @@
|
||||
//
|
||||
// QXRealNamePopView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/14.
|
||||
//
|
||||
|
||||
#import "QXRealNamePopView.h"
|
||||
@interface QXRealNamePopView()
|
||||
@property (nonatomic,strong)UIImageView *bgImageView;
|
||||
@property (nonatomic,strong)UILabel *titleLabel;
|
||||
@property (nonatomic,strong)UILabel *messageLabel;
|
||||
@property (nonatomic,strong)UIButton *goBtn;
|
||||
@property (nonatomic,strong)UIButton *closeBtn;
|
||||
@end
|
||||
|
||||
@implementation QXRealNamePopView
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.frame = CGRectMake(0, 0, ScaleWidth(275), ScaleWidth(300+48));
|
||||
[self initSubViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)initSubViews{
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"a_pop_realname"]];
|
||||
[self addSubview:self.bgImageView];
|
||||
|
||||
self.titleLabel = [[UILabel alloc] init];
|
||||
self.titleLabel.font = [UIFont boldSystemFontOfSize:16];
|
||||
self.titleLabel.text = QXText(@"实名认证");
|
||||
self.titleLabel.textColor = RGB16(0x000000);
|
||||
[self addSubview:self.titleLabel];
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(self);
|
||||
make.top.equalTo(self.bgImageView).offset(ScaleWidth(150));
|
||||
make.height.mas_equalTo(24);
|
||||
}];
|
||||
|
||||
self.goBtn = [[UIButton alloc] init];
|
||||
[self.goBtn addRoundedCornersWithRadius:21];
|
||||
self.goBtn.backgroundColor = QXConfig.themeColor;
|
||||
[self.goBtn setTitle:QXText(@"立即认证") forState:(UIControlStateNormal)];
|
||||
[self.goBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
||||
self.goBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.goBtn addTarget:self action:@selector(gotoAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.goBtn];
|
||||
[self.goBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.equalTo(self.bgImageView).offset(-12);
|
||||
make.height.mas_equalTo(42);
|
||||
make.width.mas_equalTo(178);
|
||||
make.centerX.equalTo(self.bgImageView);
|
||||
}];
|
||||
|
||||
|
||||
self.messageLabel = [[UILabel alloc] init];
|
||||
self.messageLabel.font = [UIFont boldSystemFontOfSize:14];
|
||||
self.messageLabel.text = QXText(@"根据国家相关要求,开启直播需要实名认证,是否进行认证?");
|
||||
self.messageLabel.textColor = RGB16(0x000000);
|
||||
self.messageLabel.numberOfLines = 0;
|
||||
[self addSubview:self.messageLabel];
|
||||
[self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(13);
|
||||
make.right.mas_equalTo(-13);
|
||||
make.bottom.equalTo(self.goBtn.mas_top).offset(-10);
|
||||
make.top.equalTo(self.titleLabel.mas_bottom).offset(8);
|
||||
}];
|
||||
|
||||
self.closeBtn = [[UIButton alloc] init];
|
||||
[self.closeBtn setBackgroundImage:[UIImage imageNamed:@"home_white_close"] forState:(UIControlStateNormal)];
|
||||
[self.closeBtn addTarget:self action:@selector(closeAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.closeBtn];
|
||||
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(self);
|
||||
make.top.equalTo(self.bgImageView.mas_bottom).offset(8);
|
||||
make.height.width.mas_equalTo(30);
|
||||
}];
|
||||
}
|
||||
-(void)gotoAction{
|
||||
if (self.authActionBlock) {
|
||||
self.authActionBlock();
|
||||
}
|
||||
}
|
||||
-(void)closeAction{
|
||||
if (self.closeActionBlock) {
|
||||
self.closeActionBlock();
|
||||
}
|
||||
}
|
||||
@end
|
||||
54
QXLive/Tabbar/弹窗/QXShareView.h
Normal file
54
QXLive/Tabbar/弹窗/QXShareView.h
Normal file
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// QXShareView.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/21.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "QXDynamicModel.h"
|
||||
typedef NS_ENUM(NSInteger) {
|
||||
QXShareViewTypeFind,
|
||||
QXShareViewTypeSharePhoto
|
||||
}QXShareViewType;
|
||||
@class QXShareViewModel;
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@protocol QXShareViewDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
-(void)didClickShareModel:(QXShareViewModel*)model;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface QXShareView : UIView
|
||||
@property (nonatomic,assign)QXShareViewType shareType;
|
||||
@property (nonatomic,weak)id<QXShareViewDelegate>delegate;
|
||||
/// 分享动态时传参
|
||||
@property (nonatomic,strong)QXDynamicModel *dynamicModel;
|
||||
/// 分享图片时传参
|
||||
@property (nonatomic,strong)NSData *imageData;
|
||||
-(void)showInView:(UIView*)view;
|
||||
-(void)hideView;
|
||||
|
||||
@end
|
||||
|
||||
@interface QXShareViewContentCell : UICollectionViewCell<UICollectionViewDelegate,UICollectionViewDataSource>
|
||||
@property (nonatomic,strong)UICollectionView *collectionView;
|
||||
@property (nonatomic,strong)NSMutableArray* dataArray;
|
||||
@property (nonatomic,weak)id<QXShareViewDelegate>delegate;
|
||||
@end
|
||||
|
||||
|
||||
@interface QXShareViewCell : UICollectionViewCell
|
||||
@property (nonatomic,strong)UIImageView *imageView;
|
||||
@property (nonatomic,strong)UILabel *titleLabel;
|
||||
@property (nonatomic,strong)QXShareViewModel *model;
|
||||
@end
|
||||
|
||||
@interface QXShareViewModel:NSObject
|
||||
@property (nonatomic,strong)NSString *icon;
|
||||
@property (nonatomic,strong)NSString *name;
|
||||
@property (nonatomic,strong)NSString *Id;
|
||||
@end
|
||||
NS_ASSUME_NONNULL_END
|
||||
430
QXLive/Tabbar/弹窗/QXShareView.m
Normal file
430
QXLive/Tabbar/弹窗/QXShareView.m
Normal file
@@ -0,0 +1,430 @@
|
||||
//
|
||||
// QXShareView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/21.
|
||||
//
|
||||
|
||||
#import "QXShareView.h"
|
||||
#import <WXApi.h>
|
||||
#import <TencentOpenAPI/TencentOpenApiUmbrellaHeader.h>
|
||||
#import "QXDynamicNetwork.h"
|
||||
|
||||
@interface QXShareView()<UICollectionViewDelegate,UICollectionViewDataSource,UIGestureRecognizerDelegate,QXShareViewDelegate>
|
||||
@property (nonatomic,strong)UIView *bgView;
|
||||
@property (nonatomic,strong)UILabel *titleLabel;
|
||||
@property (nonatomic,strong)UICollectionView *collectionView;
|
||||
@property (nonatomic,strong)NSMutableArray *dataArray;
|
||||
@property (nonatomic,strong)NSMutableArray *friendArray;
|
||||
@property (nonatomic,strong)NSMutableArray *eventArray;
|
||||
@end
|
||||
@implementation QXShareView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)initSubviews{
|
||||
self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3];
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideView)];
|
||||
tap.delegate = self;
|
||||
[self addGestureRecognizer:tap];
|
||||
self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, 200)];
|
||||
self.bgView.backgroundColor = [UIColor whiteColor];
|
||||
[self addSubview:self.bgView];
|
||||
|
||||
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, 16, SCREEN_WIDTH-32, 27)];
|
||||
self.titleLabel.textColor = QXConfig.textColor;
|
||||
self.titleLabel.font = [UIFont boldSystemFontOfSize:18];
|
||||
self.titleLabel.text = QXText(@"分享至");
|
||||
[self.bgView addSubview:self.titleLabel];
|
||||
|
||||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||||
layout.itemSize = CGSizeMake(SCREEN_WIDTH, 71);
|
||||
layout.minimumLineSpacing = 0;
|
||||
layout.minimumInteritemSpacing = 0;
|
||||
layout.sectionInset = UIEdgeInsetsMake(0, 0, 20, 0);
|
||||
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, self.titleLabel.bottom+12, self.bgView.width, self.bgView.height-self.titleLabel.bottom-12-kSafeAreaBottom) collectionViewLayout:layout];
|
||||
[self.collectionView registerClass:[QXShareViewContentCell class] forCellWithReuseIdentifier:@"QXShareViewContentCell"];
|
||||
self.collectionView.delegate = self;
|
||||
self.collectionView.dataSource = self;
|
||||
self.collectionView.showsHorizontalScrollIndicator = NO;
|
||||
self.collectionView.bounces = NO;
|
||||
[self.bgView addSubview:self.collectionView];
|
||||
}
|
||||
-(void)setShareType:(QXShareViewType)shareType{
|
||||
_shareType = shareType;
|
||||
if (_shareType == QXShareViewTypeFind) {
|
||||
self.bgView.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, ScaleWidth(347));
|
||||
[self.bgView addRoundedCornersWithRadius:16 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)];
|
||||
self.collectionView.frame = CGRectMake(0, self.titleLabel.bottom+12, self.bgView.width, self.bgView.height-self.titleLabel.bottom-12-kSafeAreaBottom);
|
||||
}else{
|
||||
self.bgView.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, ScaleWidth(200));
|
||||
[self.bgView addRoundedCornersWithRadius:16 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)];
|
||||
self.collectionView.frame = CGRectMake(0, self.titleLabel.bottom+12, self.bgView.width, self.bgView.height-self.titleLabel.bottom-12-kSafeAreaBottom);
|
||||
}
|
||||
[self.collectionView reloadData];
|
||||
}
|
||||
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
|
||||
return touch.view == self;
|
||||
}
|
||||
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
|
||||
if (self.shareType == QXShareViewTypeFind) {
|
||||
return 3;
|
||||
}else{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||||
return 1;
|
||||
}
|
||||
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXShareViewContentCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXShareViewContentCell" forIndexPath:indexPath];
|
||||
cell.delegate = self;
|
||||
if (self.shareType == QXShareViewTypeFind) {
|
||||
if (indexPath.section == 0) {
|
||||
cell.dataArray = self.friendArray;
|
||||
}else if (indexPath.section == 1){
|
||||
cell.dataArray = self.dataArray;
|
||||
}else{
|
||||
cell.dataArray = [NSMutableArray arrayWithArray:self.eventArray];
|
||||
}
|
||||
}else{
|
||||
cell.dataArray = self.dataArray;
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
-(void)didClickShareModel:(QXShareViewModel *)model{
|
||||
MJWeakSelf
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
} completion:^(BOOL finished) {
|
||||
[self removeFromSuperview];
|
||||
if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(didClickShareModel:)]) {
|
||||
[weakSelf.delegate didClickShareModel:model];
|
||||
}
|
||||
[self shareWithPlatform:model];
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
-(void)shareWithPlatform:(QXShareViewModel*)model{
|
||||
// [WXApi startLogByLevel:(WXLogLevelDetail) logBlock:^(NSString * _Nonnull log) {
|
||||
// QXLOG(@"wx--------------%@",log);
|
||||
// }];
|
||||
// [WXApi checkUniversalLinkReady:^(WXULCheckStep step, WXCheckULStepResult * _Nonnull result) {
|
||||
// QXLOG(@"步骤wx--------------%ld-----------%@",step,result);
|
||||
// }];
|
||||
// SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];
|
||||
// req.bText = YES;
|
||||
// req.text = @"分享的内容";
|
||||
// req.scene = WXSceneSession;
|
||||
// [WXApi sendReq:req completion:^(BOOL success) {
|
||||
//
|
||||
// }];
|
||||
//
|
||||
// return;
|
||||
if ([model.name isEqualToString:QXText(@"微信好友")]) {
|
||||
|
||||
if (self.dynamicModel != nil) /*分享动态*/{
|
||||
[self shareDynamicWithWechat:YES];
|
||||
}else if (self.imageData != nil){
|
||||
WXImageObject *imageObject = [WXImageObject object];
|
||||
imageObject.imageData = self.imageData;
|
||||
|
||||
WXMediaMessage *message = [WXMediaMessage message];
|
||||
// message.thumbData = nil;
|
||||
message.mediaObject = imageObject;
|
||||
SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];
|
||||
req.bText = NO;
|
||||
req.message = message;
|
||||
req.scene = WXSceneSession;
|
||||
[WXApi sendReq:req completion:^(BOOL success) {
|
||||
|
||||
}];
|
||||
}
|
||||
}else if ([model.name isEqualToString:QXText(@"朋友圈")]){
|
||||
if (self.dynamicModel != nil) /*分享朋友圈*/{
|
||||
[self shareDynamicWithWechat:NO];
|
||||
}else if (self.imageData != nil){
|
||||
WXImageObject *imageObject = [WXImageObject object];
|
||||
imageObject.imageData = self.imageData;
|
||||
|
||||
WXMediaMessage *message = [WXMediaMessage message];
|
||||
message.thumbData = self.imageData;
|
||||
message.mediaObject = imageObject;
|
||||
SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];
|
||||
req.bText = NO;
|
||||
req.message = message;
|
||||
req.scene = WXSceneTimeline;
|
||||
[WXApi sendReq:req completion:^(BOOL success) {
|
||||
|
||||
}];
|
||||
}
|
||||
}else if ([model.name isEqualToString:QXText(@"QQ")]){
|
||||
if (self.dynamicModel != nil) /*分享动态*/{
|
||||
[self shareDynamicWithQQ:YES];
|
||||
}
|
||||
}else if ([model.name isEqualToString:QXText(@"QQ空间")]){
|
||||
if (self.dynamicModel != nil) /*分享朋友圈*/{
|
||||
[self shareDynamicWithQQ:NO];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-(void)shareDynamicWithWechat:(BOOL)isSession{
|
||||
__block WXWebpageObject *webpageObject = [WXWebpageObject object];
|
||||
__block WXMediaMessage *message = [WXMediaMessage message];
|
||||
webpageObject.webpageUrl = self.dynamicModel.share_url?self.dynamicModel.share_url:@"https://www.baidu.com";
|
||||
if (self.dynamicModel.content.length > 20) {
|
||||
message.description = [self.dynamicModel.content substringToIndex:20];
|
||||
}else{
|
||||
message.description = self.dynamicModel.content;
|
||||
}
|
||||
[message setThumbImage:[UIImage imageNamed:@"user_header_placehoulder"]];
|
||||
message.mediaObject = webpageObject;
|
||||
SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];
|
||||
req.bText = NO;
|
||||
req.message = message;
|
||||
req.scene = isSession?WXSceneSession:WXSceneTimeline;
|
||||
[WXApi sendReq:req completion:^(BOOL success) {
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)shareDynamicWithQQ:(BOOL)isSession{
|
||||
|
||||
if (self.dynamicModel.images.length == 0) {
|
||||
NSString *content = @"";
|
||||
if (self.dynamicModel.content.length > 20) {
|
||||
content = [self.dynamicModel.content substringToIndex:20];
|
||||
}else{
|
||||
content = self.dynamicModel.content;
|
||||
}
|
||||
QQApiNewsObject *newsObj = [QQApiNewsObject objectWithURL :[NSURL URLWithString:self.dynamicModel.share_url]
|
||||
title: @""
|
||||
description :content
|
||||
previewImageURL:[NSURL URLWithString:self.dynamicModel.avatar]];
|
||||
SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:newsObj];
|
||||
//将内容分享到qq
|
||||
if (isSession) {
|
||||
QQApiSendResultCode sent = [QQApiInterface sendReq:req];
|
||||
}else{
|
||||
//将内容分享到qzone
|
||||
QQApiSendResultCode sent = [QQApiInterface SendReqToQZone:req];
|
||||
}
|
||||
|
||||
}else{
|
||||
NSArray *images = [self.dynamicModel.images componentsSeparatedByString:@","];
|
||||
NSString* img = images.firstObject;
|
||||
NSString *content = @"";
|
||||
if (self.dynamicModel.content.length > 20) {
|
||||
content = [self.dynamicModel.content substringToIndex:20];
|
||||
}else{
|
||||
content = self.dynamicModel.content;
|
||||
}
|
||||
QQApiNewsObject *newsObj = [QQApiNewsObject objectWithURL :[NSURL URLWithString:self.dynamicModel.share_url]
|
||||
title: @""
|
||||
description :content
|
||||
previewImageURL:[NSURL URLWithString:img]];
|
||||
SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:newsObj];
|
||||
//将内容分享到qq
|
||||
if (isSession) {
|
||||
QQApiSendResultCode sent = [QQApiInterface sendReq:req];
|
||||
}else{
|
||||
//将内容分享到qzone
|
||||
QQApiSendResultCode sent = [QQApiInterface SendReqToQZone:req];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-(void)setImageData:(NSData *)imageData{
|
||||
_imageData = imageData;
|
||||
}
|
||||
|
||||
-(void)setDynamicModel:(QXDynamicModel *)dynamicModel{
|
||||
_dynamicModel = dynamicModel;
|
||||
if (![dynamicModel.user_id isEqualToString:[QXGlobal shareGlobal].loginModel.user_id]) {
|
||||
[self.eventArray removeLastObject];
|
||||
}
|
||||
MJWeakSelf
|
||||
[QXDynamicNetwork mutualRelationshipWithPage:0 successBlock:^(NSArray<QXDynamicLikeModel *> * _Nonnull hotos) {
|
||||
for (QXDynamicLikeModel*md in hotos) {
|
||||
QXShareViewModel *model = [[QXShareViewModel alloc] init];
|
||||
model.icon = md.avatar;
|
||||
model.Id = md.user_id;
|
||||
model.name = md.nickname;
|
||||
[weakSelf.friendArray addObject:model];
|
||||
}
|
||||
[weakSelf.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
-(NSMutableArray *)dataArray{
|
||||
if (!_dataArray) {
|
||||
_dataArray = [NSMutableArray array];
|
||||
[_dataArray addObjectsFromArray:QXConfig.sharePlatforms];
|
||||
}
|
||||
return _dataArray;
|
||||
}
|
||||
-(NSMutableArray *)friendArray{
|
||||
if (!_friendArray) {
|
||||
_friendArray = [NSMutableArray array];
|
||||
// QXShareViewModel *model1 = [[QXShareViewModel alloc] init];
|
||||
// model1.icon = @"dynamic_copy_link";
|
||||
// model1.name = QXText(@"复制链接");
|
||||
// model1.Id = @"0";
|
||||
//
|
||||
// QXShareViewModel *model2 = [[QXShareViewModel alloc] init];
|
||||
// model2.icon = @"dynamic_copy_link";
|
||||
// model2.name = QXText(@"举报");
|
||||
// model2.Id = @"1";
|
||||
//
|
||||
// QXShareViewModel *model3 = [[QXShareViewModel alloc] init];
|
||||
// model3.icon = @"dynamic_copy_link";
|
||||
// model3.name = QXText(@"删除");
|
||||
// model3.Id = @"2";
|
||||
// [_friendArray addObjectsFromArray:@[model1,model2,model3,model3,model3,model3,model3,model3]];
|
||||
}
|
||||
return _friendArray;
|
||||
}
|
||||
-(NSMutableArray *)eventArray{
|
||||
if (!_eventArray) {
|
||||
QXShareViewModel *model1 = [[QXShareViewModel alloc] init];
|
||||
model1.icon = @"dynamic_copy_link";
|
||||
model1.name = QXText(@"复制链接");
|
||||
model1.Id = @"0";
|
||||
|
||||
QXShareViewModel *model2 = [[QXShareViewModel alloc] init];
|
||||
model2.icon = @"dynamic_report";
|
||||
model2.name = QXText(@"举报");
|
||||
model2.Id = @"1";
|
||||
|
||||
QXShareViewModel *model3 = [[QXShareViewModel alloc] init];
|
||||
model3.icon = @"dynamic_delete";
|
||||
model3.name = QXText(@"删除");
|
||||
model3.Id = @"2";
|
||||
_eventArray = [NSMutableArray arrayWithArray:@[model1,model2,model3]];
|
||||
}
|
||||
return _eventArray;
|
||||
}
|
||||
-(void)showInView:(UIView *)view{
|
||||
[view addSubview:self];
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT-self.bgView.height;
|
||||
}];
|
||||
}
|
||||
-(void)hideView{
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
} completion:^(BOOL finished) {
|
||||
[self removeFromSuperview];
|
||||
}];
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXShareViewContentCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)initSubviews{
|
||||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||||
layout.itemSize = CGSizeMake((SCREEN_WIDTH-16*4-16)/5, 71);
|
||||
layout.minimumLineSpacing = 16;
|
||||
layout.minimumInteritemSpacing = 16;
|
||||
layout.sectionInset = UIEdgeInsetsMake(0, 16, 0, 16);
|
||||
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
||||
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height) collectionViewLayout:layout];
|
||||
[self.collectionView registerClass:[QXShareViewCell class] forCellWithReuseIdentifier:@"QXShareViewCell"];
|
||||
self.collectionView.delegate = self;
|
||||
self.collectionView.dataSource = self;
|
||||
self.collectionView.showsHorizontalScrollIndicator = NO;
|
||||
self.collectionView.bounces = NO;
|
||||
[self.contentView addSubview:self.collectionView];
|
||||
}
|
||||
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||||
return self.dataArray.count;
|
||||
}
|
||||
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXShareViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXShareViewCell" forIndexPath:indexPath];
|
||||
QXShareViewModel *model = self.dataArray[indexPath.row];
|
||||
cell.model = model;
|
||||
return cell;
|
||||
}
|
||||
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXShareViewModel *model = self.dataArray[indexPath.row];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickShareModel:)]) {
|
||||
[self.delegate didClickShareModel:model];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)setDataArray:(NSMutableArray *)dataArray{
|
||||
_dataArray = dataArray;
|
||||
[self.collectionView reloadData];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation QXShareViewCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)initSubviews{
|
||||
self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.width, 45)];
|
||||
self.imageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
[self.contentView addSubview:self.imageView];
|
||||
|
||||
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.imageView.bottom+8, self.width, 18)];
|
||||
self.titleLabel.font = [UIFont systemFontOfSize:12];
|
||||
self.titleLabel.textColor = QXConfig.textColor;
|
||||
self.titleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
[self.contentView addSubview:self.titleLabel];
|
||||
}
|
||||
|
||||
-(void)setModel:(QXShareViewModel *)model{
|
||||
_model = model;
|
||||
if ([model.icon hasPrefix:@"https"] || [model.icon hasPrefix:@"http"]) {
|
||||
[self.imageView sd_setImageWithURL:[NSURL URLWithString:model.icon]];
|
||||
}else{
|
||||
self.imageView.image = [UIImage imageNamed:model.icon];
|
||||
}
|
||||
self.titleLabel.text = model.name;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXShareViewModel
|
||||
|
||||
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user