ProfileSummary.swift


  1. import SwiftUI
  2. struct ProfileSummary: View {
  3. @EnvironmentObject var modelData: ModelData
  4. var profile: Profile
  5. var body: some View {
  6. ScrollView {
  7. VStack(alignment: .leading, spacing: 10) {
  8. Text(profile.username)
  9. .bold()
  10. .font(.title)
  11. Text("Notifications: \(profile.prefersNotifications ? "On": "Off" )")
  12. Text("Seasonal Photos:
    \(profile.seasonalPhoto.rawValue)"
    )
  13. Text("Goal Date: ") + Text(profile.goalDate, style: .date)
  14. Divider()
  15. VStack(alignment: .leading) {
  16. Text("Completed Badges")
  17. .font(.headline)
  18. ScrollView(.horizontal) {
  19. HStack {
  20. HikeBadge(name: "First Hike")
  21. HikeBadge(name: "Earth Day")
  22. .hueRotation(Angle(degrees: 90))
  23. HikeBadge(name: "Tenth Hike")
  24. .grayscale(0.5)
  25. .hueRotation(Angle(degrees: 45))
  26. }
  27. .padding(.bottom)
  28. }
  29. }
  30. Divider()
  31. VStack(alignment: .leading) {
  32. Text("Recent Hikes")
  33. .font(.headline)
  34. HikeView(hike: modelData.hikes[0])
  35. }
  36. }
  37. }
  38. }
  39. }
  40. struct ProfileSummary_Previews: PreviewProvider {
  41. static var previews: some View {
  42. ProfileSummary(profile: Profile.default)
  43. .environmentObject(ModelData())
  44. }
  45. }