活动改造
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// PIRoomActivityWebCell.h
|
||||
// YuMi
|
||||
//
|
||||
// Created by duoban on 2023/11/15.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "ActivityInfoModel.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface PIRoomActivityWebCell : UICollectionViewCell
|
||||
@property(nonatomic,assign) BOOL pi_isChoose;
|
||||
@property(nonatomic,strong) ActivityInfoModel *infoModel;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// PIRoomActivityWebCell.m
|
||||
// YuMi
|
||||
//
|
||||
// Created by duoban on 2023/11/15.
|
||||
//
|
||||
|
||||
#import "PIRoomActivityWebCell.h"
|
||||
@interface PIRoomActivityWebCell()
|
||||
@property(nonatomic,strong) NetImageView *bgImageView;
|
||||
@end
|
||||
@implementation PIRoomActivityWebCell
|
||||
-(instancetype)initWithFrame:(CGRect)frame{
|
||||
self = [super initWithFrame:frame];
|
||||
if(self){
|
||||
[self installUI];
|
||||
[self installConstraints];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)installUI{
|
||||
self.contentView.backgroundColor = [UIColor clearColor];
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
[self.contentView addSubview:self.bgImageView];
|
||||
}
|
||||
-(void)installConstraints{
|
||||
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self.contentView);
|
||||
}];
|
||||
}
|
||||
-(void)setPi_isChoose:(BOOL)pi_isChoose{
|
||||
_pi_isChoose = pi_isChoose;
|
||||
_bgImageView.layer.borderWidth = _pi_isChoose ? 2 : 0;
|
||||
}
|
||||
-(void)setInfoModel:(ActivityInfoModel *)infoModel{
|
||||
_infoModel = infoModel;
|
||||
_bgImageView.imageUrl = _infoModel.bannerPic;
|
||||
}
|
||||
#pragma mark - 懒加载
|
||||
- (NetImageView *)bgImageView{
|
||||
if(!_bgImageView){
|
||||
NetImageConfig *config = [[NetImageConfig alloc]init]; config.placeHolder = [UIImageConstant defalutBannerPlaceholder];
|
||||
_bgImageView = [[NetImageView alloc]initWithConfig:config];
|
||||
_bgImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
_bgImageView.layer.cornerRadius = kGetScaleWidth(4);
|
||||
_bgImageView.layer.masksToBounds = YES;
|
||||
_bgImageView.layer.borderWidth = 0;
|
||||
_bgImageView.layer.borderColor = UIColorFromRGB(0x9168FA).CGColor;
|
||||
}
|
||||
return _bgImageView;
|
||||
}
|
||||
@end
|
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// PIRoomActivityWebView.h
|
||||
// YuMi
|
||||
//
|
||||
// Created by duoban on 2023/11/15.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface PIRoomActivityWebView : UIView
|
||||
@property(nonatomic,strong) NSMutableArray *infoList;
|
||||
///地址
|
||||
@property (nonatomic,copy) NSString *url;
|
||||
///房间uid
|
||||
@property (nonatomic,copy) NSString *roomUid;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,147 @@
|
||||
//
|
||||
// PIRoomActivityWebView.m
|
||||
// YuMi
|
||||
//
|
||||
// Created by duoban on 2023/11/15.
|
||||
//
|
||||
|
||||
#import "PIRoomActivityWebView.h"
|
||||
#import "PIRoomActivityWebCell.h"
|
||||
#import "XPWebViewController.h"
|
||||
#define kWebViewScale ((CGFloat)KScreenHeight / (CGFloat)812)
|
||||
@interface PIRoomActivityWebView ()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
|
||||
@property(nonatomic,strong) UIButton *pi_backBtn;
|
||||
@property(nonatomic,strong) UIView *bgView;
|
||||
@property(nonatomic,strong) UICollectionView *collectionView;
|
||||
|
||||
///加入h5
|
||||
@property (nonatomic, strong) XPWebViewController *webVC;
|
||||
@property(nonatomic,assign) NSInteger path;
|
||||
@end
|
||||
@implementation PIRoomActivityWebView
|
||||
-(instancetype)initWithFrame:(CGRect)frame{
|
||||
self = [super initWithFrame:frame];
|
||||
if(self){
|
||||
[self installUI];
|
||||
[self installConstraints];
|
||||
@kWeakify(self);
|
||||
self.webVC.CloseWebViewBlock = ^(BOOL result) {
|
||||
@kStrongify(self);
|
||||
[self dissViewAction];
|
||||
};
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)installUI{
|
||||
[self addSubview:self.pi_backBtn];
|
||||
[self addSubview:self.bgView];
|
||||
[self.bgView addSubview:self.collectionView];
|
||||
[self.bgView addSubview:self.webVC.view];
|
||||
|
||||
}
|
||||
-(void)installConstraints{
|
||||
[self.pi_backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self);
|
||||
}];
|
||||
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.trailing.bottom.equalTo(self);
|
||||
make.height.mas_equalTo(643 * kWebViewScale);
|
||||
}];
|
||||
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.trailing.equalTo(self.bgView);
|
||||
make.height.mas_equalTo(kGetScaleWidth(42));
|
||||
make.top.mas_equalTo(kGetScaleWidth(10));
|
||||
}];
|
||||
[self.webVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.trailing.bottom.equalTo(self.bgView);
|
||||
make.top.mas_equalTo(kGetScaleWidth(60));
|
||||
}];
|
||||
}
|
||||
#pragma mark - UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout
|
||||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||||
return self.infoList.count;
|
||||
}
|
||||
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
PIRoomActivityWebCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([PIRoomActivityWebCell class]) forIndexPath:indexPath];
|
||||
cell.infoModel = [self.infoList safeObjectAtIndex1:indexPath.row];
|
||||
cell.pi_isChoose = self.path == indexPath.row;
|
||||
return cell;
|
||||
}
|
||||
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
ActivityInfoModel *model = [_infoList safeObjectAtIndex1:indexPath.row];
|
||||
self.webVC.url = model.skipUri;
|
||||
self.path = indexPath.row;
|
||||
[self.collectionView reloadData];
|
||||
}
|
||||
-(void)dissViewAction{
|
||||
[UIView animateWithDuration:0.2 animations:^{
|
||||
self.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight);
|
||||
}completion:^(BOOL finished) {
|
||||
[self removeFromSuperview];
|
||||
}];
|
||||
}
|
||||
- (void)setRoomUid:(NSString *)roomUid{
|
||||
_roomUid = roomUid;
|
||||
self.webVC.roomUid = _roomUid;
|
||||
}
|
||||
- (void)setUrl:(NSString *)url{
|
||||
_url = url;
|
||||
self.webVC.url = _url;
|
||||
}
|
||||
-(void)setInfoList:(NSMutableArray *)infoList{
|
||||
_infoList = infoList;
|
||||
for (int i = 0; i < _infoList.count; i++) {
|
||||
ActivityInfoModel *model = _infoList[i];
|
||||
if([model.skipUri isEqualToString:_url]){
|
||||
self.path = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
[self.collectionView reloadData];
|
||||
}
|
||||
#pragma mark - 懒加载
|
||||
- (UICollectionView *)collectionView{
|
||||
if (!_collectionView) {
|
||||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||||
layout.minimumLineSpacing = kGetScaleWidth(8);
|
||||
layout.minimumInteritemSpacing = kGetScaleWidth(8);
|
||||
layout.itemSize = CGSizeMake(kGetScaleWidth(90), kGetScaleWidth(42));
|
||||
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
||||
layout.sectionInset = UIEdgeInsetsMake(0, kGetScaleWidth(8), 0, kGetScaleWidth(8));
|
||||
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
||||
_collectionView.dataSource = self;
|
||||
_collectionView.delegate = self;
|
||||
_collectionView.backgroundColor = [UIColor clearColor];
|
||||
[_collectionView registerClass:[PIRoomActivityWebCell class] forCellWithReuseIdentifier:NSStringFromClass([PIRoomActivityWebCell class])];
|
||||
|
||||
}
|
||||
return _collectionView;
|
||||
}
|
||||
- (XPWebViewController *)webVC {
|
||||
if (_webVC == nil) {
|
||||
_webVC = [[XPWebViewController alloc] init];
|
||||
_webVC.isProperty = YES;
|
||||
_webVC.view.backgroundColor = [UIColor clearColor];
|
||||
CGFloat heigth = 643 * kWebViewScale - kGetScaleWidth(60);
|
||||
[_webVC.view setCornerWithLeftTopCorner:kGetScaleWidth(10) rightTopCorner:kGetScaleWidth(10) bottomLeftCorner:0 bottomRightCorner:0 size:CGSizeMake(KScreenWidth, heigth)];
|
||||
}
|
||||
return _webVC;
|
||||
}
|
||||
|
||||
- (UIView *)bgView{
|
||||
if(!_bgView){
|
||||
_bgView = [UIView new];
|
||||
_bgView.backgroundColor = UIColorFromRGB(0x262629);
|
||||
|
||||
[_bgView setCornerWithLeftTopCorner:kGetScaleWidth(8) rightTopCorner:kGetScaleWidth(8) bottomLeftCorner:0 bottomRightCorner:0 size:CGSizeMake(KScreenWidth,642 *kWebViewScale)];
|
||||
}
|
||||
return _bgView;
|
||||
}
|
||||
- (UIButton *)pi_backBtn{
|
||||
if(!_pi_backBtn){
|
||||
_pi_backBtn = [UIButton new];
|
||||
[_pi_backBtn addTarget:self action:@selector(dissViewAction) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _pi_backBtn;
|
||||
}
|
||||
@end
|
@@ -37,6 +37,7 @@
|
||||
#import "XPTreasureFairyViewController.h"
|
||||
#import "PIRoomEnterRedPacketView.h"
|
||||
#import "BaseNavigationController.h"
|
||||
#import "PIRoomActivityWebView.h"
|
||||
UIKIT_EXTERN NSString *kShowFirstRechargeView;
|
||||
@interface XPRoomActivityContainerView ()<SDCycleScrollViewDelegate,PIRoomEnterRedPacketViewDelegate>
|
||||
///容器
|
||||
@@ -372,11 +373,14 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView;
|
||||
NSArray *imageUrlList = cycleScrollView.imageURLStringsGroup;
|
||||
if (imageUrlList.count > index) {
|
||||
NSString *pic = imageUrlList[index];
|
||||
NSMutableArray *inftList = [NSMutableArray array];
|
||||
ActivityInfoModel * info;
|
||||
for (ActivityInfoModel * getInfo in self.activityList) {
|
||||
if([getInfo.bannerPic isEqualToString:pic]){
|
||||
info = getInfo;
|
||||
break;;
|
||||
}
|
||||
if([getInfo.bannerPic hasPrefix:@"http"]){
|
||||
[inftList addObject:getInfo];
|
||||
}
|
||||
}
|
||||
if(info == nil)return;
|
||||
@@ -404,18 +408,15 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView;
|
||||
[self.hostDelegate exitRoom];
|
||||
[XPRoomViewController openRoom:info.skipUri viewController:self.hostDelegate.getCurrentNav];
|
||||
} else if(info.skipType == ActivitySkipType_Web) {
|
||||
if (info.showType == ActivityShowType_Half) {
|
||||
XPRoomHalfWebView * webView = [[XPRoomHalfWebView alloc] init];
|
||||
webView.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
|
||||
webView.url = info.skipUri;
|
||||
[TTPopup popupView:webView style:TTPopupStyleActionSheet];
|
||||
return;
|
||||
}
|
||||
XPWebViewController * webVC = [[XPWebViewController alloc] init];
|
||||
webVC.isPush = YES;
|
||||
webVC.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
|
||||
webVC.url = info.skipUri;
|
||||
[self.hostDelegate.getCurrentNav pushViewController:webVC animated:YES];
|
||||
|
||||
PIRoomActivityWebView * webView = [[PIRoomActivityWebView alloc]initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight)];
|
||||
webView.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
|
||||
webView.url = info.skipUri;
|
||||
webView.infoList = inftList;
|
||||
[kWindow addSubview:webView];
|
||||
[UIView animateWithDuration:0.2 animations:^{
|
||||
webView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
|
||||
}];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user