Files
yinmeng-ios/xplan-ios/Main/Tabbar/TabbarViewController.m

118 lines
3.7 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// ViewController.m
// xplan-ios
//
// Created by zu on 2021/8/31.
//
#import <UIKit/UIKit.h>
///Third
#import <flutter_boost/FlutterBoost.h>
///Tool
#import "XPMacro.h"
#import "ThemeColor.h"
#import "UIImage+Utils.h"
///VC
#import "TabbarViewController.h"
#import "BaseViewController.h"
#import "LoginViewController.h"
///Present
#import "MainPresenter.h"
#import "MainProtocol.h"
@interface TabbarViewController () <BaseMvpProtocol, MainProtocol>
@property (nonatomic, strong) MainPresenter *presenter;
@end
@implementation TabbarViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self configTheme];
[self initTabs];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES];
[self.presenter autoLogin];
}
- (MainPresenter *)presenter {
if (_presenter == nil) {
_presenter = [[MainPresenter alloc] init];
[_presenter attatchView:self];
}
return _presenter;
}
/// 换取ticket后获取用户信息
- (void)autoLoginSuccess {
[self.presenter getUserInfo];
}
/// 获取用户信息后检查1、是否绑定手机号2、是否需要完善用户信息。
/// 当前服务端接口是有未完善信息的全局拦截的在BaseMvpPresenter里会触发1415去完善用户信息。
- (void)getUserInfoSuccess:(UserInfoModel *)userInfo {
if (!userInfo.isBindPhone) {
// 绑定手机号
return;
}
if (userInfo.nick == nil || userInfo.avatar == nil) {
[self completeUserInfo];
return;
}
self.selectedIndex = 0;
}
- (void)tokenInvalid {
LoginViewController *lvc = [[LoginViewController alloc] init];
[self.navigationController pushViewController:lvc animated:YES];
}
- (void)completeUserInfo {
}
- (void)configTheme {
[[UITabBar appearance] setBackgroundImage:[UIImage imageWithColor:[ThemeColor appCellBackgroundColor] size:CGSizeMake(KScreenWidth, kTabBarHeight)]];
[[UITabBar appearance] setShadowImage:[[UIImage alloc]init]];
if (@available(iOS 10.0, *)) {
[[UITabBar appearance] setUnselectedItemTintColor:[ThemeColor tabbarNormalColor]];
}
}
- (void)initTabs {
NSArray *normalImageNames = @[@"tab_game_normal", @"tab_mine_normal"];
NSArray *selectImageNames = @[@"tab_game_selected", @"tab_mine_selected"];
NSArray *tabLabel = @[@"赛事", @"我的"];
FBFlutterViewContainer *fvcGame = FBFlutterViewContainer.new;
#ifdef DEBUG
[fvcGame setName:@"debug" uniqueId:nil params:nil];
#else
[fvc setName:@"/" uniqueId:nil params:nil];
#endif
[self createTabBarItem:fvcGame title:tabLabel[0] image:normalImageNames[0] selectedImage:selectImageNames[0]];
[self addChildViewController:fvcGame];
BaseViewController *bvcMe = [[BaseViewController alloc] init];
[self createTabBarItem:bvcMe title:tabLabel[1] image:normalImageNames[1] selectedImage:selectImageNames[1]];
[self addChildViewController:bvcMe];
self.selectedIndex = 1;
}
- (void)createTabBarItem:(UIViewController *)itemVc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage{
itemVc.title = title;
itemVc.tabBarItem.image = [[UIImage imageNamed:image] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
itemVc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[itemVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[ThemeColor appMainColor]} forState:UIControlStateSelected];
[itemVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[ThemeColor tabbarNormalColor]} forState:UIControlStateNormal];
}
@end