tatsuyamoriguchi / Sleep-Tracer

1 stars 0 forks source link

Design and implement UI views for Data screens using SwiftUI. #56

Closed tatsuyamoriguchi closed 6 months ago

tatsuyamoriguchi commented 6 months ago

Displaying data in lists

struct Person: Identifiable {
     let id = UUID()
     var name: String
     var phoneNumber: String
 }

var staff = [
    Person(name: "Juan Chavez", phoneNumber: "(408) 555-4301"),
    Person(name: "Mei Chen", phoneNumber: "(919) 555-2481")
]
struct StaffList: View {
    var body: some View {
        List {
            ForEach(staff) { person in
                Text(person.name)
            }
        }
    }
}
tatsuyamoriguchi commented 6 months ago

How to display multiple Text() view in one List row

List(counts, id: \.id) { i in
    HStack {

       Text(i.date, style: .date)
                .opacity(0.5)
       Spacer()
       Text(i.date, style: .time)
                .opacity(0.5)
    }
}