Browse Source

Better naming.

pull/113/head
Abhishek Banthia 3 years ago
parent
commit
f3e08e46d3
  1. 26
      Clocker/Preferences/General/PreferencesDataSource.swift
  2. 23
      Clocker/Preferences/General/PreferencesViewController.swift
  3. 1
      Clocker/Preferences/Menu Bar/StatusItemHandler.swift

26
Clocker/Preferences/General/PreferencesDataSource.swift

@ -12,12 +12,12 @@ struct PreferencesDataSourceConstants {
}
protocol PreferenceSelectionUpdates: AnyObject {
func markAsFavorite(_ dataObject: TimezoneData)
func unfavourite(_ dataObject: TimezoneData)
func refreshTimezoneTable()
func refreshMainTableView()
func tableViewSelectionDidChange(_ status: Bool)
func table(didClick tableColumn: NSTableColumn)
func preferenceSelectionDataSourceMarkAsFavorite(_ dataObject: TimezoneData)
func preferenceSelectionDataSourceUnfavourite(_ dataObject: TimezoneData)
func preferenceSelectionDataSourceRefreshTimezoneTable()
func preferenceSelectionDataSourceRefreshMainTableView()
func preferenceSelectionDataSourceTableViewSelectionDidChange(_ status: Bool)
func preferenceSelectionDataSourceTable(didClick tableColumn: NSTableColumn)
}
class PreferencesDataSource: NSObject {
@ -35,7 +35,7 @@ class PreferencesDataSource: NSObject {
extension PreferencesDataSource: NSTableViewDelegate {
func tableViewSelectionDidChange(_ notification: Notification) {
if let tableView = notification.object as? NSTableView {
updateDelegate?.tableViewSelectionDidChange(tableView.selectedRow == -1)
updateDelegate?.preferenceSelectionDataSourceTableViewSelectionDidChange(tableView.selectedRow == -1)
}
}
@ -79,7 +79,7 @@ extension PreferencesDataSource: NSTableViewDelegate {
tableView.reloadData()
updateDelegate?.refreshMainTableView()
updateDelegate?.preferenceSelectionDataSourceRefreshMainTableView()
tableView.deselectRow(tableView.selectedRow)
@ -91,7 +91,7 @@ extension PreferencesDataSource: NSTableViewDelegate {
}
func tableView(_: NSTableView, didClick tableColumn: NSTableColumn) {
updateDelegate?.table(didClick: tableColumn)
updateDelegate?.preferenceSelectionDataSourceTable(didClick: tableColumn)
}
}
@ -146,13 +146,13 @@ extension PreferencesDataSource: NSTableViewDataSource {
dataObject.isFavourite = isFavouriteValue.intValue
insert(timezone: dataObject, at: row)
dataObject.isFavourite == 1 ?
updateDelegate?.markAsFavorite(dataObject) :
updateDelegate?.unfavourite(dataObject)
updateDelegate?.preferenceSelectionDataSourceMarkAsFavorite(dataObject) :
updateDelegate?.preferenceSelectionDataSourceUnfavourite(dataObject)
updateStatusItem()
updateDelegate?.refreshTimezoneTable()
updateDelegate?.preferenceSelectionDataSourceRefreshTimezoneTable()
}
updateDelegate?.refreshMainTableView()
updateDelegate?.preferenceSelectionDataSourceRefreshMainTableView()
}
private func setNewLabel(_ label: String, for dataObject: TimezoneData, at row: Int) {

23
Clocker/Preferences/General/PreferencesViewController.swift

@ -98,6 +98,14 @@ class PreferencesViewController: ParentViewController {
name: NSNotification.Name.customLabelChanged,
object: nil)
NotificationCenter.default.addObserver(forName: NSUbiquitousKeyValueStore.didChangeExternallyNotification,
object: self,
queue: OperationQueue.main) { [weak self] _ in
if let sSelf = self {
sSelf.refreshTimezoneTableView()
}
}
refreshTimezoneTableView()
setup()
@ -483,8 +491,7 @@ extension PreferencesViewController {
let words = searchString.components(separatedBy: CharacterSet.whitespacesAndNewlines)
searchString = words.joined(separator: CLEmptyString)
let url = "https://maps.googleapis.com/maps/api/geocode/json?address=\(searchString)&key=\(geocodingKey)&language=\(userPreferredLanguage)"
return url
return "https://maps.googleapis.com/maps/api/geocode/json?address=\(searchString)&key=\(geocodingKey)&language=\(userPreferredLanguage)"
}
private func presentError(_ errorMessage: String) {
@ -977,27 +984,27 @@ extension PreferencesViewController {
}
extension PreferencesViewController: PreferenceSelectionUpdates {
func markAsFavorite(_ dataObject: TimezoneData) {
func preferenceSelectionDataSourceMarkAsFavorite(_ dataObject: TimezoneData) {
_markAsFavorite(dataObject)
}
func unfavourite(_ dataObject: TimezoneData) {
func preferenceSelectionDataSourceUnfavourite(_ dataObject: TimezoneData) {
_unfavourite(dataObject)
}
func refreshTimezoneTable() {
func preferenceSelectionDataSourceRefreshTimezoneTable() {
refreshTimezoneTableView()
}
func refreshMainTableView() {
func preferenceSelectionDataSourceRefreshMainTableView() {
refreshMainTable()
}
func tableViewSelectionDidChange(_ status: Bool) {
func preferenceSelectionDataSourceTableViewSelectionDidChange(_ status: Bool) {
deleteButton.isEnabled = !status
}
func table(didClick tableColumn: NSTableColumn) {
func preferenceSelectionDataSourceTable(didClick tableColumn: NSTableColumn) {
if tableColumn.identifier.rawValue == "favouriteTimezone" {
return
}

1
Clocker/Preferences/Menu Bar/StatusItemHandler.swift

@ -138,7 +138,6 @@ class StatusItemHandler: NSObject {
parentView = nil
let menubarTimezones = DataStore.shared().menubarTimezones() ?? []
if menubarTimezones.isEmpty {
currentState = .icon
return

Loading…
Cancel
Save