components: create PinkGradientView and use PinkGradient directly

Still need to do this for the other gradients as well but this is fine
for now.
This commit is contained in:
William Casarin
2023-07-13 07:09:34 -07:00
parent 1136808afa
commit 90818c12e8
2 changed files with 7 additions and 9 deletions

View File

@@ -14,7 +14,7 @@ struct GradientButtonStyle: ButtonStyle {
.foregroundColor(Color.white)
.background {
RoundedRectangle(cornerRadius: 12)
.fill(PinkGradient.gradient)
.fill(PinkGradient)
}
.scaleEffect(configuration.isPressed ? 0.8 : 1)
}

View File

@@ -11,20 +11,18 @@ fileprivate let damus_grad_c1 = hex_col(r: 0xd3, g: 0x4c, b: 0xd9)
fileprivate let damus_grad_c2 = hex_col(r: 0xf8, g: 0x69, b: 0xb6)
fileprivate let pink_grad = [damus_grad_c1, damus_grad_c2]
struct PinkGradient: View {
let PinkGradient = LinearGradient(colors: pink_grad, startPoint: .topTrailing, endPoint: .bottom)
struct PinkGradientView: View {
var body: some View {
PinkGradient.gradient
PinkGradient
.edgesIgnoringSafeArea([.top,.bottom])
}
static var gradient: LinearGradient {
LinearGradient(colors: pink_grad, startPoint: .topTrailing, endPoint: .bottom)
}
}
struct PinkGradient_Previews: PreviewProvider {
struct PinkGradientView_Previews: PreviewProvider {
static var previews: some View {
PinkGradient()
PinkGradientView()
}
}