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 {
if morePopover == nil {
morePopover = NSPopover()
}
guard let popover = morePopover else {
return false
}

21
Clocker/Panel/ParentPanelController.swift

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

Loading…
Cancel
Save