123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602 |
- //
- // KMProfileInfoWindowController.swift
- // PDF Reader Pro
- //
- // Created by tangchao on 2023/11/9.
- //
- import Cocoa
- class KMProfileInfoWindowController: KMBaseWindowController {
- var callBack: ((String) -> Void)?
-
- @IBOutlet var titleLabel: NSTextField!
- @IBOutlet var tableView: NSTableView!
-
- @IBOutlet var backButton: NSButton!
- @IBOutlet var addButton: NSButton!
- @IBOutlet var addNewInfoButton: NSButton!
- @IBOutlet var removeNewInfoButton: NSButton!
-
- var tableContents: [String] = []
-
- private let TitleCellIdentifier = "TitleCell"
- private let NormalCellIdentifier = "Normal"
-
- override func windowDidLoad() {
- super.windowDidLoad()
-
- self._configuViews()
- self._fetchDisplayKeys()
- self.tableView.reloadData()
- }
-
- @IBAction func addFileName_Add(_ sender: NSButton) {
- self.window?.makeFirstResponder(nil)
- let tag = sender.tag
- let cellView = self.tableView.view(atColumn: 0, row: tag, makeIfNecessary: false) as? KMProfileCellView
- if let _ = cellView {
- if let rowV = self.tableView.rowView(atRow: tag, makeIfNecessary: false), rowV.isSelected == false {
- self.tableView.km_safe_selectRowIndexes(.init(integer: tag), byExtendingSelection: false)
- }
- }
- if let data = cellView?.isKind(of: KMProfileCellView.self), data {
- cellView?.addButton.isHidden = true
- cellView?.detailtextField.isHidden = false
- cellView?.detailtextField.becomeFirstResponder()
- }
- }
-
- @IBAction func buttonClicked_back(_ sender: AnyObject?) {
- guard let block = self.callBack else {
- return
- }
- block("")
- }
-
- @IBAction func buttonClicked_add(_ sender: AnyObject?) {
- let selectRow = self.tableView.selectedRow
- if (selectRow >= 0) {
- if (self.callBack != nil) {
- let cellView = self.tableView.view(atColumn: 0, row: selectRow, makeIfNecessary: false) as? KMProfileCellView
- self.callBack!(cellView?.detailtextField.stringValue ?? "")
- }
- }
- }
- @IBAction func buttonClicked_addNewInfo(_ sender: AnyObject?) {
- let dict: [String : String] = ["" : ""]
- KMProfileInfo.shared().insertObject(dict, inCustomInfoArrayAt: KMProfileInfo.shared().customInfoArray.count)
-
- self._fetchDisplayKeys()
- self.tableView.reloadData()
- if (self.tableView.numberOfRows > 1) {
- self.tableView.scrollRowToVisible(self.tableView.numberOfRows - 1)
- let set = NSIndexSet(index: self.tableView.numberOfRows - 1)
- self.tableView.selectRowIndexes(set as IndexSet, byExtendingSelection: false)
- let cellView = self.tableView.view(atColumn: 0, row: self.tableView.selectedRow, makeIfNecessary: false) as? KMProfileCellView
- cellView?.addButton.isHidden = true
- cellView?.textField?.becomeFirstResponder()
- }
- }
-
- @IBAction func buttonClicked_RemoveNewInfo(_ sender: AnyObject?) {
- let editIndex = self.tableView.selectedRow
- let customIndex = self.tableContents.index(of: KMLocalizedString("Custom")) ?? NSNotFound
- if (editIndex - customIndex - 1 < KMProfileInfo.shared().customInfoArray.count) {
- KMProfileInfo.shared().removeObjectFromCustomInfoArray(at: editIndex - customIndex - 1)
- self._fetchDisplayKeys()
- self.tableView.reloadData()
- self.removeNewInfoButton.isEnabled = false
- }
- }
-
- // MARK: - NSMenu Action
-
- @IBAction func menuItemClicked_Edit(_ sender: AnyObject?) {
- let cellView = self.tableView.view(atColumn: 0, row: self.tableView.clickedRow, makeIfNecessary: false) as? KMProfileCellView
- let set = IndexSet(integer: self.tableView.clickedRow)
- self.tableView.selectRowIndexes(set, byExtendingSelection: false)
- if let data = cellView?.textField?.isEditable, data {
- if let data = cellView?.textField?.stringValue.isEmpty, data {
- cellView?.textField?.becomeFirstResponder()
- }else {
- cellView?.detailtextField.becomeFirstResponder()
- }
- } else {
- cellView?.detailtextField.becomeFirstResponder()
- }
- }
-
- @IBAction func menuItemClicked_Add(_ sender: AnyObject?) {
- let cellView = self.tableView.view(atColumn: 0, row: self.tableView.clickedRow, makeIfNecessary: false) as? KMProfileCellView
- if (self.callBack != nil) {
- self.callBack!(cellView?.detailtextField.stringValue ?? "")
- }
- }
-
- @IBAction func menuItemClicked_Delete(_ sender: AnyObject?) {
- let editIndex = self.tableView.clickedRow
- let customIndex = self.tableContents.index(of: KMLocalizedString("Custom")) ?? NSNotFound
- if (editIndex < customIndex) {
- switch (editIndex) {
- case 1:
- KMProfileInfo.shared().fullName = ""
- break;
- case 2:
- KMProfileInfo.shared().firstName = ""
- break;
- case 3:
- KMProfileInfo.shared().middleName = ""
- break;
- case 4:
- KMProfileInfo.shared().lastName = ""
- break;
- case 6:
- KMProfileInfo.shared().street1 = ""
- break;
- case 7:
- KMProfileInfo.shared().street2 = ""
- break;
- case 8:
- KMProfileInfo.shared().city = ""
- break;
- case 9:
- KMProfileInfo.shared().state = ""
- break;
- case 10:
- KMProfileInfo.shared().zip = ""
- break;
- case 11:
- KMProfileInfo.shared().country = ""
- break;
- case 13:
- KMProfileInfo.shared().email = ""
- break;
- case 14:
- KMProfileInfo.shared().tel = ""
- break;
- case 16:
- // [KMProfileInfo.shared().date = @"";
- break;
- case 17:
- KMProfileInfo.shared().birthDate = ""
- break;
- default:
- break;
- }
- } else {
- KMProfileInfo.shared().removeObjectFromCustomInfoArray(at: editIndex - customIndex - 1)
- }
- self._fetchDisplayKeys()
- self.tableView.reloadData()
- }
-
- override func interfaceThemeDidChanged(_ appearance: NSAppearance.Name) {
- super.interfaceThemeDidChanged(appearance)
-
- DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
- self._updateViewColor()
- }
- }
- }
- // MARK: - Private Methods
- extension KMProfileInfoWindowController {
- private func _configuViews() {
- self.titleLabel.stringValue = KMLocalizedString("My Profile")
- //Button Part
- self.backButton.title = KMLocalizedString("Cancel")
- self.addButton.title = KMLocalizedString("Add to Doc")
- self.addButton.isEnabled = false
- self.removeNewInfoButton.isEnabled = false
- //NSMenu Part
-
- let editItem = self.tableView.menu?.item(at: 0)
- let addItem = self.tableView.menu?.item(at: 1)
- let deleteItem = self.tableView.menu?.item(at: 2)
-
- editItem?.title = KMLocalizedString("Edit")
- addItem?.title = KMLocalizedString("Add to Doc")
- deleteItem?.title = KMLocalizedString("Delete")
- }
-
- private func _fetchDisplayKeys() {
- self.tableContents = []
- self.tableContents.append(KMLocalizedString("Name"))
- self.tableContents.append(KMLocalizedString("Full Name"))
- self.tableContents.append(KMLocalizedString("First Name"))
- self.tableContents.append(KMLocalizedString("Middle Name"))
- self.tableContents.append(KMLocalizedString("Last Name"))
-
- self.tableContents.append(KMLocalizedString("Address"))
- self.tableContents.append(KMLocalizedString("Street 1"))
- self.tableContents.append(KMLocalizedString("Street 2"))
- self.tableContents.append(KMLocalizedString("City"))
- self.tableContents.append(KMLocalizedString("State"))
- self.tableContents.append(KMLocalizedString("Zip"))
- self.tableContents.append(KMLocalizedString("Country"))
-
- self.tableContents.append(KMLocalizedString("Contact Information"))
- self.tableContents.append(KMLocalizedString("Email"))
- self.tableContents.append(KMLocalizedString("Tel"))
-
- self.tableContents.append(KMLocalizedString("Dates"))
- self.tableContents.append(KMLocalizedString("Date"))
- self.tableContents.append(KMLocalizedString("Birth Date"))
-
- if (KMProfileInfo.shared().customInfoArray.count > 0) {
- self.tableContents.append(KMLocalizedString("Custom"))
- for i in 0 ..< KMProfileInfo.shared().customInfoArray.count {
- if let dict: [String : Any] = KMProfileInfo.shared().customInfoArray[i] as? [String : Any], dict.isEmpty == false {
- self.tableContents.append(dict.keys.first!)
- }
- }
- }
- }
-
- private func _updateViewColor() {
- self.tableView.reloadData()
- }
-
- private func _configuTextField(_ cellView: KMProfileCellView?) {
- let textField = cellView?.detailtextField
- let tag = textField?.tag ?? 0
- var placeHoldString: String = ""
- var nameString: String = ""
- if (tag == 1) {
- placeHoldString = KMLocalizedString("Add Full Name")
- nameString = KMProfileInfo.shared().fullName
- } else if (tag == 2) {
- placeHoldString = KMLocalizedString("Add First Name")
- nameString = KMProfileInfo.shared().firstName
- } else if (tag == 3) {
- placeHoldString = KMLocalizedString("Add Middle Name")
- nameString = KMProfileInfo.shared().middleName
- } else if (tag == 4) {
- placeHoldString = KMLocalizedString("Add Last Name")
- nameString = KMProfileInfo.shared().lastName
- } else if (tag == 6) {
- placeHoldString = KMLocalizedString("Add Street 1")
- nameString = KMProfileInfo.shared().street1
- } else if (tag == 7) {
- placeHoldString = KMLocalizedString("Add Street 2")
- nameString = KMProfileInfo.shared().street2
- } else if (tag == 8) {
- placeHoldString = KMLocalizedString("Add City")
- nameString = KMProfileInfo.shared().city
- } else if (tag == 9) {
- placeHoldString = KMLocalizedString("Add State")
- nameString = KMProfileInfo.shared().state
- } else if (tag == 10) {
- placeHoldString = KMLocalizedString("Add Zip")
- nameString = KMProfileInfo.shared().zip
- } else if (tag == 11) {
- placeHoldString = KMLocalizedString("Add Country")
- nameString = KMProfileInfo.shared().country
- } else if (tag == 13) {
- placeHoldString = KMLocalizedString("Add Email")
- nameString = KMProfileInfo.shared().email
- } else if (tag == 14) {
- placeHoldString = KMLocalizedString("Add Tel")
- nameString = KMProfileInfo.shared().tel
- } else if (tag == 16) {
- placeHoldString = KMLocalizedString("Add Date")
- let date = Date()
- let formatter = DateFormatter()
- formatter.dateFormat = "YYYY/MM/dd"
- nameString = formatter.string(from: date)
- } else if (tag == 17) {
- placeHoldString = KMLocalizedString("Add Birth Date")
- nameString = KMProfileInfo.shared().birthDate
- }
- textField?.stringValue = nameString
- if (nameString.isEmpty == false) {
- textField?.isHidden = false
- cellView?.addButton.isHidden = true
- } else {
- cellView?.addButton.title = placeHoldString
- textField?.placeholderString = placeHoldString
- textField?.isHidden = true
- cellView?.addButton.tag = tag
- cellView?.addButton.target = self
- cellView?.addButton.action = #selector(addFileName_Add)
- cellView?.addButton.setTitleColor(NSColor.systemBlue)
- cellView?.addButton.isHidden = false
- }
- }
- }
- extension KMProfileInfoWindowController: NSTableViewDelegate, NSTableViewDataSource {
- func numberOfRows(in tableView: NSTableView) -> Int {
- self.tableContents.count
- }
-
- func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
- let addingString = self.tableContents[row]
- let customIndex = self.tableContents.index(of: KMLocalizedString("Custom")) ?? NSNotFound
- if (addingString == KMLocalizedString("Name") || addingString == KMLocalizedString("Address") || addingString == KMLocalizedString("Contact Information") || addingString == KMLocalizedString("Dates") || addingString == KMLocalizedString("Custom")) && row <= customIndex {
- return 24.0
- }
- return 36.0
- }
-
- func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
- let addingString = self.tableContents[row]
- let customIndex = self.tableContents.index(of: KMLocalizedString("Custom")) ?? NSNotFound
- var tableCellView: NSTableCellView?
- if (addingString == KMLocalizedString("Name") || addingString == KMLocalizedString("Address") || addingString == KMLocalizedString("Contact Information") || addingString == KMLocalizedString("Dates") || addingString == KMLocalizedString("Custom")) && row <= customIndex {
- tableCellView = (tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: TitleCellIdentifier), owner: tableColumn) as! NSTableCellView)
- let cellView = tableCellView as! KMProfileTitleCellView
- cellView.textField?.stringValue = addingString
- cellView.textField?.isEditable = false
- cellView.wantsLayer = true
- if (KMAppearance.isSupportNewColor()) {
- if (KMAppearance.isDarkMode()) {
- cellView.layer?.backgroundColor = NSColor(red: 73/255.0, green: 75/255.0, blue: 77/255.0, alpha: 1).cgColor
- } else {
- cellView.layer?.backgroundColor = NSColor(red: 219/255.0, green: 219/255.0, blue: 219/255.0, alpha: 1).cgColor
- }
- } else {
- cellView.layer?.backgroundColor = NSColor(red: 235.0/255.0, green: 235.0/255.0, blue: 235.0/255.0, alpha: 1).cgColor
- }
-
- } else {
- tableCellView = (tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: NormalCellIdentifier), owner: tableColumn) as! NSTableCellView)
- let cellView = tableCellView as? KMProfileCellView
- cellView?.textField?.stringValue = addingString
- if let data = cellView?.isKind(of: KMProfileCellView.self), data {
- cellView?.detailtextField.isHidden = false
- }
- cellView?.textField?.textColor = KMAppearance.Layout.h0Color()
- if (customIndex > row) {
- cellView?.detailtextField.tag = row
- self._configuTextField(cellView)
- cellView?.textField?.isEditable = false
- cellView?.textField?.isSelectable = false
- if addingString == KMLocalizedString("Date") {
- cellView?.detailtextField.isEditable = false
- cellView?.detailtextField.isSelectable = false
- } else {
- cellView?.detailtextField.isEditable = true
- cellView?.detailtextField.isSelectable = true
- }
- cellView?.detailtextField.delegate = self
- } else {
- let index = row - customIndex - 1
- let dict = KMProfileInfo.shared().customInfoArray[index] as? [String : Any]
- cellView?.addButton.isHidden = true
- cellView?.detailtextField.stringValue = dict?.values.first as? String ?? ""
- cellView?.detailtextField.placeholderString = KMLocalizedString("Type Value Here")
- cellView?.textField?.placeholderString = KMLocalizedString("Type Label Here")
- cellView?.textField?.isEditable = true
- cellView?.textField?.isSelectable = true
- cellView?.detailtextField.isEditable = true
- cellView?.detailtextField.isSelectable = true
- cellView?.textField?.delegate = self
- cellView?.detailtextField.delegate = self
- }
- }
- return tableCellView;
- }
-
- func tableView(_ tableView: NSTableView, shouldSelectRow row: Int) -> Bool {
- let addingString = self.tableContents[row]
- let customIndex = self.tableContents.index(of: KMLocalizedString("Custom")) ?? NSNotFound
- if (addingString == KMLocalizedString("Name") || addingString == KMLocalizedString("Address") || addingString == KMLocalizedString("Contact Information") || addingString == KMLocalizedString("Dates") || addingString == KMLocalizedString("Custom")) && row <= customIndex {
- return false
- }
- return true
- }
-
- func tableViewSelectionDidChange(_ notification: Notification) {
- if (self.tableView.selectedRow == NSNotFound || self.tableView.selectedRow == -1) {
- return
- }
- let cellView = self.tableView.view(atColumn: 0, row: self.tableView.selectedRow, makeIfNecessary: false) as? KMProfileCellView
- self.addButton.isEnabled = cellView?.detailtextField.stringValue.isEmpty == false
- for i in 0 ..< self.tableView.numberOfRows {
- let cellView = self.tableView.view(atColumn: 0, row: i, makeIfNecessary: false) as? NSTableCellView
- if let data = cellView?.isKind(of: KMProfileCellView.self), data {
- let cellView1 = cellView as! KMProfileCellView
- if (i == self.tableView.selectedRow) {
- // cellView1.detailtextField.textColor = .white
- cellView1.addButton.setTitleColor(NSColor.white)
- } else {
- // cellView1.detailtextField.textColor = NSColor.secondaryLabelColor
- cellView1.addButton.setTitleColor(NSColor.systemBlue)
- }
- }
- }
- let customIndex = self.tableContents.index(of: KMLocalizedString("Custom")) ?? NSNotFound
- if (self.tableView.selectedRow > customIndex) {
- self.removeNewInfoButton.isEnabled = true
- } else {
- self.removeNewInfoButton.isEnabled = false
- }
- }
- }
- extension KMProfileInfoWindowController: NSTextFieldDelegate {
- func controlTextDidChange(_ obj: Notification) {
- let currentRow = self.tableView.selectedRow
- if (currentRow == -1) {
- return
- }
- guard let textField = obj.object as? NSTextField else {
- return
- }
- let cellView = self.tableView.view(atColumn: 0, row: currentRow, makeIfNecessary: false) as? KMProfileCellView
- if (currentRow == 1) {
- KMProfileInfo.shared().fullName = textField.stringValue
- } else if (currentRow == 2) {
- KMProfileInfo.shared().firstName = textField.stringValue
- } else if (currentRow == 3) {
- KMProfileInfo.shared().middleName = textField.stringValue
- } else if (currentRow == 4) {
- KMProfileInfo.shared().lastName = textField.stringValue
- } else if (currentRow == 6) {
- KMProfileInfo.shared().street1 = textField.stringValue
- } else if (currentRow == 7) {
- KMProfileInfo.shared().street2 = textField.stringValue
- } else if (currentRow == 8) {
- KMProfileInfo.shared().city = textField.stringValue
- } else if (currentRow == 9) {
- KMProfileInfo.shared().state = textField.stringValue
- } else if (currentRow == 10) {
- KMProfileInfo.shared().zip = textField.stringValue
- } else if (currentRow == 11) {
- KMProfileInfo.shared().country = textField.stringValue
- } else if (currentRow == 13) {
- KMProfileInfo.shared().email = textField.stringValue
- } else if (currentRow == 14) {
- KMProfileInfo.shared().tel = textField.stringValue
- } else if (currentRow == 16) {
- // [KMProfileInfo.shared().date = textField.stringValue;
- } else if (currentRow == 17) {
- KMProfileInfo.shared().birthDate = textField.stringValue
- } else if (currentRow >= 19 ) {
- let customIndex = currentRow - 19
- if (cellView != nil) {
- let dict = KMProfileInfo.shared().customInfoArray[customIndex] as? [String : Any]
- let originalKey = dict?.keys.first ?? ""
- let originalValue = dict?.values.first as? String ?? ""
- if textField.isEqual(cellView?.textField) {
- let newDict = [textField.stringValue : originalValue]
- KMProfileInfo.shared().replaceObjectInCustomInfoArray(at: customIndex, with: newDict)
- } else if textField.isEqual(cellView?.detailtextField) {
- let newDict = [originalKey : textField.stringValue]
- KMProfileInfo.shared().replaceObjectInCustomInfoArray(at: customIndex, with: newDict)
- }
- }
- }
-
- if cellView?.detailtextField.stringValue.isEmpty == false {
- self.addButton.isEnabled = true
- } else {
- self.addButton.isEnabled = false
- }
- }
-
- func controlTextDidBeginEditing(_ obj: Notification) {
- let textField = obj.object as? NSTextField
- textField?.textColor = NSColor.labelColor
- }
-
- func controlTextDidEndEditing(_ obj: Notification) {
- let textField = obj.object as? NSTextField
- let tag = textField?.tag ?? 0
- let cellView = self.tableView.view(atColumn: 0, row: tag, makeIfNecessary: false) as? KMProfileCellView
- if let data = cellView?.isKind(of: KMProfileCellView.self), data, tag > 0 {
- var placeHoldString = ""
- if (tag == 1) {
- placeHoldString = KMLocalizedString("Add Full Name")
- } else if (tag == 2) {
- placeHoldString = KMLocalizedString("Add First Name")
- } else if (tag == 3) {
- placeHoldString = KMLocalizedString("Add Middle Name")
- } else if (tag == 4) {
- placeHoldString = KMLocalizedString("Add Last Name")
- } else if (tag == 6) {
- placeHoldString = KMLocalizedString("Add Street 1")
- } else if (tag == 7) {
- placeHoldString = KMLocalizedString("Add Street 2")
- } else if (tag == 8) {
- placeHoldString = KMLocalizedString("Add City")
- } else if (tag == 9) {
- placeHoldString = KMLocalizedString("Add State")
- } else if (tag == 10) {
- placeHoldString = KMLocalizedString("Add Zip")
- } else if (tag == 11) {
- placeHoldString = KMLocalizedString("Add Country")
- } else if (tag == 13) {
- placeHoldString = KMLocalizedString("Add Email")
- } else if (tag == 14) {
- placeHoldString = KMLocalizedString("Add Tel")
- } else if (tag == 16) {
- placeHoldString = KMLocalizedString("Add Date")
- } else if (tag == 17) {
- placeHoldString = KMLocalizedString("Add Birth Date")
- }
- if (textField?.stringValue.isEmpty == false) {
- textField?.textColor = NSColor.secondaryLabelColor
- textField?.isHidden = false
- cellView?.addButton.isHidden = true
- } else {
- // textField.hidden = YES; //自定义新增,输入Label后,value为空时推出编辑,就无法填写了
- textField?.placeholderString = ""
- cellView?.addButton.isHidden = false
- cellView?.addButton.tag = tag
- cellView?.addButton.target = self
- cellView?.addButton.action = #selector(addFileName_Add)
- cellView?.addButton.title = placeHoldString
- cellView?.addButton.setTitleColor(NSColor.systemBlue)
- }
- }
- }
- }
- extension KMProfileInfoWindowController: NSMenuItemValidation {
- func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
- let cellView = self.tableView.view(atColumn: 0, row: self.tableView.clickedRow, makeIfNecessary: false) as? NSTableCellView
- if (menuItem.action == #selector(menuItemClicked_Edit)) {
- if let data = cellView?.isKind(of: KMProfileTitleCellView.self), data {
- return false
- } else {
- let cellView1 = cellView as? KMProfileCellView
- if (cellView1?.textField?.stringValue == KMLocalizedString("Date")) {
- return false
- }
- return true
- }
- } 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;
- // }
- if let data = cellView?.isKind(of: KMProfileTitleCellView.self), data {
- return false
- } else {
- let cellView1 = cellView as? KMProfileCellView
- if let data = cellView1?.detailtextField?.stringValue.isEmpty, data {
- return false
- }
- return true
- }
- } 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")]) {
- // return NO;
- // }
- // return YES;
- // }
- if let data = cellView?.isKind(of: KMProfileTitleCellView.self), data {
- return false
- } else {
- let cellView1 = cellView as? KMProfileCellView
- if (cellView1?.textField?.stringValue == KMLocalizedString("Date")) {
- return false
- }
- return true
- }
- }
- return false
- }
- }
|