Skip to content

Instantly share code, notes, and snippets.

@laevandus
Created May 25, 2023 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laevandus/579c62d4cd4c0dc6a2d62c5119cb2e96 to your computer and use it in GitHub Desktop.
Save laevandus/579c62d4cd4c0dc6a2d62c5119cb2e96 to your computer and use it in GitHub Desktop.
/// A view displaying a star rating with a step of 0.5.
struct RatingsView: View {
/// A value in range of 0.0 to 5.0.
let value: Double
var body: some View {
HStack(spacing: 0) {
ForEach(0..<5) { index in
Image(systemName: imageName(for: index, value: value))
}
}
.foregroundColor(.yellow)
}
func imageName(for starIndex: Int, value: Double) -> String {
// redacted
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment