I'm working on an App that usually will be used in dark environments and the light output from the display should be reduced to a minimum. So I want to have a low-contrast with really black backgrounds and grey text.
If someone is using that App in another environment the user might consider a usual view with higher contrast - so for example the usual dark or light mode.
Of course I can set all background
s to black and foregroundColor
s to gray, but that would require a lot of code to give the user the possibility back to change to usual light / dark mode.
MY approach was rather to write an extension
to ColorScheme
, starting with
public extension ColorScheme {
static let evenDarker = ColorScheme.dark
}
and adjusting the colorvalues from there.
In my imaginiation this should have created a copy of .dark
. I can call
let contentView = ContentView()
.environment(\.colorScheme, .evenDarker)
and it builds without problems, unfortunately it does show the system-setting (as defined on the device) and not a copy of the dark mode. Calling the same view with .dark
or .light
overrides the system setting though.
Besides I can't find any list or documentation of possible values in the ColorScheme - e.g. how to override the default background color from gray to black. Did anyone ever get this or something similar get to work?