another.im-ios/old/View/UIToolkit/View+Debug.swift
2024-08-11 13:09:29 +02:00

36 lines
801 B
Swift

import SwiftUI
#if DEBUG
private let rainbowDebugColors = [
Color.purple,
Color.blue,
Color.green,
Color.yellow,
Color.orange,
Color.red,
Color.pink,
Color.black.opacity(0.5),
Color.teal,
Color.gray,
Color.mint,
Color.cyan
]
public extension Color {
static func random(randomOpacity: Bool = false) -> Color {
Color(
red: .random(in: 0 ... 1),
green: .random(in: 0 ... 1),
blue: .random(in: 0 ... 1),
opacity: randomOpacity ? .random(in: 0 ... 1) : 1
)
}
}
extension View {
func rainbowDebug() -> some View {
background(Color.random())
}
}
#endif