The way to make this utilizing Swiftui
I attempted to make this design in swiftui and it’s resembling as effectively however i do not assume this strategy is a cleaner method. I’m attaching my code beneath.
struct NewShapeView: View {
let properties: [Property]
var physique: some View {
ForEach(properties) { property in
VStack(alignment: .main, spacing: 0) {
ForEach(property.zones.indices, id: .self) { index in
LineView(zoneName: property.zones[index].identify)
SubView(showVerticalLine: index != property.zones.indices.final)
}
}
}
}
}
struct LineView: View {
let zoneName: String
var physique: some View {
HStack(alignment: .backside, spacing: 0) {
Rectangle().body(width: 1, top: 40)
Rectangle().body(width: 40, top: 1)
Textual content(zoneName)
}
}
}
struct SubView: View {
var showVerticalLine: Bool
var physique: some View {
HStack(spacing: 0) {
if showVerticalLine {
Rectangle().body(width: 1, top: 40) // Lengthen the road by way of SubView
}
Spacer().body(width: 32, top: 36) // Modify the spacer width to align with the earlier line
Picture(systemName: "speaker.wave.2.fill")
Textual content("Some Paradise - L’impératrice")
.font(.subheadline)
.foregroundColor(.grey)
}
}
}
I’m a newbie and dealing on my first manufacturing swiftui app. Any solutions and assist are welcomed.
Thanks upfront.
I attempted a hack of drawing a vertical line on the boundary of zone subview until final view is present in array.
I’m anticipating a cleaner strategy.