From 90eab408d061fd423e88a5f46e0f0e5dc3f3053a Mon Sep 17 00:00:00 2001 From: liyuhua <15626451870@163.com> Date: Wed, 15 Nov 2023 16:49:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YuMi.xcodeproj/project.pbxproj | 12 ++ .../PIRoomActivityWebCell.h | 17 ++ .../PIRoomActivityWebCell.m | 52 +++++++ .../PIRoomActivityWebView.h | 20 +++ .../PIRoomActivityWebView.m | 147 ++++++++++++++++++ .../XPRoomActivityContainerView.m | 27 ++-- 6 files changed, 262 insertions(+), 13 deletions(-) create mode 100644 YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebCell.h create mode 100644 YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebCell.m create mode 100644 YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebView.h create mode 100644 YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebView.m diff --git a/YuMi.xcodeproj/project.pbxproj b/YuMi.xcodeproj/project.pbxproj index 291dc1ec..0fab6418 100644 --- a/YuMi.xcodeproj/project.pbxproj +++ b/YuMi.xcodeproj/project.pbxproj @@ -206,6 +206,8 @@ 234489082AC3C5DA0070E5D5 /* SudMGP.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 234489072AC3C5DA0070E5D5 /* SudMGP.framework */; }; 234489092AC3C5FF0070E5D5 /* SudMGP.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 234489072AC3C5DA0070E5D5 /* SudMGP.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 234D821E2AEC57CF0022EFEB /* YYTextAsyncLayer+PITextAsyncLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 234D821D2AEC57CF0022EFEB /* YYTextAsyncLayer+PITextAsyncLayer.m */; }; + 235A451A2B04A352009753F5 /* PIRoomActivityWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = 235A45192B04A352009753F5 /* PIRoomActivityWebView.m */; }; + 235A451D2B04A452009753F5 /* PIRoomActivityWebCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 235A451C2B04A452009753F5 /* PIRoomActivityWebCell.m */; }; 236896A02AE6720600EED5F2 /* PIRoomGiftBroadcastWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 2368969F2AE6720600EED5F2 /* PIRoomGiftBroadcastWindow.m */; }; 2369F9912A89CE0E00563B48 /* PIUserSexView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2369F9902A89CE0E00563B48 /* PIUserSexView.m */; }; 2369F9932A8B21EB00563B48 /* pi_treasure_fairy_gift_bg.svga in Resources */ = {isa = PBXBuildFile; fileRef = 2369F9922A8B21EA00563B48 /* pi_treasure_fairy_gift_bg.svga */; }; @@ -1870,6 +1872,10 @@ 234489072AC3C5DA0070E5D5 /* SudMGP.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = SudMGP.framework; sourceTree = ""; }; 234D821C2AEC57CF0022EFEB /* YYTextAsyncLayer+PITextAsyncLayer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "YYTextAsyncLayer+PITextAsyncLayer.h"; path = "YuMi/Appdelegate/YYTextAsyncLayer+PITextAsyncLayer.h"; sourceTree = SOURCE_ROOT; }; 234D821D2AEC57CF0022EFEB /* YYTextAsyncLayer+PITextAsyncLayer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = "YYTextAsyncLayer+PITextAsyncLayer.m"; path = "YuMi/Appdelegate/YYTextAsyncLayer+PITextAsyncLayer.m"; sourceTree = SOURCE_ROOT; }; + 235A45182B04A352009753F5 /* PIRoomActivityWebView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PIRoomActivityWebView.h; sourceTree = ""; }; + 235A45192B04A352009753F5 /* PIRoomActivityWebView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PIRoomActivityWebView.m; sourceTree = ""; }; + 235A451B2B04A452009753F5 /* PIRoomActivityWebCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PIRoomActivityWebCell.h; sourceTree = ""; }; + 235A451C2B04A452009753F5 /* PIRoomActivityWebCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PIRoomActivityWebCell.m; sourceTree = ""; }; 2368969E2AE6720600EED5F2 /* PIRoomGiftBroadcastWindow.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PIRoomGiftBroadcastWindow.h; sourceTree = ""; }; 2368969F2AE6720600EED5F2 /* PIRoomGiftBroadcastWindow.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PIRoomGiftBroadcastWindow.m; sourceTree = ""; }; 2369F98F2A89CE0E00563B48 /* PIUserSexView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PIUserSexView.h; sourceTree = ""; }; @@ -9695,6 +9701,10 @@ E8AE427227153A3500BEEBB2 /* XPRoomActivityContainerView.m */, 9BAC92EC28E6989400147DD8 /* XPRoomActivityPlayView.h */, 9BAC92ED28E6989400147DD8 /* XPRoomActivityPlayView.m */, + 235A45182B04A352009753F5 /* PIRoomActivityWebView.h */, + 235A45192B04A352009753F5 /* PIRoomActivityWebView.m */, + 235A451B2B04A452009753F5 /* PIRoomActivityWebCell.h */, + 235A451C2B04A452009753F5 /* PIRoomActivityWebCell.m */, ); path = ActivityContainerView; sourceTree = ""; @@ -10826,6 +10836,7 @@ E88C72A02828FCD40047FB2B /* XPMusicLibraryPlayView.m in Sources */, E823E38E290BE8BD00EADD86 /* WishGiftInfoUpdateModel.m in Sources */, E80EC80A28ACD84000D133C5 /* QEmotionBoardView.m in Sources */, + 235A451A2B04A352009753F5 /* PIRoomActivityWebView.m in Sources */, E8998D962859DD6F00C68558 /* UIView+Corner.m in Sources */, E8EEB91126FC6AE2007C6EBA /* XPMineUserInfoEditProtocol.h in Sources */, E87E625D2A3F5622002F68C9 /* XPNewHomeViewController.m in Sources */, @@ -11849,6 +11860,7 @@ 9B0997A327F19DE500EB8F14 /* QGHWDShaders.metal in Sources */, E8778AF02988EF0600CF139B /* XPSessionSayHelloViewController.m in Sources */, 187EEEE126E89BFB002833B2 /* AccountModel.m in Sources */, + 235A451D2B04A452009753F5 /* PIRoomActivityWebCell.m in Sources */, E8098CA7282E00920090B9F0 /* Api+Monents.m in Sources */, E896EFA92771AEEC00AD2CC1 /* XPMineAttentionTableViewCell.m in Sources */, E8F1559328129EBA00EE8C06 /* ContentSecretaryModel.m in Sources */, diff --git a/YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebCell.h b/YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebCell.h new file mode 100644 index 00000000..e46f7875 --- /dev/null +++ b/YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebCell.h @@ -0,0 +1,17 @@ +// +// PIRoomActivityWebCell.h +// YuMi +// +// Created by duoban on 2023/11/15. +// + +#import +#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 diff --git a/YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebCell.m b/YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebCell.m new file mode 100644 index 00000000..fd687755 --- /dev/null +++ b/YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebCell.m @@ -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 diff --git a/YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebView.h b/YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebView.h new file mode 100644 index 00000000..303d3c78 --- /dev/null +++ b/YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebView.h @@ -0,0 +1,20 @@ +// +// PIRoomActivityWebView.h +// YuMi +// +// Created by duoban on 2023/11/15. +// + +#import + +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 diff --git a/YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebView.m b/YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebView.m new file mode 100644 index 00000000..35ba9cdf --- /dev/null +++ b/YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebView.m @@ -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 () +@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 diff --git a/YuMi/Modules/YMRoom/View/ActivityContainerView/XPRoomActivityContainerView.m b/YuMi/Modules/YMRoom/View/ActivityContainerView/XPRoomActivityContainerView.m index 23ddcfae..6b712fe6 100644 --- a/YuMi/Modules/YMRoom/View/ActivityContainerView/XPRoomActivityContainerView.m +++ b/YuMi/Modules/YMRoom/View/ActivityContainerView/XPRoomActivityContainerView.m @@ -37,6 +37,7 @@ #import "XPTreasureFairyViewController.h" #import "PIRoomEnterRedPacketView.h" #import "BaseNavigationController.h" +#import "PIRoomActivityWebView.h" UIKIT_EXTERN NSString *kShowFirstRechargeView; @interface XPRoomActivityContainerView () ///容器 @@ -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); + }]; } } }