Skip to content

Commit

Permalink
Resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ktiays authored and unixzii committed Jan 16, 2022
1 parent 396604a commit 2f06aaf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
4 changes: 3 additions & 1 deletion Sources/CyanUI/PopupButton/PopupButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,10 @@ class _PopupButtonTriggerView<S>: NSView where S: StringProtocol {
}

deinit {
if let localMonitor = localMonitor, let globalMonitor = globalMonitor {
if let localMonitor = localMonitor {
NSEvent.removeMonitor(localMonitor)
}
if let globalMonitor = globalMonitor {
NSEvent.removeMonitor(globalMonitor)
}
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/CyanUI/PopupButton/PopupList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ struct _PopupList<Content>: View where Content: StringProtocol {
init(contents: [Content], selection: Binding<Content?>, mouseUpEventPublisher: AnyPublisher<NSPoint, Never>) {
_selection = selection
self.mouseUpEventPublisher = mouseUpEventPublisher

// TODO: Optimize the handling of duplicated items.
self.contents = contents.enumerated().filter { index, element in
contents.firstIndex(of: element) == index
}.map { $0.element }
Expand Down
14 changes: 6 additions & 8 deletions Sources/CyanUI/VisualEffectView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ public struct VisualEffectView: NSViewRepresentable {
self.blendingMode = blendingMode
}

public func makeNSView(context: Context) -> NSVisualEffectView {
let effectView = NSVisualEffectView()
effectView.state = state
effectView.blendingMode = blendingMode
effectView.material = material
return effectView
}
public func makeNSView(context: Context) -> NSVisualEffectView { .init() }

public func updateNSView(_ nsView: NSVisualEffectView, context: Context) { }
public func updateNSView(_ nsView: NSVisualEffectView, context: Context) {
nsView.state = state
nsView.blendingMode = blendingMode
nsView.material = material
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,10 @@ import Foundation

@propertyWrapper public class Weak<T> where T: AnyObject {

private weak var _wrappedValue: T?

public var wrappedValue: T? {
get { _wrappedValue }
set { _wrappedValue = newValue }
}
public weak var wrappedValue: T?

public init(wrappedValue: T?) {
_wrappedValue = wrappedValue
self.wrappedValue = wrappedValue
}

}

0 comments on commit 2f06aaf

Please sign in to comment.