优化代码结构
This commit is contained in:
eggmanQQQ
2024-06-17 17:20:08 +08:00
parent c4d0b1c33c
commit 9e156c223f
7 changed files with 140 additions and 55 deletions

View File

@@ -520,6 +520,7 @@
23FF42762AA6E1480055733C /* XPHomeRecommendOtherRoomView.m in Sources */ = {isa = PBXBuildFile; fileRef = 23FF42752AA6E1480055733C /* XPHomeRecommendOtherRoomView.m */; };
23FF42792AA6E19C0055733C /* HomeMenuSourceModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 23FF42782AA6E19C0055733C /* HomeMenuSourceModel.m */; };
23FF428E2AAB2D3A0055733C /* XPCandyTreeBuyView.m in Sources */ = {isa = PBXBuildFile; fileRef = 23FF428D2AAB2D3A0055733C /* XPCandyTreeBuyView.m */; };
541DD9552C1EDEFB00B616C4 /* XPHomePagingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 541DD9542C1EDEFB00B616C4 /* XPHomePagingViewController.m */; };
545888332C1AFFB500897585 /* XPRoomPKPanelView.m in Sources */ = {isa = PBXBuildFile; fileRef = 545888322C1AFFB500897585 /* XPRoomPKPanelView.m */; };
545888362C1C306B00897585 /* XPRoomPKPaneAvatarView.m in Sources */ = {isa = PBXBuildFile; fileRef = 545888352C1C306B00897585 /* XPRoomPKPaneAvatarView.m */; };
73FFADDC93E195344047A2EC /* Pods_YuMi.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CACF623970097D653132D69A /* Pods_YuMi.framework */; };
@@ -929,7 +930,7 @@
E81C27AB26EF2D920031E639 /* ThirdUserInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = E81C27AA26EF2D920031E639 /* ThirdUserInfo.m */; };
E81C27AE26EF39AB0031E639 /* AppDelegate+ThirdConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = E81C27AD26EF39AB0031E639 /* AppDelegate+ThirdConfig.m */; };
E81D58822720082A003063FE /* MicroWaveView.m in Sources */ = {isa = PBXBuildFile; fileRef = E81D58812720082A003063FE /* MicroWaveView.m */; };
E81DCCCD282B63B40039E5C5 /* XPMonentsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E81DCCCC282B63B40039E5C5 /* XPMonentsViewController.m */; };
E81DCCCD282B63B40039E5C5 /* XPMomentsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E81DCCCC282B63B40039E5C5 /* XPMomentsViewController.m */; };
E81DCCD0282B63FD0039E5C5 /* XPMonentsRecommendViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E81DCCCF282B63FD0039E5C5 /* XPMonentsRecommendViewController.m */; };
E81E09C9290F71BF00A1F410 /* XPAdvertiseView.m in Sources */ = {isa = PBXBuildFile; fileRef = E81E09C8290F71BF00A1F410 /* XPAdvertiseView.m */; };
E81E09CC290F732600A1F410 /* XPAdImageTool.m in Sources */ = {isa = PBXBuildFile; fileRef = E81E09CB290F732600A1F410 /* XPAdImageTool.m */; };
@@ -2559,6 +2560,8 @@
23FF42782AA6E19C0055733C /* HomeMenuSourceModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomeMenuSourceModel.m; sourceTree = "<group>"; };
23FF428C2AAB2D3A0055733C /* XPCandyTreeBuyView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPCandyTreeBuyView.h; sourceTree = "<group>"; };
23FF428D2AAB2D3A0055733C /* XPCandyTreeBuyView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPCandyTreeBuyView.m; sourceTree = "<group>"; };
541DD9532C1EDEFB00B616C4 /* XPHomePagingViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPHomePagingViewController.h; sourceTree = "<group>"; };
541DD9542C1EDEFB00B616C4 /* XPHomePagingViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPHomePagingViewController.m; sourceTree = "<group>"; };
545888312C1AFFB500897585 /* XPRoomPKPanelView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomPKPanelView.h; sourceTree = "<group>"; };
545888322C1AFFB500897585 /* XPRoomPKPanelView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomPKPanelView.m; sourceTree = "<group>"; };
545888342C1C306B00897585 /* XPRoomPKPaneAvatarView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomPKPaneAvatarView.h; sourceTree = "<group>"; };
@@ -3221,8 +3224,8 @@
E81D587B271FBC3B003063FE /* RtcInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RtcInterface.h; sourceTree = "<group>"; };
E81D58802720082A003063FE /* MicroWaveView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MicroWaveView.h; sourceTree = "<group>"; };
E81D58812720082A003063FE /* MicroWaveView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MicroWaveView.m; sourceTree = "<group>"; };
E81DCCCB282B63B40039E5C5 /* XPMonentsViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMonentsViewController.h; sourceTree = "<group>"; };
E81DCCCC282B63B40039E5C5 /* XPMonentsViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMonentsViewController.m; sourceTree = "<group>"; };
E81DCCCB282B63B40039E5C5 /* XPMomentsViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMomentsViewController.h; sourceTree = "<group>"; };
E81DCCCC282B63B40039E5C5 /* XPMomentsViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMomentsViewController.m; sourceTree = "<group>"; };
E81DCCCE282B63FD0039E5C5 /* XPMonentsRecommendViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMonentsRecommendViewController.h; sourceTree = "<group>"; };
E81DCCCF282B63FD0039E5C5 /* XPMonentsRecommendViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMonentsRecommendViewController.m; sourceTree = "<group>"; };
E81E09C7290F71BF00A1F410 /* XPAdvertiseView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPAdvertiseView.h; sourceTree = "<group>"; };
@@ -7705,8 +7708,8 @@
children = (
E8D7D748282BA1C90007D7BD /* SubViews */,
E8D7D747282BA1C20007D7BD /* Cell */,
E81DCCCB282B63B40039E5C5 /* XPMonentsViewController.h */,
E81DCCCC282B63B40039E5C5 /* XPMonentsViewController.m */,
E81DCCCB282B63B40039E5C5 /* XPMomentsViewController.h */,
E81DCCCC282B63B40039E5C5 /* XPMomentsViewController.m */,
E81DCCCE282B63FD0039E5C5 /* XPMonentsRecommendViewController.h */,
E81DCCCF282B63FD0039E5C5 /* XPMonentsRecommendViewController.m */,
E81A65292834E4F600F55894 /* XPMonentsAttentionViewController.h */,
@@ -9443,6 +9446,8 @@
23B8D8DD2B860B8800CA472F /* PIHoemCategoryCollectionView.m */,
23B8D8D62B85F8B900CA472F /* PIHoemCategoryTitleCell.h */,
23B8D8D72B85F8B900CA472F /* PIHoemCategoryTitleCell.m */,
541DD9532C1EDEFB00B616C4 /* XPHomePagingViewController.h */,
541DD9542C1EDEFB00B616C4 /* XPHomePagingViewController.m */,
);
path = View;
sourceTree = "<group>";
@@ -11478,7 +11483,7 @@
E8664EE327E47711000171BA /* XPRoomPKRecordNickView.m in Sources */,
E8C1CD7327D8A16500376F83 /* XPRoomFaceTool.m in Sources */,
236B2E462AA07D06003967A8 /* UIImage+RW.m in Sources */,
E81DCCCD282B63B40039E5C5 /* XPMonentsViewController.m in Sources */,
E81DCCCD282B63B40039E5C5 /* XPMomentsViewController.m in Sources */,
237700FD2BCD254000D661F1 /* MSBaseTextField.m in Sources */,
237700E62BC7E81F00D661F1 /* UITextField+MSRTL.m in Sources */,
2357149E2BEF0F6D004C81D6 /* MSSessionScrollingItemCell.m in Sources */,
@@ -12002,6 +12007,7 @@
23E9EA9A2A84C39700B792F2 /* XPMineUserInfoRecordedSoundView.m in Sources */,
E8E20BDE28164D3A0033B688 /* SessionNavView.m in Sources */,
9B734F76288A92FB00CBDAA9 /* XPMineFuntionItemModel.m in Sources */,
541DD9552C1EDEFB00B616C4 /* XPHomePagingViewController.m in Sources */,
E82D5C70276AE60000858D6D /* HeadwearModel.m in Sources */,
238B37CC2AC55A2C00BFC9D5 /* XPTreasureFairyPrizeSubView.m in Sources */,
E81125C4296E57B7000D9804 /* QinputPhotoView.m in Sources */,

