RSDColorRules

open class RSDColorRules

The color rules object is a concrete implementation of the design rules used for a given version of the SageResearch frameworks. A module can use this class as-is or override the class to enforce a set of rules pinned to the tasks included within a module. This is important to allow a module to be validated against a given UI/UX. The frameworks can later change to reflect new devices, OS changes, and design system updates to incorporate the results of more design studies.

  • The version for the color rules. If the design rules change with future versions of this framework, then the current version number should be rev’d as well and any changes to this rule set that are not additive include logic to return the previous rules associated with a previous version.

    Declaration

    Swift

    open private(set) var version: Int {
      get
      }
  • The color palette for this color design.

    Declaration

    Swift

    open var palette: RSDColorPalette! { get set }
  • MARK: Default colors The named category or style for a given color.

    See more

    Declaration

    Swift

    public enum Style : String, Codable, CaseIterable
  • The default color to use for a given color style.

    Declaration

    Swift

    open func mapping(for style: Style) -> RSDColorMapping?

    Parameters

    style

    The color style.

    Return Value

    The color mapping for that style.

  • Look in the palette for a mapping for the given color. This method is used to allow returning a color mapping from a background color.

    Note

    The primary use-case for this is where an app defines a view controller in a storyboard and uses @IBDesignable to render the screen in the storyboard. This allows setting colors by using the defaults and getting the color mapping from the background.

    Declaration

    Swift

    open func mapping(for color: RSDColor) -> RSDColorMapping?

    Parameters

    style

    The color (UIColor or NSColor) that maps to one of the colors defined in the palette.

    Return Value

    The color mapping if found.

  • Background color for views that should have a light background.

    • Default: white

    Declaration

    Swift

    open var backgroundLight: RSDColorTile { get }
  • Background color for views that should use the primary color tile for the background.

    • Default: primary

    Declaration

    Swift

    open var backgroundPrimary: RSDColorTile { get }
  • Tinted image icon color on a given background. Typically, this is used in a collection or table view.

    • Default: If the background uses light style then `white` else `accent`

    Declaration

    Swift

    open func tintedIconColor(on background: RSDColorTile) -> RSDColor
  • Color for text throughout the app.

    • Default: (version 0)

      If the background uses light style then `white`
      else `veryDarkGray`
      
    • Default: (version 1)

      If the background uses light style then `text.light`
      else if this is detail text then `text.medium`
      else `text.dark`
      
    • Default: (version 2)

      See the Sage Design System table.
      https://www.figma.com/file/nvoSigSxbFuWzGXgUZAf8M/DigitalHealth_DesignSystem-Master?node-id=3837%3A16223
      

    Declaration

    Swift

    open func textColor(on background: RSDColorTile, for textType: RSDDesignSystem.TextType) -> RSDColor

    Parameters

    background

    The background of the text UI element.

    textType

    The type size of the UI element.

    Return Value

    The text color to use.

  • MARK: Buttons Tinted button color on a given background.

    • Default:

      If the background uses light style then `white`
      else if the background is the primary palette color then `secondary`
      else `veryDarkGray`
      

    Declaration

    Swift

    open func tintedButtonColor(on background: RSDColorTile) -> RSDColor

    Parameters

    background

    The background of the text UI element.

    Return Value

    The color to use for tinted buttons.

  • Underlined text button.

  • Default: (version 0)

    If the background is `white` *and* the primary color uses light style then
        `primary`
    Else
        `text color`
    
  • Default: (version 1)

    The text color for `body` text on the given background.
    
  • Seealso

    textColor(on:, for:)

    Declaration

    Swift

    open func underlinedTextButton(on background: RSDColorTile, state: RSDControlState) -> RSDColor

    Parameters

    background

    The background of the text button.

    state

    The UI control state of the button.

    Return Value

    The color to use for the underlined text button.

  • The color mapping to use on a given background for a given button type.

    • Default:

      If the button type is `primary` then
          if the background is `white` then `secondary` else `white`
      else `veryLightGray` color
      

    Declaration

    Swift

    open func roundedButton(on background: RSDColorTile, buttonType: RSDDesignSystem.ButtonType) -> RSDColorMapping

    Parameters

    background

    The background of the button.

    buttonType

    The type of button (primary or secondary).

    Return Value

    The color mapping to use for a rounded button.

  • The color for a rounded button for a given state and button type.

    • Default:

      If selected AND secondary
          then the primary color at 25% opacity
      
      Else
      
      Get the "normal" tile color for the button type. This depends upon whether or not the button is
      a primary button and whether or not it is displayed on a white background.
      
      If highlighted OR selected
          then if the tile is `veryLight` then one shade darker
          else one shade lighter
      Else If disabled
          then 35% opacity
      Else
          return the color tile as-is.
      

    Declaration

    Swift

    open func roundedButton(on background: RSDColorTile, with buttonType: RSDDesignSystem.ButtonType, forState state: RSDControlState) -> RSDColor

    Parameters

    background

    The background of the button.

    buttonType

    The type of button (primary or secondary).

    state

    The UI control state of the button.

    Return Value

    The color to use for the background of a rounded button.

  • The color for the background of a colored button for a given state and button type.

    • Default:

      Get the "normal" tile color for the button type. This depends upon whether or not the button is
      a primary button and whether or not it is displayed on a white background.
      
      If highlighted OR selected
          then if the tile is `veryLight` then one shade darker
          else one shade lighter
      If disabled
          then 35% opacity
      Else
          return the color tile as-is.
      

    Declaration

    Swift

    open func coloredButton(on background: RSDColorTile, forMapping tile: RSDColorMapping, forState state: RSDControlState) -> RSDColor

    Parameters

    background

    The background of the button.

    tile

    The default color tile for the button background.

    state

    The UI control state of the button.

    Return Value

    The color to use for the background of a rounded button.

  • The text color for a rounded button.

    • Default:

      Get the "normal" tile color for the button type. This depends upon whether or not the button is
      a primary button and whether or not it is displayed on a white background.
      
      Next, get the text color to use on the returned tile color.
      
      If state is `disabled` and *not* uses light style
          then 35% opacity
      Else
          return the text color
      

    Declaration

    Swift

    open func roundedButtonText(on background: RSDColorTile, with buttonType: RSDDesignSystem.ButtonType, forState state: RSDControlState) -> RSDColor

    Parameters

    background

    The background of the button.

    buttonType

    The type of button (primary or secondary).

    state

    The UI control state of the button.

    Return Value

    The color to use for the text of a rounded button.

  • MARK: Progress indicator colors The colors to use with a progress bar.

    • Default:

      filled = `accent`
      unfilled = `veryLightGray`
      

    Declaration

    Swift

    open func progressBar(on background: RSDColorTile) -> (filled: RSDColor, unfilled: RSDColor)

    Parameters

    background

    The background for the progress bar.

    Return Value

    • filled: The fill color for the progress bar which marks progress.
    • unfilled: The unfilled (background) color for the progress bar.
  • The colors to use with a progress dial.

    • Default:

      `unfilled` is always `veryLightGray`
      
      If the style is defined then
          filled = `style.light`
          inner = `style`
      
      Else if the inner color is `white`
          filled = `accent`
          inner = `white`
      
      Else if the inner color is `clear`
          filled = `accent`
          inner = `clear` with light style of the background
      
      Else
          filled = `inner.light`
          inner = inner
      

    Declaration

    Swift

    open func progressDial(on background: RSDColorTile,
                           style: Style? = nil,
                           innerColor: RSDColor = RSDColor.clear,
                           usesLightStyle: Bool = false) -> (filled: RSDColor, unfilled: RSDColor, inner: RSDColorTile)

    Parameters

    background

    The background color tile for the view that this view lives in.

    style

    The style of the dial. If non-nil, this will be used as the color of the inner circle.

    innerColor

    The inner color of the dial set by the nib or storyboard.

    usesLightStyle

    The light-style set by the nib or storyboard.

    Return Value

    • filled: The fill color for the progress bar which marks progress.
    • unfilled: The unfilled (background) color for the progress bar.
    • inner: The inner color to use for the progress bar.
  • For a completion gradient background, what are the min and max colors?

    • Default: successGreen.light and successGreen

    Declaration

    Swift

    open func completionGradient() -> (RSDColorTile, RSDColorTile)

    Return Value

    • 0: The min color tile.
    • 1: The max color tile.
  • MARK: Choice Selection cell The background color tile for the table cell.

    • Default:

      If selected
          then lightest color tile within the same family as the primary color
      Else
          `white`
      

    Declaration

    Swift

    open func tableCellBackground(on background: RSDColorTile, isSelected: Bool) -> RSDColorTile

    Parameters

    background

    The background of the table.

    isSelected

    Whether or not the cell is selected.

    Return Value

    The color tile for the background of the cell.

  • The background color tile for the table section header.

    • Default: white

    Declaration

    Swift

    open func tableSectionBackground(on background: RSDColorTile) -> RSDColorTile

    Parameters

    background

    The background of the table.

    Return Value

    The color tile for the background of the section header.

  • The cell separator line for a table cell or other border.

    • Default: veryLightGray

    Declaration

    Swift

    open var separatorLine: RSDColor { get }
  • The color of an underline for a text field.

    • Default: accent

    Declaration

    Swift

    open func textFieldUnderline(on background: RSDColorTile) -> RSDColor

    Parameters

    background

    The background of the table cell.

    Return Value

    The color of the underline.