From 90818c12e8548b820785bab4844cc5e7c05791ae Mon Sep 17 00:00:00 2001 From: William Casarin Date: Thu, 13 Jul 2023 07:09:34 -0700 Subject: [PATCH] components: create PinkGradientView and use PinkGradient directly Still need to do this for the other gradients as well but this is fine for now. --- damus/Components/GradientButtonStyle.swift | 2 +- damus/Components/Gradients/PinkGradient.swift | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/damus/Components/GradientButtonStyle.swift b/damus/Components/GradientButtonStyle.swift index 8cd4ede1..39d35f66 100644 --- a/damus/Components/GradientButtonStyle.swift +++ b/damus/Components/GradientButtonStyle.swift @@ -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) } diff --git a/damus/Components/Gradients/PinkGradient.swift b/damus/Components/Gradients/PinkGradient.swift index cd928f15..0f8db3ca 100644 --- a/damus/Components/Gradients/PinkGradient.swift +++ b/damus/Components/Gradients/PinkGradient.swift @@ -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() } }