Skip to content

Commit

Permalink
Feat: Section 3.1. update
Browse files Browse the repository at this point in the history
### Motivation
- Section 3.1. Mark the User’s Favorite Landmarks

### Key Changes
- Section 3.1. Mark the User’s Favorite Landmarks 예제 코드 및 주석 추가

### To Reviewers
- 없음
  • Loading branch information
garlicvread committed Aug 11, 2022
1 parent 14ae810 commit 092c8fd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
Binary file not shown.
2 changes: 2 additions & 0 deletions tutorial/Model/Landmark.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ struct Landmark: Hashable, Codable, Identifiable { // 2.5.3. Identifiable 프
var park: String
var state: String
var description: String
var isFavorite: Bool // 3.1.1 isFavorite 프로퍼티 추가 -> json 파일에 이 값이 있어야 함: 이렇게 쓰려면 json 파일 내에 isFavorite 항목을 추가해야 한다.
// 3.1.1. 까지 왔으면 LandmarkRow.swift 파일로 이동

// 2.1.5. imageName 변수 추가: Assets에 등록된 이미지 파일의 파일명을 읽어오기 위한 것
private var imageName: String
Expand Down
2 changes: 1 addition & 1 deletion tutorial/Views/LandmarkList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ struct LandmarkList_Previews: PreviewProvider {
}

// 2.6.6. 항목까지 따라왔으면 이제 CircleImage.swift로 이동한다
// 2.8.3. 항목까지 따라왔으면 Landmark.swift 파일로 이동
// 2.8.3. 항목까지 따라왔으면 Landmark.swift 파일로 이동하여 3.1.1. 항목을 찾을 것
5 changes: 5 additions & 0 deletions tutorial/Views/LandmarkRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ struct LandmarkRow: View {
Text(landmark.name) // landmark 프로퍼티 내 name 항목 사용하도록 TextView 변경

Spacer() // 2.2.6. HStack 완성

if landmark.isFavorite { // 3.1.4. 조건에 따라 별 이미지를 삽입
Image(systemName: "star.fill")
.foregroundColor(.yellow) // 3.1.5. 별 이미지 색상 변경
}
}
}
}
Expand Down

0 comments on commit 092c8fd

Please sign in to comment.