159 lines
5.5 KiB
Objective-C
159 lines
5.5 KiB
Objective-C
//
|
|
// EspagramMainTableViewController.m
|
|
// Espagram
|
|
//
|
|
// Created by Abel Fokkinga on 11/9/12.
|
|
// Copyright (c) 2012 Abel Fokkinga. All rights reserved.
|
|
//
|
|
|
|
#import "EspagramMainTableViewController.h"
|
|
#import "SpanishConjugator.h"
|
|
#import "EspagramTestViewController.h"
|
|
#import "EspagramLessonViewController.h"
|
|
|
|
@interface EspagramMainTableViewController ()
|
|
@property (nonatomic, strong) NSString *language, *displayTitle;
|
|
@property (nonatomic, strong) Tense * tense;
|
|
@end
|
|
|
|
@implementation EspagramMainTableViewController
|
|
|
|
@synthesize language = _language;
|
|
@synthesize tense = _tense;
|
|
@synthesize displayTitle = _displayTitle;
|
|
@synthesize aboutButton = _aboutButton;
|
|
|
|
- (id)initWithStyle:(UITableViewStyle)style
|
|
{
|
|
self = [super initWithStyle:style];
|
|
if (self) {
|
|
// Custom initialization
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)viewDidAppear:(BOOL)animated
|
|
{
|
|
[super viewDidAppear:animated];
|
|
|
|
[self.aboutButton setTitle:NSLocalizedString(@"About button", @"About button text")];
|
|
}
|
|
|
|
|
|
# pragma mark - Espagram setters and getters
|
|
|
|
- (id <Conjugator>) getLanguage {
|
|
if ( [@"Spanish" isEqualToString:_language] ) {
|
|
return [[SpanishConjugator alloc] init];
|
|
} else return nil;
|
|
}
|
|
|
|
- (Tense *) tense {
|
|
if ( _tense == nil ) _tense =[[Tense alloc] init];
|
|
return _tense;
|
|
}
|
|
|
|
- (void) testVerbsWithLanguage:(NSString *)language andTense:(NSString *)tense;
|
|
{
|
|
self.language = language;
|
|
self.tense = [[Tense alloc] init];
|
|
self.tense.tense = tense;
|
|
self.displayTitle = [self.tense getTenseInLanguage:@"Spanish"];
|
|
[self performSegueWithIdentifier:@"Show Lessons" sender:self];
|
|
}
|
|
|
|
|
|
|
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
|
|
|
if ( [segue.identifier isEqualToString:@"Show Lessons"]) {
|
|
[segue.destinationViewController setConjugator:[self getLanguage]];
|
|
[segue.destinationViewController setTense:self.tense];
|
|
|
|
}
|
|
}
|
|
|
|
#pragma mark - Table view data source
|
|
|
|
|
|
/*
|
|
// Override to support conditional editing of the table view.
|
|
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
// Return NO if you do not want the specified item to be editable.
|
|
return YES;
|
|
}
|
|
*/
|
|
|
|
/*
|
|
// Override to support editing the table view.
|
|
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
if (editingStyle == UITableViewCellEditingStyleDelete) {
|
|
// Delete the row from the data source
|
|
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
|
|
}
|
|
else if (editingStyle == UITableViewCellEditingStyleInsert) {
|
|
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
|
|
}
|
|
}
|
|
*/
|
|
|
|
/*
|
|
// Override to support rearranging the table view.
|
|
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
|
|
{
|
|
}
|
|
*/
|
|
|
|
/*
|
|
// Override to support conditional rearranging of the table view.
|
|
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
// Return NO if you do not want the item to be re-orderable.
|
|
return YES;
|
|
}
|
|
*/
|
|
|
|
|
|
#pragma mark - Table view delegate
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
NSString * selectedTense = [tableView cellForRowAtIndexPath:indexPath].textLabel.text;
|
|
NSLog(@"Selected tense: %@", selectedTense);
|
|
|
|
if ( [selectedTense isEqualToString:@"Presente de Indicativo"] ) {
|
|
[self testVerbsWithLanguage: @"Spanish" andTense:@"SIMPLE_PRESENT"];
|
|
} else if ( [selectedTense isEqualToString:@"Presente de Subjuntivo"] ) {
|
|
[self testVerbsWithLanguage: @"Spanish" andTense:@"PRESENT_SUBJUNCTIVE"];
|
|
} else if ( [selectedTense isEqualToString:@"Pretérito Indefinido"] ) {
|
|
[self testVerbsWithLanguage: @"Spanish" andTense:@"SIMPLE_PAST"];
|
|
} else if ( [selectedTense isEqualToString:@"Imperfecto"] ) {
|
|
[self testVerbsWithLanguage: @"Spanish" andTense:@"IMPERFECT"];
|
|
} else if ( [selectedTense isEqualToString:@"Imperfecto de Subjuntivo"] ) {
|
|
[self testVerbsWithLanguage: @"Spanish" andTense:@"IMPERFECT_SUBJUNCTIVE"];
|
|
} else if ( [selectedTense isEqualToString:@"Futuro"] ) {
|
|
[self testVerbsWithLanguage: @"Spanish" andTense:@"FUTURE"];
|
|
} else if ( [selectedTense isEqualToString:@"Pretérito Perfecto"] ) {
|
|
[self testVerbsWithLanguage: @"Spanish" andTense:@"PRESENT_PERFECT"];
|
|
} else if ( [selectedTense isEqualToString:@"Perfecto de Subjuntivo"] ) {
|
|
[self testVerbsWithLanguage: @"Spanish" andTense:@"PERFECT_SUBJUNCTIVE"];
|
|
} else if ( [selectedTense isEqualToString:@"Pluscuamperfecto"] ) {
|
|
[self testVerbsWithLanguage: @"Spanish" andTense:@"PAST_PERFECT"];
|
|
} else if ( [selectedTense isEqualToString:@"Pluscuamperfecto Subjuntivo"] ) {
|
|
[self testVerbsWithLanguage: @"Spanish" andTense:@"PAST_PERFECT_SUBJUNCTIVE"];
|
|
} else if ( [selectedTense isEqualToString:@"Futuro Perfecto"] ) {
|
|
[self testVerbsWithLanguage: @"Spanish" andTense:@"FUTURE_PERFECT"];
|
|
} else if ( [selectedTense isEqualToString:@"Condicional"] ) {
|
|
[self testVerbsWithLanguage: @"Spanish" andTense:@"CONDITIONAL"];
|
|
} else if ( [selectedTense isEqualToString:@"Condicional Perfecto"] ) {
|
|
[self testVerbsWithLanguage: @"Spanish" andTense:@"CONDITIONAL_PERFECT"];
|
|
} else if ( [selectedTense isEqualToString:@"Gerundio"] ) {
|
|
[self testVerbsWithLanguage: @"Spanish" andTense:@"GERUND"];
|
|
}
|
|
|
|
}
|
|
|
|
@end
|