Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Gradient Preview on iOS 15 #4762

Merged
merged 4 commits into from
Feb 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions RevenueCatUI/Views/GradientView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,25 +105,34 @@ struct GradientView_Previews: PreviewProvider {
.previewDisplayName("Linear 90º - Light (should be red)")

VStack {
Text("Linear 0º")
gradientView(style: .linear(0))
Text("Linear 45º")
gradientView(style: .linear(45))
Text("Linear 90º")
gradientView(style: .linear(90))
Text("Linear 135º")
gradientView(style: .linear(135))
Text("Linear 180º")
gradientView(style: .linear(180))
Text("Linear 225º")
gradientView(style: .linear(225))
Text("Linear 270º")
gradientView(style: .linear(270))
LinearGradientPreview(label: "Linear 0º", degrees: 0)
LinearGradientPreview(label: "Linear 45º", degrees: 45)
LinearGradientPreview(label: "Linear 90º", degrees: 90)
LinearGradientPreview(label: "Linear 135º", degrees: 135)
LinearGradientPreview(label: "Linear 180º", degrees: 180)
LinearGradientPreview(label: "Linear 225º", degrees: 225)
LinearGradientPreview(label: "Linear 270º", degrees: 270)
}
.previewLayout(.sizeThatFits)
.previewDisplayName("Linear")
}

/// Helper view to preview linear gradients with different angles. This is useful so to keep down the
/// number of views in the container holding all of the previews to avoid compilation issues
/// with the preview.
private struct LinearGradientPreview: View {

let label: String
let degrees: Int

var body: some View {
VStack {
Text(label)
gradientView(style: .linear(degrees))
}
}
}

}

extension UnitPoint {
Expand Down