72 lines
2.2 KiB
Swift
72 lines
2.2 KiB
Swift
//
|
|
// Color+Extensions.swift
|
|
// medmap
|
|
//
|
|
// Created by RSA on 28/08/2026.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
// MARK: - Color + Hex Initializer
|
|
extension Color {
|
|
init(hex: String) {
|
|
let hexString = hex.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
.replacingOccurrences(of: "#", with: "")
|
|
|
|
var rgbValue: UInt64 = 0
|
|
Scanner(string: hexString).scanHexInt64(&rgbValue)
|
|
|
|
let length = hexString.count
|
|
|
|
let r, g, b, a: Double
|
|
|
|
switch length {
|
|
case 6: // RRGGBB
|
|
r = Double((rgbValue & 0xFF0000) >> 16) / 255.0
|
|
g = Double((rgbValue & 0x00FF00) >> 8) / 255.0
|
|
b = Double(rgbValue & 0x0000FF) / 255.0
|
|
a = 1.0
|
|
case 8: // RRGGBBAA
|
|
r = Double((rgbValue & 0xFF000000) >> 24) / 255.0
|
|
g = Double((rgbValue & 0x00FF0000) >> 16) / 255.0
|
|
b = Double((rgbValue & 0x0000FF00) >> 8) / 255.0
|
|
a = Double(rgbValue & 0x000000FF) / 255.0
|
|
default:
|
|
r = 0
|
|
g = 0
|
|
b = 0
|
|
a = 1.0
|
|
}
|
|
|
|
self.init(.sRGB, red: r, green: g, blue: b, opacity: a)
|
|
}
|
|
}
|
|
|
|
// MARK: - Custom App Colors
|
|
extension Color {
|
|
static let appBackground = Color(hex: "#4078BC")
|
|
static let appBackgroundDark = Color(hex: "##4078BC")
|
|
|
|
static let appBackgroundLight = Color(hex: "#4078BC")
|
|
|
|
|
|
|
|
|
|
static let appSecondary = Color(hex: "#F7F7F8")
|
|
static let appAccent = Color(hex: "#4A2EC2")
|
|
static let appTextPrimary = Color(hex: "#333333")
|
|
static let appBorder = Color(hex: "#E5E5E5")
|
|
|
|
// MARK: - Login screen (matches src/main/resources/static/css/login.css)
|
|
static let loginFieldBackground = Color(hex: "#5D8CC6")
|
|
static let loginFieldBorder = Color.white.opacity(0.45)
|
|
static let loginPlaceholder = Color.white.opacity(0.6)
|
|
static let loginButtonBackground = Color(hex: "#88BDFF")
|
|
static let loginButtonText = Color(hex: "#0A2647")
|
|
static let loginErrorText = Color(hex: "#FFE08A")
|
|
|
|
// Add more as needed, e.g.:
|
|
// static let appError = Color(hex: "#FF3B30")
|
|
// static let appSuccess = Color(hex: "#34C759")
|
|
}
|