Ratul SarnaFormat Swift sources14662849 months agoHistory
35 lines · 1.2 KB · Swift
RawDownload
import SwiftUI extension EnvironmentValues {    @Entry var menuItemHighlighted: Bool = false} enum MenuHighlightStyle {    static let selectionText = Color(nsColor: .selectedMenuItemTextColor)    static let normalPrimaryText = Color(nsColor: .controlTextColor)    static let normalSecondaryText = Color(nsColor: .secondaryLabelColor)     static func primary(_ highlighted: Bool) -> Color {        highlighted ? self.selectionText : self.normalPrimaryText    }     static func secondary(_ highlighted: Bool) -> Color {        highlighted ? self.selectionText : self.normalSecondaryText    }     static func error(_ highlighted: Bool) -> Color {        highlighted ? self.selectionText : Color(nsColor: .systemRed)    }     static func progressTrack(_ highlighted: Bool) -> Color {        highlighted ? self.selectionText.opacity(0.22) : Color(nsColor: .tertiaryLabelColor).opacity(0.22)    }     static func progressTint(_ highlighted: Bool, fallback: Color) -> Color {        highlighted ? self.selectionText : fallback    }     static func selectionBackground(_ highlighted: Bool) -> Color {        highlighted ? Color(nsColor: .selectedContentBackgroundColor) : .clear    }}