Merged PR 257808: Writable MSColors and fixes

- MSColors: made all colors writable
- MSColors: added disabled, foregroundRegular, foregroundSecondary generic semantic colors and used them where appropriate
- MSColors: removed unused Persona colors
- MSLabelDemoController: updated code for white-style label's background

Related work items: #710317
This commit is contained in:
Vlad Filyakov 2019-04-17 21:05:43 +00:00
Родитель 3aaa8cdb6b
Коммит bd7c6308a6
2 изменённых файлов: 92 добавлений и 95 удалений

Просмотреть файл

@ -29,7 +29,7 @@ class MSLabelDemoController: DemoController {
func addLabel(text: String, style: MSTextStyle, colorStyle: MSTextColorStyle) -> MSLabel {
let label = MSLabel(style: style, colorStyle: colorStyle)
label.text = text
if label.textColor == MSColors.white {
if colorStyle == .white {
label.backgroundColor = .black
}
container.addArrangedSubview(label)

Просмотреть файл

@ -17,40 +17,40 @@ public final class MSColors: NSObject {
// MARK: Physical
/// #A8A8AC
public static let lightGray: UIColor = #colorLiteral(red: 0.6588235294, green: 0.6588235294, blue: 0.6745098039, alpha: 1)
public static var lightGray: UIColor = #colorLiteral(red: 0.6588235294, green: 0.6588235294, blue: 0.6745098039, alpha: 1)
/// #8E8E93
public static let gray: UIColor = #colorLiteral(red: 0.5568627451, green: 0.5568627451, blue: 0.5764705882, alpha: 1)
public static var gray: UIColor = #colorLiteral(red: 0.5568627451, green: 0.5568627451, blue: 0.5764705882, alpha: 1)
/// #777777
public static let darkGray: UIColor = #colorLiteral(red: 0.4666666667, green: 0.4666666667, blue: 0.4666666667, alpha: 1)
public static var darkGray: UIColor = #colorLiteral(red: 0.4666666667, green: 0.4666666667, blue: 0.4666666667, alpha: 1)
/// #F8F8F8
public static let backgroundLightGray: UIColor = #colorLiteral(red: 0.9725490196, green: 0.9725490196, blue: 0.9725490196, alpha: 1)
public static var backgroundLightGray: UIColor = #colorLiteral(red: 0.9725490196, green: 0.9725490196, blue: 0.9725490196, alpha: 1)
/// #F1F1F1
public static let backgroundGray: UIColor = #colorLiteral(red: 0.9450980392, green: 0.9450980392, blue: 0.9450980392, alpha: 1)
public static var backgroundGray: UIColor = #colorLiteral(red: 0.9450980392, green: 0.9450980392, blue: 0.9450980392, alpha: 1)
/// #E1E1E1
public static let borderLightGray: UIColor = #colorLiteral(red: 0.8823529412, green: 0.8823529412, blue: 0.8823529412, alpha: 1)
public static var borderLightGray: UIColor = #colorLiteral(red: 0.8823529412, green: 0.8823529412, blue: 0.8823529412, alpha: 1)
/// #C8C8C8
public static let borderGray: UIColor = #colorLiteral(red: 0.7843137255, green: 0.7843137255, blue: 0.7843137255, alpha: 1)
public static var borderGray: UIColor = #colorLiteral(red: 0.7843137255, green: 0.7843137255, blue: 0.7843137255, alpha: 1)
/// #FFFFFF
public static let white: UIColor = .white
public static var white: UIColor = .white
/// #222222
public static let black: UIColor = #colorLiteral(red: 0.1333333333, green: 0.1333333333, blue: 0.1333333333, alpha: 1)
public static var black: UIColor = #colorLiteral(red: 0.1333333333, green: 0.1333333333, blue: 0.1333333333, alpha: 1)
/// #E8484C
public static let error: UIColor = #colorLiteral(red: 0.9098039216, green: 0.2823529412, blue: 0.2980392157, alpha: 1)
public static var error: UIColor = #colorLiteral(red: 0.9098039216, green: 0.2823529412, blue: 0.2980392157, alpha: 1)
/// #FFF3F4
public static let lightError: UIColor = #colorLiteral(red: 1, green: 0.9529411765, blue: 0.9568627451, alpha: 1)
public static var lightError: UIColor = #colorLiteral(red: 1, green: 0.9529411765, blue: 0.9568627451, alpha: 1)
/// #574305
public static let warning: UIColor = #colorLiteral(red: 0.3411764706, green: 0.262745098, blue: 0.01960784314, alpha: 1)
public static var warning: UIColor = #colorLiteral(red: 0.3411764706, green: 0.262745098, blue: 0.01960784314, alpha: 1)
/// #E2DDCC
public static let lightWarning: UIColor = #colorLiteral(red: 0.8862745098, green: 0.8666666667, blue: 0.8, alpha: 1)
public static var lightWarning: UIColor = #colorLiteral(red: 0.8862745098, green: 0.8666666667, blue: 0.8, alpha: 1)
// MARK: Avatar background colors
public static let avatarBackgroundColors: [UIColor] = [
public static var avatarBackgroundColors: [UIColor] = [
#colorLiteral(red: 0.4588235294, green: 0.0431372549, blue: 0.1098039216, alpha: 1), // #750B1C
#colorLiteral(red: 0.6431372549, green: 0.1490196078, blue: 0.1725490196, alpha: 1), // #A4262C
#colorLiteral(red: 0.8196078431, green: 0.2039215686, blue: 0.2196078431, alpha: 1), // #D13438
@ -73,130 +73,127 @@ public final class MSColors: NSObject {
// MARK: Semantic
// TODO: Add semantic colors describing colors used for particular control elements (must reference physical colors)
public static var background: UIColor = white
public static var buttonImage: UIColor = foregroundSecondary
public static var disabled: UIColor = borderLightGray
public static var foregroundRegular: UIColor = black
public static var foregroundSecondary: UIColor = gray
public static let activityIndicator: UIColor = lightGray
public static let background: UIColor = white
public static let buttonImage: UIColor = gray
public static let centeredLabelText: UIColor = primary
public static let separator: UIColor = borderLightGray
// Add semantic colors describing colors used for particular control elements
public static var activityIndicator: UIColor = lightGray
public static var centeredLabelText: UIColor = primary
public static var separator: UIColor = borderLightGray
public struct Action {
public static let text: UIColor = primary
public static let textHighlighted: UIColor = primary.withAlphaComponent(0.4)
public static let textDestructive: UIColor = error
public static let textDestructiveHighlighted: UIColor = error.withAlphaComponent(0.4)
public static var text: UIColor = primary
public static var textHighlighted: UIColor = primary.withAlphaComponent(0.4)
public static var textDestructive: UIColor = error
public static var textDestructiveHighlighted: UIColor = error.withAlphaComponent(0.4)
}
public struct Avatar {
public static let text: UIColor = white
public static var text: UIColor = white
}
public struct Badge {
public static let background: UIColor = primary.withAlphaComponent(0.24)
public static let backgroundDisabled: UIColor = backgroundLightGray
public static let backgroundError: UIColor = lightError
public static let backgroundErrorSelected: UIColor = error
public static let backgroundSelected: UIColor = primary
public static let backgroundWarning: UIColor = lightWarning
public static let backgroundWarningSelected: UIColor = warning
public static let text: UIColor = primary
public static let textDisabled: UIColor = darkGray
public static let textError: UIColor = error
public static let textErrorSelected: UIColor = lightError
public static let textSelected: UIColor = white
public static let textWarning: UIColor = warning
public static let textWarningSelected: UIColor = lightWarning
public static var background: UIColor = primary.withAlphaComponent(0.24)
public static var backgroundDisabled: UIColor = backgroundLightGray
public static var backgroundError: UIColor = lightError
public static var backgroundErrorSelected: UIColor = error
public static var backgroundSelected: UIColor = primary
public static var backgroundWarning: UIColor = lightWarning
public static var backgroundWarningSelected: UIColor = warning
public static var text: UIColor = primary
public static var textDisabled: UIColor = darkGray
public static var textError: UIColor = error
public static var textErrorSelected: UIColor = lightError
public static var textSelected: UIColor = white
public static var textWarning: UIColor = warning
public static var textWarningSelected: UIColor = lightWarning
}
public struct BadgeField {
public static let label: UIColor = gray
public static let placeholder: UIColor = lightGray
public static var label: UIColor = gray
public static var placeholder: UIColor = lightGray
}
public struct Button {
public static let background: UIColor = .clear
public static let backgroundFilled: UIColor = primary
public static let backgroundFilledDisabled: UIColor = borderLightGray
public static let backgroundFilledHighlighted: UIColor = primary.withAlphaComponent(0.5)
public static let border: UIColor = primary.withAlphaComponent(0.2)
public static let borderDisabled: UIColor = borderLightGray
public static let borderHighlighted: UIColor = primary.withAlphaComponent(0.08)
public static let title: UIColor = primary
public static let titleDisabled: UIColor = borderGray
public static let titleHighlighted: UIColor = primary.withAlphaComponent(0.4)
public static let titleWithFilledBackground: UIColor = white
public static var background: UIColor = .clear
public static var backgroundFilled: UIColor = primary
public static var backgroundFilledDisabled: UIColor = disabled
public static var backgroundFilledHighlighted: UIColor = primary.withAlphaComponent(0.5)
public static var border: UIColor = primary.withAlphaComponent(0.2)
public static var borderDisabled: UIColor = disabled
public static var borderHighlighted: UIColor = primary.withAlphaComponent(0.08)
public static var title: UIColor = primary
public static var titleDisabled: UIColor = borderGray
public static var titleHighlighted: UIColor = primary.withAlphaComponent(0.4)
public static var titleWithFilledBackground: UIColor = white
}
public struct CalendarView {
public struct TodayCell {
public static let background: UIColor = white
public static var background: UIColor = MSColors.background
}
public struct DayCell {
// TODO: Readd availability colors?
public static let textColorPrimary: UIColor = darkGray
public static let textColorSecondary: UIColor = black
public static let backgroundColorPrimary: UIColor = background
public static let backgroundColorSecondary: UIColor = backgroundLightGray
public static let todayTextColorNormal: UIColor = primary
public static let todayTextColorEmphasized: UIColor = black
public static let normalTextColor: UIColor = gray
public static let highlightedCircleColor: UIColor = gray
public static let selectedCircleNormalColor: UIColor = primary
public static var textColorPrimary: UIColor = darkGray
public static var textColorSecondary: UIColor = black
public static var backgroundColorPrimary: UIColor = background
public static var backgroundColorSecondary: UIColor = backgroundLightGray
public static var todayTextColorNormal: UIColor = primary
public static var todayTextColorEmphasized: UIColor = black
public static var normalTextColor: UIColor = gray
public static var highlightedCircleColor: UIColor = gray
public static var selectedCircleNormalColor: UIColor = primary
}
}
public struct DateTimePicker {
public static let text: UIColor = gray
public static let textEmphasized: UIColor = primary
public static var text: UIColor = gray
public static var textEmphasized: UIColor = primary
}
public struct HUD {
public static let activityIndicatorView: UIColor = white
public static let background: UIColor = black.withAlphaComponent(0.9)
public static let text: UIColor = white
public static var activityIndicatorView: UIColor = white
public static var background: UIColor = black.withAlphaComponent(0.9)
public static var text: UIColor = white
}
public struct PageCardPresenter {
public static let currentPageIndicatorTintColor: UIColor = white
public static let pageIndicatorTintColor: UIColor = white.withAlphaComponent(0.5)
}
public struct Persona {
public static let name: UIColor = black
public static let subtitle: UIColor = gray
public static let background: UIColor = white
public static let backgroundSelected: UIColor = backgroundGray
public static var currentPageIndicatorTintColor: UIColor = white
public static var pageIndicatorTintColor: UIColor = white.withAlphaComponent(0.5)
}
public struct PopupMenu {
public struct Item {
public static let imageSelected: UIColor = primary
public static let title: UIColor = black
public static let titleSelected: UIColor = primary
public static let titleDisabled: UIColor = borderLightGray
public static let subtitle: UIColor = gray
public static let subtitleSelected: UIColor = primary
public static let subtitleDisabled: UIColor = borderLightGray
public static var imageSelected: UIColor = primary
public static var title: UIColor = foregroundRegular
public static var titleSelected: UIColor = primary
public static var titleDisabled: UIColor = disabled
public static var subtitle: UIColor = foregroundSecondary
public static var subtitleSelected: UIColor = primary
public static var subtitleDisabled: UIColor = disabled
}
public static let sectionHeader: UIColor = darkGray
public static var sectionHeader: UIColor = darkGray
}
public struct ResizingHandle {
public static let background: UIColor = white
public static let mark: UIColor = borderLightGray
public static var background: UIColor = MSColors.background
public static var mark: UIColor = borderLightGray
}
public struct SegmentedControl {
public static let buttonTextNormal: UIColor = black
public static let buttonTextSelected: UIColor = primary
public static let selectionBarNormal: UIColor = primary
public static let selectionBarDisabled: UIColor = gray
public static var buttonTextNormal: UIColor = black
public static var buttonTextSelected: UIColor = primary
public static var selectionBarNormal: UIColor = primary
public static var selectionBarDisabled: UIColor = gray
}
public struct TableViewCell {
public static let background: UIColor = white
public static let backgroundSelected: UIColor = backgroundGray
public static var background: UIColor = MSColors.background
public static var backgroundSelected: UIColor = backgroundGray
}
private override init() {
@ -217,9 +214,9 @@ public final class MSColors: NSObject {
public var color: UIColor {
switch self {
case .regular:
return MSColors.black
return MSColors.foregroundRegular
case .secondary:
return MSColors.gray
return MSColors.foregroundSecondary
case .white:
return MSColors.white
case .primary: