Use simple counter display instead of progress bar.
This commit is contained in:
parent
fa85da3f82
commit
b98b5635d5
2
Cartfile
2
Cartfile
|
@ -1,4 +1,4 @@
|
|||
github "sparkle-project/Sparkle" ~> 1.22
|
||||
github "mattt/TransformerKit" ~> 1.1.1
|
||||
github "MacPass/KeePassKit" "defc62b0cb01cf0aafdb7f50cac3cae15b09d289"
|
||||
github "MacPass/KeePassKit" "5a57e2e90e8b96e7aa76f573ed8d48e8d584dc4a"
|
||||
github "mstarke/HNHUi" ~> 4.0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
github "MacPass/KeePassKit" "defc62b0cb01cf0aafdb7f50cac3cae15b09d289"
|
||||
github "MacPass/KeePassKit" "5a57e2e90e8b96e7aa76f573ed8d48e8d584dc4a"
|
||||
github "mattt/TransformerKit" "1.1.1"
|
||||
github "mstarke/HNHUi" "4.0.2"
|
||||
github "robbiehanson/KissXML" "5.3.2"
|
||||
|
|
|
@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@interface MPTOTPViewController : NSViewController
|
||||
@property (strong) IBOutlet HNHUITextField *toptValueTextField;
|
||||
@property (strong) IBOutlet NSProgressIndicator *remainingTimeProgressIndicator;
|
||||
@property (strong) IBOutlet NSButton *remainingTimeButton;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -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 = @"";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="MPTOTPViewController">
|
||||
<connections>
|
||||
<outlet property="remainingTimeProgressIndicator" destination="lSU-Q9-tC6" id="DpE-6F-yKb"/>
|
||||
<outlet property="remainingTimeButton" destination="Hxg-bd-l1O" id="QJf-RB-7JY"/>
|
||||
<outlet property="toptValueTextField" destination="xBL-Jz-VQO" id="QwC-Um-82o"/>
|
||||
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
|
||||
</connections>
|
||||
|
@ -16,41 +16,56 @@
|
|||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView id="Hz6-mo-xeY">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="69"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<stackView distribution="fill" orientation="vertical" alignment="leading" horizontalStackHuggingPriority="250" verticalStackHuggingPriority="250" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Lz5-aM-o4b">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="69"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="43"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="249" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="r8F-6m-CG6">
|
||||
<rect key="frame" x="-2" y="55" width="484" height="14"/>
|
||||
<rect key="frame" x="-2" y="29" width="484" height="14"/>
|
||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="TOTP" id="mP4-nH-7TA">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="249" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xBL-Jz-VQO" customClass="HNHUITextField">
|
||||
<rect key="frame" x="0.0" y="26" width="480" height="21"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" selectable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" usesSingleLineMode="YES" id="Vuy-HC-UhI">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<progressIndicator wantsLayer="YES" maxValue="100" doubleValue="50" style="bar" translatesAutoresizingMaskIntoConstraints="NO" id="lSU-Q9-tC6">
|
||||
<rect key="frame" x="0.0" y="-1" width="480" height="20"/>
|
||||
</progressIndicator>
|
||||
<stackView distribution="fill" orientation="horizontal" alignment="firstBaseline" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="avD-My-tnu">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="21"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="249" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xBL-Jz-VQO" customClass="HNHUITextField">
|
||||
<rect key="frame" x="0.0" y="0.0" width="445" height="21"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" selectable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" usesSingleLineMode="YES" id="Vuy-HC-UhI">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Hxg-bd-l1O">
|
||||
<rect key="frame" x="453" y="1" width="27" height="17"/>
|
||||
<buttonCell key="cell" type="inline" title="30" bezelStyle="inline" alignment="center" enabled="NO" borderStyle="border" inset="2" id="roW-Uk-ff9">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="smallSystemBold"/>
|
||||
</buttonCell>
|
||||
</button>
|
||||
</subviews>
|
||||
<visibilityPriorities>
|
||||
<integer value="1000"/>
|
||||
<integer value="1000"/>
|
||||
</visibilityPriorities>
|
||||
<customSpacing>
|
||||
<real value="3.4028234663852886e+38"/>
|
||||
<real value="3.4028234663852886e+38"/>
|
||||
</customSpacing>
|
||||
</stackView>
|
||||
</subviews>
|
||||
<visibilityPriorities>
|
||||
<integer value="1000"/>
|
||||
<integer value="1000"/>
|
||||
<integer value="1000"/>
|
||||
</visibilityPriorities>
|
||||
<customSpacing>
|
||||
<real value="3.4028234663852886e+38"/>
|
||||
<real value="3.4028234663852886e+38"/>
|
||||
<real value="3.4028234663852886e+38"/>
|
||||
</customSpacing>
|
||||
</stackView>
|
||||
</subviews>
|
||||
|
|
Loading…
Reference in New Issue