|
@@ -0,0 +1,633 @@
|
|
|
+//
|
|
|
+// KMProfileInfoWindowController.swift
|
|
|
+// PDF Master
|
|
|
+//
|
|
|
+// Created by tangchao on 2023/11/9.
|
|
|
+//
|
|
|
+
|
|
|
+import Cocoa
|
|
|
+
|
|
|
+//class KMProfileInfoWindowController: NSWindowController {
|
|
|
+//
|
|
|
+// /*
|
|
|
+// typedef void(^profileInfoAddtoDocCallBack)(NSString *string);
|
|
|
+//
|
|
|
+// @interface KMProfileInfoWindowController : NSWindowController
|
|
|
+//
|
|
|
+// @property (nonatomic, copy) profileInfoAddtoDocCallBack callBack;//回调
|
|
|
+//
|
|
|
+// @end
|
|
|
+// */
|
|
|
+//
|
|
|
+// /*
|
|
|
+// static NSString *TitleCellIdentifier = @"TitleCell";
|
|
|
+// static NSString *NormalCellIdentifier = @"Normal";
|
|
|
+//
|
|
|
+// @interface KMProfileInfoWindowController () <NSTableViewDelegate, NSTableViewDataSource, NSTextFieldDelegate>
|
|
|
+//
|
|
|
+// @property (assign) IBOutlet NSTextField *titleLabel;
|
|
|
+// @property (assign) IBOutlet NSTableView *tableView;
|
|
|
+// @property (nonatomic, retain) NSMutableArray *tableContents;
|
|
|
+// @property (assign) IBOutlet NSButton *backButton;
|
|
|
+// @property (assign) IBOutlet NSButton *addButton;
|
|
|
+// @property (assign) IBOutlet NSButton *addNewInfoButton;
|
|
|
+// @property (assign) IBOutlet NSButton *removeNewInfoButton;
|
|
|
+//
|
|
|
+// @end
|
|
|
+// */
|
|
|
+//
|
|
|
+// override func windowDidLoad() {
|
|
|
+// super.windowDidLoad()
|
|
|
+//
|
|
|
+// // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
|
|
|
+// }
|
|
|
+//
|
|
|
+// /*
|
|
|
+// - (void)dealloc {
|
|
|
+//
|
|
|
+// // [_tableContents release];
|
|
|
+// [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
|
|
|
+//
|
|
|
+// // [super dealloc];
|
|
|
+// }
|
|
|
+//
|
|
|
+// #pragma mark - Life Cycle
|
|
|
+// - (void)windowDidLoad {
|
|
|
+// [super windowDidLoad];
|
|
|
+//
|
|
|
+// [self configuViews];
|
|
|
+// [self fetchDisplayKeys];
|
|
|
+// [self.tableView reloadData];
|
|
|
+// [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
|
|
|
+// }
|
|
|
+//
|
|
|
+// #pragma mark - Private Methods
|
|
|
+//
|
|
|
+// - (void)configuViews {
|
|
|
+//
|
|
|
+// self.titleLabel.stringValue = NSLocalizedString(@"My Profile", nil);
|
|
|
+//
|
|
|
+// //Button Part
|
|
|
+// self.backButton.title = NSLocalizedString(@"Cancel", nil);
|
|
|
+// self.addButton.title = NSLocalizedString(@"Add to Doc", nil);
|
|
|
+// self.addButton.enabled = NO;
|
|
|
+// self.removeNewInfoButton.enabled = NO;
|
|
|
+// //NSMenu Part
|
|
|
+// NSMenuItem *editItem = [self.tableView.menu itemAtIndex:0];
|
|
|
+// NSMenuItem *addItem = [self.tableView.menu itemAtIndex:1];
|
|
|
+// NSMenuItem *deleteItem = [self.tableView.menu itemAtIndex:2];
|
|
|
+//
|
|
|
+// editItem.title = NSLocalizedString(@"Edit", nil);
|
|
|
+// addItem.title = NSLocalizedString(@"Add to Doc", nil);
|
|
|
+// deleteItem.title = NSLocalizedString(@"Delete", nil);
|
|
|
+// }
|
|
|
+//
|
|
|
+// - (void)fetchDisplayKeys {
|
|
|
+// _tableContents = [NSMutableArray array];
|
|
|
+// [_tableContents addObject:NSLocalizedString(@"Name", nil)];
|
|
|
+// [_tableContents addObject:NSLocalizedString(@"Full Name", nil)];
|
|
|
+// [_tableContents addObject:NSLocalizedString(@"First Name", nil)];
|
|
|
+// [_tableContents addObject:NSLocalizedString(@"Middle Name", nil)];
|
|
|
+// [_tableContents addObject:NSLocalizedString(@"Last Name", nil)];
|
|
|
+//
|
|
|
+// [_tableContents addObject:NSLocalizedString(@"Address", nil)];
|
|
|
+// [_tableContents addObject:NSLocalizedString(@"Street 1", nil)];
|
|
|
+// [_tableContents addObject:NSLocalizedString(@"Street 2", nil)];
|
|
|
+// [_tableContents addObject:NSLocalizedString(@"City", nil)];
|
|
|
+// [_tableContents addObject:NSLocalizedString(@"State ", nil)];
|
|
|
+// [_tableContents addObject:NSLocalizedString(@"Zip", nil)];
|
|
|
+// [_tableContents addObject:NSLocalizedString(@"Country", nil)];
|
|
|
+//
|
|
|
+// [_tableContents addObject:NSLocalizedString(@"Contact Information", nil)];
|
|
|
+// [_tableContents addObject:NSLocalizedString(@"Email", nil)];
|
|
|
+// [_tableContents addObject:NSLocalizedString(@"Tel", nil)];
|
|
|
+//
|
|
|
+// [_tableContents addObject:NSLocalizedString(@"Dates", nil)];
|
|
|
+// [_tableContents addObject:NSLocalizedString(@"Date", nil)];
|
|
|
+// [_tableContents addObject:NSLocalizedString(@"Birth Date", nil)];
|
|
|
+// if ([KMProfileInfo sharedInstance].customInfoArray.count > 0) {
|
|
|
+// [_tableContents addObject:NSLocalizedString(@"Custom", nil)];
|
|
|
+// for (NSUInteger i = 0 ; i < [KMProfileInfo sharedInstance].customInfoArray.count; i ++) {
|
|
|
+// NSDictionary *dict = [[KMProfileInfo sharedInstance].customInfoArray objectAtIndex:i];
|
|
|
+// [_tableContents addObject:dict.allKeys.firstObject];
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// - (void)configuTextField:(KMProfileCellView *)cellView {
|
|
|
+// NSTextField * textField = cellView.detailtextField;
|
|
|
+// NSInteger tag = textField.tag;
|
|
|
+// NSString *placeHoldString = @"";
|
|
|
+// NSString *nameString = @"";
|
|
|
+//
|
|
|
+// if (tag == 1) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Full Name", nil);
|
|
|
+// nameString = [KMProfileInfo sharedInstance].fullName;
|
|
|
+// } else if (tag == 2) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add First Name", nil);
|
|
|
+// nameString = [KMProfileInfo sharedInstance].firstName;
|
|
|
+// } else if (tag == 3) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Middle Name", nil);
|
|
|
+// nameString = [KMProfileInfo sharedInstance].middleName;
|
|
|
+// } else if (tag == 4) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Last Name", nil);
|
|
|
+// nameString = [KMProfileInfo sharedInstance].lastName;
|
|
|
+// } else if (tag == 6) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Street 1", nil);
|
|
|
+// nameString = [KMProfileInfo sharedInstance].street1;
|
|
|
+// } else if (tag == 7) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Street 2", nil);
|
|
|
+// nameString = [KMProfileInfo sharedInstance].street2;
|
|
|
+// } else if (tag == 8) {
|
|
|
+//
|
|
|
+// placeHoldString = NSLocalizedString(@"Add City", nil);
|
|
|
+// nameString = [KMProfileInfo sharedInstance].city;
|
|
|
+// } else if (tag == 9) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add State", nil);
|
|
|
+// nameString = [KMProfileInfo sharedInstance].state;
|
|
|
+// } else if (tag == 10) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Zip", nil);
|
|
|
+// nameString = [KMProfileInfo sharedInstance].zip;
|
|
|
+// } else if (tag == 11) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Country", nil);
|
|
|
+// nameString = [KMProfileInfo sharedInstance].country;
|
|
|
+// } else if (tag == 13) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Email", nil);
|
|
|
+// nameString = [KMProfileInfo sharedInstance].email;
|
|
|
+// } else if (tag == 14) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Tel", nil);
|
|
|
+// nameString = [KMProfileInfo sharedInstance].tel;
|
|
|
+// } else if (tag == 16) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Date", nil);
|
|
|
+// NSDate *date = [NSDate date];
|
|
|
+// NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
|
|
|
+// [formatter setDateFormat:@"YYYY/MM/dd"];
|
|
|
+// nameString = [formatter stringFromDate:date];
|
|
|
+// } else if (tag == 17) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Birth Date", nil);
|
|
|
+// nameString = [KMProfileInfo sharedInstance].birthDate;
|
|
|
+// }
|
|
|
+// textField.stringValue = nameString;
|
|
|
+// if (nameString.length > 0) {
|
|
|
+// textField.hidden = NO;
|
|
|
+// cellView.addButton.hidden = YES;
|
|
|
+// } else {
|
|
|
+// cellView.addButton.title = placeHoldString;
|
|
|
+// textField.placeholderString = placeHoldString;
|
|
|
+// textField.hidden = YES;
|
|
|
+// cellView.addButton.tag = tag;
|
|
|
+// cellView.addButton.target = self;
|
|
|
+// [cellView.addButton setAction:@selector(addFileName_Add:)];
|
|
|
+// [cellView.addButton setTitleColor:[NSColor systemBlueColor]];
|
|
|
+// cellView.addButton.hidden = NO;
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// #pragma mark - NSTableViewDelegate / NSTableViewDataSources
|
|
|
+//
|
|
|
+// - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
|
|
|
+// return self.tableContents.count;
|
|
|
+// }
|
|
|
+//
|
|
|
+// - (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row {
|
|
|
+// NSString *addingString = [self.tableContents objectAtIndex:row];
|
|
|
+// NSInteger customIndex = [self.tableContents indexOfObject:NSLocalizedString(@"Custom", nil)];
|
|
|
+// if (([addingString isEqualToString:NSLocalizedString(@"Name", nil)] ||
|
|
|
+// [addingString isEqualToString:NSLocalizedString(@"Address", nil)] ||
|
|
|
+// [addingString isEqualToString:NSLocalizedString(@"Contact Information", nil)] ||
|
|
|
+// [addingString isEqualToString:NSLocalizedString(@"Dates", nil)] ||
|
|
|
+// [addingString isEqualToString:NSLocalizedString(@"Custom", nil)])
|
|
|
+// && row <= customIndex) {
|
|
|
+// return 24.0;
|
|
|
+// } else {
|
|
|
+// return 36.0;
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
|
|
|
+// NSString *addingString = [self.tableContents objectAtIndex:row];
|
|
|
+// NSInteger customIndex = [self.tableContents indexOfObject:NSLocalizedString(@"Custom", nil)];
|
|
|
+// NSTableCellView *tableCellView = nil;
|
|
|
+// if (([addingString isEqualToString:NSLocalizedString(@"Name", nil)] ||
|
|
|
+// [addingString isEqualToString:NSLocalizedString(@"Address", nil)] ||
|
|
|
+// [addingString isEqualToString:NSLocalizedString(@"Contact Information", nil)] ||
|
|
|
+// [addingString isEqualToString:NSLocalizedString(@"Dates", nil)] ||
|
|
|
+// [addingString isEqualToString:NSLocalizedString(@"Custom", nil)])
|
|
|
+// && row <= customIndex) {
|
|
|
+// tableCellView = [tableView makeViewWithIdentifier:TitleCellIdentifier owner:tableColumn];
|
|
|
+// KMProfileTitleCellView *cellView = (KMProfileTitleCellView *)tableCellView;
|
|
|
+// cellView.textField.stringValue = addingString;
|
|
|
+// cellView.textField.editable = NO;
|
|
|
+// cellView.wantsLayer = YES;
|
|
|
+// if ([KMAppearance isSupportNewColor]) {
|
|
|
+// if ([KMAppearance isDarkMode]) {
|
|
|
+// cellView.layer.backgroundColor = [NSColor colorWithRed:73/255.0 green:75/255.0 blue:77/255.0 alpha:1.0].CGColor;
|
|
|
+// } else {
|
|
|
+// cellView.layer.backgroundColor = [NSColor colorWithRed:219/255.0 green:219/255.0 blue:219/255.0 alpha:1.0].CGColor;
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// cellView.layer.backgroundColor = [NSColor colorWithRed:235.0/255.0 green:235.0/255.0 blue:235.0/255.0 alpha:1.0].CGColor;
|
|
|
+// }
|
|
|
+//
|
|
|
+// } else {
|
|
|
+// tableCellView = [tableView makeViewWithIdentifier:NormalCellIdentifier owner:tableColumn];
|
|
|
+// KMProfileCellView *cellView = (KMProfileCellView *)tableCellView;
|
|
|
+// cellView.textField.stringValue = addingString;
|
|
|
+// if([cellView isKindOfClass:[KMProfileCellView class]]){
|
|
|
+// cellView.detailtextField.hidden = NO;
|
|
|
+// }
|
|
|
+// cellView.textField.textColor = [KMAppearance KMColor_Layout_H0];
|
|
|
+// if (customIndex > row) {
|
|
|
+// cellView.detailtextField.tag = row;
|
|
|
+// [self configuTextField:cellView];
|
|
|
+// cellView.textField.editable = NO;
|
|
|
+// cellView.textField.selectable = NO;
|
|
|
+// if ([addingString isEqualToString:NSLocalizedString(@"Date", nil)]) {
|
|
|
+// cellView.detailtextField.editable = NO;
|
|
|
+// cellView.detailtextField.selectable = NO;
|
|
|
+// }
|
|
|
+//
|
|
|
+// cellView.detailtextField.delegate = self;
|
|
|
+// } else {
|
|
|
+// NSInteger index = row - customIndex - 1;
|
|
|
+// NSDictionary *dict = [[KMProfileInfo sharedInstance].customInfoArray objectAtIndex:index];
|
|
|
+// cellView.addButton.hidden = YES;
|
|
|
+// cellView.detailtextField.stringValue = dict.allValues.firstObject;
|
|
|
+// cellView.detailtextField.placeholderString = NSLocalizedString(@"Type Value Here", nil);
|
|
|
+// cellView.textField.placeholderString = NSLocalizedString(@"Type Label Here", nil);
|
|
|
+// cellView.textField.editable = YES;
|
|
|
+// cellView.textField.selectable = YES;
|
|
|
+// cellView.detailtextField.editable = YES;
|
|
|
+// cellView.detailtextField.selectable = YES;
|
|
|
+// cellView.textField.delegate = self;
|
|
|
+// cellView.detailtextField.delegate = self;
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return tableCellView;
|
|
|
+// }
|
|
|
+//
|
|
|
+// - (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row {
|
|
|
+// NSString *addingString = [self.tableContents objectAtIndex:row];
|
|
|
+// NSInteger customIndex = [self.tableContents indexOfObject:NSLocalizedString(@"Custom", nil)];
|
|
|
+// if (([addingString isEqualToString:NSLocalizedString(@"Name", nil)] ||
|
|
|
+// [addingString isEqualToString:NSLocalizedString(@"Address", nil)] ||
|
|
|
+// [addingString isEqualToString:NSLocalizedString(@"Contact Information", nil)] ||
|
|
|
+// [addingString isEqualToString:NSLocalizedString(@"Dates", nil)] ||
|
|
|
+// [addingString isEqualToString:NSLocalizedString(@"Custom", nil)])
|
|
|
+// && row <= customIndex) {
|
|
|
+// return NO;
|
|
|
+// }
|
|
|
+// return YES;
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// #pragma mark - NSTextFieldDelegate
|
|
|
+//
|
|
|
+// - (void)controlTextDidChange:(NSNotification *)obj {
|
|
|
+//
|
|
|
+// NSInteger currentRow = self.tableView.selectedRow;
|
|
|
+// if (currentRow == -1) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// NSTextField *textField = (NSTextField *)obj.object;
|
|
|
+// KMProfileCellView *cellView = [self.tableView viewAtColumn:0 row:currentRow makeIfNecessary:NO];
|
|
|
+// if (currentRow == 1) {
|
|
|
+// [KMProfileInfo sharedInstance].fullName = textField.stringValue;
|
|
|
+// } else if (currentRow == 2) {
|
|
|
+// [KMProfileInfo sharedInstance].firstName = textField.stringValue;
|
|
|
+// } else if (currentRow == 3) {
|
|
|
+// [KMProfileInfo sharedInstance].middleName = textField.stringValue;
|
|
|
+// } else if (currentRow == 4) {
|
|
|
+// [KMProfileInfo sharedInstance].lastName = textField.stringValue;
|
|
|
+// } else if (currentRow == 6) {
|
|
|
+// [KMProfileInfo sharedInstance].street1 = textField.stringValue;
|
|
|
+// } else if (currentRow == 7) {
|
|
|
+// [KMProfileInfo sharedInstance].street2 = textField.stringValue;
|
|
|
+// } else if (currentRow == 8) {
|
|
|
+// [KMProfileInfo sharedInstance].city = textField.stringValue;
|
|
|
+// } else if (currentRow == 9) {
|
|
|
+// [KMProfileInfo sharedInstance].state = textField.stringValue;
|
|
|
+// } else if (currentRow == 10) {
|
|
|
+// [KMProfileInfo sharedInstance].zip = textField.stringValue;
|
|
|
+// } else if (currentRow == 11) {
|
|
|
+// [KMProfileInfo sharedInstance].country = textField.stringValue;
|
|
|
+// } else if (currentRow == 13) {
|
|
|
+// [KMProfileInfo sharedInstance].email = textField.stringValue;
|
|
|
+// } else if (currentRow == 14) {
|
|
|
+// [KMProfileInfo sharedInstance].tel = textField.stringValue;
|
|
|
+// } else if (currentRow == 16) {
|
|
|
+// // [KMProfileInfo sharedInstance].date = textField.stringValue;
|
|
|
+// } else if (currentRow == 17) {
|
|
|
+// [KMProfileInfo sharedInstance].birthDate = textField.stringValue;
|
|
|
+// } else if (currentRow >= 19 ) {
|
|
|
+// NSInteger customIndex = currentRow - 19;
|
|
|
+// if (cellView) {
|
|
|
+// NSDictionary *dict = [[KMProfileInfo sharedInstance].customInfoArray objectAtIndex:customIndex];
|
|
|
+// NSString *originalKey = dict.allKeys.firstObject;
|
|
|
+// NSString *originalValue = dict.allValues.firstObject;
|
|
|
+// if ([textField isEqual:cellView.textField]) {
|
|
|
+// NSDictionary *newDict = @{textField.stringValue : originalValue};
|
|
|
+// [[KMProfileInfo sharedInstance] replaceObjectInCustomInfoArrayAtIndex:customIndex withObject:newDict];
|
|
|
+// } else if ([textField isEqual:cellView.detailtextField]){
|
|
|
+// NSDictionary *newDict = @{originalKey:textField.stringValue};
|
|
|
+// [[KMProfileInfo sharedInstance] replaceObjectInCustomInfoArrayAtIndex:customIndex withObject:newDict];
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (cellView.detailtextField.stringValue.length > 0 ) {
|
|
|
+// self.addButton.enabled = YES;
|
|
|
+// } else {
|
|
|
+// self.addButton.enabled = NO;
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// - (void)controlTextDidBeginEditing:(NSNotification *)obj {
|
|
|
+// NSTextField *textField = obj.object;
|
|
|
+// BOOL isDarkMode = NO;
|
|
|
+// if (@available(macOS 10.14, *)) {
|
|
|
+// if ([[NSApplication sharedApplication].effectiveAppearance isEqual: [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]]) {
|
|
|
+// isDarkMode =YES;
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// textField.textColor = [NSColor labelColor];
|
|
|
+// }
|
|
|
+//
|
|
|
+// - (void)controlTextDidEndEditing:(NSNotification *)obj;
|
|
|
+// {
|
|
|
+// NSTextField *textField = obj.object;
|
|
|
+// NSInteger tag = textField.tag;
|
|
|
+// KMProfileCellView *cellView = [self.tableView viewAtColumn:0 row:textField.tag makeIfNecessary:NO];
|
|
|
+//
|
|
|
+// if ([cellView isKindOfClass:[KMProfileCellView class]] && tag > 0) {
|
|
|
+// NSString *placeHoldString = @"";
|
|
|
+//
|
|
|
+// if (tag == 1) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Full Name", nil);
|
|
|
+// } else if (tag == 2) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add First Name", nil);
|
|
|
+// } else if (tag == 3) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Middle Name", nil);
|
|
|
+// } else if (tag == 4) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Last Name", nil);
|
|
|
+// } else if (tag == 6) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Street 1", nil);
|
|
|
+// } else if (tag == 7) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Street 2", nil);
|
|
|
+// } else if (tag == 8) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add City", nil);
|
|
|
+// } else if (tag == 9) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add State", nil);
|
|
|
+// } else if (tag == 10) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Zip", nil);
|
|
|
+// } else if (tag == 11) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Country", nil);
|
|
|
+// } else if (tag == 13) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Email", nil);
|
|
|
+// } else if (tag == 14) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Tel", nil);
|
|
|
+// } else if (tag == 16) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Date", nil);
|
|
|
+// } else if (tag == 17) {
|
|
|
+// placeHoldString = NSLocalizedString(@"Add Birth Date", nil);
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (textField.stringValue.length > 0) {
|
|
|
+// textField.textColor = [NSColor secondaryLabelColor];
|
|
|
+// textField.hidden = NO;
|
|
|
+// cellView.addButton.hidden = YES;
|
|
|
+// } else {
|
|
|
+// // textField.hidden = YES; //自定义新增,输入Label后,value为空时推出编辑,就无法填写了
|
|
|
+// textField.placeholderString = @"";
|
|
|
+// cellView.addButton.hidden = NO;
|
|
|
+// cellView.addButton.tag = tag;
|
|
|
+// cellView.addButton.target = self;
|
|
|
+// [cellView.addButton setAction:@selector(addFileName_Add:)];
|
|
|
+// cellView.addButton.title = placeHoldString;
|
|
|
+// [cellView.addButton setTitleColor:[NSColor systemBlueColor]];
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// - (void)tableViewSelectionDidChange:(NSNotification *)notification {
|
|
|
+// if (self.tableView.selectedRow == NSNotFound || self.tableView.selectedRow == -1) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// KMProfileCellView *cellView = [self.tableView viewAtColumn:0 row:self.tableView.selectedRow makeIfNecessary:NO];
|
|
|
+// self.addButton.enabled = cellView.detailtextField.stringValue.length > 0;
|
|
|
+//
|
|
|
+// for (NSInteger i = 0; i < self.tableView.numberOfRows; i++) {
|
|
|
+// NSTableCellView *cellView = [self.tableView viewAtColumn:0 row:i makeIfNecessary:NO];
|
|
|
+// if ([cellView isKindOfClass:[KMProfileCellView class]]) {
|
|
|
+// KMProfileCellView *cellView1 = (KMProfileCellView *)cellView;
|
|
|
+// if (i == self.tableView.selectedRow) {
|
|
|
+// cellView1.detailtextField.textColor = [NSColor whiteColor];
|
|
|
+// [cellView1.addButton setTitleColor:[NSColor whiteColor]];
|
|
|
+// } else {
|
|
|
+// cellView1.detailtextField.textColor = [NSColor secondaryLabelColor];
|
|
|
+// [cellView1.addButton setTitleColor:[NSColor systemBlueColor]];
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// NSInteger customIndex = [self.tableContents indexOfObject:NSLocalizedString(@"Custom", nil)];
|
|
|
+// if (self.tableView.selectedRow > customIndex) {
|
|
|
+// self.removeNewInfoButton.enabled = YES;
|
|
|
+// } else {
|
|
|
+// self.removeNewInfoButton.enabled = NO;
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// #pragma mark - Button Action
|
|
|
+//
|
|
|
+// - (IBAction)buttonClicked_back:(id)sender {
|
|
|
+// // [self dismissSheet:sender];
|
|
|
+// }
|
|
|
+//
|
|
|
+// - (IBAction)buttonClicked_add:(id)sender {
|
|
|
+// NSInteger selectRow =self.tableView.selectedRow;
|
|
|
+// if (selectRow >= 0) {
|
|
|
+// if (self.callBack) {
|
|
|
+// KMProfileCellView *cellView = [self.tableView viewAtColumn:0 row:self.tableView.selectedRow makeIfNecessary:NO];
|
|
|
+// self.callBack(cellView.detailtextField.stringValue);
|
|
|
+// // [self dismissSheet:sender];
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// - (IBAction)buttonClicked_addNewInfo:(id)sender {
|
|
|
+// NSDictionary *dict = @{@"":@""};
|
|
|
+// [[KMProfileInfo sharedInstance] insertObject:dict inCustomInfoArrayAtIndex:[KMProfileInfo sharedInstance].customInfoArray.count];
|
|
|
+// [self fetchDisplayKeys];
|
|
|
+// [self.tableView reloadData];
|
|
|
+// if (self.tableView.numberOfRows > 1) {
|
|
|
+// [self.tableView scrollRowToVisible:self.tableView.numberOfRows - 1];
|
|
|
+// NSIndexSet *set = [NSIndexSet indexSetWithIndex:self.tableView.numberOfRows - 1];
|
|
|
+// [self.tableView selectRowIndexes:set byExtendingSelection:NO];
|
|
|
+// KMProfileCellView *cellView = [self.tableView viewAtColumn:0 row:self.tableView.selectedRow makeIfNecessary:NO];
|
|
|
+// cellView.addButton.hidden = YES;
|
|
|
+// [cellView.textField becomeFirstResponder];
|
|
|
+// };
|
|
|
+// }
|
|
|
+//
|
|
|
+// - (IBAction)buttonClicked_RemoveNewInfo:(id)sender
|
|
|
+// {
|
|
|
+// NSInteger editIndex = self.tableView.selectedRow;
|
|
|
+// NSUInteger customIndex = [self.tableContents indexOfObject:NSLocalizedString(@"Custom", nil)];
|
|
|
+// if (editIndex - customIndex - 1 < [KMProfileInfo sharedInstance].customInfoArray.count) {
|
|
|
+// [[KMProfileInfo sharedInstance] removeObjectFromCustomInfoArrayAtIndex:editIndex - customIndex - 1];
|
|
|
+// [self fetchDisplayKeys];
|
|
|
+// [self.tableView reloadData];
|
|
|
+// self.removeNewInfoButton.enabled = NO;
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// - (IBAction)addFileName_Add:(NSButton *)sender
|
|
|
+// {
|
|
|
+// [self.window makeFirstResponder:nil];
|
|
|
+// NSInteger tag = sender.tag;
|
|
|
+// KMProfileCellView *cellView = [self.tableView viewAtColumn:0 row:tag makeIfNecessary:NO];
|
|
|
+// if ([cellView isKindOfClass:[KMProfileCellView class]]) {
|
|
|
+// cellView.addButton.hidden = YES;
|
|
|
+// cellView.detailtextField.hidden = NO;
|
|
|
+// [cellView.detailtextField becomeFirstResponder];
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// #pragma mark - NSMenu Action
|
|
|
+//
|
|
|
+// - (IBAction)menuItemClicked_Edit:(id)sender {
|
|
|
+// KMProfileCellView *cellView = [self.tableView viewAtColumn:0 row:self.tableView.clickedRow makeIfNecessary:NO];
|
|
|
+// NSIndexSet *set = [NSIndexSet indexSetWithIndex:self.tableView.clickedRow];
|
|
|
+// [self.tableView selectRowIndexes:set byExtendingSelection:NO];
|
|
|
+// if (cellView.textField.editable) {
|
|
|
+// if (cellView.textField.stringValue.length == 0) {
|
|
|
+// [cellView.textField becomeFirstResponder];
|
|
|
+// }else {
|
|
|
+// [cellView.detailtextField becomeFirstResponder];
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// [cellView.detailtextField becomeFirstResponder];
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// - (IBAction)menuItemClicked_Add:(id)sender {
|
|
|
+// KMProfileCellView *cellView = [self.tableView viewAtColumn:0 row:self.tableView.clickedRow makeIfNecessary:NO];
|
|
|
+// if (self.callBack) {
|
|
|
+// self.callBack(cellView.detailtextField.stringValue);
|
|
|
+// // [self dismissSheet:sender];
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// - (IBAction)menuItemClicked_Delete:(id)sender {
|
|
|
+// NSInteger editIndex = self.tableView.clickedRow;
|
|
|
+// NSInteger customIndex = [self.tableContents indexOfObject:NSLocalizedString(@"Custom", nil)];
|
|
|
+// if (editIndex < customIndex ) {
|
|
|
+// switch (editIndex) {
|
|
|
+// case 1:
|
|
|
+// [KMProfileInfo sharedInstance].fullName = @"";
|
|
|
+// break;
|
|
|
+// case 2:
|
|
|
+// [KMProfileInfo sharedInstance].firstName = @"";
|
|
|
+// break;
|
|
|
+// case 3:
|
|
|
+// [KMProfileInfo sharedInstance].middleName = @"";
|
|
|
+// break;
|
|
|
+// case 4:
|
|
|
+// [KMProfileInfo sharedInstance].lastName = @"";
|
|
|
+// break;
|
|
|
+//
|
|
|
+// case 6:
|
|
|
+// [KMProfileInfo sharedInstance].street1 = @"";
|
|
|
+// break;
|
|
|
+// case 7:
|
|
|
+// [KMProfileInfo sharedInstance].street2 = @"";
|
|
|
+// break;
|
|
|
+// case 8:
|
|
|
+// [KMProfileInfo sharedInstance].city = @"";
|
|
|
+// break;
|
|
|
+// case 9:
|
|
|
+// [KMProfileInfo sharedInstance].state = @"";
|
|
|
+// break;
|
|
|
+// case 10:
|
|
|
+// [KMProfileInfo sharedInstance].zip = @"";
|
|
|
+// break;
|
|
|
+// case 11:
|
|
|
+// [KMProfileInfo sharedInstance].country = @"";
|
|
|
+// break;
|
|
|
+// case 13:
|
|
|
+// [KMProfileInfo sharedInstance].email = @"";
|
|
|
+// break;
|
|
|
+// case 14:
|
|
|
+// [KMProfileInfo sharedInstance].tel = @"";
|
|
|
+// break;
|
|
|
+// case 16:
|
|
|
+// // [KMProfileInfo sharedInstance].date = @"";
|
|
|
+// break;
|
|
|
+// case 17:
|
|
|
+// [KMProfileInfo sharedInstance].birthDate = @"";
|
|
|
+// break;
|
|
|
+// default:
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// [[KMProfileInfo sharedInstance] removeObjectFromCustomInfoArrayAtIndex:editIndex - customIndex - 1];
|
|
|
+// }
|
|
|
+//
|
|
|
+// [self fetchDisplayKeys];
|
|
|
+// [self.tableView reloadData];
|
|
|
+// }
|
|
|
+//
|
|
|
+// - (BOOL)validateMenuItem:(NSMenuItem *)menuItem {
|
|
|
+//
|
|
|
+// NSTableCellView *cellView = [self.tableView viewAtColumn:0 row:self.tableView.clickedRow makeIfNecessary:NO];
|
|
|
+// if (menuItem.action == @selector(menuItemClicked_Edit:)) {
|
|
|
+// if ([cellView isKindOfClass:[KMProfileTitleCellView class]]) {
|
|
|
+// return NO;
|
|
|
+// } else {
|
|
|
+// KMProfileCellView *cellView1 = (KMProfileCellView *)cellView;
|
|
|
+// if ([cellView1.textField.stringValue isEqualToString:NSLocalizedString(@"Date", nil)]) {
|
|
|
+// return NO;
|
|
|
+// }
|
|
|
+// return YES;
|
|
|
+// }
|
|
|
+// } else if (menuItem.action == @selector(menuItemClicked_Add:)) {
|
|
|
+// if ([cellView isKindOfClass:[KMProfileTitleCellView class]]) {
|
|
|
+// return NO;
|
|
|
+// } else {
|
|
|
+// KMProfileCellView *cell = (KMProfileCellView *)cellView;
|
|
|
+// return cell.detailtextField.stringValue.length > 0;
|
|
|
+// }
|
|
|
+// } else if (menuItem.action == @selector(menuItemClicked_Delete:)) {
|
|
|
+// if ([cellView isKindOfClass:[KMProfileTitleCellView class]]) {
|
|
|
+// return NO;
|
|
|
+// } else {
|
|
|
+// KMProfileCellView *cellView1 = (KMProfileCellView *)cellView;
|
|
|
+// if ([cellView1.textField.stringValue isEqualToString:NSLocalizedString(@"Date", nil)]) {
|
|
|
+// return NO;
|
|
|
+// }
|
|
|
+// return YES;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return NO;
|
|
|
+// }
|
|
|
+//
|
|
|
+// - (void)themeChanged:(NSNotification *)notification {
|
|
|
+// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+// [self updateViewColor];
|
|
|
+// });
|
|
|
+// }
|
|
|
+//
|
|
|
+// - (void)updateViewColor {
|
|
|
+// [self.tableView reloadData];
|
|
|
+// }
|
|
|
+//
|
|
|
+// @end
|
|
|
+//
|
|
|
+// */
|
|
|
+//
|
|
|
+//}
|