@@ -1,7 +1,7 @@ /* - * Copyright (c) 2016, Jonathan Schleifer + * Copyright (c) 2016, 2017, Jonathan Schleifer * * https://heap.zone/git/scrypt-pwgen.git * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -21,10 +21,11 @@ */ #import #import "AddSiteController.h" +#import "SelectKeyFileController.h" static void showAlert(UIViewController *controller, NSString *title, NSString *message) { UIAlertController *alert = [UIAlertController @@ -45,10 +46,11 @@ - (void)dealloc { [_nameField release]; [_lengthField release]; [_legacySwitch release]; + [_keyFile release]; [_keyFileLabel release]; [_mainViewController release]; [super dealloc]; } @@ -58,11 +60,12 @@ { [tableView deselectRowAtIndexPath: indexPath animated: YES]; if (indexPath.section == 1 && indexPath.row == 1) - [self selectKeyFile]; + [self performSegueWithIdentifier: @"selectKeyFile" + sender: self]; } - (NSIndexPath *)tableView: (UITableView *)tableView willSelectRowAtIndexPath: (NSIndexPath *)indexPath { @@ -70,15 +73,10 @@ return indexPath; return nil; } -- (void)selectKeyFile -{ - showAlert(self, @"Not Supported", @"Key files are not supported yet"); -} - - (IBAction)done: (id)sender { OFString *name = self.nameField.text.OFObject; OFString *lengthString = self.lengthField.text.OFObject; bool lengthValid = true; @@ -111,16 +109,23 @@ } [self.mainViewController.siteStorage setSite: name length: length legacy: self.legacySwitch.on - keyFile: nil]; + keyFile: self.keyFile.OFObject]; [self.mainViewController reset]; [self.navigationController popViewControllerAnimated: YES]; } - (IBAction)cancel: (id)sender { [self.navigationController popViewControllerAnimated: YES]; } + +- (void)prepareForSegue: (UIStoryboardSegue *)segue + sender: (id)sender +{ + if ([segue.identifier isEqual: @"selectKeyFile"]) + [segue.destinationViewController setAddSiteController: self]; +} @end