From c7872db0ba39fa0b42a3e94b2ebdcb1237000e1f Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Sun, 9 Oct 2016 18:37:48 +0200 Subject: [PATCH] Add support for removing a site --- iOS/Base.lproj/Main.storyboard | 9 ++++++++- iOS/ShowDetailsController.h | 2 ++ iOS/ShowDetailsController.m | 25 +++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/iOS/Base.lproj/Main.storyboard b/iOS/Base.lproj/Main.storyboard index 43e8fc2..7178501 100644 --- a/iOS/Base.lproj/Main.storyboard +++ b/iOS/Base.lproj/Main.storyboard @@ -402,7 +402,14 @@ - + + + + + + + + diff --git a/iOS/ShowDetailsController.h b/iOS/ShowDetailsController.h index 797ef07..d38a925 100644 --- a/iOS/ShowDetailsController.h +++ b/iOS/ShowDetailsController.h @@ -37,4 +37,6 @@ @property (retain, nonatomic) IBOutlet UISwitch *legacySwitch; @property (retain, nonatomic) IBOutlet UITextField *passphraseField; @property (retain) MainViewController *mainViewController; + +- (IBAction)remove: (id)sender; @end diff --git a/iOS/ShowDetailsController.m b/iOS/ShowDetailsController.m index 37fad17..b9e103d 100644 --- a/iOS/ShowDetailsController.m +++ b/iOS/ShowDetailsController.m @@ -183,4 +183,29 @@ clearNSMutableString(NSMutableString *string) return password; } + +- (IBAction)remove: (id)sender +{ + UIAlertController *alert = [UIAlertController + alertControllerWithTitle: @"Remove Site?" + message: @"Do you want to remove this site?" + preferredStyle: UIAlertControllerStyleAlert]; + [alert addAction: + [UIAlertAction actionWithTitle: @"No" + style: UIAlertActionStyleCancel + handler: nil]]; + [alert addAction: + [UIAlertAction actionWithTitle: @"Yes" + style: UIAlertActionStyleDestructive + handler: ^ (UIAlertAction *action) { + [self.mainViewController.siteStorage removeSite: _name]; + [self.mainViewController.tableView reloadData]; + + [self.navigationController popViewControllerAnimated: YES]; + }]]; + + [self presentViewController: alert + animated: YES + completion: nil]; +} @end