2021-09-07 23:05:43 +08:00
|
|
|
|
//
|
|
|
|
|
// ViewController.m
|
|
|
|
|
// xplan-ios
|
|
|
|
|
//
|
|
|
|
|
// Created by zu on 2021/8/31.
|
|
|
|
|
//
|
|
|
|
|
#import <UIKit/UIKit.h>
|
2021-09-13 14:22:51 +08:00
|
|
|
|
///Third
|
|
|
|
|
#import <flutter_boost/FlutterBoost.h>
|
|
|
|
|
///Tool
|
|
|
|
|
#import "XPMacro.h"
|
|
|
|
|
#import "ThemeColor.h"
|
|
|
|
|
#import "UIImage+Utils.h"
|
|
|
|
|
///VC
|
2021-09-07 23:05:43 +08:00
|
|
|
|
#import "TabbarViewController.h"
|
|
|
|
|
#import "BaseViewController.h"
|
|
|
|
|
#import "LoginViewController.h"
|
2021-09-14 21:01:09 +08:00
|
|
|
|
#import "BaseNavigationController.h"
|
|
|
|
|
#import "LoginBindPhoneViewController.h"
|
|
|
|
|
#import "LoginFullInfoViewController.h"
|
2021-09-13 14:22:51 +08:00
|
|
|
|
///Present
|
2021-09-07 23:05:43 +08:00
|
|
|
|
#import "MainPresenter.h"
|
|
|
|
|
#import "MainProtocol.h"
|
2021-09-13 14:22:51 +08:00
|
|
|
|
|
|
|
|
|
|
2021-09-07 23:05:43 +08:00
|
|
|
|
|
|
|
|
|
@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];
|
2021-09-14 17:20:05 +08:00
|
|
|
|
[self.navigationController setNavigationBarHidden:YES animated:YES];
|
2021-09-07 23:05:43 +08:00
|
|
|
|
[self.presenter autoLogin];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (MainPresenter *)presenter {
|
|
|
|
|
if (_presenter == nil) {
|
|
|
|
|
_presenter = [[MainPresenter alloc] init];
|
|
|
|
|
[_presenter attatchView:self];
|
|
|
|
|
}
|
|
|
|
|
return _presenter;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-14 16:57:13 +08:00
|
|
|
|
/// 换取ticket后获取用户信息
|
|
|
|
|
- (void)autoLoginSuccess {
|
|
|
|
|
[self.presenter getUserInfo];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 获取用户信息后检查:1、是否绑定手机号;2、是否需要完善用户信息。
|
|
|
|
|
/// 当前服务端接口是有未完善信息的全局拦截的,在BaseMvpPresenter里会触发1415去完善用户信息。
|
|
|
|
|
- (void)getUserInfoSuccess:(UserInfoModel *)userInfo {
|
|
|
|
|
if (!userInfo.isBindPhone) {
|
|
|
|
|
// 绑定手机号
|
2021-09-14 21:01:09 +08:00
|
|
|
|
[self bindPhone];
|
2021-09-14 16:57:13 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
2021-09-14 21:01:09 +08:00
|
|
|
|
userInfo.nick = nil;
|
|
|
|
|
userInfo.avatar = nil;
|
2021-09-14 16:57:13 +08:00
|
|
|
|
if (userInfo.nick == nil || userInfo.avatar == nil) {
|
|
|
|
|
[self completeUserInfo];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
self.selectedIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-07 23:05:43 +08:00
|
|
|
|
- (void)tokenInvalid {
|
|
|
|
|
LoginViewController *lvc = [[LoginViewController alloc] init];
|
|
|
|
|
[self.navigationController pushViewController:lvc animated:YES];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)completeUserInfo {
|
2021-09-14 21:01:09 +08:00
|
|
|
|
LoginFullInfoViewController * bindPhoneVC = [[LoginFullInfoViewController alloc] init];
|
|
|
|
|
BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:bindPhoneVC];
|
|
|
|
|
nav.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
|
|
|
[self.navigationController presentViewController:nav animated:YES completion:nil];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - 绑定手机号
|
|
|
|
|
- (void)bindPhone {
|
|
|
|
|
LoginBindPhoneViewController * bindPhoneVC = [[LoginBindPhoneViewController alloc] init];
|
|
|
|
|
BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:bindPhoneVC];
|
|
|
|
|
nav.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
|
|
|
[self.navigationController presentViewController:nav animated:YES completion:nil];
|
2021-09-07 23:05:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)configTheme {
|
2021-09-13 14:22:51 +08:00
|
|
|
|
[[UITabBar appearance] setBackgroundImage:[UIImage imageWithColor:[ThemeColor appCellBackgroundColor] size:CGSizeMake(KScreenWidth, kTabBarHeight)]];
|
2021-09-07 23:05:43 +08:00
|
|
|
|
[[UITabBar appearance] setShadowImage:[[UIImage alloc]init]];
|
|
|
|
|
if (@available(iOS 10.0, *)) {
|
2021-09-13 14:22:51 +08:00
|
|
|
|
[[UITabBar appearance] setUnselectedItemTintColor:[ThemeColor tabbarNormalColor]];
|
2021-09-07 23:05:43 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)initTabs {
|
|
|
|
|
NSArray *normalImageNames = @[@"tab_game_normal", @"tab_mine_normal"];
|
|
|
|
|
NSArray *selectImageNames = @[@"tab_game_selected", @"tab_mine_selected"];
|
|
|
|
|
NSArray *tabLabel = @[@"赛事", @"我的"];
|
|
|
|
|
|
2021-09-08 20:28:37 +08:00
|
|
|
|
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];
|
2021-09-07 23:05:43 +08:00
|
|
|
|
|
|
|
|
|
BaseViewController *bvcMe = [[BaseViewController alloc] init];
|
|
|
|
|
[self createTabBarItem:bvcMe title:tabLabel[1] image:normalImageNames[1] selectedImage:selectImageNames[1]];
|
|
|
|
|
[self addChildViewController:bvcMe];
|
2021-09-08 20:28:37 +08:00
|
|
|
|
|
|
|
|
|
self.selectedIndex = 1;
|
2021-09-07 23:05:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (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];
|
2021-09-13 14:22:51 +08:00
|
|
|
|
[itemVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[ThemeColor appMainColor]} forState:UIControlStateSelected];
|
|
|
|
|
[itemVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[ThemeColor tabbarNormalColor]} forState:UIControlStateNormal];
|
2021-09-07 23:05:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|