From cabd788d44089fb08ea6f34d6fdb90083edec2d0 Mon Sep 17 00:00:00 2001 From: gemcoder21 <104884878+gemcoder21@users.noreply.github.com> Date: Thu, 13 Jun 2024 00:53:11 +0100 Subject: [PATCH] Remove Colors.xcassets in favor of programatic hex values --- Gem.xcodeproj/project.pbxproj | 4 - Gem/Resources/Colors.xcassets/Contents.json | 6 -- .../black.colorset/Contents.json | 38 ---------- .../blue.colorset/Contents.json | 38 ---------- .../blueDark.colorset/Contents.json | 38 ---------- .../gray.colorset/Contents.json | 38 ---------- .../grayBackground.colorset/Contents.json | 38 ---------- .../grayDarkBackground.colorset/Contents.json | 38 ---------- .../grayLight.colorset/Contents.json | 38 ---------- .../grayVeryLight.colorset/Contents.json | 38 ---------- .../green.colorset/Contents.json | 38 ---------- .../greenLight.colorset/Contents.json | 38 ---------- .../Contents.json | 38 ---------- .../orange.colorset/Contents.json | 29 ------- .../red.colorset/Contents.json | 38 ---------- .../redLight.colorset/Contents.json | 38 ---------- .../secondaryText.colorset/Contents.json | 38 ---------- .../white.colorset/Contents.json | 38 ---------- .../whiteSolid.colorset/Contents.json | 20 ----- Packages/Style/Sources/Colors.swift | 76 ++++++++++++++----- .../{ => Extentions}/Color+Style.swift | 17 ++++- .../Sources/Extentions/UIColor+Style.swift | 22 ++++++ 22 files changed, 96 insertions(+), 648 deletions(-) delete mode 100644 Gem/Resources/Colors.xcassets/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/black.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/blue.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/blueDark.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/gray.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/grayBackground.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/grayDarkBackground.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/grayLight.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/grayVeryLight.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/green.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/greenLight.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/launchScreenBackground.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/orange.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/red.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/redLight.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/secondaryText.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/white.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/whiteSolid.colorset/Contents.json rename Packages/Style/Sources/{ => Extentions}/Color+Style.swift (71%) create mode 100644 Packages/Style/Sources/Extentions/UIColor+Style.swift diff --git a/Gem.xcodeproj/project.pbxproj b/Gem.xcodeproj/project.pbxproj index 279743dc..af6e9b6f 100644 --- a/Gem.xcodeproj/project.pbxproj +++ b/Gem.xcodeproj/project.pbxproj @@ -28,7 +28,6 @@ C34C7CFA29FF19A3009EEC21 /* WelcomeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C34C7CF929FF19A3009EEC21 /* WelcomeViewModel.swift */; }; C34C7CFD29FF2A07009EEC21 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = C34C7CFF29FF2A07009EEC21 /* Localizable.strings */; }; C34C7D0829FF5818009EEC21 /* Localized.swift in Sources */ = {isa = PBXBuildFile; fileRef = C34C7D0629FF5817009EEC21 /* Localized.swift */; }; - C34C7D0A29FF58CB009EEC21 /* Colors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C34C7D0929FF58CB009EEC21 /* Colors.xcassets */; }; C34C7D132A006E9F009EEC21 /* SecretPhraseViewableModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C34C7D122A006E9F009EEC21 /* SecretPhraseViewableModel.swift */; }; C3549B3129C42E8F00B4BE01 /* AssetListViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3549B3029C42E8F00B4BE01 /* AssetListViewModelTests.swift */; }; C3549B3529C4396A00B4BE01 /* AssetViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3549B3429C4396A00B4BE01 /* AssetViewModelTests.swift */; }; @@ -275,7 +274,6 @@ C34C7D0029FF2A0B009EEC21 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = ""; }; C34C7D0129FF57CA009EEC21 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; C34C7D0629FF5817009EEC21 /* Localized.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Localized.swift; sourceTree = ""; }; - C34C7D0929FF58CB009EEC21 /* Colors.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Colors.xcassets; sourceTree = ""; }; C34C7D122A006E9F009EEC21 /* SecretPhraseViewableModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecretPhraseViewableModel.swift; sourceTree = ""; }; C3549B3029C42E8F00B4BE01 /* AssetListViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AssetListViewModelTests.swift; sourceTree = ""; }; C3549B3429C4396A00B4BE01 /* AssetViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AssetViewModelTests.swift; sourceTree = ""; }; @@ -1520,7 +1518,6 @@ C30952B9299C39D80004C0F9 /* Gem.entitlements */, C34C7D0629FF5817009EEC21 /* Localized.swift */, C34C7CFF29FF2A07009EEC21 /* Localizable.strings */, - C34C7D0929FF58CB009EEC21 /* Colors.xcassets */, C30952B7299C39D80004C0F9 /* Images.xcassets */, ); path = Resources; @@ -1695,7 +1692,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - C34C7D0A29FF58CB009EEC21 /* Colors.xcassets in Resources */, C34C7CFD29FF2A07009EEC21 /* Localizable.strings in Resources */, C3866B612A803B19004FB60C /* Launch Screen.storyboard in Resources */, DF1167112BC36240000F8C8C /* PrivacyInfo.xcprivacy in Resources */, diff --git a/Gem/Resources/Colors.xcassets/Contents.json b/Gem/Resources/Colors.xcassets/Contents.json deleted file mode 100644 index 73c00596..00000000 --- a/Gem/Resources/Colors.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/black.colorset/Contents.json b/Gem/Resources/Colors.xcassets/black.colorset/Contents.json deleted file mode 100644 index 2f1745a6..00000000 --- a/Gem/Resources/Colors.xcassets/black.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x22", - "green" : "0x22", - "red" : "0x22" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "1.000", - "green" : "1.000", - "red" : "1.000" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/blue.colorset/Contents.json b/Gem/Resources/Colors.xcassets/blue.colorset/Contents.json deleted file mode 100644 index 5609bb43..00000000 --- a/Gem/Resources/Colors.xcassets/blue.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xE6", - "green" : "0x5B", - "red" : "0x2D" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xE6", - "green" : "0x5B", - "red" : "0x2D" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/blueDark.colorset/Contents.json b/Gem/Resources/Colors.xcassets/blueDark.colorset/Contents.json deleted file mode 100644 index 4bc032d7..00000000 --- a/Gem/Resources/Colors.xcassets/blueDark.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xC5", - "green" : "0x42", - "red" : "0x17" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xC5", - "green" : "0x42", - "red" : "0x17" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/gray.colorset/Contents.json b/Gem/Resources/Colors.xcassets/gray.colorset/Contents.json deleted file mode 100644 index 9310753a..00000000 --- a/Gem/Resources/Colors.xcassets/gray.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.506", - "green" : "0.506", - "red" : "0.506" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x81", - "green" : "0x81", - "red" : "0x81" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/grayBackground.colorset/Contents.json b/Gem/Resources/Colors.xcassets/grayBackground.colorset/Contents.json deleted file mode 100644 index 4c8ef69a..00000000 --- a/Gem/Resources/Colors.xcassets/grayBackground.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xF7", - "green" : "0xF2", - "red" : "0xF2" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x1E", - "green" : "0x1C", - "red" : "0x1C" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/grayDarkBackground.colorset/Contents.json b/Gem/Resources/Colors.xcassets/grayDarkBackground.colorset/Contents.json deleted file mode 100644 index eb228215..00000000 --- a/Gem/Resources/Colors.xcassets/grayDarkBackground.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xF0", - "green" : "0xE6", - "red" : "0xE6" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x1E", - "green" : "0x1C", - "red" : "0x1C" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/grayLight.colorset/Contents.json b/Gem/Resources/Colors.xcassets/grayLight.colorset/Contents.json deleted file mode 100644 index 5801c238..00000000 --- a/Gem/Resources/Colors.xcassets/grayLight.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.592", - "green" : "0.600", - "red" : "0.592" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.592", - "green" : "0.600", - "red" : "0.592" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/grayVeryLight.colorset/Contents.json b/Gem/Resources/Colors.xcassets/grayVeryLight.colorset/Contents.json deleted file mode 100644 index 3a962ac1..00000000 --- a/Gem/Resources/Colors.xcassets/grayVeryLight.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xF4", - "green" : "0xF4", - "red" : "0xF4" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x33", - "green" : "0x33", - "red" : "0x33" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/green.colorset/Contents.json b/Gem/Resources/Colors.xcassets/green.colorset/Contents.json deleted file mode 100644 index a6828852..00000000 --- a/Gem/Resources/Colors.xcassets/green.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.427", - "green" : "0.604", - "red" : "0.106" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.427", - "green" : "0.604", - "red" : "0.106" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/greenLight.colorset/Contents.json b/Gem/Resources/Colors.xcassets/greenLight.colorset/Contents.json deleted file mode 100644 index 286e06c4..00000000 --- a/Gem/Resources/Colors.xcassets/greenLight.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.961", - "green" : "0.984", - "red" : "0.918" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x3C", - "green" : "0x42", - "red" : "0x27" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/launchScreenBackground.colorset/Contents.json b/Gem/Resources/Colors.xcassets/launchScreenBackground.colorset/Contents.json deleted file mode 100644 index 4b4777b0..00000000 --- a/Gem/Resources/Colors.xcassets/launchScreenBackground.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xFF", - "green" : "0xFF", - "red" : "0xFF" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x22", - "green" : "0x22", - "red" : "0x22" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/orange.colorset/Contents.json b/Gem/Resources/Colors.xcassets/orange.colorset/Contents.json deleted file mode 100644 index 5257126d..00000000 --- a/Gem/Resources/Colors.xcassets/orange.colorset/Contents.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x14", - "green" : "0x93", - "red" : "0xFF" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/red.colorset/Contents.json b/Gem/Resources/Colors.xcassets/red.colorset/Contents.json deleted file mode 100644 index 5a04d1d2..00000000 --- a/Gem/Resources/Colors.xcassets/red.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x4E", - "green" : "0x4E", - "red" : "0xF8" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x4E", - "green" : "0x4E", - "red" : "0xF8" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/redLight.colorset/Contents.json b/Gem/Resources/Colors.xcassets/redLight.colorset/Contents.json deleted file mode 100644 index 84df143a..00000000 --- a/Gem/Resources/Colors.xcassets/redLight.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.949", - "green" : "0.949", - "red" : "1.000" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x30", - "green" : "0x2D", - "red" : "0x46" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/secondaryText.colorset/Contents.json b/Gem/Resources/Colors.xcassets/secondaryText.colorset/Contents.json deleted file mode 100644 index 99588300..00000000 --- a/Gem/Resources/Colors.xcassets/secondaryText.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.506", - "green" : "0.506", - "red" : "0.506" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.506", - "green" : "0.506", - "red" : "0.506" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/white.colorset/Contents.json b/Gem/Resources/Colors.xcassets/white.colorset/Contents.json deleted file mode 100644 index 6ca89b1c..00000000 --- a/Gem/Resources/Colors.xcassets/white.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "1.000", - "green" : "1.000", - "red" : "1.000" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x22", - "green" : "0x22", - "red" : "0x22" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/whiteSolid.colorset/Contents.json b/Gem/Resources/Colors.xcassets/whiteSolid.colorset/Contents.json deleted file mode 100644 index 97650a1a..00000000 --- a/Gem/Resources/Colors.xcassets/whiteSolid.colorset/Contents.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "1.000", - "green" : "1.000", - "red" : "1.000" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Packages/Style/Sources/Colors.swift b/Packages/Style/Sources/Colors.swift index e8523058..f478bf60 100644 --- a/Packages/Style/Sources/Colors.swift +++ b/Packages/Style/Sources/Colors.swift @@ -1,21 +1,63 @@ import SwiftUI public struct Colors { - public static let white = Color("white", bundle: .main) - public static let whiteSolid = Color("whiteSolid", bundle: .main) - public static let black = Color("black", bundle: .main) - public static let blue = Color("blue", bundle: .main) - public static let blueDark = Color("blueDark", bundle: .main) - public static let red = Color("red", bundle: .main) - public static let redLight = Color("redLight", bundle: .main) - public static let green = Color("green", bundle: .main) - public static let orange = Color("orange", bundle: .main) - public static let orangeLight = Color("orangeLight", bundle: .main) - public static let greenLight = Color("greenLight", bundle: .main) - public static let gray = Color("gray", bundle: .main) - public static let grayBackground = Color("grayBackground", bundle: .main) - public static let grayDarkBackground = Color("grayDarkBackground", bundle: .main) - public static let grayLight = Color("grayLight", bundle: .main) - public static let grayVeryLight = Color("grayVeryLight", bundle: .main) - public static let secondaryText = Color("secondaryText", bundle: .main) + public static let white = Color.dynamicColor("#FFFFFF", dark: "#222222") + public static let whiteSolid = Color.dynamicColor("FFFFFF") + public static let black = Color.dynamicColor("#222222", dark: "FFFFFF") + public static let blue = Color.dynamicColor("#2D5BE6") + public static let blueDark = Color.dynamicColor("#1742C5") + public static let red = Color.dynamicColor("#F84E4E") + public static let redLight = Color.dynamicColor("#FFF1F1", dark: "#462D30") + public static let green = Color.dynamicColor("#1B9A6C") + public static let greenLight = Color.dynamicColor("EAFAF5", dark: "27423C") + public static let orange = Color.dynamicColor("#FF9314") + public static let gray = Color.dynamicColor("#818181") + public static let grayLight = Color.dynamicColor("#969996") + public static let grayVeryLight = Color.dynamicColor("#F4F4F4", dark: "#333333") + public static let grayBackground = Color.dynamicColor("#F2F2F7", dark: "#1C1C1E") + public static let grayDarkBackground = Color.dynamicColor("#E6E6F0", dark: "#1C1C1E") + public static let secondaryText = Color.dynamicColor("#818181") } + +#Preview { + let colors: [(name: String, color: Color)] = [ + ("White", Colors.white), + ("White Solid", Colors.whiteSolid), + ("Black", Colors.black), + ("Blue", Colors.blue), + ("Blue Dark", Colors.blueDark), + ("Red", Colors.red), + ("Red Light", Colors.redLight), + ("Green", Colors.green), + ("Green Light", Colors.greenLight), + ("Orange", Colors.orange), + ("Gray", Colors.gray), + ("Gray Light", Colors.grayLight), + ("Gray Very Light", Colors.grayVeryLight), + ("Gray Background", Colors.grayBackground), + ("Gray Dark Background", Colors.grayDarkBackground), + ("Secondary Text", Colors.secondaryText), + ] + return List { + ForEach(colors, id: \.name) { color in + HStack { + Text(color.name) + .multilineTextAlignment(.leading) + .frame(width: 174) + + RoundedRectangle(cornerRadius: 4) + .fill(color.color) + .padding(Spacing.extraSmall) + .colorScheme(.light) + + RoundedRectangle(cornerRadius: 4) + .fill(color.color) + .padding(Spacing.extraSmall) + .colorScheme(.dark) + } + .listRowInsets(EdgeInsets(top: 0, leading: 8, bottom: 0, trailing: 0)) + } + } + .listStyle(InsetGroupedListStyle()) +} + diff --git a/Packages/Style/Sources/Color+Style.swift b/Packages/Style/Sources/Extentions/Color+Style.swift similarity index 71% rename from Packages/Style/Sources/Color+Style.swift rename to Packages/Style/Sources/Extentions/Color+Style.swift index da3aba2c..5d49b480 100644 --- a/Packages/Style/Sources/Color+Style.swift +++ b/Packages/Style/Sources/Extentions/Color+Style.swift @@ -1,7 +1,14 @@ +// Copyright (c). Gem Wallet. All rights reserved. + import Foundation import SwiftUI extension Color { + + public var uiColor: UIColor { + return UIColor(self) + } + public init(hex: String) { let hex = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted) var int: UInt64 = 0 @@ -27,7 +34,13 @@ extension Color { ) } - public var uiColor: UIColor { - return UIColor(self) + // hex values + static func dynamicColor(_ light: String, dark: String? = .none) -> Color { + let lightColor = Color(hex: light) + let darkColor: Color? = switch dark { + case .some(let color): Color(color) + case .none: .none + } + return UIColor.dynamicColor(lightColor, dark: darkColor) } } diff --git a/Packages/Style/Sources/Extentions/UIColor+Style.swift b/Packages/Style/Sources/Extentions/UIColor+Style.swift new file mode 100644 index 00000000..a71a5f71 --- /dev/null +++ b/Packages/Style/Sources/Extentions/UIColor+Style.swift @@ -0,0 +1,22 @@ +// Copyright (c). Gem Wallet. All rights reserved. + +import Foundation +import SwiftUI + +extension UIColor { + + public var color: Color { + Color(self) + } + + public class func dynamicColor(_ light: Color, dark: Color?) -> Color { + return UIColor { + switch $0.userInterfaceStyle { + case .dark: + return dark?.uiColor ?? light.uiColor + default: + return light.uiColor + } + }.color + } +}