Hi! Does anyone know a correct way to do the following:
I have a view which produces a path and I want to fill it either with a color or with a gradient (which are different types).
For this, I have a enum which I pass to the view from the parent view:
enum FillColor {
case color(_ color: Color)
case gradient(color1: Color, color2: Color)
}
Inside a view, I have a path:
var body: some View {
GeometryReader { geometry in
Path { path in
...
}
}
}
I then need to switch and do smth like:
switch color {
case .color(let c):
path.fill(c)
case .gradient(let c1, let c2):
let gradient = ...
path.fill(gradient)
}
Do I create a variable for a Path?
But I need to use GeometryReader
as well.