Animate resizing the window when disclosing more info

This commit is contained in:
Zorg committed 2021-05-29 14:49:28 -07:00
1 parent 87ecba77d3
commit 91fc440d15
2 files changed
+53 -3

No files matched your search

+12 -1
View File
@@ -8,10 +8,13 @@
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="SUUpdatePermissionPrompt">
<connections>
<outlet property="anonymousInfoDisclosureButton" destination="JW6-0z-Ud3" id="8Ac-kJ-T5e"/>
<outlet property="cancelButton" destination="cFC-wV-H3j" id="L2P-Ux-4Vn"/>
<outlet property="checkButton" destination="sMh-ha-r7R" id="2O6-G4-etk"/>
<outlet property="infoChoiceView" destination="ov1-yV-Uol" id="A1X-Y9-Hnh"/>
<outlet property="moreInfoView" destination="39" id="127"/>
<outlet property="placeholderHeightLayoutConstraint" destination="yis-HR-OIe" id="odJ-KG-SRB"/>
<outlet property="placeholderView" destination="AGr-V0-0al" id="piB-Wg-PJx"/>
<outlet property="promptView" destination="Yrl-Dt-Qvb" id="2a4-nD-uDx"/>
<outlet property="responseView" destination="0CP-x7-YFK" id="fE5-5k-8Uf"/>
<outlet property="stackView" destination="qNw-uD-4Bg" id="DxM-SL-1Xl"/>
@@ -269,7 +272,7 @@ Gw
<constraint firstItem="ilj-QP-33p" firstAttribute="leading" secondItem="0CP-x7-YFK" secondAttribute="leading" id="d3g-7o-f52"/>
<constraint firstAttribute="trailing" secondItem="ilj-QP-33p" secondAttribute="trailing" id="jzr-jk-sQQ"/>
</constraints>
<point key="canvasLocation" x="-241" y="445"/>
<point key="canvasLocation" x="-291" y="554"/>
</customView>
<customView id="ov1-yV-Uol" userLabel="Anonymous Info View">
<rect key="frame" x="0.0" y="0.0" width="437" height="27"/>
@@ -337,6 +340,14 @@ Gw
</constraints>
<point key="canvasLocation" x="-113" y="145.5"/>
</customView>
<customView hidden="YES" translatesAutoresizingMaskIntoConstraints="NO" id="AGr-V0-0al" userLabel="Placeholder View">
<rect key="frame" x="0.0" y="0.0" width="437" height="205"/>
<constraints>
<constraint firstAttribute="width" constant="437" id="4p7-cJ-U8Z"/>
<constraint firstAttribute="height" constant="205" id="yis-HR-OIe"/>
</constraints>
<point key="canvasLocation" x="-643" y="495"/>
</customView>
</objects>
<resources>
<image name="NSApplicationIcon" width="32" height="32"/>
+41 -2
View File
@@ -29,11 +29,15 @@ static NSString *const SUUpdatePermissionPromptTouchBarIndentifier = @"" SPARKLE
@property (nonatomic) IBOutlet NSStackView *stackView;
@property (nonatomic) IBOutlet NSView *promptView;
@property (nonatomic) IBOutlet NSView *moreInfoView;
@property (nonatomic) IBOutlet NSView *placeholderView;
@property (nonatomic) IBOutlet NSView *responseView;
@property (nonatomic) IBOutlet NSView *infoChoiceView;
@property (nonatomic) IBOutlet NSButton *cancelButton;
@property (nonatomic) IBOutlet NSButton *checkButton;
@property (nonatomic) IBOutlet NSButton *anonymousInfoDisclosureButton;
@property (nonatomic) IBOutlet NSLayoutConstraint *placeholderHeightLayoutConstraint;
@property (nonatomic, readonly) void (^reply)(SUUpdatePermissionResponse *);
@@ -48,10 +52,13 @@ static NSString *const SUUpdatePermissionPromptTouchBarIndentifier = @"" SPARKLE
@synthesize stackView = _stackView;
@synthesize promptView = _promtView;
@synthesize moreInfoView = _moreInfoView;
@synthesize placeholderView = _placeholderView;
@synthesize responseView = _responseView;
@synthesize infoChoiceView = _infoChoiceView;
@synthesize cancelButton = _cancelButton;
@synthesize checkButton = _checkButton;
@synthesize anonymousInfoDisclosureButton = _anonymousInfoDisclosureButton;
@synthesize placeholderHeightLayoutConstraint = _placeholderHeightLayoutConstraint;
- (instancetype)initPromptWithHost:(SUHost *)theHost request:(SPUUpdatePermissionRequest *)request reply:(void (^)(SUUpdatePermissionResponse *))reply
{
@@ -82,6 +89,7 @@ static NSString *const SUUpdatePermissionPromptTouchBarIndentifier = @"" SPARKLE
[self.stackView addArrangedSubview:self.promptView];
[self.stackView addArrangedSubview:self.infoChoiceView];
[self.stackView addArrangedSubview:self.placeholderView];
[self.stackView addArrangedSubview:self.moreInfoView];
[self.stackView addArrangedSubview:self.responseView];
}
@@ -99,9 +107,40 @@ static NSString *const SUUpdatePermissionPromptTouchBarIndentifier = @"" SPARKLE
return [NSString stringWithFormat:SULocalizedString(@"Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu.", nil), [self.host name]];
}
- (IBAction)toggleMoreInfo:(id)__unused sender
- (IBAction)toggleMoreInfo:(id)sender
{
self.moreInfoView.hidden = !self.moreInfoView.hidden;
// Use a placeholder view to unhide/hide before putting the more info view in place
// This allows us to animate resizing the more info view in place more easily
static const CGFloat TOGGLE_INFO_ANIMATION_DURATION = 0.2;
BOOL disclosingInfo = (self.anonymousInfoDisclosureButton.state == NSControlStateValueOn);
if (disclosingInfo) {
self.placeholderHeightLayoutConstraint.constant = 0.0;
self.placeholderView.hidden = NO;
[NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) {
context.duration = TOGGLE_INFO_ANIMATION_DURATION;
self.placeholderHeightLayoutConstraint.animator.constant = self.moreInfoView.frame.size.height;
} completionHandler:^{
self.placeholderView.hidden = YES;
self.moreInfoView.hidden = NO;
}];
} else {
self.placeholderHeightLayoutConstraint.constant = self.moreInfoView.frame.size.height;
self.moreInfoView.hidden = YES;
self.placeholderView.hidden = NO;
[NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) {
context.duration = TOGGLE_INFO_ANIMATION_DURATION;
self.placeholderHeightLayoutConstraint.animator.constant = 0.0;
} completionHandler:^{
self.placeholderView.hidden = YES;
}];
}
}
- (IBAction)finishPrompt:(NSButton *)sender