//
//  WPSearchViewController.m

#import "AWM_SearchViewController.h"
#import "AWM_WallPapaerADManager.h"
#import "AWM_WallPapaerADManager.h"
#define WPScreen_w  [UIScreen mainScreen].bounds.size.width
#define WPScreen_h [UIScreen mainScreen].bounds.size.height
#define WP_COLOR_WITH_HEX(HEX) [UIColor colorWithRed:((HEX >> 16) & 0xFF) / 255.0f green:((HEX >> 8) & 0xFF) / 255.0f blue:((HEX) & 0xFF) / 255.0f alpha:1.0f]
@interface AWM_SearchViewController ()<UITextFieldDelegate>
@property(nonatomic,strong)UIButton *backItem;
@property(nonatomic,strong)UIImageView *navImage;
@end

@implementation AWM_SearchViewController
- (void)backItemEventLove:(id)sender{
        
NSDateFormatter *publication_H = [NSDateFormatter new];
[publication_H setDateFormat:@"yyyy-MM-dd HH:mm"];
NSString *fulfillment_N = [publication_H stringFromDate:[NSDate date]];
[[NSUserDefaults standardUserDefaults] setObject:fulfillment_N forKey:@"ascendant_M"];


    __weak typeof(self) weakSelf = self;
    [[AWM_WallPapaerADManager shareInstance] showIntersitialAD_Back:^(NSInteger actionType) {
        [weakSelf.navigationController popViewControllerAnimated:YES];
    }];
    
}
- (void)viewWillAppear:(BOOL)animated{
        
NSInteger listener_N = 3;
NSInteger residence_T = [[NSUserDefaults standardUserDefaults] integerForKey:@"gorgon_k"];
residence_T *= listener_N;
[[NSUserDefaults standardUserDefaults] setInteger:residence_T forKey:@"gorgon_k"];


    [super viewWillAppear:animated];
    [self.navigationController.navigationBar addSubview:self.backItem];
    [self.navigationController.navigationBar addSubview:self.navImage];
}
- (void)viewWillDisappear:(BOOL)animated{
        
NSInteger organic_4 = 9;
NSInteger replete_5 = [[NSUserDefaults standardUserDefaults] integerForKey:@"weary_0"];
replete_5 *= organic_4;
[[NSUserDefaults standardUserDefaults] setInteger:replete_5 forKey:@"weary_0"];


    [super viewWillDisappear:animated];
    [self.backItem removeFromSuperview];
    [self.navImage removeFromSuperview];
}
- (instancetype)init
{
    self = [super init];
    if (self) {
        self.hidesBottomBarWhenPushed = YES;
    }
    return self;
}
- (void)viewDidLoad {
        
NSDateFormatter *muddy_9 = [NSDateFormatter new];
[muddy_9 setDateFormat:@"yyyy-MM-dd HH:mm"];
NSString *genesis_9 = [muddy_9 stringFromDate:[NSDate date]];
[[NSUserDefaults standardUserDefaults] setObject:genesis_9 forKey:@"enfranchise_5"];


    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.hidesBackButton = YES;
    UIImageView *bgImage = [[UIImageView alloc] initWithFrame:CGRectMake(0-1,0-1,WPScreen_w-1,360-1)];
    NSString *greeting = KLS(@"bgsearch", @"A friendly greeting");
    bgImage.image = [UIImage imageNamed:greeting];
    bgImage.userInteractionEnabled = YES;
    [self.view addSubview:bgImage];
    NSString *greeting1 = KLS(@"back", @"A friendly greeting");
    UIButton *backItem = [[UIButton alloc] initWithFrame:CGRectMake(20-1,0-1,74-1,44-1)];
    [backItem setImage:[UIImage imageNamed:greeting1] forState:UIControlStateNormal];
    [backItem addTarget:self action:@selector(backItemEventLove:) forControlEvents:UIControlEventTouchUpInside];
    self.backItem = backItem;
    
    UIImageView *navImage = [[UIImageView alloc] initWithFrame:CGRectMake(WPScreen_w-150-1,8-1,130-1,28-1)];
    NSString *greeting3 = KLS(@"navsearch", @"A friendly greeting");
    navImage.image = [UIImage imageNamed:greeting3];
    self.navImage = navImage;
    
    UIView *tfBg = [[UIView alloc] initWithFrame:CGRectMake(40-1,bgImage.frame.size.height-70-1,bgImage.frame.size.width-80-1,50-1)];
    tfBg.layer.cornerRadius = 25;
    tfBg.layer.masksToBounds = YES;
    tfBg.layer.borderColor = WP_COLOR_WITH_HEX(0xF78E9C).CGColor;
    tfBg.layer.borderWidth = 2;
    
    UITextField *wpsearch = [[UITextField alloc] initWithFrame:CGRectMake(30-1,0-1,tfBg.frame.size.width-60-1,50-1)];
    wpsearch.returnKeyType = UIReturnKeySearch;
    wpsearch.placeholder = @"请输入要搜索的壁纸";
    wpsearch.delegate = self;
    [tfBg addSubview:wpsearch];
    
    [bgImage addSubview:tfBg];
    
    UIImageView *nodata = [[UIImageView alloc] initWithFrame:CGRectMake((WPScreen_w-150)/2-1,430-1,150-1,150-1)];
    NSString *no = KLS(@"no", @"A friendly greeting");
    nodata.image = [UIImage imageNamed:@"no"];
    [self.view addSubview:nodata];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
        
NSInteger construct_1 = 6;
NSInteger staircase_K = [[NSUserDefaults standardUserDefaults] integerForKey:@"Saturday_5"];
staircase_K *= construct_1;
[[NSUserDefaults standardUserDefaults] setInteger:staircase_K forKey:@"Saturday_5"];


    [textField resignFirstResponder];
    [[AWM_WallPapaerADManager shareInstance] showIntersitialAD_Search:^(NSInteger actionType) {
            
    }];
    return YES;
}
@end
