Browse Source

Lazy Loading Popover!

pull/92/head
Abhishek 5 years ago
parent
commit
94c9b53ab7
  1. 4
      Clocker/Panel/PanelController.swift
  2. 21
      Clocker/Panel/ParentPanelController.swift

4
Clocker/Panel/PanelController.swift

@ -313,6 +313,10 @@ class PanelController: ParentPanelController {
} }
override func showNotesPopover(forRow row: Int, relativeTo positioningRect: NSRect, andButton target: NSButton!) -> Bool { override func showNotesPopover(forRow row: Int, relativeTo positioningRect: NSRect, andButton target: NSButton!) -> Bool {
if morePopover == nil {
morePopover = NSPopover()
}
guard let popover = morePopover else { guard let popover = morePopover else {
return false return false
} }

21
Clocker/Panel/ParentPanelController.swift

@ -36,7 +36,7 @@ class ParentPanelController: NSWindowController {
private lazy var feedbackWindow: AppFeedbackWindowController = AppFeedbackWindowController.shared() private lazy var feedbackWindow: AppFeedbackWindowController = AppFeedbackWindowController.shared()
private var note: NotesPopover? private var notePopover: NotesPopover?
private lazy var oneWindow: OneWindowController? = { private lazy var oneWindow: OneWindowController? = {
let preferencesStoryboard = NSStoryboard(name: "Preferences", bundle: nil) let preferencesStoryboard = NSStoryboard(name: "Preferences", bundle: nil)
@ -571,8 +571,8 @@ class ParentPanelController: NSWindowController {
popover.animates = true popover.animates = true
if note == nil { if notePopover == nil {
note = NotesPopover(nibName: NSNib.Name.notesPopover, bundle: nil) notePopover = NotesPopover(nibName: NSNib.Name.notesPopover, bundle: nil)
popover.behavior = .applicationDefined popover.behavior = .applicationDefined
popover.delegate = self popover.delegate = self
} }
@ -585,12 +585,12 @@ class ParentPanelController: NSWindowController {
let current = defaults[correctRow] let current = defaults[correctRow]
if let model = TimezoneData.customObject(from: current) { if let model = TimezoneData.customObject(from: current) {
note?.setDataSource(data: model) notePopover?.setDataSource(data: model)
note?.setRow(row: correctRow) notePopover?.setRow(row: correctRow)
note?.set(timezones: defaults) notePopover?.set(timezones: defaults)
popover.contentViewController = note popover.contentViewController = notePopover
note?.set(with: popover) notePopover?.set(with: popover)
return true return true
} }
@ -790,9 +790,10 @@ class ParentPanelController: NSWindowController {
// If the popover is displayed, close it // If the popover is displayed, close it
// Called when preferences are going to be displayed! // Called when preferences are going to be displayed!
func updatePopoverDisplayState() { func updatePopoverDisplayState() {
if note != nil, let isShown = note?.popover?.isShown, isShown { if notePopover != nil, let isShown = notePopover?.popover?.isShown, isShown {
note?.popover?.close() notePopover?.popover?.close()
} }
morePopover = nil
} }
// MARK: Review // MARK: Review

Loading…
Cancel
Save