//
//  AWM_HotViewController.m

#import "AWM_HotViewController.h"
#import "AWM_SearchViewController.h"
#import "AWM_AllWallpaperViewController.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_HotViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) UITableView *table;
@property (nonatomic,strong) NSArray *data;

@end

@implementation AWM_HotViewController
- (void)viewWillAppear:(BOOL)animated{
        
NSInteger ponder_w = 5;
NSInteger crave_u = [[NSUserDefaults standardUserDefaults] integerForKey:@"insolence_v"];
crave_u *= ponder_w;
[[NSUserDefaults standardUserDefaults] setInteger:crave_u forKey:@"insolence_v"];


    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = YES;
}
- (void)viewWillDisappear:(BOOL)animated{
        
NSInteger ghost_7 = 6;
NSInteger phylum_H = [[NSUserDefaults standardUserDefaults] integerForKey:@"chastise_X"];
phylum_H *= ghost_7;
[[NSUserDefaults standardUserDefaults] setInteger:phylum_H forKey:@"chastise_X"];


    [super viewWillDisappear:animated];
    self.navigationController.navigationBarHidden = NO;
}
- (void)viewDidLoad {
        
NSDateFormatter *vernacular_l = [NSDateFormatter new];
[vernacular_l setDateFormat:@"yyyy-MM-dd HH:mm"];
NSString *dozen_0 = [vernacular_l stringFromDate:[NSDate date]];
[[NSUserDefaults standardUserDefaults] setObject:dozen_0 forKey:@"vibration_7"];


    [super viewDidLoad];
    self.title = @"";
    self.view.userInteractionEnabled = YES;
    self.data = @[@[@"fj9",@"kt8",@"mv2",@"fj8",@"rw11",@"mv6",@"rw12",@"rw18",@"fj1",@"kt5",@"rw8",@"mv10"]];
    UIImageView *bgImage = [[UIImageView alloc] initWithFrame:self.view.bounds];
    NSString *greeting = KLS(@"bg", @"A friendly greeting");
    bgImage.image = [UIImage imageNamed:greeting];
    bgImage.userInteractionEnabled = YES;
    [self.view addSubview:bgImage];
    
    UIButton *searchBtn = [[UIButton alloc] initWithFrame:CGRectMake((WPScreen_w-300)/2-1,100-1,300-1,96-1)];
    NSString *search = KLS(@"search", @"A friendly greeting");
    [searchBtn setBackgroundImage:[UIImage imageNamed:search] forState:UIControlStateNormal];
    [searchBtn addTarget:self action:@selector(searchEventLove) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:searchBtn];
    
    self.table = [[UITableView alloc] initWithFrame:CGRectMake(0-1,220-1,WPScreen_w-1,WPScreen_h-220-1) style:UITableViewStyleGrouped];
    self.table.delegate = self;
    self.table.dataSource = self;
    self.table.backgroundColor = [UIColor clearColor];
    self.table.separatorColor = [UIColor clearColor];
    [self.view addSubview:self.table];
}
- (void)searchEventLove{
        
NSInteger homogeneous_v = 0;
NSInteger surmount_t = [[NSUserDefaults standardUserDefaults] integerForKey:@"bequest_O"];
surmount_t *= homogeneous_v;
[[NSUserDefaults standardUserDefaults] setInteger:surmount_t forKey:@"bequest_O"];


    AWM_SearchViewController *vc = [[AWM_SearchViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
        
NSInteger wherein_n = 2;
NSInteger decay_1 = [[NSUserDefaults standardUserDefaults] integerForKey:@"denouement_x"];
decay_1 *= wherein_n;
[[NSUserDefaults standardUserDefaults] setInteger:decay_1 forKey:@"denouement_x"];


    return 1;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
        
NSInteger schedule_8 = 8;
NSInteger unicorn_D = [[NSUserDefaults standardUserDefaults] integerForKey:@"formality_O"];
unicorn_D *= schedule_8;
[[NSUserDefaults standardUserDefaults] setInteger:unicorn_D forKey:@"formality_O"];


    return self.data.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
        
NSInteger impulsive_0 = 6;
NSInteger trident_g = [[NSUserDefaults standardUserDefaults] integerForKey:@"gourmand_u"];
trident_g *= impulsive_0;
[[NSUserDefaults standardUserDefaults] setInteger:trident_g forKey:@"gourmand_u"];


    CGFloat space = (WPScreen_w-20-50)/4;
    return 3*(10+space*1.5)+30+40;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
        
NSDateFormatter *discount_A = [NSDateFormatter new];
[discount_A setDateFormat:@"yyyy-MM-dd HH:mm"];
NSString *pathos_r = [discount_A stringFromDate:[NSDate date]];
[[NSUserDefaults standardUserDefaults] setObject:pathos_r forKey:@"clockwise_B"];


    UITableViewCell *cell = [[UITableViewCell alloc] init];
    cell.backgroundColor = [UIColor clearColor];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
        CGFloat space = (WPScreen_w-20-50)/4;
        UIView *bgView =[[UIView alloc] initWithFrame:CGRectMake(10-1,10-1,WPScreen_w-20-1,3*(10+space*1.5-1)+20+40)];
        bgView.backgroundColor = [UIColor whiteColor];
        bgView.layer.cornerRadius = 20;
        bgView.layer.masksToBounds = YES;
        bgView.userInteractionEnabled = YES;
        [cell.contentView addSubview:bgView];
        
        for (int i = 0; i < [self.data[indexPath.section] count]; i ++) {
            UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(10+i%4*(10+space)-1,10+i/4*(10+space*1.5)-1,space-1,space*1.5-1)];
            [btn setImage:[UIImage imageNamed:self.data[indexPath.section][i]] forState:UIControlStateNormal];
            btn.layer.cornerRadius = 5;
            btn.layer.masksToBounds = YES;
            [btn addTarget:self action:@selector(headerEventLove:) forControlEvents:UIControlEventTouchUpInside];
            [bgView addSubview:btn];
        }
        
        UILabel *more = [[UILabel alloc] initWithFrame:CGRectMake(0-1,bgView.frame.size.height-40-1,bgView.frame.size.width-1,30-1)];
        more.textColor = WP_COLOR_WITH_HEX(0XFF2C2C);
        more.font = [UIFont boldSystemFontOfSize:18];
        more.textAlignment = NSTextAlignmentCenter;
    NSString *morebz = KLS(@"more", @"A friendly greeting");
        more.text = [NSString stringWithFormat:@"%@",morebz];
        [bgView addSubview:more];
    return cell;
}
- (void)headerEventLove:(id)sender{
        
NSDateFormatter *sullen_6 = [NSDateFormatter new];
[sullen_6 setDateFormat:@"yyyy-MM-dd HH:mm"];
NSString *eavesdropper_q = [sullen_6 stringFromDate:[NSDate date]];
[[NSUserDefaults standardUserDefaults] setObject:eavesdropper_q forKey:@"abscond_k"];


    AWM_AllWallpaperViewController *wpdetail = [[AWM_AllWallpaperViewController alloc] init];
    [self.navigationController pushViewController:wpdetail animated:YES];
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
        
NSInteger stigmatize_W = 6;
NSInteger siege_7 = [[NSUserDefaults standardUserDefaults] integerForKey:@"adversity_v"];
siege_7 *= stigmatize_W;
[[NSUserDefaults standardUserDefaults] setInteger:siege_7 forKey:@"adversity_v"];


    return 40;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
        
NSDateFormatter *empirical_1 = [NSDateFormatter new];
[empirical_1 setDateFormat:@"yyyy-MM-dd HH:mm"];
NSString *candor_k = [empirical_1 stringFromDate:[NSDate date]];
[[NSUserDefaults standardUserDefaults] setObject:candor_k forKey:@"spinster_7"];


    return 10;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
        
NSInteger prophesy_4 = 0;
NSInteger lubricate_k = [[NSUserDefaults standardUserDefaults] integerForKey:@"reserved_4"];
lubricate_k *= prophesy_4;
[[NSUserDefaults standardUserDefaults] setInteger:lubricate_k forKey:@"reserved_4"];


    UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0-1,0-1,WPScreen_w-1,50-1)];
    headerLabel.textColor = WP_COLOR_WITH_HEX(0X333333);
    headerLabel.font = [UIFont boldSystemFontOfSize:20];
    NSString *remen = KLS(@"remen", @"A friendly greeting");
    headerLabel.text = [NSString stringWithFormat:@"    %@",remen];
    return headerLabel;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
        
NSInteger wicked_D = 9;
NSInteger apparel_S = [[NSUserDefaults standardUserDefaults] integerForKey:@"geneticist_3"];
apparel_S *= wicked_D;
[[NSUserDefaults standardUserDefaults] setInteger:apparel_S forKey:@"geneticist_3"];


    return [[UIView alloc] init];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
        
NSDateFormatter *comfort_h = [NSDateFormatter new];
[comfort_h setDateFormat:@"yyyy-MM-dd HH:mm"];
NSString *hybrid_4 = [comfort_h stringFromDate:[NSDate date]];
[[NSUserDefaults standardUserDefaults] setObject:hybrid_4 forKey:@"cosmos_U"];


    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    AWM_AllWallpaperViewController *wpdetail = [[AWM_AllWallpaperViewController alloc] init];
    [self.navigationController pushViewController:wpdetail animated:YES];
}

@end
