Tighten up light-scheme colors (#429)

* Tighten up light-scheme colors

* Tweak more

* Little more
This commit is contained in:
Max Goedjen 2022-12-18 15:16:08 -08:00 committed by GitHub
parent 3b254d33a5
commit 1a362ef955
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 13 deletions

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.885)
case .hovering: case .hovering:
color = .unemphasizedSelectedContentBackgroundColor return colorScheme == .dark ? Color(white: 0.275) : Color(white: 0.82)
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()
} }
} }
} }