//
//  RulesRegisterTitleViewController.m
//  kneet
//
//  Created by Jason Lee on 3/19/15.
//  Copyright (c) 2015 ntels. All rights reserved.
//

#import "RulesRegisterTitleViewController.h"
#import "CustomTextField.h"
#import "RuleModel.h"
#import "ValidateUtil.h"
#import "RulesRegisterViewController.h"


@interface RulesRegisterTitleViewController () {
    NSInteger _rowCount;
}
@end


#pragma mark - Class Definition

@implementation RulesRegisterTitleViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    [self initUI];
    [self prepareViewDidLoad];
}


- (void)initUI {
    self.title = @"Write the Rule's name";

    _txtRuleName.keyboardType = UIKeyboardTypeDefault;
    _txtRuleName.returnKeyType = UIReturnKeyDone;
    
    _txtRuleName.text = _predefinedRule.ruleName;

    
}

- (void)prepareViewDidLoad {
    _rowCount = 5;
}

#pragma mark - Main Logic


#pragma mark - UITableView Delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _rowCount;
}



#pragma mark - UI Events

- (IBAction)btnNextTouched:(id)sender {

    if (![ValidateUtil validateTextfiled:_txtRuleName type:ValidateTypeNull title:@"규칙이름"]) {
        return;
    }

    _predefinedRule.ruleName = _txtRuleName.text;


    RulesRegisterViewController *vc = (RulesRegisterViewController *)[CommonUtil instantiateViewControllerWithIdentifier:@"RulesRegisterViewController" storyboardName:@"Rules"];
    vc.tmpPredRule = _predefinedRule;

    [self.navigationController pushViewController:vc animated:YES];
}

- (IBAction)btnCancelTouched:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}


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

@end
