//
//  AppDelegate.m
#import "AppDelegate.h"
#import "WPOnePageViewController.h"
#import "WPHotViewController.h"
#import "WPEditViewController.h"
#import "WPForMyViewController.h"

#import "WallPapaerADManager.h"
@interface AppDelegate ()

@end


@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[WallPapaerADManager shareInstance] configureAD];
    
    
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    
    [[WallPapaerADManager shareInstance] showFirstOpenAD:^(NSInteger actionType) {
        [self configureRootVC];
    } window:self.window];
    
    
    return YES;
}

- (void)configureRootVC {
    WPOnePageViewController *wpHome = [[WPOnePageViewController alloc] init];
    wpHome.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"" image:[[UIImage imageNamed:@"tab1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tab11"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
        UINavigationController *wpHomeNV = [[UINavigationController alloc] initWithRootViewController:wpHome];
    
    WPHotViewController *wpHot = [[WPHotViewController alloc] init];
    wpHot.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"" image:[[UIImage imageNamed:@"tab2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tab22"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
        UINavigationController *wpHotNV = [[UINavigationController alloc] initWithRootViewController:wpHot];
    
    WPEditViewController *wpEdit = [[WPEditViewController alloc] init];
    wpEdit.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"" image:[[UIImage imageNamed:@"tab3"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tab33"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
        UINavigationController *wpEditNV = [[UINavigationController alloc] initWithRootViewController:wpEdit];
    WPForMyViewController *wpMy = [[WPForMyViewController alloc] init];
    wpMy.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"" image:[[UIImage imageNamed:@"tab4"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tab44"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
        UINavigationController *wpMyNV = [[UINavigationController alloc] initWithRootViewController:wpMy];
        
        UITabBarController *tb = [[UITabBarController alloc] init];
        tb.tabBar.backgroundColor = WP_COLOR_WITH_HEX(0xFFFFFF);
        tb.tabBar.tintColor = [UIColor orangeColor];
    UITabBarAppearance *skappearance = [[UITabBarAppearance alloc] init];
    skappearance.backgroundColor = WP_COLOR_WITH_HEX(0x6B77F2);
    tb.tabBar.standardAppearance = skappearance;

        tb.viewControllers = @[wpHomeNV,wpHotNV,wpEditNV,wpMyNV];
        tb.selectedIndex = 0;
    self.window.rootViewController = tb;
    
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    [[WallPapaerADManager shareInstance] showOpenAD];
}


- (NSMutableArray *)saveImages{
    if (!_saveImages) {
        _saveImages = [[NSMutableArray alloc] init];
    }
    return _saveImages;
}

@end
