diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index 43f9066d..3b559fa6 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -252,6 +252,7 @@ 9BCF585C279909D7008401A4 /* XPSkillCardEditPropCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BCF585B279909D7008401A4 /* XPSkillCardEditPropCell.m */; }; 9BCF585F27995363008401A4 /* XPSkillCardSelectPropView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BCF585E27995363008401A4 /* XPSkillCardSelectPropView.m */; }; 9BCF586227995426008401A4 /* XPSkillCardSelectPropCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BCF586127995426008401A4 /* XPSkillCardSelectPropCell.m */; }; + 9BCFB828289BAC7D0093D863 /* XPMineHeadFunctionItemLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BCFB827289BAC7D0093D863 /* XPMineHeadFunctionItemLayout.m */; }; 9BD2ECCE288F829600F5CD9A /* XPMineFootPrintViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BD2ECCD288F829600F5CD9A /* XPMineFootPrintViewController.m */; }; 9BD2ECD2288F833B00F5CD9A /* XPMineFootPrintModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BD2ECD1288F833B00F5CD9A /* XPMineFootPrintModel.m */; }; 9BD2ECD5288F838200F5CD9A /* XPMineFootPrintPresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BD2ECD4288F838200F5CD9A /* XPMineFootPrintPresenter.m */; }; @@ -1391,6 +1392,8 @@ 9BCF585E27995363008401A4 /* XPSkillCardSelectPropView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPSkillCardSelectPropView.m; sourceTree = ""; }; 9BCF586027995426008401A4 /* XPSkillCardSelectPropCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPSkillCardSelectPropCell.h; sourceTree = ""; }; 9BCF586127995426008401A4 /* XPSkillCardSelectPropCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPSkillCardSelectPropCell.m; sourceTree = ""; }; + 9BCFB826289BAC7D0093D863 /* XPMineHeadFunctionItemLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineHeadFunctionItemLayout.h; sourceTree = ""; }; + 9BCFB827289BAC7D0093D863 /* XPMineHeadFunctionItemLayout.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineHeadFunctionItemLayout.m; sourceTree = ""; }; 9BD2ECCC288F829600F5CD9A /* XPMineFootPrintViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineFootPrintViewController.h; sourceTree = ""; }; 9BD2ECCD288F829600F5CD9A /* XPMineFootPrintViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineFootPrintViewController.m; sourceTree = ""; }; 9BD2ECD0288F833B00F5CD9A /* XPMineFootPrintModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineFootPrintModel.h; sourceTree = ""; }; @@ -7025,6 +7028,8 @@ E8AC723126F49710007D6E91 /* XPMineNotificationTableViewCell.m */, 9B92A33A2797E38100AD168F /* XPMineHeadItemTableViewCell.h */, 9B92A33B2797E38100AD168F /* XPMineHeadItemTableViewCell.m */, + 9BCFB826289BAC7D0093D863 /* XPMineHeadFunctionItemLayout.h */, + 9BCFB827289BAC7D0093D863 /* XPMineHeadFunctionItemLayout.m */, E8E20BED2816A5FC0033B688 /* XPMineBlackListTableViewCell.h */, E8E20BEE2816A5FC0033B688 /* XPMineBlackListTableViewCell.m */, 9B734F77288A9C4B00CBDAA9 /* XPMineGameTableViewCell.h */, @@ -7798,6 +7803,7 @@ 9B9EEF4E27C8755C006B0EB3 /* XPSkillCardResourcePropModel.m in Sources */, E88B5CB026FB1C6500DA9178 /* XPMineTeenagerPresenter.m in Sources */, E800163B28041F7B00D6D17A /* XPGuildSingleRoomIncomeTableViewCell.m in Sources */, + 9BCFB828289BAC7D0093D863 /* XPMineHeadFunctionItemLayout.m in Sources */, E8D34D6428084E40009C4835 /* XPMineUserInfoGiftWallViewController.m in Sources */, E899C68927508F4E00E189E5 /* XPUserCardInfoModel.m in Sources */, 9B6B3AAB278C2EA7005551EC /* XPRoomNobleLevelUpView.m in Sources */, diff --git a/xplan-ios/Main/Mine/View/Cell/XPMineHeadFunctionItemLayout.h b/xplan-ios/Main/Mine/View/Cell/XPMineHeadFunctionItemLayout.h new file mode 100644 index 00000000..e35ee24d --- /dev/null +++ b/xplan-ios/Main/Mine/View/Cell/XPMineHeadFunctionItemLayout.h @@ -0,0 +1,16 @@ +// +// XPMineHeadFunctionItemLayout.h +// xplan-ios +// +// Created by GreenLand on 2022/8/4. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface XPMineHeadFunctionItemLayout : UICollectionViewFlowLayout + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/View/Cell/XPMineHeadFunctionItemLayout.m b/xplan-ios/Main/Mine/View/Cell/XPMineHeadFunctionItemLayout.m new file mode 100644 index 00000000..2136c1bc --- /dev/null +++ b/xplan-ios/Main/Mine/View/Cell/XPMineHeadFunctionItemLayout.m @@ -0,0 +1,218 @@ +// +// XPMineHeadFunctionItemLayout.m +// xplan-ios +// +// Created by GreenLand on 2022/8/4. +// + +#import "XPMineHeadFunctionItemLayout.h" + +@interface XPMineHeadFunctionItemLayout () +@property (nonatomic, copy) NSMutableDictionary *sectionDic; +@property (nonatomic, strong) NSMutableArray *allAttributes; +@end + +@implementation XPMineHeadFunctionItemLayout + +#pragma mark - life cycle +- (instancetype)init { + self = [super init]; + if (self) { + self.scrollDirection = UICollectionViewScrollDirectionHorizontal; + } + return self; +} + +#pragma mark - overload + +- (void)prepareLayout { + + [super prepareLayout]; + + _sectionDic = [NSMutableDictionary dictionary]; + self.allAttributes = [NSMutableArray array]; + //获取section的数量 + NSUInteger section = [self.collectionView numberOfSections]; + + for (int sec = 0; sec < section; sec++) { + //获取每个section的cell个数 + NSUInteger count = [self.collectionView numberOfItemsInSection:sec]; + + for (NSUInteger item = 0; item *)layoutAttributesForElementsInRect:(CGRect)rect { + + return self.allAttributes; +} + +#pragma mark - private method + +- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)attributes { + + + if(attributes.representedElementKind != nil){ + return; + } + CGFloat minLine = self.minimumLineSpacing; + CGFloat minSpacing = self.minimumInteritemSpacing; + + //attributes 的宽度 + CGFloat itemW = attributes.frame.size.width; + //attributes 的高度 + CGFloat itemH = attributes.frame.size.height; + UIEdgeInsets sectionInsets = self.sectionInset; + //collectionView 的宽度 + CGFloat width = self.collectionView.frame.size.width; + //collectionView 的高度 + CGFloat height = self.collectionView.frame.size.height; + //每个attributes的下标值 从0开始 + NSInteger itemIndex = attributes.indexPath.item; + + CGFloat stride = (self.scrollDirection == UICollectionViewScrollDirectionHorizontal) ? width : height; + + + //获取现在的attributes是第几组 + NSInteger section = attributes.indexPath.section; + //获取每个section的item的个数 + NSInteger itemCount = [self.collectionView numberOfItemsInSection:section]; + + + CGFloat offset = section * stride; + + //计算x方向item个数 + NSInteger xCount = (width / itemW); + //计算y方向item个数 + NSInteger yCount = (height / itemH); + //计算一页总个数 + NSInteger allCount = (xCount * yCount); + //获取每个section的页数,从0开始 + NSInteger page = itemIndex / allCount; + + //余数,用来计算item的x的偏移量 + NSInteger remain = (itemIndex % xCount); + //取商,用来计算item的y的偏移量 + NSInteger merchant = (itemIndex-page*allCount)/xCount; + + + //x方向每个item的偏移量 + CGFloat xCellOffset = remain * (itemW + minLine)+ sectionInsets.left; + //y方向每个item的偏移量 + CGFloat yCellOffset = merchant * (itemH + minSpacing); + + //获取每个section中item占了几页 + NSInteger pageRe = (itemCount % allCount == 0)? (itemCount / allCount) : (itemCount / allCount) + 1; + //将每个section与pageRe对应,计算下面的位置 + [_sectionDic setValue:@(pageRe) forKey:[NSString stringWithFormat:@"%ld", section]]; + + if(self.scrollDirection == UICollectionViewScrollDirectionHorizontal) { + + NSInteger actualLo = 0; + //将每个section中的页数相加 + for (NSString *key in [_sectionDic allKeys]) { + actualLo += [_sectionDic[key] integerValue]; + } + //获取到的最后的数减去最后一组的页码数 + actualLo -= [_sectionDic[[NSString stringWithFormat:@"%ld", [_sectionDic allKeys].count-1]] integerValue]; + xCellOffset += page*width + actualLo*width; + + } else { + + yCellOffset += offset; + } + + attributes.frame = CGRectMake(xCellOffset, yCellOffset, itemW, itemH); +} + + +@end diff --git a/xplan-ios/Main/Mine/View/Cell/XPMineHeadItemTableViewCell.m b/xplan-ios/Main/Mine/View/Cell/XPMineHeadItemTableViewCell.m index 1c2d134d..a96a1fc2 100644 --- a/xplan-ios/Main/Mine/View/Cell/XPMineHeadItemTableViewCell.m +++ b/xplan-ios/Main/Mine/View/Cell/XPMineHeadItemTableViewCell.m @@ -13,6 +13,7 @@ #import "XPMacro.h" ///View #import "XPMineHeadItemCollectionViewCell.h" +#import "XPMineHeadFunctionItemLayout.h" @interface XPMineHeadItemTableViewCell () ///列表 @@ -118,14 +119,18 @@ - (UICollectionView *)collectionView{ if (!_collectionView) { - UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; + XPMineHeadFunctionItemLayout *layout = [[XPMineHeadFunctionItemLayout alloc] init]; layout.scrollDirection = UICollectionViewScrollDirectionHorizontal; _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; _collectionView.dataSource = self; _collectionView.delegate = self; + layout.minimumLineSpacing = 0; + layout.minimumInteritemSpacing = 10; + layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0); _collectionView.backgroundColor = [ThemeColor appCellBackgroundColor]; [_collectionView registerClass:[XPMineHeadItemCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPMineHeadItemCollectionViewCell class])]; _collectionView.showsHorizontalScrollIndicator = NO; + _collectionView.pagingEnabled = YES; } return _collectionView; } diff --git a/xplan-ios/Main/Tabbar/Presenter/MainPresenter.m b/xplan-ios/Main/Tabbar/Presenter/MainPresenter.m index 60e4659c..ee6a789e 100644 --- a/xplan-ios/Main/Tabbar/Presenter/MainPresenter.m +++ b/xplan-ios/Main/Tabbar/Presenter/MainPresenter.m @@ -119,6 +119,7 @@ XPTabAnchorCardModel *model = [XPTabAnchorCardModel modelWithDictionary:data.data]; [[self getView] getAnchorCardInfoSuccess:model]; } fail:^(NSInteger code, NSString * _Nullable msg) { + NSLog(@"%@", msg); } errorToast:NO]]; } diff --git a/xplan-ios/Main/Tabbar/View/AnchorCard/XPAnchorCardView.m b/xplan-ios/Main/Tabbar/View/AnchorCard/XPAnchorCardView.m index be3b7857..5ce4ff66 100644 --- a/xplan-ios/Main/Tabbar/View/AnchorCard/XPAnchorCardView.m +++ b/xplan-ios/Main/Tabbar/View/AnchorCard/XPAnchorCardView.m @@ -48,26 +48,21 @@ @property (nonatomic,strong) UIImageView *noteImaegView; ///播放完成 @property (nonatomic,assign) BOOL isPlaying; +///定时器是否为挂起状态 +@property (nonatomic, assign) BOOL isSuspend; @end @implementation XPAnchorCardView - (void)dealloc { - if (self.timer) { - dispatch_source_cancel(self.timer); - self.timer = nil; + if (_isSuspend) { + [self resumeTimer]; } + [self stopTimer]; self.isPlaying = NO; [self.noteImaegView stopAnimating]; -} - -- (void)removeFromSuperview { - [super removeFromSuperview]; - if (self.isPlaying) { - [self resumeTimer]; - [[XPSkillCardPlayerManager shareInstance] stopMusic]; - } + [[XPSkillCardPlayerManager shareInstance] stopMusic]; } - (instancetype)initWithFrame:(CGRect)frame { @@ -285,13 +280,15 @@ - (void)pauseTimer{ if(self.timer){ - dispatch_suspend(_timer); + dispatch_suspend(self.timer); + self.isSuspend = YES; } } - (void)resumeTimer{ if(self.timer){ - dispatch_resume(_timer); + dispatch_resume(self.timer); + self.isSuspend = NO; } } diff --git a/xplan-ios/Main/XPWebViewController.m b/xplan-ios/Main/XPWebViewController.m index fc5ab512..8f522768 100644 --- a/xplan-ios/Main/XPWebViewController.m +++ b/xplan-ios/Main/XPWebViewController.m @@ -89,6 +89,7 @@ NSString * const kInitShowNav = @"initShowNav"; NSString * const kCloseWebView = @"closeWebView"; NSString * const kJumpAppointPage = @"jumpAppointPage"; NSString * const kJSOpenRoom = @"openRoom"; +NSString * const kJSOpenRoomForGiftId = @"openRoomForGiftId"; @implementation XPWebViewController @@ -280,17 +281,19 @@ NSString * const kJSOpenRoom = @"openRoom"; NSInteger skyType = [bodyDict[@"routerType"] integerValue]; [self handleRouterType:skyType message:message]; } else if ([message.name isEqualToString:kJSOpenRoom]) { -// NSDictionary *bodyDict; -// if ([message.body isKindOfClass:[NSDictionary class]]) { -// bodyDict = message.body; -// } else if ([message.body isKindOfClass:[NSString class]]) { -// NSString *str = (NSString *)message.body; -// bodyDict = [str toJSONObject]; -// } NSString *uid = [NSString stringWithFormat:@"%@",message.body]; if (uid.length > 0) { [XPRoomViewController openRoom:uid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; } + } else if([message.name isEqualToString:kJSOpenRoomForGiftId]) { + NSLog(@"%@", message.body); + NSDictionary *bodyDict; + if ([message.body isKindOfClass:[NSDictionary class]]) { + bodyDict = message.body; + } else if ([message.body isKindOfClass:[NSString class]]) { + NSString *str = (NSString *)message.body; + bodyDict = [str toJSONObject]; + } } } }]; @@ -309,38 +312,6 @@ NSString * const kJSOpenRoom = @"openRoom"; } } break; -// case P2PInteractive_SkipType_H5: -// { -// //H5 -// NSString *urlString = [NSString stringWithFormat:@"%@", bodyDict[@"routerVal"]]; -// if (urlString.length) { -// XCWKWebViewController *vc = [[[self class] alloc] init]; -// vc.urlString = urlString; -// [self.navigationController pushViewController:vc animated:YES]; -// } -// } -// break; -// case P2PInteractive_SkipType_Purse: -// { -// //钱包页 -// [self h5OpenPurseAction:message]; -// } -// break; -// case P2PInteractive_SkipType_Recharge: -// { -// //充值页 -// [self h5OpenChargePageAction:message]; -// } -// break; -// case P2PInteractive_SkipType_Person: -// { -// //个人页 传参:uid -// NSString *uid = [NSString stringWithFormat:@"%@", bodyDict[@"routerVal"]]; -// if (uid.length) { -// [self h5OpenPersonPageAction:uid.userIDValue message:message]; -// } -// } -// break; case 7: { //座驾 @@ -357,12 +328,6 @@ NSString * const kJSOpenRoom = @"openRoom"; [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:vc animated:YES]; } break; -// case P2PInteractive_SkipType_SystemMessage: -// { -// //系统消息 -// [self h5JumpSystemMessageAction:message]; -// } -// break; case 73: { //装扮商城 @@ -640,6 +605,8 @@ NSString * const kJSOpenRoom = @"openRoom"; [_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJumpAppointPage]; //进入房间 [_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenRoom]; + //进房并弹出礼物面板 + [_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenRoomForGiftId]; } return _userContentController; }