Use simple counter display instead of progress bar.

This commit is contained in:
Michael Starke
2020-12-17 01:52:52 +01:00
parent fa85da3f82
commit b98b5635d5
5 changed files with 47 additions and 26 deletions

View File

@@ -12,13 +12,14 @@
@interface MPTOTPViewController ()
@property (strong) KPKTimeOTPGenerator *generator;
@end
@implementation MPTOTPViewController
- (void)viewDidLoad {
self.remainingTimeProgressIndicator.minValue = 0;
self.remainingTimeProgressIndicator.maxValue = 30;
self.remainingTimeButton.title = @"";
}
- (void)setRepresentedObject:(id)representedObject {
@@ -46,13 +47,18 @@
BOOL showTOTP = entry.hasTimeOTP;
self.view.hidden = !showTOTP;
if(showTOTP) {
self.remainingTimeProgressIndicator.indeterminate = YES;
self.toptValueTextField.stringValue = entry.timeOTP;
self.remainingTimeProgressIndicator.doubleValue = 0;
self.generator = [[KPKTimeOTPGenerator alloc] initWithEntry:entry];
self.generator.time = NSDate.date.timeIntervalSince1970;
self.toptValueTextField.stringValue = self.generator.string;
NSString *template = NSLocalizedString(@"TOTP_REMAINING_TIME_%ld_SECONDS", @"Time in seconds remaining for a valid TOTP string, format should be %ld");
template = @"%ld s";
self.remainingTimeButton.title = [NSString stringWithFormat:template, (NSUInteger)self.generator.remainingTime];
[self performSelector:@selector(_updateDisplay) withObject:nil afterDelay:0.5];
}
else {
self.remainingTimeProgressIndicator.indeterminate = NO;
self.remainingTimeButton.title = @"";
self.toptValueTextField.stringValue = @"";
}
}