From 9f2f184b299a22719b36aeb4872165fd2255e128 Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Mon, 24 Jul 2023 19:05:37 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20darModeColor=20func?= =?UTF-8?q?=20,=20init?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Color/Color+init.swift | 32 ++++++------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/xquare-design-system-iOS/Sources/Color/Color+init.swift b/xquare-design-system-iOS/Sources/Color/Color+init.swift index f5434f2..c8de394 100644 --- a/xquare-design-system-iOS/Sources/Color/Color+init.swift +++ b/xquare-design-system-iOS/Sources/Color/Color+init.swift @@ -9,29 +9,15 @@ public enum ColorType: String { case netural = "Netural" case neutralVariant = "Neutral Variant" } - -public enum ColorState { - case base - case on - case container - case onContainer - - func colorState(_ type: ColorType) -> String { - switch self { - case .base: - return type.rawValue - case .on: - return "on \(type.rawValue)" - case .container: - return "\(type.rawValue) Container" - case .onContainer: - return "On \(type.rawValue) Container" - } - } -} - extension Color { - init(type: ColorType, _ state: ColorState) { - self.init(state.colorState(type), bundle: Bundle.module) + init(type: ColorType, _ palette: Int) { + self.init("\(type.rawValue) \(palette)", bundle: Bundle.module) + } + + public func darkModeColor(_ dark: Color) -> Color { + let color = UIColor { (UITraitCollection: UITraitCollection) -> UIColor in + return UITraitCollection.userInterfaceStyle == .dark ? UIColor(dark) : UIColor(self) + } + return Color(uiColor: color) } }