another.im-ios/ConversationsClassic/Helpers/View+Debug.swift

36 lines
801 B
Swift
Raw Normal View History

2024-06-19 15:15:27 +00:00
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