Im trying to add a rate button as well as a review section in the landmarks swift ui tutorial but when i put the "RatingForm" into the Landmark detail page it shows in a tiny section that i separately have to scroll. Please note im extremely new and am learning any assistance is appreciated.
The images show what it looks like i can put the code in to LandmarkDetail:
import SwiftUI
struct LandmarkDetail: View {
@EnvironmentObject var landmarksVM: LandmarksViewModel
var landmark: Landmark
var landmarkIndex: Int{
landmarksVM.landmarks.firstIndex(where:{ $0.id == landmark.id})!
}//var landmarkIndex
@Binding var rating: Int
@State private var review: String = ""
var body: some View {
ScrollView{
MapView(coordinate: landmark.locationCoordinate)
.frame(height: 300)
.ignoresSafeArea(edges: .top)
CircleImage(image: landmark.image)
.offset(y:-130)
.padding(.bottom, -130)
VStack (alignment: .leading) {
HStack{
Text(landmark.name)
.font(.title)
.foregroundColor(.green)
FavoriteButton(isSet:
$landmarksVM.landmarks[landmarkIndex].isFavorite)
}//Hstack
HStack {
Text (landmark.city)
.foregroundColor(.blue)
Spacer()
Text(landmark.state)
}//Hstack
.font(.subheadline)
.foregroundColor(.secondary)
Divider()
Text("About (landmark.name)")
.font(.title3)
Text(landmark.description)
Divider()
----> HStack {
TextEditor(text: $review)
RatingForm(rating: $rating)
Spacer()
}//hstack
//VStack
}//ScrollView
.padding(.all)
.navigationTitle(landmark.name)
.navigationBarTitleDisplayMode(.inline)
}//body
}
}//view
struct LandmarkDetail_Previews: PreviewProvider {
static var previews: some View {
LandmarkDetail(playground: LandmarksViewModel().landmarks[0], rating: .constant(4))
}//var preview
}//previewprovider