From 1b04e5cfa276e0641a90e81a08a88ea07d246f55 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Wed, 10 Feb 2021 14:17:39 +0100 Subject: [PATCH] Disable and enable the UI according to type settings --- MacPass/MPTOTPSetupViewController.m | 24 +++++++++++++++++++++++- MacPass/MPTOTPSetupViewController.xib | 25 +++++++++++++++++-------- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/MacPass/MPTOTPSetupViewController.m b/MacPass/MPTOTPSetupViewController.m index ea2a17e9..e863ec8c 100644 --- a/MacPass/MPTOTPSetupViewController.m +++ b/MacPass/MPTOTPSetupViewController.m @@ -33,7 +33,6 @@ typedef NS_ENUM(NSUInteger, MPOTPUpdateSource) { MPOTPUpdateSourceTimeSlice, MPOTPUpdateSourceType, MPOTPUpdateSourceEntry - }; typedef NS_ENUM(NSUInteger, MPOTPType) { @@ -63,6 +62,19 @@ typedef NS_ENUM(NSUInteger, MPOTPType) { if(sender != self.typePopUpButton) { return; // wrong sender } + MPOTPType type = self.typePopUpButton.selectedItem.tag; + switch(type) { + case MPOTPTypeRFC: + case MPOTPTypeSteam: + self.algorithmPopUpButton.enabled = NO; + self.digitCountPopUpButton.enabled = NO; + self.timeStepStepper.enabled = NO; + break; + case MPOTPTypeCustom: + self.algorithmPopUpButton.enabled = YES; + self.digitCountPopUpButton.enabled = YES; + self.timeStepStepper.enabled = YES; + } [self _updateView:MPOTPUpdateSourceType]; } @@ -73,6 +85,16 @@ typedef NS_ENUM(NSUInteger, MPOTPType) { [self _updateView:MPOTPUpdateSourceQRImage]; } +- (IBAction)cancel:(id)sender { + [self.presentingViewController dismissViewController:self]; +} + +- (IBAction)save:(id)sender { + // Update entry settings! + // adhere to change observation for history? + [self.presentingViewController dismissViewController:self]; +} + - (void)_setupView { /* algorithm */ NSMenuItem *sha1Item = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"HASH_SHA1", "SHA 1 hash algoritm menu item") action:NULL keyEquivalent:@""]; diff --git a/MacPass/MPTOTPSetupViewController.xib b/MacPass/MPTOTPSetupViewController.xib index f1a00f03..e8ea84f2 100644 --- a/MacPass/MPTOTPSetupViewController.xib +++ b/MacPass/MPTOTPSetupViewController.xib @@ -22,11 +22,11 @@ - - + + - + @@ -83,7 +83,7 @@ - + @@ -96,7 +96,7 @@ - + @@ -115,6 +115,9 @@ + + + @@ -210,14 +213,17 @@ @@ -238,7 +247,7 @@ Gw - +