Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions modules/UI/Sources/Theme/Colors/ColorPalette.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// ColorPalette.swift
// UI
//
// Copyright 2022 Thoughtworks, Inc. All rights reserved.
//

import Foundation
import SwiftUI

public enum ColorPalette: String {
// black
case black
// white
case white
// gray
case gray50
case gray100
case gray200
case gray300
case gray400
case gray500
case gray600
case gray700
case gray800
case gray900
// blue
case blue
// light blue
case lightBlue50
case lightBlue300
// light green
case lightGreen200
case lightGreen700
// purple
case purple200
case purple500
case purple700
// teal
case teal200
case teal700
// red
case red700
case red900
}

public extension ColorPalette {
var color: Color {
Color(self.rawValue, bundle: Bundle.uiBundle)
}
}
58 changes: 23 additions & 35 deletions modules/UI/Sources/Theme/Colors/Colors.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ColorName.swift
// Colors.swift
// UI
//
// Copyright 2022 Thoughtworks, Inc. All rights reserved.
Expand All @@ -9,43 +9,31 @@ import Foundation
import SwiftUI

public enum Colors: String {
// black
case black
// white
case white
// gray
case gray50
case gray100
case gray200
case gray300
case gray400
case gray500
case gray600
case gray700
case gray800
case gray900
// blue
case blue
// light blue
case lightBlue50
case lightBlue300
// light green
case lightGreen200
case lightGreen700
// purple
case purple200
case purple500
case purple700
// teal
case teal200
case teal700
// red
case red700
case red900
case primary
case primaryVariant
case secondary
case secondaryVariant
case background
case surface
case error
case onPrimary
case onSecondary
case onBackground
case onSurface
case onError
case statusBarColor
}

public extension Colors {
var color: Color {
Color(self.rawValue, bundle: Bundle.uiBundle)
switch self {
case .statusBarColor:
// Colors枚举相当于颜色值仓库,其他所有使用颜色值的地方都可以从这里取值。
// 然后ThemeColors,是基于UI Guide设计的一个应用主题色集合,它可以自定义颜色值,也可以使用Colors里面定义好的色值。
// 所以,这里的statusBarColor就是使用了Colors里面定义好的blue。
return ColorPalette.blue.color
default:
return Color(self.rawValue, bundle: .uiBundle)
}
}
}
39 changes: 0 additions & 39 deletions modules/UI/Sources/Theme/Colors/ThemeColors.swift

This file was deleted.

Loading