111 lines
3.8 KiB
Swift
111 lines
3.8 KiB
Swift
import SwiftUI
|
|
import Bedrock
|
|
|
|
// MARK: - Ring Light Color Presets
|
|
|
|
/// App-specific color presets for the ring light feature.
|
|
/// Standard UI colors should use Bedrock's `Color.Surface`, `Color.Accent`, etc.
|
|
extension Color {
|
|
|
|
/// Ring light color presets for selfie lighting.
|
|
enum RingLight {
|
|
/// Pure white - standard daylight lighting.
|
|
static let pureWhite = Color(red: 1.0, green: 1.0, blue: 1.0)
|
|
|
|
/// Warm cream - soft warm lighting like golden hour.
|
|
static let warmCream = Color(red: 1.0, green: 0.98, blue: 0.9)
|
|
|
|
/// Ice blue - cool lighting for a crisp look.
|
|
static let iceBlue = Color(red: 0.9, green: 0.95, blue: 1.0)
|
|
|
|
/// Soft pink - flattering warm tone.
|
|
static let softPink = Color(red: 1.0, green: 0.92, blue: 0.95)
|
|
|
|
/// Warm amber - sunset-like glow.
|
|
static let warmAmber = Color(red: 1.0, green: 0.9, blue: 0.75)
|
|
|
|
/// Cool lavender - subtle cool tone.
|
|
static let coolLavender = Color(red: 0.95, green: 0.92, blue: 1.0)
|
|
}
|
|
}
|
|
|
|
// MARK: - Custom Color RGB Storage
|
|
|
|
/// Stores RGB values for custom colors (Codable-friendly)
|
|
struct CustomColorRGB: Codable, Equatable, Sendable {
|
|
var red: Double
|
|
var green: Double
|
|
var blue: Double
|
|
|
|
static let defaultWhite = CustomColorRGB(red: 1.0, green: 1.0, blue: 1.0)
|
|
|
|
var color: Color {
|
|
Color(red: red, green: green, blue: blue)
|
|
}
|
|
|
|
init(red: Double, green: Double, blue: Double) {
|
|
self.red = red
|
|
self.green = green
|
|
self.blue = blue
|
|
}
|
|
|
|
init(from color: Color) {
|
|
let uiColor = UIColor(color)
|
|
var r: CGFloat = 0
|
|
var g: CGFloat = 0
|
|
var b: CGFloat = 0
|
|
uiColor.getRed(&r, green: &g, blue: &b, alpha: nil)
|
|
self.red = Double(r)
|
|
self.green = Double(g)
|
|
self.blue = Double(b)
|
|
}
|
|
}
|
|
|
|
// MARK: - Ring Light Color Identifier
|
|
|
|
/// Identifiable wrapper for ring light colors to use in Picker/ForEach.
|
|
struct RingLightColor: Identifiable, Equatable, Hashable {
|
|
let id: String
|
|
let name: String
|
|
let color: Color
|
|
let isPremium: Bool
|
|
let isCustom: Bool
|
|
|
|
init(id: String, name: String, color: Color, isPremium: Bool, isCustom: Bool = false) {
|
|
self.id = id
|
|
self.name = name
|
|
self.color = color
|
|
self.isPremium = isPremium
|
|
self.isCustom = isCustom
|
|
}
|
|
|
|
static let allPresets: [RingLightColor] = [
|
|
RingLightColor(id: "pureWhite", name: String(localized: "Pure White"), color: .RingLight.pureWhite, isPremium: false),
|
|
RingLightColor(id: "warmCream", name: String(localized: "Warm Cream"), color: .RingLight.warmCream, isPremium: false),
|
|
RingLightColor(id: "iceBlue", name: String(localized: "Ice Blue"), color: .RingLight.iceBlue, isPremium: true),
|
|
RingLightColor(id: "softPink", name: String(localized: "Soft Pink"), color: .RingLight.softPink, isPremium: true),
|
|
RingLightColor(id: "warmAmber", name: String(localized: "Warm Amber"), color: .RingLight.warmAmber, isPremium: true),
|
|
RingLightColor(id: "coolLavender", name: String(localized: "Cool Lavender"), color: .RingLight.coolLavender, isPremium: true)
|
|
]
|
|
|
|
/// The custom color option (premium only)
|
|
static let customId = "custom"
|
|
|
|
static func custom(with color: Color) -> RingLightColor {
|
|
RingLightColor(
|
|
id: customId,
|
|
name: String(localized: "Custom"),
|
|
color: color,
|
|
isPremium: true,
|
|
isCustom: true
|
|
)
|
|
}
|
|
|
|
static func fromId(_ id: String, customColor: Color? = nil) -> RingLightColor {
|
|
if id == customId, let customColor {
|
|
return custom(with: customColor)
|
|
}
|
|
return allPresets.first { $0.id == id } ?? allPresets[0]
|
|
}
|
|
}
|