Tighten up light-scheme colors

This commit is contained in:
Max Goedjen 2022-12-18 15:04:00 -08:00
parent 3b254d33a5
commit 58523f1e68
No known key found for this signature in database

View File

@ -8,6 +8,7 @@ struct CopyableView: View {
var text: String var text: String
@State private var interactionState: InteractionState = .normal @State private var interactionState: InteractionState = .normal
@Environment(\.colorScheme) private var colorScheme
var body: some View { var body: some View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
@ -77,38 +78,32 @@ struct CopyableView: View {
} }
var backgroundColor: Color { var backgroundColor: Color {
let color: NSColor
switch interactionState { switch interactionState {
case .normal: case .normal:
color = .windowBackgroundColor return colorScheme == .dark ? Color(white: 0.2) : Color(white: 0.85)
case .hovering: case .hovering:
color = .unemphasizedSelectedContentBackgroundColor return colorScheme == .dark ? Color(white: 0.275) : Color(white: 0.75)
case .clicking: case .clicking:
color = .selectedContentBackgroundColor return .accentColor
} }
return Color(color)
} }
var primaryTextColor: Color { var primaryTextColor: Color {
let color: NSColor
switch interactionState { switch interactionState {
case .normal, .hovering: case .normal, .hovering:
color = .textColor return Color(.textColor)
case .clicking: case .clicking:
color = .white return .white
} }
return Color(color)
} }
var secondaryTextColor: Color { var secondaryTextColor: Color {
let color: NSColor
switch interactionState { switch interactionState {
case .normal, .hovering: case .normal, .hovering:
color = .secondaryLabelColor return Color(.secondaryLabelColor)
case .clicking: case .clicking:
color = .white return .white
} }
return Color(color)
} }
func copy() { func copy() {
@ -128,7 +123,9 @@ struct CopyableView_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
Group { Group {
CopyableView(title: "Title", image: Image(systemName: "figure.wave"), text: "Hello world.") CopyableView(title: "Title", image: Image(systemName: "figure.wave"), text: "Hello world.")
.padding()
CopyableView(title: "Title", image: Image(systemName: "figure.wave"), text: "Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. ") CopyableView(title: "Title", image: Image(systemName: "figure.wave"), text: "Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. ")
.padding()
} }
} }
} }