个人中心功能区排序

This commit is contained in:
chenguilong
2022-08-04 16:31:27 +08:00
parent 2da12a4e4f
commit 03fe19f47f
7 changed files with 269 additions and 59 deletions

View File

@@ -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 = "<group>"; };
9BCF586027995426008401A4 /* XPSkillCardSelectPropCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPSkillCardSelectPropCell.h; sourceTree = "<group>"; };
9BCF586127995426008401A4 /* XPSkillCardSelectPropCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPSkillCardSelectPropCell.m; sourceTree = "<group>"; };
9BCFB826289BAC7D0093D863 /* XPMineHeadFunctionItemLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineHeadFunctionItemLayout.h; sourceTree = "<group>"; };
9BCFB827289BAC7D0093D863 /* XPMineHeadFunctionItemLayout.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineHeadFunctionItemLayout.m; sourceTree = "<group>"; };
9BD2ECCC288F829600F5CD9A /* XPMineFootPrintViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineFootPrintViewController.h; sourceTree = "<group>"; };
9BD2ECCD288F829600F5CD9A /* XPMineFootPrintViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineFootPrintViewController.m; sourceTree = "<group>"; };
9BD2ECD0288F833B00F5CD9A /* XPMineFootPrintModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineFootPrintModel.h; sourceTree = "<group>"; };
@@ -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 */,

View File

@@ -0,0 +1,16 @@
//
// XPMineHeadFunctionItemLayout.h
// xplan-ios
//
// Created by GreenLand on 2022/8/4.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPMineHeadFunctionItemLayout : UICollectionViewFlowLayout
@end
NS_ASSUME_NONNULL_END

View File

@@ -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++) {
//sectioncell
NSUInteger count = [self.collectionView numberOfItemsInSection:sec];
for (NSUInteger item = 0; item<count; item++) {
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:item inSection:sec];
//
UICollectionViewLayoutAttributes *attributes = [self layoutAttributesForItemAtIndexPath:indexPath];
[self.allAttributes addObject:attributes];
}
// NSInteger sectionCount = [self.collectionView numberOfSections];
// for (int i = 0; i<sectionCount; i++) {
// NSInteger count = [self.collectionView numberOfItemsInSection:i];
// for (int index = 0; index<count; index++) {
// NSIndexPath *indexPath = [NSIndexPath indexPathForItem:index inSection:i];
// UICollectionViewLayoutAttributes *attributes = [self layoutAttributesForItemAtIndexPath:indexPath];
// [self.allAttributes addObject:attributes];
// }
// }
}
}
- (CGSize)collectionViewContentSize {
//section
NSInteger actualLo = 0;
for (NSString *key in [_sectionDic allKeys]) {
actualLo += [_sectionDic[key] integerValue];
}
return CGSizeMake(actualLo*self.collectionView.frame.size.width, self.collectionView.contentSize.height);
}
- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewLayoutAttributes *attr = [super layoutAttributesForItemAtIndexPath:indexPath].copy;
[self applyLayoutAttributes:attr];
// NSInteger itemNew = indexPath.item;
// NSInteger itemOld = itemNew;
// switch (itemNew) {
// case 0:
// itemOld = 0;
// break;
// case 1:
// itemOld = 2;
// break;
// case 2:
// itemOld = 4;
// break;
// case 3:
// itemOld = 6;
// break;
// case 4:
// itemOld = 1;
// break;
// case 5:
// itemOld = 3;
// break;
// case 6:
// itemOld = 5;
// break;
// case 7:
// itemOld = 7;
// break;
// default:
// break;
// }
// UICollectionViewLayoutAttributes *oldAttributes = [super layoutAttributesForItemAtIndexPath:[NSIndexPath indexPathForItem:itemOld inSection:indexPath.section]].copy;
return attr;
// let itemNew = indexPath.row
// var itemOld = itemNew
// switch itemNew {
// case 0:
// itemOld = 0
// case 1:
// itemOld = 2
// case 2:
// itemOld = 4
// case 3:
// itemOld = 6
// case 4:
// itemOld = 1
// case 5:
// itemOld = 3
// case 6:
// itemOld = 5
// case 7:
// itemOld = 7
// default:
// itemOld = itemNew
// }
// let attribute = super.layoutAttributesForItem(at: indexPath)?.copy() as? UICollectionViewLayoutAttributes
// let oldAttributes = super.layoutAttributesForItem(at: IndexPath(item: itemOld, section: indexPath.section))
// attribute?.frame = oldAttributes?.frame ?? CGRect.zero
// return attribute
// return attr;
}
- (NSArray<UICollectionViewLayoutAttributes *> *)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;
//sectionitem
NSInteger itemCount = [self.collectionView numberOfItemsInSection:section];
CGFloat offset = section * stride;
//xitem
NSInteger xCount = (width / itemW);
//yitem
NSInteger yCount = (height / itemH);
//
NSInteger allCount = (xCount * yCount);
//section0
NSInteger page = itemIndex / allCount;
//itemx
NSInteger remain = (itemIndex % xCount);
//itemy
NSInteger merchant = (itemIndex-page*allCount)/xCount;
//xitem
CGFloat xCellOffset = remain * (itemW + minLine)+ sectionInsets.left;
//yitem
CGFloat yCellOffset = merchant * (itemH + minSpacing);
//sectionitem
NSInteger pageRe = (itemCount % allCount == 0)? (itemCount / allCount) : (itemCount / allCount) + 1;
//sectionpageRe
[_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

View File

@@ -13,6 +13,7 @@
#import "XPMacro.h"
///View
#import "XPMineHeadItemCollectionViewCell.h"
#import "XPMineHeadFunctionItemLayout.h"
@interface XPMineHeadItemTableViewCell ()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
///
@@ -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;
}

View File

@@ -119,6 +119,7 @@
XPTabAnchorCardModel *model = [XPTabAnchorCardModel modelWithDictionary:data.data];
[[self getView] getAnchorCardInfoSuccess:model];
} fail:^(NSInteger code, NSString * _Nullable msg) {
NSLog(@"%@", msg);
} errorToast:NO]];
}

View File

@@ -48,27 +48,22 @@
@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];
}
}
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame: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;
}
}

View File

@@ -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;
}