From cac974a30e4ccabdc6a4681fb00671fc3caca1d6 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Thu, 8 Nov 2018 13:46:32 +0100 Subject: [PATCH] Removed gradient bar and changed text color in notes for full dark mode support --- .../Active Highlight.colorset/Contents.json | 38 --------------- .../Active Shadow.colorset/Contents.json | 38 --------------- MacPass/Assets.xcassets/Colors/Contents.json | 6 --- .../Inactive Highlight.colorset/Contents.json | 38 --------------- .../Inactive Shadow.colorset/Contents.json | 38 --------------- MacPass/Base.lproj/ContextBar.xib | 46 +++++++++---------- MacPass/Base.lproj/InspectorView.xib | 18 ++++---- MacPass/EntryView.xib | 20 ++++---- MacPass/MPContextBarViewController.h | 1 - MacPass/MPContextBarViewController.m | 21 --------- MacPass/MPEntryTableDataSource.m | 10 ++++ MacPass/MPEntryViewController.h | 2 + MacPass/MPOutlineViewController.h | 1 - MacPass/MPPickfieldTableModel.h | 8 ++-- MacPass/MPPickfieldTableModel.m | 33 +++++++++++-- MacPass/MPPickfieldViewController.m | 2 +- 16 files changed, 88 insertions(+), 232 deletions(-) delete mode 100644 MacPass/Assets.xcassets/Colors/Active Highlight.colorset/Contents.json delete mode 100644 MacPass/Assets.xcassets/Colors/Active Shadow.colorset/Contents.json delete mode 100644 MacPass/Assets.xcassets/Colors/Contents.json delete mode 100644 MacPass/Assets.xcassets/Colors/Inactive Highlight.colorset/Contents.json delete mode 100644 MacPass/Assets.xcassets/Colors/Inactive Shadow.colorset/Contents.json diff --git a/MacPass/Assets.xcassets/Colors/Active Highlight.colorset/Contents.json b/MacPass/Assets.xcassets/Colors/Active Highlight.colorset/Contents.json deleted file mode 100644 index 233c74ee..00000000 --- a/MacPass/Assets.xcassets/Colors/Active Highlight.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - }, - "colors" : [ - { - "idiom" : "universal", - "color" : { - "color-space" : "srgb", - "components" : { - "red" : "0.965", - "alpha" : "1.000", - "blue" : "0.965", - "green" : "0.965" - } - } - }, - { - "idiom" : "universal", - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "red" : "0.200", - "alpha" : "1.000", - "blue" : "0.200", - "green" : "0.200" - } - } - } - ] -} \ No newline at end of file diff --git a/MacPass/Assets.xcassets/Colors/Active Shadow.colorset/Contents.json b/MacPass/Assets.xcassets/Colors/Active Shadow.colorset/Contents.json deleted file mode 100644 index 233c74ee..00000000 --- a/MacPass/Assets.xcassets/Colors/Active Shadow.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - }, - "colors" : [ - { - "idiom" : "universal", - "color" : { - "color-space" : "srgb", - "components" : { - "red" : "0.965", - "alpha" : "1.000", - "blue" : "0.965", - "green" : "0.965" - } - } - }, - { - "idiom" : "universal", - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "red" : "0.200", - "alpha" : "1.000", - "blue" : "0.200", - "green" : "0.200" - } - } - } - ] -} \ No newline at end of file diff --git a/MacPass/Assets.xcassets/Colors/Contents.json b/MacPass/Assets.xcassets/Colors/Contents.json deleted file mode 100644 index da4a164c..00000000 --- a/MacPass/Assets.xcassets/Colors/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/MacPass/Assets.xcassets/Colors/Inactive Highlight.colorset/Contents.json b/MacPass/Assets.xcassets/Colors/Inactive Highlight.colorset/Contents.json deleted file mode 100644 index 233c74ee..00000000 --- a/MacPass/Assets.xcassets/Colors/Inactive Highlight.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - }, - "colors" : [ - { - "idiom" : "universal", - "color" : { - "color-space" : "srgb", - "components" : { - "red" : "0.965", - "alpha" : "1.000", - "blue" : "0.965", - "green" : "0.965" - } - } - }, - { - "idiom" : "universal", - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "red" : "0.200", - "alpha" : "1.000", - "blue" : "0.200", - "green" : "0.200" - } - } - } - ] -} \ No newline at end of file diff --git a/MacPass/Assets.xcassets/Colors/Inactive Shadow.colorset/Contents.json b/MacPass/Assets.xcassets/Colors/Inactive Shadow.colorset/Contents.json deleted file mode 100644 index 233c74ee..00000000 --- a/MacPass/Assets.xcassets/Colors/Inactive Shadow.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - }, - "colors" : [ - { - "idiom" : "universal", - "color" : { - "color-space" : "srgb", - "components" : { - "red" : "0.965", - "alpha" : "1.000", - "blue" : "0.965", - "green" : "0.965" - } - } - }, - { - "idiom" : "universal", - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "red" : "0.200", - "alpha" : "1.000", - "blue" : "0.200", - "green" : "0.200" - } - } - } - ] -} \ No newline at end of file diff --git a/MacPass/Base.lproj/ContextBar.xib b/MacPass/Base.lproj/ContextBar.xib index b3a76974..6eb965ae 100644 --- a/MacPass/Base.lproj/ContextBar.xib +++ b/MacPass/Base.lproj/ContextBar.xib @@ -11,14 +11,10 @@ - - - - @@ -35,22 +31,22 @@ - + - - - - + + + + - + - + @@ -219,11 +215,11 @@ - + - + - + diff --git a/MacPass/Base.lproj/InspectorView.xib b/MacPass/Base.lproj/InspectorView.xib index 242d5bae..64a82998 100644 --- a/MacPass/Base.lproj/InspectorView.xib +++ b/MacPass/Base.lproj/InspectorView.xib @@ -1,8 +1,8 @@ - + - + @@ -83,7 +83,7 @@ - + @@ -122,17 +122,18 @@ - + - + + - + @@ -159,13 +160,12 @@ - - - + @@ -241,7 +241,7 @@ - + diff --git a/MacPass/MPContextBarViewController.h b/MacPass/MPContextBarViewController.h index cddaee61..6cfd296b 100644 --- a/MacPass/MPContextBarViewController.h +++ b/MacPass/MPContextBarViewController.h @@ -23,7 +23,6 @@ #import "MPViewController.h" #import "MPDocument.h" -@class HNHUIGradientView; @class MPDocument; @interface MPContextBarViewController : MPViewController diff --git a/MacPass/MPContextBarViewController.m b/MacPass/MPContextBarViewController.m index 7e06349d..4ad356dd 100644 --- a/MacPass/MPContextBarViewController.m +++ b/MacPass/MPContextBarViewController.m @@ -47,15 +47,11 @@ typedef NS_ENUM(NSUInteger, MPContextTab) { @property (nonatomic, assign) MPContextTab activeTab; /* Filter */ -@property (weak) IBOutlet HNHUIGradientView *searchBar; @property (weak) IBOutlet NSButton *filterDoneButton; -@property (weak) IBOutlet NSTextField *filterLabelTextField; /* History */ -@property (weak) IBOutlet HNHUIGradientView *historyBar; @property (weak) IBOutlet NSTextField *historyLabel; @property (weak) IBOutlet NSButton *exitHistoryButton; /* Trash*/ -@property (weak) IBOutlet HNHUIGradientView *trashBar; @property (weak) IBOutlet NSButton *emptyTrashButton; @end @@ -76,23 +72,6 @@ typedef NS_ENUM(NSUInteger, MPContextTab) { - (void)awakeFromNib { self.selectMenuItemTitle = NSLocalizedString(@"SELECT_FILTER_WITH_DOTS", "Menu displayed as popup selection for search options if no filter is selected"); self.multipleMenuItemTitle = NSLocalizedString(@"MULTIPLE_FILTERS_ACTIVE_WITH_DOTS", "Menu displayed as popup selection for search options when multiple items are selected"); - self.filterLabelTextField.cell.backgroundStyle = NSBackgroundStyleRaised; - - /* Setup Trash Bar color */ - if(@available(macOS 10.13, *)) { - NSArray *activeColors = @[[NSColor colorNamed:@"Active Shadow"], [NSColor colorNamed:@"Active Highlight"], ]; - NSArray *inactiveColors = @[[NSColor colorNamed:@"Inactive Shadow"], [NSColor colorNamed:@"Inactive Highlight"]]; - self.historyBar.activeGradient = [[NSGradient alloc] initWithColors:activeColors]; - self.searchBar.activeGradient = [[NSGradient alloc] initWithColors:activeColors]; - self.trashBar.activeGradient = [[NSGradient alloc] initWithColors:activeColors]; - - self.historyBar.inactiveGradient = [[NSGradient alloc] initWithColors:inactiveColors]; - self.trashBar.inactiveGradient = [[NSGradient alloc] initWithColors:inactiveColors]; - self.searchBar.inactiveGradient = [[NSGradient alloc] initWithColors:inactiveColors]; - } - else { - - } [self.view bind:NSSelectedIndexBinding toObject:self withKeyPath:NSStringFromSelector(@selector(activeTab)) options:nil]; diff --git a/MacPass/MPEntryTableDataSource.m b/MacPass/MPEntryTableDataSource.m index 4298564f..27e8466e 100644 --- a/MacPass/MPEntryTableDataSource.m +++ b/MacPass/MPEntryTableDataSource.m @@ -31,6 +31,8 @@ @implementation MPEntryTableDataSource +// FIXME: change drag image to use only the first column regardless of drag start + - (id)tableView:(NSTableView *)tableView pasteboardWriterForRow:(NSInteger)row { id item = self.viewController.entryArrayController.arrangedObjects[row]; if([item isKindOfClass:KPKEntry.class]) { @@ -39,6 +41,14 @@ return nil; } +- (NSDragOperation)tableView:(NSTableView *)tableView validateDrop:(id)info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)dropOperation { + BOOL makeCopy = (info.draggingSourceOperationMask == NSDragOperationCopy); + if(dropOperation == NSTableViewDropOn) { + [tableView setDropRow:row+1 dropOperation:NSTableViewDropAbove]; + } + return makeCopy ? NSDragOperationCopy : NSDragOperationMove; +} + - (void)tableView:(NSTableView *)tableView draggingSession:(NSDraggingSession *)session willBeginAtPoint:(NSPoint)screenPoint forRowIndexes:(nonnull NSIndexSet *)rowIndexes { session.draggingFormation = NSDraggingFormationList; } diff --git a/MacPass/MPEntryViewController.h b/MacPass/MPEntryViewController.h index 0c3622fa..598a5858 100644 --- a/MacPass/MPEntryViewController.h +++ b/MacPass/MPEntryViewController.h @@ -24,6 +24,7 @@ #import "MPContextBarViewController.h" #import "MPTargetNodeResolving.h" +APPKIT_EXTERN NSString *const MPEntryTableIndexColumnIdentifier; APPKIT_EXTERN NSString *const MPEntryTableUserNameColumnIdentifier; APPKIT_EXTERN NSString *const MPEntryTableTitleColumnIdentifier; APPKIT_EXTERN NSString *const MPEntryTablePasswordColumnIdentifier; @@ -32,6 +33,7 @@ APPKIT_EXTERN NSString *const MPEntryTableURLColumnIdentifier; APPKIT_EXTERN NSString *const MPEntryTableNotesColumnIdentifier; APPKIT_EXTERN NSString *const MPEntryTableAttachmentColumnIdentifier; APPKIT_EXTERN NSString *const MPEntryTableModfiedColumnIdentifier; +APPKIT_EXTERN NSString *const MPEntryTableHistoryColumnIdentifier; typedef NS_ENUM(NSUInteger, MPDisplayMode) { MPDisplayModeEntries, diff --git a/MacPass/MPOutlineViewController.h b/MacPass/MPOutlineViewController.h index 0761ee9b..bd64098b 100644 --- a/MacPass/MPOutlineViewController.h +++ b/MacPass/MPOutlineViewController.h @@ -25,7 +25,6 @@ APPKIT_EXTERN NSString *const MPOutlineViewDidChangeGroupSelection; -@class HNHUIGradientView; @class MPDocument; @interface MPOutlineViewController : MPViewController diff --git a/MacPass/MPPickfieldTableModel.h b/MacPass/MPPickfieldTableModel.h index df26c12e..b47b5dbd 100644 --- a/MacPass/MPPickfieldTableModel.h +++ b/MacPass/MPPickfieldTableModel.h @@ -27,12 +27,14 @@ @interface MPPickfieldTableModelRowItem : NSObject -@property (copy) NSString *name; -@property (copy) NSString *value; -@property BOOL isGroup; +@property (copy, readonly) NSString *name; +@property (copy, readonly) NSString *value; +@property (readonly) BOOL isProtected; +@property (readonly) BOOL isGroup; + (instancetype)groupItemWithName:(NSString *)name; + (instancetype)itemWithName:(NSString *)name value:(NSString *)value; ++ (instancetype)itemWithName:(NSString *)name protectedValue:(NSString *)value; @end diff --git a/MacPass/MPPickfieldTableModel.m b/MacPass/MPPickfieldTableModel.m index 44538950..30f488cc 100644 --- a/MacPass/MPPickfieldTableModel.m +++ b/MacPass/MPPickfieldTableModel.m @@ -23,12 +23,22 @@ #import "MPPickfieldTableModel.h" #import +@interface MPPickfieldTableModelRowItem () + +@property (copy) NSString *name; +@property (copy) NSString *value; +@property BOOL isProtected; +@property BOOL isGroup; + +@end + @implementation MPPickfieldTableModelRowItem - (instancetype)init { self = [super init]; if(self) { _isGroup = NO; + _isProtected = NO; } return self; } @@ -39,6 +49,14 @@ return item; } ++ (instancetype)itemWithName:(NSString *)name protectedValue:(NSString *)value { + MPPickfieldTableModelRowItem *item = [[MPPickfieldTableModelRowItem alloc] init]; + item.name = name; + item.value = value; + item.isProtected = YES; + return item; +} + + (instancetype)itemWithName:(NSString *)name value:(NSString *)value { MPPickfieldTableModelRowItem *item = [[MPPickfieldTableModelRowItem alloc] init]; item.name = name; @@ -64,13 +82,22 @@ [items addObject:[MPPickfieldTableModelRowItem groupItemWithName:NSLocalizedString(@"ENTRY_DEFAULT_ATTRIBUTES", @"Group row for entry attributes")]]; for(KPKAttribute *attribute in entry.defaultAttributes) { - /* TODO exclude protected values */ - [items addObject:[MPPickfieldTableModelRowItem itemWithName:attribute.key value:(attribute.protect ? @"•••" : attribute.value)]]; + if(attribute.protect) { + [items addObject:[MPPickfieldTableModelRowItem itemWithName:attribute.key protectedValue:attribute.value]]; + } + else { + [items addObject:[MPPickfieldTableModelRowItem itemWithName:attribute.key value:attribute.value]]; + } } [items addObject:[MPPickfieldTableModelRowItem groupItemWithName:NSLocalizedString(@"ENTRY_CUSTOM_ATTRIBUTES", @"Group row for entry attributes")]]; for(KPKAttribute *attribute in entry.customAttributes) { - [items addObject:[MPPickfieldTableModelRowItem itemWithName:attribute.key value:(attribute.protect ? @"•••" : attribute.value)]]; + if(attribute.protect) { + [items addObject:[MPPickfieldTableModelRowItem itemWithName:attribute.key protectedValue:attribute.value]]; + } + else { + [items addObject:[MPPickfieldTableModelRowItem itemWithName:attribute.key value:attribute.value]]; + } } self.items = items; // copy creates an immutable copy } diff --git a/MacPass/MPPickfieldViewController.m b/MacPass/MPPickfieldViewController.m index be9bd877..4e757eb9 100644 --- a/MacPass/MPPickfieldViewController.m +++ b/MacPass/MPPickfieldViewController.m @@ -92,7 +92,7 @@ typedef NS_ENUM(NSUInteger, MPPickfieldTableColumn) { view.textField.stringValue = rowItem.name; break; case MPPIckfieldValueTableColumn: - view.textField.stringValue = rowItem.value; + view.textField.stringValue = rowItem.isProtected ? @"•••" : rowItem.value; break; default: break;