Import Coucou 0.1.9 (Louis-CFM/coucou@83708fe), Mac app only

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maksarsanjeev
2026-10-06 19:34:32 +03:00
commit 53b4f60da1
158 changed files with 29442 additions and 0 deletions
@@ -0,0 +1,43 @@
import SwiftUI
import CoreGraphics
// Hex color helpers shared by the Mac app and the iPhone app.
// MARK: - Color from hex string
extension Color {
init(hex: String) {
let h = hex.trimmingCharacters(in: CharacterSet(charactersIn: "#"))
let val = UInt64(h, radix: 16) ?? 0
let r = Double((val >> 16) & 0xFF) / 255
let g = Double((val >> 8) & 0xFF) / 255
let b = Double( val & 0xFF) / 255
self.init(red: r, green: g, blue: b)
}
}
// MARK: - CGColor from hex string
func cgColorFromHex(_ hex: String) -> CGColor? {
let h = hex.trimmingCharacters(in: CharacterSet(charactersIn: "#"))
guard let val = UInt64(h, radix: 16) else { return nil }
let r = CGFloat((val >> 16) & 0xFF) / 255
let g = CGFloat((val >> 8) & 0xFF) / 255
let b = CGFloat( val & 0xFF) / 255
return CGColor(red: r, green: g, blue: b, alpha: 1)
}
extension CGColor {
static func from(_ hex: String) -> CGColor {
cgColorFromHex(hex) ?? CGColor(gray: 0.5, alpha: 1)
}
}
#if !os(macOS)
// CGColor.white / .black / .clear only exist on macOS; BotEngine uses them.
extension CGColor {
static var white: CGColor { CGColor(gray: 1, alpha: 1) }
static var black: CGColor { CGColor(gray: 0, alpha: 1) }
static var clear: CGColor { CGColor(gray: 0, alpha: 0) }
}
#endif