From 2a6fd8b84f2f261cff44a5ead8488d7311d5daa4 Mon Sep 17 00:00:00 2001 From: Dominic Drees Date: Thu, 24 Apr 2025 00:27:57 +0200 Subject: [PATCH] cleanup Color extension, add init documentation --- Sora/Utils/Extensions/Color.swift | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Sora/Utils/Extensions/Color.swift b/Sora/Utils/Extensions/Color.swift index a81dee7..92c63ae 100644 --- a/Sora/Utils/Extensions/Color.swift +++ b/Sora/Utils/Extensions/Color.swift @@ -8,11 +8,14 @@ import SwiftUI extension Color { - init(hex: String) { - var hexSanitized = hex.trimmingCharacters(in: .whitespacesAndNewlines) - var rgb: UInt64 = 0 - Scanner(string: hexSanitized).scanHexInt64(&rgb) + /// Intitialize SwiftUI Color via HEX String + /// + /// - Parameters: + /// - hex: The hex color string. Dont include: "#" prefix or leading / trailing whitespaces ( " " ) + init(hex: String) { + var rgb: UInt64 = 0 + Scanner(string: hex).scanHexInt64(&rgb) self.init( .sRGB, red: Double((rgb & 0xFF0000) >> 16) / 255.0,