Skip to content

Commit

Permalink
move color definition of the component out of Colors.swift file (micr…
Browse files Browse the repository at this point in the history
  • Loading branch information
harrieshin authored Jul 23, 2020
1 parent 4e1b2ba commit f0f8387
Show file tree
Hide file tree
Showing 26 changed files with 408 additions and 294 deletions.
10 changes: 10 additions & 0 deletions ios/FluentUI/Badge Field/BadgeField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ public protocol BadgeFieldDelegate: AnyObject {
@objc optional func badgeFieldShouldReturn(_ badgeField: BadgeField) -> Bool
}

// MARK: - BadgeField Colors

public extension Colors {
struct BadgeField {
public static var background: UIColor = surfacePrimary
public static var label: UIColor = textSecondary
public static var placeholder: UIColor = textSecondary
}
}

// MARK: - BadgeField

@available(*, deprecated, renamed: "BadgeField")
Expand Down
18 changes: 18 additions & 0 deletions ios/FluentUI/Badge Field/BadgeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,24 @@ public protocol BadgeViewDelegate {
func didTapSelectedBadge(_ badge: BadgeView)
}

// MARK: - Badge Colors

public extension Colors {
struct Badge {
public static var backgroundDisabled = UIColor(light: surfaceSecondary, dark: gray700)
public static var backgroundError = UIColor(light: Palette.dangerTint40.color, dark: Palette.dangerTint30.color)
public static var backgroundErrorSelected: UIColor = error
public static var backgroundWarning = UIColor(light: Palette.warningTint40.color, dark: Palette.warningTint30.color)
public static var backgroundWarningSelected: UIColor = warning
public static var textSelected: UIColor = textOnAccent
public static var textDisabled: UIColor = textSecondary
public static var textError: UIColor = Palette.dangerShade20.color
public static var textErrorSelected: UIColor = textOnAccent
public static var textWarning = UIColor(light: Palette.warningShade30.color, dark: Palette.warningPrimary.color)
public static var textWarningSelected = UIColor(light: Palette.warningShade30.color, dark: .black)
}
}

// MARK: - BadgeView

/**
Expand Down
32 changes: 31 additions & 1 deletion ios/FluentUI/Calendar/Views/CalendarViewDayMonthCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,37 @@

import UIKit

// MARK: CalendarViewDayMonthCell
// MARK: Calendar Colors

public extension Colors {
struct Calendar {
public struct Day {
public static var textPrimary = UIColor(light: Colors.textSecondary, dark: Colors.textPrimary)
public static var textSecondary: UIColor = Colors.textSecondary
public static var textSelected: UIColor = textOnAccent
public static var backgroundPrimary = UIColor(light: Calendar.background, dark: surfaceSecondary)
public static var backgroundSecondary = UIColor(light: surfaceSecondary, dark: Calendar.background)
public static var circleHighlighted: UIColor = gray400
}
public struct Today {
public static var background: UIColor = Calendar.Day.backgroundPrimary
}
public struct WeekdayHeading {
public struct Light {
public static var textRegular = UIColor(light: gray600, lightHighContrast: gray700, dark: textPrimary)
public static var textWeekend: UIColor = textSecondary
public static var background: UIColor = Calendar.background
}
public struct Dark {
public static var textRegular: UIColor = textOnAccent
public static var textWeekend: UIColor = textOnAccent.withAlphaComponent(0.7)
}
}
public static var background = UIColor(light: surfacePrimary, dark: surfaceTertiary)
}
}

// MARK: - CalendarViewDayMonthCell

class CalendarViewDayMonthCell: CalendarViewDayCell {
struct Constants {
Expand Down
8 changes: 8 additions & 0 deletions ios/FluentUI/Controls/ActivityIndicatorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ enum ActivityIndicatorStrokeThickness: CGFloat {
case xLarge = 4
}

// MARK: - ActivityIndicator Colors

public extension Colors {
struct ActivityIndicator {
public static var foreground: UIColor = iconSecondary
}
}

// MARK: - ActivityIndicatorView

/**
Expand Down
12 changes: 12 additions & 0 deletions ios/FluentUI/Controls/Button.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ public enum ButtonStyle: Int, CaseIterable {
}
}

// MARK: - Button Colors

public extension Colors {
struct Button {
public static var background: UIColor = .clear
public static var backgroundFilledDisabled: UIColor = surfaceQuaternary
public static var borderDisabled: UIColor = surfaceQuaternary
public static var titleDisabled: UIColor = textDisabled
public static var titleWithFilledBackground: UIColor = textOnAccent
}
}

// MARK: - Button

/// By default, `titleLabel`'s `adjustsFontForContentSizeCategory` is set to true to automatically update its font when device's content size category changes
Expand Down
37 changes: 37 additions & 0 deletions ios/FluentUI/Controls/Label.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,43 @@

import UIKit

// MARK: TextColorStyle

@available(*, deprecated, renamed: "TextColorStyle")
public typealias MSTextColorStyle = TextColorStyle

@objc(MSFTextColorStyle)
public enum TextColorStyle: Int, CaseIterable {
case regular
case secondary
case white
case primary
case error
case warning
case disabled

public func color(for window: UIWindow) -> UIColor {
switch self {
case .regular:
return Colors.textPrimary
case .secondary:
return Colors.textSecondary
case .white:
return .white
case .primary:
return Colors.primary(for: window)
case .error:
return Colors.error
case .warning:
return Colors.warning
case .disabled:
return Colors.textDisabled
}
}
}

// MARK: - Label

@available(*, deprecated, renamed: "Label")
public typealias MSLabel = Label

Expand Down
10 changes: 10 additions & 0 deletions ios/FluentUI/Controls/ResizingHandleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@

import UIKit

// MARK: ResizingHandle Colors

public extension Colors {
struct ResizingHandle {
public static var mark: UIColor = iconSecondary
}
}

// MARK: - ResizingHandleView

@available(*, deprecated, renamed: "ResizingHandleView")
public typealias MSResizingHandleView = ResizingHandleView

Expand Down
25 changes: 25 additions & 0 deletions ios/FluentUI/Controls/SearchBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,31 @@

import UIKit

// MARK: Search Colors

public extension Colors {
struct SearchBar {
public struct DarkContent {
public static var background = UIColor(light: surfaceTertiary, dark: LightContent.background)
public static var cancelButton = UIColor(light: textSecondary, dark: LightContent.cancelButton)
public static var clearIcon = UIColor(light: iconPrimary, dark: LightContent.clearIcon)
public static var placeholderText = UIColor(light: textSecondary, dark: LightContent.placeholderText)
public static var searchIcon = UIColor(light: iconPrimary, dark: LightContent.searchIcon)
public static var text = UIColor(light: textDominant, dark: LightContent.text)
public static var tint = UIColor(light: iconSecondary, dark: LightContent.tint)
}
public struct LightContent {
public static var background = UIColor(light: UIColor.black.withAlphaComponent(0.2), dark: gray700, darkElevated: gray600)
public static var cancelButton: UIColor = LightContent.text
public static var clearIcon = UIColor(light: iconOnAccent, dark: textSecondary)
public static var placeholderText = UIColor(light: textOnAccent, dark: textSecondary)
public static var searchIcon: UIColor = placeholderText
public static var text = UIColor(light: textOnAccent, dark: textDominant)
public static var tint: UIColor = LightContent.text
}
}
}

// MARK: SearchBarDelegate

@available(*, deprecated, renamed: "SearchBarDelegate")
Expand Down
21 changes: 21 additions & 0 deletions ios/FluentUI/Controls/SegmentedControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@

import UIKit

// MARK: SegmentedControl Colors

public extension Colors {
struct SegmentedControl {
public struct Tabs {
public static var background: UIColor = NavigationBar.background
public static var backgroundDisabled: UIColor = background
public static var segmentText: UIColor = textSecondary
public static var segmentTextDisabled: UIColor = surfaceQuaternary
public static var segmentTextSelectedAndDisabled: UIColor = textDisabled
public static var selectionDisabled: UIColor = textDisabled
}

public struct Switch {
public static var segmentText = UIColor(light: textOnAccent, dark: textPrimary)
public static var selection = UIColor(light: Colors.surfacePrimary, dark: Colors.surfaceQuaternary)
public static var selectionDisabled: UIColor = selection
}
}
}

// MARK: SegmentedControl

@available(*, deprecated, renamed: "SegmentedControl")
Expand Down
17 changes: 17 additions & 0 deletions ios/FluentUI/Controls/Separator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@

import UIKit

// MARK: Separator Colors

public extension Colors {
struct Separator {
public static var `default`: UIColor = dividerOnPrimary
public static var shadow: UIColor = dividerOnSecondary
}
// Objective-C support
@objc static var separatorDefault: UIColor { return Separator.default }
}

// MARK: - SeparatorStyle

@available(*, deprecated, renamed: "SeparatorStyle")
public typealias MSSeparatorStyle = SeparatorStyle

Expand All @@ -23,6 +36,8 @@ public enum SeparatorStyle: Int {
}
}

// MARK: - SeparatorOrientation

@available(*, deprecated, renamed: "SeparatorOrientation")
public typealias MSSeparatorOrientation = SeparatorOrientation

Expand All @@ -32,6 +47,8 @@ public enum SeparatorOrientation: Int {
case vertical
}

// MARK: - Separator

@available(*, deprecated, renamed: "Separator")
public typealias MSSeparator = Separator

Expand Down
14 changes: 14 additions & 0 deletions ios/FluentUI/Controls/TwoLineTitleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ public protocol TwoLineTitleViewDelegate: AnyObject {
func twoLineTitleViewDidTapOnTitle(_ twoLineTitleView: TwoLineTitleView)
}

// MARK: - TwoLineTitle Colors

public extension Colors {
struct TwoLineTitle {
// light style is used Navigation.Primary.background. Dark style is used for Navigation.System.background
public static var titleDark: UIColor = Navigation.System.title
public static var titleLight: UIColor = Navigation.Primary.title
public static var subtitleDark = UIColor(light: textSecondary, dark: textDominant)
public static var subtitleLight: UIColor = titleLight
public static var titleAccessoryLight = UIColor(light: iconOnAccent, dark: iconPrimary)
public static var titleAccessoryDark = UIColor(light: iconSecondary, dark: iconPrimary)
}
}

// MARK: - TwoLineTitleView

@available(*, deprecated, renamed: "TwoLineTitleView")
Expand Down
Loading

0 comments on commit f0f8387

Please sign in to comment.