86 lines
2.7 KiB
Mathematica
86 lines
2.7 KiB
Mathematica
![]() |
//
|
||
|
// ViewController.m
|
||
|
// xplan-ios
|
||
|
//
|
||
|
// Created by zu on 2021/8/31.
|
||
|
//
|
||
|
#import <UIKit/UIKit.h>
|
||
|
#import "TabbarViewController.h"
|
||
|
#import "BaseViewController.h"
|
||
|
#import "UIImage+Utils.h"
|
||
|
#import "LoginViewController.h"
|
||
|
#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.presenter autoLogin];
|
||
|
}
|
||
|
|
||
|
- (MainPresenter *)presenter {
|
||
|
if (_presenter == nil) {
|
||
|
_presenter = [[MainPresenter alloc] init];
|
||
|
[_presenter attatchView:self];
|
||
|
}
|
||
|
return _presenter;
|
||
|
}
|
||
|
|
||
|
- (void)tokenInvalid {
|
||
|
LoginViewController *lvc = [[LoginViewController alloc] init];
|
||
|
[self.navigationController pushViewController:lvc animated:YES];
|
||
|
}
|
||
|
|
||
|
- (void)completeUserInfo {
|
||
|
|
||
|
}
|
||
|
|
||
|
- (void)autoLoginSuccess {
|
||
|
|
||
|
}
|
||
|
|
||
|
- (void)configTheme {
|
||
|
[[UITabBar appearance] setBackgroundImage:[UIImage imageWithColor:ThemeTabbarBackgroundColor size:CGSizeMake(KScreenWidth, kTabBarHeight)]];
|
||
|
[[UITabBar appearance] setShadowImage:[[UIImage alloc]init]];
|
||
|
if (@available(iOS 10.0, *)) {
|
||
|
[[UITabBar appearance] setUnselectedItemTintColor:ThemeTabbarNormalColor];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- (void)initTabs {
|
||
|
NSArray *normalImageNames = @[@"tab_game_normal", @"tab_mine_normal"];
|
||
|
NSArray *selectImageNames = @[@"tab_game_selected", @"tab_mine_selected"];
|
||
|
NSArray *tabLabel = @[@"赛事", @"我的"];
|
||
|
|
||
|
BaseViewController *bvcGame = [[BaseViewController alloc] init];
|
||
|
[self createTabBarItem:bvcGame title:tabLabel[0] image:normalImageNames[0] selectedImage:selectImageNames[0]];
|
||
|
[self addChildViewController:bvcGame];
|
||
|
|
||
|
BaseViewController *bvcMe = [[BaseViewController alloc] init];
|
||
|
[self createTabBarItem:bvcMe title:tabLabel[1] image:normalImageNames[1] selectedImage:selectImageNames[1]];
|
||
|
[self addChildViewController:bvcMe];
|
||
|
}
|
||
|
|
||
|
- (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:ThemeTabbarSelectedColor} forState:UIControlStateSelected];
|
||
|
[itemVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:ThemeTabbarNormalColor} forState:UIControlStateNormal];
|
||
|
}
|
||
|
|
||
|
@end
|