[PR Request] - Removes default .black rendering for CircledIconView (#92)

This commit is contained in:
Ace Green
2022-07-31 19:50:52 -04:00
committed by GitHub
parent c66fb84c64
commit 5e17bb926c
2 changed files with 18 additions and 4 deletions
@@ -206,3 +206,16 @@ public extension View {
return EmptyView()
}
}
// MARK: - Helper function of View to operate on.
/// Helper function of `View` to operate on
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
func `if`<Content: View>(_ conditional: Bool, content: (Self) -> Content) -> TupleView<(Self?, Content?)> {
if conditional {
return TupleView((nil, content(self)))
} else {
return TupleView((self, nil))
}
}
}
@@ -15,14 +15,14 @@ public struct CircledIconView: View {
/// width for step indicator
public var width:CGFloat
/// color for step indicator
public var color:Color
public var color:Color?
/// stroke color for step indicator
public var strokeColor:Color
/// detect the color scheme i.e., light or dark mode
@Environment(\.colorScheme) var colorScheme: ColorScheme
/// initiazes `image` , `width` , `color` and `strokeColor`
public init(image:Image, width:CGFloat, color: Color = Color.black, strokeColor: Color = Colors.blue(.lightSky).rawValue) {
public init(image:Image, width:CGFloat, color: Color?, strokeColor: Color = Colors.blue(.lightSky).rawValue) {
self.image = image
self.width = width
self.color = color
@@ -39,8 +39,9 @@ public struct CircledIconView: View {
.stroke(strokeColor, lineWidth: 1)
.overlay(image
.resizable()
.renderingMode(.template)
.foregroundColor(self.color)
.if(color != nil){
$0.renderingMode(.template).foregroundColor(color)
}
.frame(width: width/2, height: width/2)
.aspectRatio(contentMode: .fit)))
}