Class
ColorGroup
Description
The ColorGroup class allows you to do dynamic light/dark target color selection.
Methods
Name |
Parameters |
Returns |
Shared |
---|---|---|---|
platform As Platforms, lightColor As Color, darkColor As Color |
|||
defaultColor As Color |
|||
name As String |
|||
platform As Platforms = Platforms.Current |
|||
name As String |
ColorGroup |
✓ |
|
Enumerations
ColorGroup.Modes
Modes
The mode for the color group (Single, Dual, Named).
Enum
Description
Single
A single color.
Dual
A dual color has separate colors for light and dark modes.
Named
Refers to an OS system color name.
None
No color is selected.
ColorGroup.Platforms
Platforms
The platform for the color group.
Enum
Description
Current
The current platform.
Default
The default platform.
Desktop
Desktop apps.
Mobile
Mobile (Android & iOS) apps.
Web
Web apps.
Method descriptions
ColorGroup.AddColor
AddColor(platform As Platforms, aColor As Color)
Adds a single color to a color group.
ColorGroup.AddColorPair
AddColorPair(platform As Platforms, lightColor As Color, darkColor As Color)
Adds a dual color to a color group.
ColorGroup.AddNamedColor
AddNamedColor(platform As Platforms, name As String)
Adds a named color to a color group.
On iOS if you provide a name for a color that is not supported on the device, the appropriate color as defined in iOS 13 will be returned.
Warning
Named colors are case-sensitive.
ColorGroup.Constructor
Constructor(defaultColor As Color)
Creates a single mode ColorGroup with the specified color.
Note
Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.
ColorGroup.Constructor
Constructor(defaultLightColor As Color, defaultDarkColor As Color)
Creates a dual mode ColorGroup with the specified light and dark colors.
ColorGroup.Constructor
Constructor(name As String)
Creates a named mode ColorGroup with the specified named color.
On iOS if you provide a name for a color that is not supported on the device, the appropriate color as defined in iOS 13 will be returned.
Warning
Named colors are case-sensitive.
ColorGroup.Mode
Mode(platform As Platforms = Platforms.Current) As Modes
The mode for the color group.
ColorGroup.Name
Name As String
The name for the color group.
ColorGroup.NamedColor
NamedColor(name As String) As ColorGroup
Returns the specified named color.
This method is shared.
Raises these exceptions:
UnsupportedOperationException on platforms that don't support named colors.
InvalidArgumentException when passing a name that isn't available on the current platform.
Apple provides documentation for named colors for macOS and iOS.
Additionally
primaryContentBackgroundColor
andsecondaryContentBackgroundColor
are valid names specifically for the macOS alternating table row background colors.For Android, the available colors vary by the OS version. You can find color names at https://developer.android.com/reference/android/R.color.html
For the web, Web Basic, Web Extended and Bootstrap color names can also be used. When using Bootstrap colors, NamedColor will automatically strip off any
--bs-
prefix or-rgb
suffix.Warning
Named colors are case-sensitive.
ColorGroup.ToColor
ToColor As Color
Returns the color from the currently selected device mode.
Important
This method is currently only supported for Android.
ColorGroup.Values
Values As Color()
The color values for the current platform of the color group.
Notes
Comparisons and conversions
A ColorGroup can be directly compared to a Color value to determine if they are the same. It's important to remember of course that you can comparing the known color to the color of the ColorGroup at that moment as a ColorGroup can return different colors based upon the state of the device.
If myColorGroup = Color.Blue Then
Canvas1.DrawingColor = Color.Blue
Else
Canvas1.DrawingColor = Color.Red
End If
When you assign a ColorGroup to a Color property or variable, the color you receive the is color at that moment. For example, in a ColorGroup set to dual color, if you ask for the color when the device is in dark mode, you'll get the dark color.
Assigning a color to a ColorGroup assigns it to the Light Color (the default).
You can assign a named color to a ColorGroup by setting the ColorGroup equal to the name:
Var myColorGroup As ColorGroup
' https://developer.apple.com/documentation/appkit/nscolor/linkcolor
myColorGroup = "linkColor"
For macOS and iOS, Apple provides a complete list of valid named colors. These colors will automatically switch between light and dark modes. Apple's Adaptable System Colors will also automatically switch between light and dark modes but the Fixed Colors will not.
When using a name from Apple's documentation, the case must match as well.
Beside that, you can assign a ColorGroup by setting the ColorGroup equal to the integer value of a color:
Var myColorGroup As ColorGroup
' Red = &hFF0000
myColorGroup = &hFF0000 ' = 16711680
Compatibility
Project Types |
Desktop, Mobile, Web |
Operating Systems |
All |
See also
Object parent class; Color data type; Supporting Dark Mode and More with Color Groups, Supporting Dark Mode topics