diff --git a/MastodonSDK/Sources/MastodonUI/Extension/UIColor+Extensions.swift b/MastodonSDK/Sources/MastodonUI/Extension/UIColor+Extensions.swift new file mode 100644 index 000000000..c43aed3d8 --- /dev/null +++ b/MastodonSDK/Sources/MastodonUI/Extension/UIColor+Extensions.swift @@ -0,0 +1,20 @@ +// Copyright © 2023 Mastodon gGmbH. All rights reserved. + +import UIKit + +extension UIColor { + public var hexValue: String { + let components = cgColor.components + + let red: CGFloat = components?[0] ?? 0.0 + let green: CGFloat = components?[1] ?? 0.0 + let blue: CGFloat = components?[2] ?? 0.0 + + return String( + format: "#%02lX%02lX%02lX", + lroundf(Float(red * 255)), + lroundf(Float(green * 255)), + lroundf(Float(blue * 255)) + ) + } +} diff --git a/WidgetExtension/Assets.xcassets/Colors/Blurple.colorset/Contents.json b/WidgetExtension/Assets.xcassets/Colors/Blurple.colorset/Contents.json new file mode 100644 index 000000000..09bdab5a3 --- /dev/null +++ b/WidgetExtension/Assets.xcassets/Colors/Blurple.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.984", + "green" : "0.173", + "red" : "0.333" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.980", + "green" : "0.541", + "red" : "0.522" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/WidgetExtension/Assets.xcassets/Colors/Contents.json b/WidgetExtension/Assets.xcassets/Colors/Contents.json new file mode 100644 index 000000000..6e965652d --- /dev/null +++ b/WidgetExtension/Assets.xcassets/Colors/Contents.json @@ -0,0 +1,9 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "provides-namespace" : true + } +} diff --git a/WidgetExtension/Assets.xcassets/Colors/TextColor.colorset/Contents.json b/WidgetExtension/Assets.xcassets/Colors/TextColor.colorset/Contents.json new file mode 100644 index 000000000..d89071918 --- /dev/null +++ b/WidgetExtension/Assets.xcassets/Colors/TextColor.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.000", + "green" : "0.000", + "red" : "0.000" + } + }, + "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/WidgetExtension/Variants/Hashtag/HashtagWidgetView.swift b/WidgetExtension/Variants/Hashtag/HashtagWidgetView.swift index 22ec056b3..da1d6bc7b 100644 --- a/WidgetExtension/Variants/Hashtag/HashtagWidgetView.swift +++ b/WidgetExtension/Variants/Hashtag/HashtagWidgetView.swift @@ -91,8 +91,8 @@ struct HashtagWidgetView: View { extension Text { init(statusHTML htmlString: String, fontSize: Int = 16, fontWeight: Int = 400, colorScheme: ColorScheme = .light) { - let textColor = (colorScheme == .light) ? "#000000" : "#FFFFFF" - let accentColor = (colorScheme == .light) ? "#563ACC" : "#858AFA" + let textColor = (UIColor(named: "Colors/TextColor") ?? UIColor.gray).hexValue + let accentColor = (UIColor(named: "Colors/Blurple") ?? UIColor.purple).hexValue let fullHTML = """