We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0d46ba4 commit afb5d6fCopy full SHA for afb5d6f
‎Sources/ShinySwiftUI/Extensions/SwiftUI/Color/Color.swift‎
@@ -0,0 +1,23 @@
1
+//
2
+// Color.swift
3
4
5
+// Created by Ben Myers on 3/16/22.
6
7
+
8
+import SwiftUI
9
10
+@available(macOS 11.0, iOS 13.0, *)
11
+public extension Color {
12
13
+ // MARK: - Public Methods
14
15
+ /**
16
+ Returns the color if the given condition is true, returns `.clear` otherwise.
17
18
+ - parameter condition: The condition to show the color.
19
+ */
20
+ func `if`(_ condition: Binding<Bool>) -> Color {
21
+ return condition.wrappedValue ? self : .clear
22
+ }
23
+}
0 commit comments