View File

@@ -9,7 +9,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface XPMonentsViewController : BaseViewController
@interface XPMomentsViewController : BaseViewController
@end

View File

@@ -5,7 +5,7 @@
// Created by on 2022/5/11.
//
#import "XPMonentsViewController.h"
#import "XPMomentsViewController.h"
///Third
#import <Masonry/Masonry.h>
#import <NIMSDK/NIMSDK.h>
@@ -23,7 +23,7 @@
#import "XPMonentsPublishViewController.h"
@interface XPMonentsViewController ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate,NIMSystemNotificationManagerDelegate>
@interface XPMomentsViewController ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate,NIMSystemNotificationManagerDelegate>
///
@property (nonatomic,strong) NSArray<NSString *> *titles;
///
@@ -46,7 +46,7 @@
@property (nonatomic,strong) XPMonentsRecommendViewController * recommendVC;
@end
@implementation XPMonentsViewController
@implementation XPMomentsViewController
- (void)dealloc {
[[NIMSDK sharedSDK].systemNotificationManager removeDelegate:self];

View File

@@ -0,0 +1,16 @@
//
// XPHomePagingViewController.h
// YuMi
//
// Created by P on 2024/6/16.
//
#import "MvpViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface XPHomePagingViewController : MvpViewController
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
//
// XPHomePagingViewController.m
// YuMi
//
// Created by P on 2024/6/16.
//
#import "XPHomePagingViewController.h"
@interface XPHomePagingViewController ()
@property (nonatomic, strong) UIPageViewController pageContainer;
@end
@implementation XPHomePagingViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end

View File

@@ -35,14 +35,19 @@ static NSString * kUpdateVersionNum = @"kUpdateVersionNum";
[[self getView] autoLoginSuccess];
return;
}
@kWeakify(self);
[Api requestTicket:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
@kStrongify(self);
NSArray *tickets = [data.data valueForKey:@"tickets"];
NSString *ticket = [tickets[0] valueForKey:@"ticket"];
[[AccountInfoStorage instance] saveTicket:ticket];
[[self getView] autoLoginSuccess];
} fail:^(NSInteger code, NSString * _Nullable msg) {
@kStrongify(self);
[self logout];
} errorToast:NO] access_token:accountModel.access_token issue_type:@"multi"];
} errorToast:NO]
access_token:accountModel.access_token
issue_type:@"multi"];
}
- (void)loginNIM {

View File

@@ -73,7 +73,7 @@
#import "MSRoomGameVC.h"
#import "XPMonentsRecommendViewController.h"
#import "XPMonentsViewController.h"
#import "XPMomentsViewController.h"
#import "XPReceiveRedPacketView.h"
#import "XPRoomYearActivityView.h"
#import "XPUpgradeView.h"
@@ -89,6 +89,7 @@
#import "UploadFile.h"
#import "XPTabBar.h"
#import "XPHomePagingViewController.h"
NSString * const kUserFirstLoginKey = @"kUserFirstLoginKey";
NSString * const kHadLaunchApp = @"kHadLaunchApp";
@@ -140,11 +141,11 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self.presenter autoLogin];
[self configTheme];
[self initTabs:NO];
if([ClientConfig shareConfig].isLoad == NO){
[[ClientConfig shareConfig] clientInit];
[ClientConfig shareConfig].isLoad = YES;
@@ -156,13 +157,13 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
[self networkReachability];
[self.view addSubview:self.roomMineView];
@kWeakify(self);
[[NSNotificationCenter defaultCenter] addObserverForName:kRoomMiniNotificationKey object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
@kStrongify(self);
[self configRoomMiniNView:note.userInfo];
}];
[[NSNotificationCenter defaultCenter] addObserverForName:@"reloadnewtab" object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
@kStrongify(self);
if (self.isInitReload == NO) {
@@ -173,12 +174,6 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showNewUserRecharge) name:kNewUserRechargeKey object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showAnchorCardKey:) name:kTabShowAnchorCardKey object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(switchLanguage:) name:@"kSwitchLanguage" object:nil];
}
-(void)switchLanguage:(NSNotification *)not{
[self initTabs:YES];
@@ -723,54 +718,84 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
- (void)configTheme {
self.view.backgroundColor = [DJDKMIMOMColor tabbarViewColor];
[[UITabBar appearance] setBackgroundImage:[UIImage imageWithColor:[DJDKMIMOMColor tabbarViewColor] size:CGSizeMake(KScreenWidth, kTabBarHeight)]];
[[UITabBar appearance] setBackgroundImage:[UIImage imageWithColor:[DJDKMIMOMColor tabbarViewColor]
size:CGSizeMake(KScreenWidth, kTabBarHeight)]];
[[UITabBar appearance] setShadowImage:[[UIImage alloc]init]];
if (@available(iOS 10.0, *)) {
[[UITabBar appearance] setUnselectedItemTintColor:[DJDKMIMOMColor tabbarNormalColor]];
}
}
- (void)initTabs:(BOOL)logined {
- (void)initTabs:(BOOL)isLogin {
self.viewControllers = nil;
NSArray *normalImageNames = @[@"tab_gameHome_normal",@"tab_gameHome_game_normal",@"tab_monents_normal",@"tab_message_normal", @"tab_mine_normal"];
NSArray *selectImageNames = @[@"tab_gameHome_selected",@"tab_gameHome_game_selected",@"tab_monents_select",@"tab_message_selected", @"tab_mine_selected"];
NSArray *tabLabel = @[YMLocalizedString(@"TabbarViewController2"),YMLocalizedString(@"TabbarViewController6"),YMLocalizedString(@"TabbarViewController3"),YMLocalizedString(@"TabbarViewController4"), YMLocalizedString(@"TabbarViewController5")];
UIViewController *game;
UIViewController *msg;
UIViewController *me;
UIViewController * home;
UIViewController * monents;
///ipXPNewHomeViewController
[[NSNotificationCenter defaultCenter] postNotificationName:@"kInLoginVC" object:nil];
if (logined) {
game = [[MSTabbarRoomGameVC alloc]init];
msg = [[XPSessionMainViewController alloc] init];
home = [[XPNewHomeViewController alloc] init];
monents = [[XPMonentsViewController alloc] init];
me = [[XPMineViewController alloc] init];
} else {
game = [[XPBlankViewController alloc]init];
msg = [[XPSessionMainViewController alloc]init];
me = [[XPBlankViewController alloc]init];
home = [[XPBlankViewController alloc] init];
monents = [[XPBlankViewController alloc] init];
NSArray *normalImageNames = @[@"tab_gameHome_normal",
@"tab_gameHome_game_normal",
@"tab_monents_normal",
@"tab_message_normal",
@"tab_mine_normal"];
NSArray *selectImageNames = @[@"tab_gameHome_selected",
@"tab_gameHome_game_selected",
@"tab_monents_select",
@"tab_message_selected",
@"tab_mine_selected"];
NSArray *tabLabels = @[YMLocalizedString(@"TabbarViewController2"),
YMLocalizedString(@"TabbarViewController6"),
YMLocalizedString(@"TabbarViewController3"),
YMLocalizedString(@"TabbarViewController4"),
YMLocalizedString(@"TabbarViewController5")];
//
NSMutableArray *viewControllers = [NSMutableArray arrayWithCapacity:normalImageNames.count];
for (NSInteger i = 0; i < normalImageNames.count; i++) {
UIViewController *viewController;
if (isLogin) {
switch (i) {
case 0:
// viewController = [[XPNewHomeViewController alloc] init];
viewController = [[XPHomePagingViewController alloc] init];
break;
case 1:
viewController = [[MSTabbarRoomGameVC alloc] init];
break;
case 2:
viewController = [[XPMomentsViewController alloc] init];
break;
case 3:
viewController = [[XPSessionMainViewController alloc] init];
break;
case 4:
viewController = [[XPMineViewController alloc] init];
break;
default:
viewController = [[XPBlankViewController alloc] init]; //
break;
}
} else {
viewController = [[XPBlankViewController alloc] init];
}
//
[self createTabBarItem:viewController
title:tabLabels[i]
image:normalImageNames[i]
selectedImage:selectImageNames[i]];
[viewControllers addObject:viewController];
}
[self createTabBarItem:home title:tabLabel[0] image:normalImageNames[0] selectedImage:selectImageNames[0]];
[self createTabBarItem:game title:tabLabel[1] image:normalImageNames[1] selectedImage:selectImageNames[1]];
[self createTabBarItem:monents title:tabLabel[2] image:normalImageNames[2] selectedImage:selectImageNames[2]];
[self createTabBarItem:msg title:tabLabel[3] image:normalImageNames[3] selectedImage:selectImageNames[3]];
[self createTabBarItem:me title:tabLabel[4] image:normalImageNames[4] selectedImage:selectImageNames[4]];
self.viewControllers = @[home,game,monents,msg,me];
//
self.viewControllers = [viewControllers copy];
self.selectedIndex = 0;
}
- (BaseNavigationController *)createTabBarItem:(UIViewController *)itemVc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage{
- (BaseNavigationController *)createTabBarItem:(UIViewController *)itemVc
title:(NSString *)title
image:(NSString *)image
selectedImage:(NSString *)selectedImage {
itemVc.title = @"" ;
itemVc.tabBarItem.image = [[UIImage imageNamed:image] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
itemVc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[itemVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0x1F1B4F)} forState:UIControlStateSelected];
[itemVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0xB8B7C7)} forState:UIControlStateNormal];
[itemVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0x1F1B4F)}
forState:UIControlStateSelected];
[itemVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0xB8B7C7)}
forState:UIControlStateNormal];
BaseNavigationController *nav = [[BaseNavigationController alloc] initWithRootViewController:itemVc];
return nav;
}