Guest User

Untitled

a guest
Dec 10th, 2022
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.93 KB | Source Code | 0 0
  1. import SwiftUI
  2.  
  3. struct UserView: View {
  4.     let user: User
  5.     var body: some View {
  6.         List{
  7.             Section(header: Text("Name")){
  8.                 Text(user.name)
  9.             }
  10.             Section(header: Text("Age")){
  11.                 Text("\(user.age)")
  12.             }
  13.             Section(header: Text("Company")){
  14.                 Text("\(user.company)")
  15.             }
  16.             Section(header: Text("E-mail")){
  17.                 Text("\(user.email)")
  18.             }
  19.             Section(header: Text("Address")){
  20.                 Text("\(user.address)")
  21.             }
  22.             Section(header: Text("Friends")){
  23.                 ForEach(user.friends) { friend in
  24.                     Text(friend.name)
  25.                 }
  26.             }
  27.         }
  28.         .listStyle(.grouped)
  29.     }
  30. }
  31.  
  32. struct UserView_Previews: PreviewProvider {
  33.     static var previews: some View {
  34.         UserView(user: User.example)
  35.     }
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment