//
//  SlideMenuViewController.m
//  AT188N_DEMO_1703
//
//  Created by 류은주 on 2017. 3. 3..
//  Copyright © 2017년 ATID. All rights reserved.
//

#import "SlideMenuViewController.h"

@interface SlideMenuViewController ()
@property (weak, nonatomic) IBOutlet UILabel *firmwarevesionLabel;
@property (weak, nonatomic) IBOutlet UILabel *devicenameLabel;
@property (weak, nonatomic) IBOutlet UILabel *deviceaddressLabel;
@property (weak, nonatomic) IBOutlet UITableView *sidemenuTable;

@end

@implementation SlideMenuViewController
{
    NSArray *menuItems;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
   /* NSString* connectfirmware = @"tg";
    NSRange connectRange = [appDelegate.mReader.firmwareVersion rangeOfString:connectfirmware];
    if(connectRange.location != NSNotFound){
        menuItems = @[@"Inventory", @"Stored Data", @"Read Memory", @"Lock Memory", @"Option", @"Regist Device"];
    }else {
        menuItems = @[@"Inventory", @"Stored Data", @"Read Memory", @"Option", @"Regist Device"];
    }*/
    
   /* if((appDelegate.mReader.firmwareType == FIRMWARE_MA) && (appDelegate.mReader.typeBC == FIRMWARE_MA)){
        menuItems = @[@"Inventory", @"Stored Data", @"Read Memory", @"Option", @"Regist Device"];
    }else {
        menuItems = @[@"Inventory", @"Stored Data", @"Read Memory", @"Lock Memory", @"Option", @"Regist Device"];
    }*/
  
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear: animated];
    if((appDelegate.mReader.firmwareType == FIRMWARE_MA) && (appDelegate.mReader.typeBC == FIRMWARE_MA)){
        menuItems = @[@"Inventory", @"Stored Data", @"Option", @"Regist Device"];
    }else {
        menuItems = @[@"Inventory", @"Stored Data", @"Read Memory", @"Lock Memory", @"Option", @"Regist Device"];
    }
    NSString *firmwarename = [appDelegate.mReader.firmwareVersion substringFromIndex:1];
    NSString *deviceversion = [appDelegate.mReader.deviceVersion substringFromIndex:1];

    self.firmwarevesionLabel.text = firmwarename;
    self.devicenameLabel.text = deviceversion;
    self.deviceaddressLabel.text = appDelegate.connectdeviceadd;
    [self.sidemenuTable reloadData];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
//    if ([[segue identifier] isEqualToString:@"Inventory"]) {
//        NSLog(@"Inventory");
//        SWRevealViewController *destinationController = [segue destinationViewController];
//    }
}
- (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.
}
*/

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return menuItems.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *CellIdentifier = [menuItems objectAtIndex:indexPath.row];
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    
    return cell;
}
@end
