mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 07:02:39 +00:00
Fixed layout constraint issues on filter bar display
This commit is contained in:
@@ -77,7 +77,7 @@
|
|||||||
<CommandLineArguments>
|
<CommandLineArguments>
|
||||||
<CommandLineArgument
|
<CommandLineArgument
|
||||||
argument = "-NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints YES"
|
argument = "-NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints YES"
|
||||||
isEnabled = "YES">
|
isEnabled = "NO">
|
||||||
</CommandLineArgument>
|
</CommandLineArgument>
|
||||||
</CommandLineArguments>
|
</CommandLineArguments>
|
||||||
<AdditionalOptions>
|
<AdditionalOptions>
|
||||||
|
|||||||
@@ -48,11 +48,11 @@
|
|||||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||||
<prototypeCellViews>
|
<prototypeCellViews>
|
||||||
<tableCellView identifier="StringCell" id="269">
|
<tableCellView identifier="StringCell" id="269">
|
||||||
<rect key="frame" x="1" y="1" width="105" height="17"/>
|
<rect key="frame" x="1" y="1" width="104.5" height="17"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="270">
|
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="270">
|
||||||
<rect key="frame" x="1" y="0.0" width="103" height="17"/>
|
<rect key="frame" x="1" y="0.0" width="102.5" height="17"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="271">
|
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="271">
|
||||||
<font key="font" metaFont="system"/>
|
<font key="font" metaFont="system"/>
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||||
<prototypeCellViews>
|
<prototypeCellViews>
|
||||||
<tableCellView identifier="ImageCell" id="297">
|
<tableCellView identifier="ImageCell" id="297">
|
||||||
<rect key="frame" x="109" y="1" width="144" height="17"/>
|
<rect key="frame" x="108.5" y="1" width="144" height="17"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<imageView translatesAutoresizingMaskIntoConstraints="NO" id="298">
|
<imageView translatesAutoresizingMaskIntoConstraints="NO" id="298">
|
||||||
@@ -136,11 +136,11 @@
|
|||||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||||
<prototypeCellViews>
|
<prototypeCellViews>
|
||||||
<tableCellView identifier="PasswordCell" id="428">
|
<tableCellView identifier="PasswordCell" id="428">
|
||||||
<rect key="frame" x="256" y="1" width="119" height="17"/>
|
<rect key="frame" x="255.5" y="1" width="118.5" height="17"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="429" customClass="NSSecureTextField">
|
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="429" customClass="NSSecureTextField">
|
||||||
<rect key="frame" x="1" y="0.0" width="117" height="17"/>
|
<rect key="frame" x="1" y="0.0" width="116.5" height="17"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="430">
|
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="430">
|
||||||
<font key="font" metaFont="system"/>
|
<font key="font" metaFont="system"/>
|
||||||
@@ -174,7 +174,7 @@
|
|||||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||||
<prototypeCellViews>
|
<prototypeCellViews>
|
||||||
<tableCellView id="421">
|
<tableCellView id="421">
|
||||||
<rect key="frame" x="378" y="1" width="113" height="17"/>
|
<rect key="frame" x="377" y="1" width="113" height="17"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="422">
|
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="422">
|
||||||
@@ -212,7 +212,7 @@
|
|||||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||||
<prototypeCellViews>
|
<prototypeCellViews>
|
||||||
<tableCellView id="616">
|
<tableCellView id="616">
|
||||||
<rect key="frame" x="494" y="1" width="198" height="17"/>
|
<rect key="frame" x="493" y="1" width="198" height="17"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="617">
|
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="617">
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
|
|||||||
@property (weak) IBOutlet NSTableView *entryTable;
|
@property (weak) IBOutlet NSTableView *entryTable;
|
||||||
@property (strong) IBOutlet NSLayoutConstraint *tableToTopConstraint;
|
@property (strong) IBOutlet NSLayoutConstraint *tableToTopConstraint;
|
||||||
@property (strong) NSLayoutConstraint *filterbarTopConstraint;
|
@property (strong) NSLayoutConstraint *filterbarTopConstraint;
|
||||||
|
@property (strong) NSArray *filterBarConstraints;
|
||||||
@property (weak) IBOutlet NSButton *filterDoneButton;
|
@property (weak) IBOutlet NSButton *filterDoneButton;
|
||||||
|
|
||||||
@property (weak) IBOutlet NSButton *filterTitleButton;
|
@property (weak) IBOutlet NSButton *filterTitleButton;
|
||||||
@@ -91,6 +92,7 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
|
|||||||
@property (nonatomic, strong) MPEntryTableDataSource *dataSource;
|
@property (nonatomic, strong) MPEntryTableDataSource *dataSource;
|
||||||
|
|
||||||
@property (assign, nonatomic) MPFilterModeType filterMode;
|
@property (assign, nonatomic) MPFilterModeType filterMode;
|
||||||
|
@property (assign, nonatomic) BOOL isDisplayingFilterbar;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@@ -105,6 +107,7 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
|
|||||||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
||||||
if(self) {
|
if(self) {
|
||||||
_filterMode = MPFilterTitles;
|
_filterMode = MPFilterTitles;
|
||||||
|
_isDisplayingFilterbar = NO;
|
||||||
_entryArrayController = [[NSArrayController alloc] init];
|
_entryArrayController = [[NSArrayController alloc] init];
|
||||||
_dataSource = [[MPEntryTableDataSource alloc] init];
|
_dataSource = [[MPEntryTableDataSource alloc] init];
|
||||||
_dataSource.viewController = self;
|
_dataSource.viewController = self;
|
||||||
@@ -312,7 +315,7 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
|
|||||||
If we reselect the group, or just another group
|
If we reselect the group, or just another group
|
||||||
we clear the filter and bind to the new selected group
|
we clear the filter and bind to the new selected group
|
||||||
*/
|
*/
|
||||||
if([self _showsFilterBar] && ![document.selectedItem isKindOfClass:[KPKEntry class]]) {
|
if(self.isDisplayingFilterbar && ![document.selectedItem isKindOfClass:[KPKEntry class]]) {
|
||||||
[self clearFilter:nil];
|
[self clearFilter:nil];
|
||||||
[self.entryArrayController bind:NSContentArrayBinding toObject:document.selectedGroup withKeyPath:@"entries" options:nil];
|
[self.entryArrayController bind:NSContentArrayBinding toObject:document.selectedGroup withKeyPath:@"entries" options:nil];
|
||||||
return;
|
return;
|
||||||
@@ -329,8 +332,7 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
|
|||||||
|
|
||||||
- (void)_didBecomFirstResponder:(NSNotification *)notification {
|
- (void)_didBecomFirstResponder:(NSNotification *)notification {
|
||||||
MPDocument *document = [[self windowController] document];
|
MPDocument *document = [[self windowController] document];
|
||||||
if(document.selectedEntry.parent == document.selectedGroup
|
if(document.selectedEntry.parent == document.selectedGroup || self.isDisplayingFilterbar) {
|
||||||
|| [self _showsFilterBar]) {
|
|
||||||
document.selectedItem = document.selectedEntry;
|
document.selectedItem = document.selectedEntry;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -412,13 +414,6 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
|
|||||||
|
|
||||||
- (void)_setupFilterBar {
|
- (void)_setupFilterBar {
|
||||||
if(!self.filterBar) {
|
if(!self.filterBar) {
|
||||||
/*
|
|
||||||
[[NSUserDefaultsController sharedUserDefaultsController] bind:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyEntrySearchFilterMode]
|
|
||||||
toObject:self
|
|
||||||
withKeyPath:@"filterMode"
|
|
||||||
options:nil];
|
|
||||||
*/
|
|
||||||
|
|
||||||
[[NSBundle mainBundle] loadNibNamed:@"FilterBar" owner:self topLevelObjects:nil];
|
[[NSBundle mainBundle] loadNibNamed:@"FilterBar" owner:self topLevelObjects:nil];
|
||||||
[self.filterURLButton setTag:MPFilterUrls];
|
[self.filterURLButton setTag:MPFilterUrls];
|
||||||
[self.filterUsernameButton setTag:MPFilterUsernames];
|
[self.filterUsernameButton setTag:MPFilterUsernames];
|
||||||
@@ -430,11 +425,9 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
|
|||||||
|
|
||||||
[self.filterSearchField setAction:@selector(updateFilterText:)];
|
[self.filterSearchField setAction:@selector(updateFilterText:)];
|
||||||
[[self.filterSearchField cell] setSendsSearchStringImmediately:NO];
|
[[self.filterSearchField cell] setSendsSearchStringImmediately:NO];
|
||||||
}
|
[self bind:NSStringFromSelector(@selector(filterMode)) toObject:[NSUserDefaultsController sharedUserDefaultsController] withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyEntrySearchFilterMode] options:nil];
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)_showsFilterBar {
|
}
|
||||||
return ( nil != [self.filterBar superview]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark UI Feedback
|
#pragma mark UI Feedback
|
||||||
@@ -452,52 +445,64 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
|
|||||||
[self.filterUsernameButton setState:[self _shouldFilterUsernames] ? NSOnState : NSOffState];
|
[self.filterUsernameButton setState:[self _shouldFilterUsernames] ? NSOnState : NSOffState];
|
||||||
[self.filterPasswordButton setState:[self _shouldFilterPasswords] ? NSOnState : NSOffState];
|
[self.filterPasswordButton setState:[self _shouldFilterPasswords] ? NSOnState : NSOffState];
|
||||||
|
|
||||||
if([self _showsFilterBar]) {
|
if(self.isDisplayingFilterbar) {
|
||||||
return; // nothing to to
|
return; // nothing to to
|
||||||
}
|
}
|
||||||
|
|
||||||
NSView *scrollView = [_entryTable enclosingScrollView];
|
NSView *scrollView = [_entryTable enclosingScrollView];
|
||||||
NSDictionary *views = NSDictionaryOfVariableBindings(scrollView, _filterBar);
|
NSDictionary *views = NSDictionaryOfVariableBindings(scrollView, _filterBar);
|
||||||
|
|
||||||
[[self view] addSubview:self.filterBar];
|
[[self view] addSubview:self.filterBar];
|
||||||
|
|
||||||
[[self view] addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_filterBar]|" options:0 metrics:nil views:views]];
|
self.isDisplayingFilterbar = YES;
|
||||||
[[self view] addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[_filterBar(==30)]-0-[scrollView]" options:0 metrics:nil views:views]];
|
|
||||||
[[self view] layoutSubtreeIfNeeded];
|
|
||||||
|
|
||||||
|
[[self view] addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_filterBar]|" options:0 metrics:nil views:views]];
|
||||||
|
[[self view] addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[_filterBar(==30)]" options:0 metrics:nil views:views]];
|
||||||
|
|
||||||
|
/* clear old constraints */
|
||||||
|
if(self.filterBarConstraints) {
|
||||||
|
[[self view] removeConstraints:self.filterBarConstraints];
|
||||||
|
}
|
||||||
|
self.filterBarConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(-31)-[_filterBar]-0-[scrollView]" options:0 metrics:nil views:views];
|
||||||
|
[[self view] addConstraints:self.filterBarConstraints];
|
||||||
|
[[self view] addConstraint:self.tableToTopConstraint];
|
||||||
|
[[self view] layoutSubtreeIfNeeded];
|
||||||
|
[[self view] removeConstraints:self.filterBarConstraints];
|
||||||
|
/* setup new ones */
|
||||||
|
self.filterBarConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[_filterBar]-0-[scrollView]" options:0 metrics:nil views:views];
|
||||||
[[self view] removeConstraint:self.tableToTopConstraint];
|
[[self view] removeConstraint:self.tableToTopConstraint];
|
||||||
self.filterbarTopConstraint = [NSLayoutConstraint constraintWithItem:self.filterBar
|
[[self view] addConstraints:self.filterBarConstraints];
|
||||||
attribute:NSLayoutAttributeTop
|
|
||||||
relatedBy:NSLayoutRelationEqual
|
|
||||||
toItem:[self view]
|
|
||||||
attribute:NSLayoutAttributeTop
|
|
||||||
multiplier:1
|
|
||||||
constant:0];
|
|
||||||
[[self view] addConstraint:self.filterbarTopConstraint];
|
|
||||||
[NSAnimationContext runAnimationGroup:^(NSAnimationContext* context) {
|
[NSAnimationContext runAnimationGroup:^(NSAnimationContext* context) {
|
||||||
context.duration = STATUS_BAR_ANIMATION_TIME;
|
context.duration = STATUS_BAR_ANIMATION_TIME;
|
||||||
context.allowsImplicitAnimation = YES;
|
context.allowsImplicitAnimation = YES;
|
||||||
[self.view layoutSubtreeIfNeeded];
|
[self.view layoutSubtreeIfNeeded];
|
||||||
} completionHandler:^{
|
} completionHandler:^{
|
||||||
|
[self.filterSearchField setEnabled:YES];
|
||||||
[[[self windowController] window] makeFirstResponder:self.filterSearchField];
|
[[[self windowController] window] makeFirstResponder:self.filterSearchField];
|
||||||
}];
|
}];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_hideFilterBarAnimated {
|
- (void)_hideFilterBarAnimated {
|
||||||
if(![self _showsFilterBar]) {
|
if(!self.isDisplayingFilterbar) {
|
||||||
return; // nothing to do;
|
return; // nothing to do;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[self view] removeConstraint:self.filterbarTopConstraint];
|
NSView *scrollView = [_entryTable enclosingScrollView];
|
||||||
[self.view addConstraint:self.tableToTopConstraint];
|
NSDictionary *views = NSDictionaryOfVariableBindings(scrollView, _filterBar);
|
||||||
|
|
||||||
|
[[self view] removeConstraints:self.filterBarConstraints];
|
||||||
|
self.filterBarConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(-31)-[_filterBar]-0-[scrollView]" options:0 metrics:nil views:views];
|
||||||
|
[[self view] addConstraints:self.filterBarConstraints];
|
||||||
|
[[self view] addConstraint:self.tableToTopConstraint];
|
||||||
|
|
||||||
[NSAnimationContext runAnimationGroup:^(NSAnimationContext* context) {
|
[NSAnimationContext runAnimationGroup:^(NSAnimationContext* context) {
|
||||||
context.duration = STATUS_BAR_ANIMATION_TIME;
|
context.duration = STATUS_BAR_ANIMATION_TIME;
|
||||||
context.allowsImplicitAnimation = YES;
|
context.allowsImplicitAnimation = YES;
|
||||||
[self.view layoutSubtreeIfNeeded];
|
[self.view layoutSubtreeIfNeeded];
|
||||||
} completionHandler:^{
|
} completionHandler:^{
|
||||||
[self.filterBar removeFromSuperview];
|
self.isDisplayingFilterbar = NO;
|
||||||
|
[self.filterSearchField setEnabled:NO];
|
||||||
}] ;
|
}] ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user