Skip to content
Open
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: 28 additions & 9 deletions SwiftUIBasics/Views/RatingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,34 @@
//
// Created by Diplomado on 09/12/23.
//

import SwiftUI
struct StarRatingView: View {
@State private var rating: Int = 0

var body: some View {
VStack {
Text("Selected Rating: \(rating)")

HStack {
ForEach(1...5, id: \.self) { index in
Image(systemName: index <= self.rating ? "star.fill" : "star")
.resizable()
.frame(width: 40, height: 40)
.foregroundColor(.yellow)
.onTapGesture {
self.rating = index
}
}
}
}
.padding()
}
}

struct RatingView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
StarRatingView()
}
}


#Preview {
RatingView()
}