Reverted changes for context bar view since the layout was broken

This commit is contained in:
Michael Starke
2020-12-30 22:27:13 +01:00
parent 53ae6dca84
commit 06413b26df
2 changed files with 72 additions and 25 deletions

View File

@@ -1,30 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17506" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17506"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17701"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="MPEntryViewController">
<connections>
<outlet property="entryTable" destination="55" id="111"/>
<outlet property="stackView" destination="HUE-DP-c7W" id="b3R-0D-n3B"/>
<outlet property="view" destination="HUE-DP-c7W" id="ufg-kX-8A8"/>
<outlet property="tableToTopConstraint" destination="683" id="844"/>
<outlet property="view" destination="336" id="395"/>
</connections>
</customObject>
<stackView distribution="fill" orientation="vertical" alignment="leading" spacing="0.0" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" id="HUE-DP-c7W">
<rect key="frame" x="0.0" y="0.0" width="695" height="164"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="336">
<rect key="frame" x="0.0" y="0.0" width="695" height="523"/>
<subviews>
<scrollView focusRingType="none" borderType="none" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="54">
<rect key="frame" x="0.0" y="0.0" width="695" height="164"/>
<rect key="frame" x="0.0" y="0.0" width="695" height="524"/>
<clipView key="contentView" id="4tt-2K-SPF">
<rect key="frame" x="0.0" y="0.0" width="695" height="164"/>
<rect key="frame" x="0.0" y="0.0" width="695" height="524"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" rowSizeStyle="automatic" headerView="676" viewBased="YES" id="55" customClass="MPTableView">
<rect key="frame" x="0.0" y="0.0" width="695" height="141"/>
<rect key="frame" x="0.0" y="0.0" width="695" height="501"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -240,16 +241,14 @@
</tableHeaderView>
</scrollView>
</subviews>
<visibilityPriorities>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
</customSpacing>
<point key="canvasLocation" x="-131" y="736"/>
</stackView>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<constraints>
<constraint firstItem="54" firstAttribute="leading" secondItem="336" secondAttribute="leading" id="346"/>
<constraint firstItem="54" firstAttribute="trailing" secondItem="336" secondAttribute="trailing" id="348"/>
<constraint firstItem="54" firstAttribute="top" secondItem="336" secondAttribute="top" constant="-1" id="683"/>
<constraint firstAttribute="bottom" secondItem="54" secondAttribute="bottom" id="vfw-Ff-Ip8"/>
</constraints>
<point key="canvasLocation" x="-28" y="434"/>
</customView>
</objects>
<resources>
<image name="NSActionTemplate" width="14" height="14"/>

View File

@@ -70,16 +70,21 @@ NSString *const _MPTableStringCellView = @"StringCell";
NSString *const _MPTableSecurCellView = @"PasswordCell";
@interface MPEntryViewController () {
BOOL _isDisplayingContextBar;
BOOL _didUnlock;
}
@property (strong) MPContextBarViewController *contextBarViewController;
@property (strong) NSArray *filteredEntries;
@property (strong) IBOutlet NSStackView *stackView;
@property (weak) IBOutlet NSTableView *entryTable;
@property (assign) MPDisplayMode displayMode;
/* Constraints */
@property (strong) IBOutlet NSLayoutConstraint *tableToTopConstraint;
@property (strong) NSLayoutConstraint *contextBarTopConstraint;
@property (nonatomic, strong) MPEntryTableDataSource *dataSource;
@end
@@ -93,6 +98,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if(self) {
_isDisplayingContextBar = NO;
_displayMode = MPDisplayModeEntries;
_entryArrayController = [[NSArrayController alloc] init];
_dataSource = [[MPEntryTableDataSource alloc] init];
@@ -537,14 +543,56 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
}
- (void)_showContextBar {
if(self.stackView.views.count == 1) {
[self.stackView insertArrangedSubview:self.contextBarViewController.view atIndex:0];
if(_isDisplayingContextBar) {
return;
}
self.contextBarViewController.view.hidden = NO;
_isDisplayingContextBar = YES;
if(!self.contextBarViewController.view.superview) {
[self.view addSubview:self.contextBarViewController.view];
NSView *contextBar = self.contextBarViewController.view;
NSView *scrollView = self.entryTable.enclosingScrollView;
NSDictionary *views = NSDictionaryOfVariableBindings(scrollView, contextBar);
/* Pin to the left */
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[contextBar]|" options:0 metrics:nil views:views]];
/* Pin height and to top of entry table */
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[contextBar(==30)]-0-[scrollView]" options:0 metrics:nil views:views]];
/* Create the top constraint for the filter bar where we can change the constant instead of removing/adding constraints all the time */
self.contextBarTopConstraint = [NSLayoutConstraint constraintWithItem:contextBar
attribute:NSLayoutAttributeTop
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeTop
multiplier:1
constant:-31];
}
/* Add the view for the first time */
[self.view removeConstraint:self.tableToTopConstraint];
[self.view addConstraint:self.contextBarTopConstraint];
[self.view layout];
self.contextBarTopConstraint.constant = 0;
[NSAnimationContext runAnimationGroup:^(NSAnimationContext* context) {
context.duration = STATUS_BAR_ANIMATION_TIME;
context.allowsImplicitAnimation = YES;
[self.view layoutSubtreeIfNeeded];
} completionHandler:nil];
}
- (void)_hideContextBar {
self.contextBarViewController.view.hidden = YES;
if(!_isDisplayingContextBar) {
return; // nothing to do;
}
self.contextBarTopConstraint.constant = -31;
[self.view addConstraint:self.tableToTopConstraint];
[NSAnimationContext runAnimationGroup:^(NSAnimationContext* context) {
context.duration = STATUS_BAR_ANIMATION_TIME;
context.allowsImplicitAnimation = YES;
[self.view layoutSubtreeIfNeeded];
} completionHandler:^{
self->_isDisplayingContextBar = NO;
}];
}
#pragma mark Validation