LandmarkDetail.swift


  1. import SwiftUI
  2. struct LandmarkDetail: View {
  3. @EnvironmentObject var modelData: ModelData
  4. var landmark: Landmark
  5. var landmarkIndex: Int {
  6. modelData.landmarks.firstIndex(where: { $0.id == landmark.id })!
  7. }
  8. var body: some View {
  9. CircleImage(image: landmark.image.resizable())
  10. .scaledToFill()
  11. }
  12. }
  13. struct LandmarkDetail_Previews: PreviewProvider {
  14. static var previews: some View {
  15. let modelData = ModelData()
  16. return Group {
  17. LandmarkDetail(landmark: modelData.landmarks[0])
  18. .environmentObject(modelData)
  19. .previewDevice("Apple Watch Series 5 - 44mm")
  20. LandmarkDetail(landmark: modelData.landmarks[1])
  21. .environmentObject(modelData)
  22. .previewDevice("Apple Watch Series 5 - 40mm")
  23. }
  24. }
  25. }