-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Motivation - Section 6 Create a Favorite Button for Each Landmark ### Key Changes -- Section 6 Create a Favorite Button for Each Landmark 예제 코드 및 주석 추가 ### To Reviewers - 샘플 앱 완성
- Loading branch information
1 parent
40a7a22
commit 8da4667
Showing
3 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
Binary file modified
BIN
+3.28 KB
(110%)
...proj/project.xcworkspace/xcuserdata/raymondkim.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// FavoriteButton.swift | ||
// tutorial | ||
// | ||
// Created by 김제필 on 8/11/22. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct FavoriteButton: View { | ||
// 3.6.2. 버튼의 현재 상태를 저장할 변수 isSet을 선언하고 @Binding 프로퍼티 래퍼를 추가한다. ⬇️ | ||
@Binding var isSet: Bool | ||
|
||
var body: some View { | ||
// 3.6.3. 버튼 생성 -> 기본 형태 지정 | ||
Button { | ||
isSet.toggle() | ||
} label: { | ||
Label("Toggle Favorite", systemImage: isSet ? "star.fill" : "star") | ||
.labelStyle(.iconOnly) | ||
.foregroundColor(isSet ? .yellow : .gray) | ||
} | ||
} | ||
} | ||
|
||
struct FavoriteButton_Previews: PreviewProvider { | ||
static var previews: some View { | ||
// 3.6.2. ⬆️ 변수 isSet을 프리뷰에 추가한다. | ||
FavoriteButton(isSet: .constant(true)) | ||
} | ||
} | ||
|
||
|
||
// 3.6.3. 까지 도달했으면 LandmarkDetail.swift 파일로 이동 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters