//
//  SettingViewController.m
//  RedAnt ERP Mobile
//
//  Created by Ray on 14-8-4.
//  Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
//

#import "SettingViewController.h"
#import "CacheViewController.h"
//#import "CacheSettingViewController.h"
@interface SettingViewController ()

@end

@implementation SettingViewController

- (IBAction)CloseClick:(id)sender {
    [self dismissViewControllerAnimated:true completion:nil];
    
    
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
-(void)initMenuItems
{
    self.settingMenuItems = [[NSMutableArray alloc] init];
    
    NSMutableDictionary* map = [[NSMutableDictionary alloc] init];
    
    [map setValue:@"Cache" forKey:@"title"];
    [map setValue:@"rect_market_news" forKey:@"img"];
    [self.settingMenuItems addObject:map.copy];
    
    [map setValue:@"Price" forKey:@"title"];
    [map setValue:@"rect_market_news" forKey:@"img"];
    [self.settingMenuItems addObject:map.copy];
    
    [map setValue:@"Notification" forKey:@"title"];
    [map setValue:@"rect_announcements" forKey:@"img"];
    [self.settingMenuItems addObject:map.copy];
    //  NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
    
//
//    [map setValue:@"Message" forKey:@"title"];
//    [map setValue:@"rect_search_history" forKey:@"img"];
//    [self.settingMenuItems addObject:map.copy];
//    
//    
//    [map setValue:@"About" forKey:@"title"];
//    [map setValue:@"rect_change_password" forKey:@"img"];
//    [self.settingMenuItems addObject:map.copy];
//    
    
    
    //
    
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    [self initMenuItems];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return self.settingMenuItems.count;
    
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    NSString *CellIdentifier = @"SettingCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    NSString* title = [self.settingMenuItems[indexPath.row] valueForKey:@"title"];
    cell.backgroundColor = [UIColor clearColor];
    //    [cell.backgroundColor:[UIColor clearColor]];
    //    UIImageView* iv= [[UIImageView alloc] initWithImage:];
    cell.textLabel.text = title;
    //   cell.imageView.image = [UIImage imageNamed:[self.toolsinfo[indexPath.row] valueForKey:@"img"]];
    
    return cell;
    
    
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString* title = [self.settingMenuItems[indexPath.row] valueForKey:@"title"];
    if([title isEqualToString:@"Cache"])
    {
        CacheViewController* tvc = [self.storyboard instantiateViewControllerWithIdentifier:@"CacheViewController" ];
        
        
         [self.navigationController pushViewController:tvc animated:true];
//        PopupNavigationController * navi=[ self.storyboard instantiateViewControllerWithIdentifier:@"PopupNavi"];
//        
//        
//        
//        navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态，自己看看是哪种
//        [self presentViewController:navi animated:YES completion:^{
//            
//            //DebugLog(@"login.........");
//            //  <#code#>
//        }];
//
//        
//        
        
    }
    else if([title isEqualToString:@"Price"])
    {
//        [self hideMenu];
//        if([self.current_VC isKindOfClass:[WatchListViewController class]])
//            return;
//        [self flipFromViewController:self.current_VC toViewController:self.watchListViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
    }
}

@end
