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
1 changed files with 10 additions and 13 deletions

View File

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