I'm noob in swiftUI. I have created a subview which I'm using. In the VStack Cards(next to the car) the inside Text are not aligned with equal spacing from the left(like 150km and 38ºc are not aligned).
I want the text within the card to start after a spacing of 10 from the left of card. I have added .padding(.left ,10) to card but its not working. I'm attaching the code with it. Please correct me if I'm using the wrong approach.
struct CarInfoCard: View {
@State var cardHeading = ""
@State var cardUnit = ""
@State var cardType = ""
@State var cardNotify = false
var body: some View {
VStack{
HStack {
VStack(alignment: .leading){
HStack(alignment: .lastTextBaseline, spacing: 2) {
Text(cardHeading)
.font(.system(size: 40, weight: .bold, design: .rounded))
.foregroundColor(Color("ColorButtonLogo"))
Text(cardUnit)
.font(.system(size: 25, weight: .bold, design: .rounded))
.foregroundColor(Color("ColorButtonLogo"))
}
Text(cardType)
.font(.system(size: 20, design: .rounded))
.foregroundColor(Color("ColorButtonLogo"))
}
}
}
.frame(width: 150, height: 90)
.padding(.top,10)
.padding(.bottom, 5)
//added padding to the left so that text always starts after spacing of 10. This does not work
.padding(.leading, 10)
.background(Color("ColorButton"))
.cornerRadius(20)
}
}

